a23fd118e437af0a7877dd313db8fdaa3537c675yl * CDDL HEADER START
a23fd118e437af0a7877dd313db8fdaa3537c675yl * The contents of this file are subject to the terms of the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Common Development and Distribution License (the "License").
a23fd118e437af0a7877dd313db8fdaa3537c675yl * You may not use this file except in compliance with the License.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See the License for the specific language governing permissions
a23fd118e437af0a7877dd313db8fdaa3537c675yl * and limitations under the License.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * When distributing Covered Code, include this CDDL HEADER in each
a23fd118e437af0a7877dd313db8fdaa3537c675yl * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * If applicable, add the following below this CDDL HEADER, with the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * fields enclosed by brackets "[]" replaced with your own identifying
a23fd118e437af0a7877dd313db8fdaa3537c675yl * information: Portions Copyright [yyyy] [name of copyright owner]
a23fd118e437af0a7877dd313db8fdaa3537c675yl * CDDL HEADER END
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Copyright (c) 2002-2006 Neterion, Inc.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng * Use is subject to license terms.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_bar0 - Get BAR0 mapped address.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: BAR0 address of the specified device.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_isrbar0 - Get BAR0 mapped address.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: BAR0 address of the specified device.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_bar1 - Get BAR1 mapped address.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: BAR1 address of the specified device.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_bar0_set - Set BAR0 mapped address.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @bar0: BAR0 mapped address.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * * Set BAR0 address in the HAL device object.
a23fd118e437af0a7877dd313db8fdaa3537c675ylxge_hal_device_bar0_set(xge_hal_device_t *hldev, char *bar0)
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_isrbar0_set - Set BAR0 mapped address.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @isrbar0: BAR0 mapped address.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * * Set BAR0 address in the HAL device object.
8347601bcb0a439f6e50fc36b4039a73d08700e1ylxge_hal_device_isrbar0_set(xge_hal_device_t *hldev, char *isrbar0)
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_bar1_set - Set BAR1 mapped address.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @channelh: Channel handle.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @bar1: BAR1 mapped address.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Set BAR1 address for the given channel.
a23fd118e437af0a7877dd313db8fdaa3537c675ylxge_hal_device_bar1_set(xge_hal_device_t *hldev, xge_hal_channel_h channelh,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Initializing the BAR1 address as the start of
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * the FIFO queue pointer and as a location of FIFO control
a23fd118e437af0a7877dd313db8fdaa3537c675yl * word. */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_rev - Get Device revision number.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: Device revision number
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_begin_irq - Begin IRQ processing.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @reason: "Reason" for the interrupt, the value of Xframe's
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * general_int_status register.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * The function performs two actions, It first checks whether (shared IRQ) the
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * interrupt was raised by the device. Next, it masks the device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_begin_irq() does not flush MMIO writes through the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * bridge. Therefore, two back-to-back interrupts are potentially possible.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * It is the responsibility of the ULD to make sure that only one
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_continue_irq() runs at a time.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: 0, if the interrupt is not "ours" (note that in this case the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * device remain enabled).
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Otherwise, xge_hal_device_begin_irq() returns 64bit general adapter
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_handle_irq()
a23fd118e437af0a7877dd313db8fdaa3537c675ylxge_hal_device_begin_irq(xge_hal_device_t *hldev, u64 *reason)
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* not Xframe interrupt */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* separate fast path, i.e. no errors */
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_clear_rx - Acknowledge (that is, clear) the
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * condition that has caused the RX interrupt.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Acknowledge (that is, clear) the condition that has caused
a23fd118e437af0a7877dd313db8fdaa3537c675yl * the Rx interrupt.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_begin_irq(), xge_hal_device_continue_irq(),
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_clear_tx(), xge_hal_device_mask_rx().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl 0xFFFFFFFFFFFFFFFFULL,
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_clear_tx - Acknowledge (that is, clear) the
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * condition that has caused the TX interrupt.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Acknowledge (that is, clear) the condition that has caused
a23fd118e437af0a7877dd313db8fdaa3537c675yl * the Tx interrupt.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_begin_irq(), xge_hal_device_continue_irq(),
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_clear_rx(), xge_hal_device_mask_tx().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl 0xFFFFFFFFFFFFFFFFULL,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_poll_rx_channel - Poll Rx channel for completed
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * descriptors and process the same.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @channel: HAL channel.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @got_rx: Buffer to return the flag set if receive interrupt is occured
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * The function polls the Rx channel for the completed descriptors and calls
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * the upper-layer driver (ULD) via supplied completion callback.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: XGE_HAL_OK, if the polling is completed successful.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * XGE_HAL_COMPLETIONS_REMAIN: There are still more completed
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * descriptors available which are yet to be processed.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * See also: xge_hal_device_poll_tx_channel()
8347601bcb0a439f6e50fc36b4039a73d08700e1ylxge_hal_device_poll_rx_channel(xge_hal_channel_t *channel, int *got_rx)
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_device_t *hldev = (xge_hal_device_t *)channel->devh;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* for each opened rx channel */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl if ((ret = xge_hal_ring_dtr_next_completed (channel, &first_dtrh,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl hldev->irq_workload_rxlen[channel->post_qid] += got_bytes;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_poll_tx_channel - Poll Tx channel for completed
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * descriptors and process the same.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @channel: HAL channel.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @got_tx: Buffer to return the flag set if transmit interrupt is occured
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * The function polls the Tx channel for the completed descriptors and calls
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * the upper-layer driver (ULD) via supplied completion callback.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: XGE_HAL_OK, if the polling is completed successful.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * XGE_HAL_COMPLETIONS_REMAIN: There are still more completed
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * descriptors available which are yet to be processed.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * See also: xge_hal_device_poll_rx_channel().
8347601bcb0a439f6e50fc36b4039a73d08700e1ylxge_hal_device_poll_tx_channel(xge_hal_channel_t *channel, int *got_tx)
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_device_t *hldev = (xge_hal_device_t *)channel->devh;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* for each opened tx channel */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl if (xge_hal_fifo_dtr_next_completed (channel, &first_dtrh,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl hldev->irq_workload_txlen[channel->post_qid] += got_bytes;
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_poll_rx_channels - Poll Rx channels for completed
a23fd118e437af0a7877dd313db8fdaa3537c675yl * descriptors and process the same.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @got_rx: Buffer to return flag set if receive is ready
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * The function polls the Rx channels for the completed descriptors and calls
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * the upper-layer driver (ULD) via supplied completion callback.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: XGE_HAL_OK, if the polling is completed successful.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * XGE_HAL_COMPLETIONS_REMAIN: There are still more completed
a23fd118e437af0a7877dd313db8fdaa3537c675yl * descriptors available which are yet to be processed.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * See also: xge_hal_device_poll_tx_channels(), xge_hal_device_continue_irq().
8347601bcb0a439f6e50fc36b4039a73d08700e1ylxge_hal_device_poll_rx_channels(xge_hal_device_t *hldev, int *got_rx)
a23fd118e437af0a7877dd313db8fdaa3537c675yl /* for each opened rx channel */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl channel = xge_container_of(item, xge_hal_channel_t, item);
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng if (!(channel->flags & XGE_HAL_CHANNEL_FLAG_USE_RX_POLLING)) {
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng (void) xge_hal_device_poll_rx_channel(channel, got_rx);
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_poll_tx_channels - Poll Tx channels for completed
a23fd118e437af0a7877dd313db8fdaa3537c675yl * descriptors and process the same.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @got_tx: Buffer to return flag set if transmit is ready
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * The function polls the Tx channels for the completed descriptors and calls
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * the upper-layer driver (ULD) via supplied completion callback.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: XGE_HAL_OK, if the polling is completed successful.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * XGE_HAL_COMPLETIONS_REMAIN: There are still more completed
a23fd118e437af0a7877dd313db8fdaa3537c675yl * descriptors available which are yet to be processed.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * See also: xge_hal_device_poll_rx_channels(), xge_hal_device_continue_irq().
8347601bcb0a439f6e50fc36b4039a73d08700e1ylxge_hal_device_poll_tx_channels(xge_hal_device_t *hldev, int *got_tx)
a23fd118e437af0a7877dd313db8fdaa3537c675yl /* for each opened tx channel */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl channel = xge_container_of(item, xge_hal_channel_t, item);
da14cebe459d3275048785f25bd869cb09b5307fEric Chengxge_hal_device_rx_channel_enable_polling(xge_hal_channel_t *channel)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng channel->flags |= XGE_HAL_CHANNEL_FLAG_USE_RX_POLLING;
da14cebe459d3275048785f25bd869cb09b5307fEric Chengxge_hal_device_rx_channel_disable_polling(xge_hal_channel_t *channel)
da14cebe459d3275048785f25bd869cb09b5307fEric Cheng channel->flags &= ~XGE_HAL_CHANNEL_FLAG_USE_RX_POLLING;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_mask_tx - Mask Tx interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Mask Tx device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_unmask_tx(), xge_hal_device_mask_rx(),
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_clear_tx().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl 0xFFFFFFFFFFFFFFFFULL,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_mask_rx - Mask Rx interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Mask Rx device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_unmask_rx(), xge_hal_device_mask_tx(),
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_clear_rx().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl 0xFFFFFFFFFFFFFFFFULL,
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_mask_all - Mask all device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Mask all device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_unmask_all()
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl 0xFFFFFFFFFFFFFFFFULL,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_unmask_tx - Unmask Tx interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Unmask Tx device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_mask_tx(), xge_hal_device_clear_tx().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_unmask_rx - Unmask Rx interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Unmask Rx device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_mask_rx(), xge_hal_device_clear_rx().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_unmask_all - Unmask all device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Unmask all device interrupts.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_mask_all()
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_hal_pci_bar0_t *isrbar0 = (xge_hal_pci_bar0_t *)hldev->isrbar0;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_device_continue_irq - Continue handling IRQ: process all
a23fd118e437af0a7877dd313db8fdaa3537c675yl * completed descriptors.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Process completed descriptors and unmask the device interrupts.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * The xge_hal_device_continue_irq() walks all open channels
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * and calls upper-layer driver (ULD) via supplied completion
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * callback. Note that the completion callback is specified at channel open
a23fd118e437af0a7877dd313db8fdaa3537c675yl * time, see xge_hal_channel_open().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Note that the xge_hal_device_continue_irq is part of the _fast_ path.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * To optimize the processing, the function does _not_ check for
a23fd118e437af0a7877dd313db8fdaa3537c675yl * errors and alarms.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * The latter is done in a polling fashion, via xge_hal_device_poll().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: XGE_HAL_OK.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_handle_irq(), xge_hal_device_poll(),
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_ring_dtr_next_completed(),
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_fifo_dtr_next_completed(), xge_hal_channel_callback_f{}.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * xge_hal_device_handle_irq - Handle device IRQ.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device handle.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Perform the complete handling of the line interrupt. The function
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * performs two calls.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * First it uses xge_hal_device_begin_irq() to check the reason for
a23fd118e437af0a7877dd313db8fdaa3537c675yl * the interrupt and mask the device interrupts.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Second, it calls xge_hal_device_continue_irq() to process all
a23fd118e437af0a7877dd313db8fdaa3537c675yl * completed descriptors and re-enable the interrupts.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Returns: XGE_HAL_OK - success;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * XGE_HAL_ERR_WRONG_IRQ - (shared) IRQ produced by other device.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * See also: xge_hal_device_begin_irq(), xge_hal_device_continue_irq().
8347601bcb0a439f6e50fc36b4039a73d08700e1yl__hal_lro_check_for_session_match(lro_t *lro, tcplro_t *tcp, iplro_t *ip)
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Match Source address field */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Match Destination address field */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Match Source Port field */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Match Destination Port field */
a23fd118e437af0a7877dd313db8fdaa3537c675yl * __hal_tcp_seg_len: Find the tcp seg len.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @tcp: tcp header.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * returns: Tcp seg length.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * __hal_ip_lro_capable: Finds whether ip is lro capable.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @ext_info: descriptor info.
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
8347601bcb0a439f6e50fc36b4039a73d08700e1yl for (i =0; i < 40; i++) {
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_debug_ring(XGE_ERR, "iphdr !=45 :%d",ip->version_ihl);
8347601bcb0a439f6e50fc36b4039a73d08700e1yl if (ext_info->proto & XGE_HAL_FRAME_PROTO_IP_FRAGMENTED) {
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * __hal_tcp_lro_capable: Finds whether tcp is lro capable.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @tcp: tcp header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
8347601bcb0a439f6e50fc36b4039a73d08700e1yl__hal_tcp_lro_capable(iplro_t *ip, tcplro_t *tcp, lro_t *lro, int *ts_off)
8347601bcb0a439f6e50fc36b4039a73d08700e1yl for (i =0; i < 20; i++) {
8347601bcb0a439f6e50fc36b4039a73d08700e1yl u16 tcp_hdr_len = tcp->doff_res >> 2; /* TCP header len */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Does Packet can contain time stamp */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * If the session is not opened, we can consider
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * this packet for LRO
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Ignore No-operation 0x1 */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Next option == Timestamp */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * If the session ie not opened, we can consider
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * this packet for LRO
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Now the session is opened. If the LRO frame doesn't
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * have time stamp, we cannot consider current packet for
7eced415e5dd557aef2d78483b5a7785f0e13670xw xge_debug_ring(XGE_ERR, "Pkt received with time stamp after session opened with no time stamp : %02x %02x", tcp->doff_res, tcp->ctrl);
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * If the difference is greater than three, then there are
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * more options possible.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * else, there are two cases:
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * case 1: remaining are padding bytes.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * case 2: remaining can contain options or padding
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Probably contains more options.
7eced415e5dd557aef2d78483b5a7785f0e13670xw xge_debug_ring(XGE_ERR, "tcphdr not fastpth : pkt received with tcp options in addition to time stamp after the session is opened %02x %02x ", tcp->doff_res, tcp->ctrl);
8347601bcb0a439f6e50fc36b4039a73d08700e1yl for (i = 0; i < diff; i++) {
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Ignore No-operation 0x1 */
7eced415e5dd557aef2d78483b5a7785f0e13670xw xge_debug_ring(XGE_ERR, "tcphdr not fastpth : pkt received with tcp options in addition to time stamp after the session is opened %02x %02x ", tcp->doff_res, tcp->ctrl);
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Update the time stamp of LRO frame.
7eced415e5dd557aef2d78483b5a7785f0e13670xw xge_debug_ring(XGE_TRACE, "tcphdr not fastpth %02x %02x", tcp->doff_res, tcp->ctrl);
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * __hal_lro_capable: Finds whether frame is lro capable.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @buffer: Ethernet frame.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip frame.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @tcp: tcp frame.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @ext_info: Descriptor info.
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_debug_ring(XGE_ERR, "Cant do lro %d", ext_info->proto);
8347601bcb0a439f6e50fc36b4039a73d08700e1yl for (i =0; i < 60; i++) {
7eced415e5dd557aef2d78483b5a7785f0e13670xw default: // XGE_HAL_FRAME_TYPE_IPX, etc.
7eced415e5dd557aef2d78483b5a7785f0e13670xw /* Grab ip, tcp headers */
7eced415e5dd557aef2d78483b5a7785f0e13670xw } /* !*ip */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl xge_debug_ring(XGE_TRACE, "ip_length:%d ip:"XGE_OS_LLXFMT
7eced415e5dd557aef2d78483b5a7785f0e13670xw (unsigned long long)(ulong_t)*ip, (unsigned long long)(ulong_t)*tcp);
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * __hal_open_lro_session: Open a new LRO session.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @buffer: Ethernet frame.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @tcp: tcp header.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @lro: lro pointer
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ext_info: Descriptor info.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @hldev: Hal context.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @ring_lro: LRO descriptor per rx ring.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @slot: Bucket no.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @tcp_seg_len: Length of tcp segment.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ts_off: time stamp offset in the packet.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl__hal_open_lro_session (u8 *buffer, iplro_t *ip, tcplro_t *tcp, lro_t **lro,
7eced415e5dd557aef2d78483b5a7785f0e13670xw xge_hal_device_t *hldev, xge_hal_lro_desc_t *ring_lro, int slot,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * __hal_lro_get_free_slot: Get a free LRO bucket.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @ring_lro: LRO descriptor per ring.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl for (i = 0; i < XGE_HAL_LRO_MAX_BUCKETS; i++) {
8347601bcb0a439f6e50fc36b4039a73d08700e1yl return -1;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * __hal_get_lro_session: Gets matching LRO session or creates one.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @eth_hdr: Ethernet header.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @tcp: tcp header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @lro: lro pointer
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @ext_info: Descriptor info.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: Hal context.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @ring_lro: LRO descriptor per rx ring
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Compare the incoming frame with the lro session left from the
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * previous call. There is a good chance that this incoming frame
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * matches the lro session.
7eced415e5dd557aef2d78483b5a7785f0e13670xw if (ring_lro->lro_recent && ring_lro->lro_recent->in_use) {
7eced415e5dd557aef2d78483b5a7785f0e13670xw if (__hal_lro_check_for_session_match(ring_lro->lro_recent,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Search in the pool of LROs for the session that matches
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * the incoming frame.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl for (i = 0; i < XGE_HAL_LRO_MAX_BUCKETS; i++) {
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Matching LRO Session found
8347601bcb0a439f6e50fc36b4039a73d08700e1yl if (lro_match->tcp_next_seq_num != xge_os_ntohl(tcp->seq)) {
a23fd118e437af0a7877dd313db8fdaa3537c675yl "found***");
8347601bcb0a439f6e50fc36b4039a73d08700e1yl if (XGE_HAL_OK != __hal_tcp_lro_capable(ip, tcp, lro_match,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Close the current session and open a new
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * LRO session with this packet,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * provided it has tcp payload
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* Get a free bucket */
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Open a new LRO session
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * The frame is good, in-sequence, can be LRO-ed;
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * take its (latest) ACK - unless it is a dupack.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Note: to be exact need to check window size as well..
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* ********** New Session ***************/
8347601bcb0a439f6e50fc36b4039a73d08700e1yl if (XGE_HAL_FAIL == __hal_tcp_lro_capable(ip, tcp, NULL, &ts_off))
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * Open a LRO session, provided the packet contains payload.
7eced415e5dd557aef2d78483b5a7785f0e13670xw __hal_open_lro_session (eth_hdr, ip, tcp, lro, hldev, ring_lro, free_slot,
a23fd118e437af0a7877dd313db8fdaa3537c675yl * __hal_lro_under_optimal_thresh: Finds whether combined session is optimal.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @tcp: tcp header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @lro: lro pointer
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: Hal context.
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * __hal_collapse_ip_hdr: Collapses ip header.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @tcp: tcp header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @lro: lro pointer
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: Hal context.
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
8347601bcb0a439f6e50fc36b4039a73d08700e1yl /* May be we have to handle time stamps or more options */
a23fd118e437af0a7877dd313db8fdaa3537c675yl * __hal_collapse_tcp_hdr: Collapses tcp header.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @tcp: tcp header.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @lro: lro pointer
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: Hal context.
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
a23fd118e437af0a7877dd313db8fdaa3537c675yl * __hal_append_lro: Appends new frame to existing LRO session.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @ip: ip header.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @tcp: IN tcp header, OUT tcp payload.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @seg_len: tcp payload length.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @lro: lro pointer
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: Hal context.
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
8347601bcb0a439f6e50fc36b4039a73d08700e1yl // Update mbuf chain will be done in ll driver.
a23fd118e437af0a7877dd313db8fdaa3537c675yl // xge_hal_accumulate_large_rx on success of appending new frame to
8347601bcb0a439f6e50fc36b4039a73d08700e1yl // lro will return to ll driver tcpdata pointer, and tcp payload length.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl // along with return code lro frame appended.
7eced415e5dd557aef2d78483b5a7785f0e13670xw *tcp = (tcplro_t *)((char *)*tcp + (((*tcp)->doff_res)>>2));
7eced415e5dd557aef2d78483b5a7785f0e13670xw * __xge_hal_accumulate_large_rx: LRO a given frame
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @ring: rx ring number
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @eth_hdr: ethernet header.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @ip_hdr: ip header (optional)
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @tcp: tcp header.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @seglen: packet length.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @p_lro: lro pointer.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @ext_info: descriptor info, see xge_hal_dtr_info_t{}.
a23fd118e437af0a7877dd313db8fdaa3537c675yl * @hldev: HAL device.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @lro_end3: for lro_end3 output
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * LRO the newly received frame, i.e. attach it (if possible) to the
a23fd118e437af0a7877dd313db8fdaa3537c675yl * already accumulated (i.e., already LRO-ed) received frames (if any),
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * to form one super-sized frame for the subsequent processing
a23fd118e437af0a7877dd313db8fdaa3537c675yl * by the stack.
a23fd118e437af0a7877dd313db8fdaa3537c675yl__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
7eced415e5dd557aef2d78483b5a7785f0e13670xwxge_hal_lro_process_rx(int ring, u8 *eth_hdr, u8 *ip_hdr, tcplro_t **tcp,
7eced415e5dd557aef2d78483b5a7785f0e13670xw if (XGE_HAL_OK != __hal_lro_capable(eth_hdr, &ip, (tcplro_t **)tcp,
7eced415e5dd557aef2d78483b5a7785f0e13670xw * This function shall get matching LRO or else
a23fd118e437af0a7877dd313db8fdaa3537c675yl * create one and return it
7eced415e5dd557aef2d78483b5a7785f0e13670xw ret = __hal_get_lro_session(eth_hdr, ip, (tcplro_t *)*tcp,
a23fd118e437af0a7877dd313db8fdaa3537c675yl * Since its time to flush,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * update ip header so that it can be sent up
a23fd118e437af0a7877dd313db8fdaa3537c675yl lro->ip_hdr->tot_len = xge_os_htons((*p_lro)->total_length);
8347601bcb0a439f6e50fc36b4039a73d08700e1yl lro->ip_hdr->check = XGE_LL_IP_FAST_CSUM(((u8 *)(lro->ip_hdr)),
7eced415e5dd557aef2d78483b5a7785f0e13670xw * xge_hal_accumulate_large_rx: LRO a given frame
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @buffer: Ethernet frame.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @tcp: tcp header.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @seglen: packet length.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @p_lro: lro pointer.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @ext_info: descriptor info, see xge_hal_dtr_info_t{}.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @hldev: HAL device.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @lro_end3: for lro_end3 output
7eced415e5dd557aef2d78483b5a7785f0e13670xw * LRO the newly received frame, i.e. attach it (if possible) to the
7eced415e5dd557aef2d78483b5a7785f0e13670xw * already accumulated (i.e., already LRO-ed) received frames (if any),
7eced415e5dd557aef2d78483b5a7785f0e13670xw * to form one super-sized frame for the subsequent processing
7eced415e5dd557aef2d78483b5a7785f0e13670xw * by the stack.
7eced415e5dd557aef2d78483b5a7785f0e13670xw__HAL_STATIC_CHANNEL __HAL_INLINE_CHANNEL xge_hal_status_e
7eced415e5dd557aef2d78483b5a7785f0e13670xwxge_hal_accumulate_large_rx(u8 *buffer, tcplro_t **tcp, u32 *seglen,
7eced415e5dd557aef2d78483b5a7785f0e13670xwlro_t **p_lro, xge_hal_dtr_info_t *ext_info, xge_hal_device_t *hldev,
7eced415e5dd557aef2d78483b5a7785f0e13670xw return xge_hal_lro_process_rx(ring, buffer, NULL, tcp, seglen, p_lro,
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * xge_hal_lro_close_session: Close LRO session
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @lro: LRO Session.
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * @hldev: HAL Context.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * xge_hal_lro_next_session: Returns next LRO session in the list or NULL
8347601bcb0a439f6e50fc36b4039a73d08700e1yl * if none exists.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @hldev: HAL Context.
7eced415e5dd557aef2d78483b5a7785f0e13670xw * @ring: rx ring number.
7eced415e5dd557aef2d78483b5a7785f0e13670xwxge_hal_lro_next_session (xge_hal_device_t *hldev, int ring)