ixgbe_rx.c revision 5b6dd21f5401160f9a62ac2e76a858c2bc105370
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright(c) 2007-2010 Intel Corporation. All rights reserved.
*/
/*
*/
#include "ixgbe_sw.h"
/* function prototypes */
#ifndef IXGBE_DEBUG
#pragma inline(ixgbe_rx_assoc_hcksum)
#pragma inline(ixgbe_lro_get_start)
#pragma inline(ixgbe_lro_get_first)
#endif
/*
* ixgbe_rx_recycle - The call-back function to reclaim rx buffer.
*
* This function is called when an mp is freed by the user thru
* freeb call (Only for mp constructed through desballoc call).
* It returns back the freed buffer to the free list.
*/
void
{
if (recycle_rcb->ref_cnt == 0) {
/*
* This case only happens when rx buffers are being freed
* in ixgbe_stop() and freemsg() is called.
*/
return;
}
/*
* Using the recycled data buffer to generate a new mblk
*/
0, &recycle_rcb->free_rtn);
/*
* Put the recycled rx control block into free list
*/
/*
* The atomic operation on the number of the available rx control
* blocks in the free list is used to make the recycling mutual
* exclusive with the receiving.
*/
/*
* Considering the case that the interface is unplumbed
* and there are still some buffers held by the upper layer.
* When the buffer is returned back, we need to free it.
*/
if (ref_cnt == 0) {
}
/*
* When there is not any buffer belonging to this rx_data
* held by the upper layer, the rx_data can be freed.
*/
(rx_data->rcb_pending == 0))
}
}
/*
* ixgbe_rx_copy - Use copy to process the received packet.
*
* This function will use bcopy to process the packet
* and send the copied packet upstream.
*/
static mblk_t *
{
DDI_FM_OK) {
return (NULL);
}
/*
* Allocate buffer to receive this packet
*/
return (NULL);
}
/*
* Copy the data received into the new cluster
*/
return (mp);
}
/*
* ixgbe_rx_bind - Use existing DMA buffer to build mblk for receiving.
*
* This function will use pre-bound DMA buffer to receive the packet
* and build mblk that will be sent upstream.
*/
static mblk_t *
{
/*
* If the free list is empty, we cannot proceed to send
* the current DMA buffer upstream. We'll have to return
* and use bcopy to process the packet.
*/
return (NULL);
/*
* If the mp of the rx control block is NULL, try to do
* desballoc again.
*/
0, ¤t_rcb->free_rtn);
/*
* If it is failed to built a mblk using the current
* DMA buffer, we have to return and use bcopy to
* process the packet.
*/
return (NULL);
}
}
/*
* Sync up the data received
*/
DDI_FM_OK) {
return (NULL);
}
/*
* Strip off one free rx control block from the free list
*/
/*
* Put the rx control block to the work list
*/
return (mp);
}
/*
* ixgbe_lro_bind - Use existing DMA buffer to build LRO mblk for receiving.
*
* This function will use pre-bound DMA buffers to receive the packet
* and build LRO mblk that will be sent upstream.
*/
static mblk_t *
{
union ixgbe_adv_rx_desc *current_rbd;
int lro_next;
uint32_t i;
/*
* If the free list is empty, we cannot proceed to send
* the current DMA buffer upstream. We'll have to return
* and use bcopy to process the packet.
*/
return (NULL);
/*
* If any one of the rx data blocks can not support
* lro bind operation, We'll have to return and use
* bcopy to process the lro packet.
*/
for (i = lro_num; i > 0; i--) {
/*
* Sync up the data received
*/
DDI_FM_OK) {
return (NULL);
}
/*
* If the mp of the rx control block is NULL, try to do
* desballoc again.
*/
0, ¤t_rcb->free_rtn);
/*
* If it is failed to built a mblk using the current
* DMA buffer, we have to return and use bcopy to
* process the packet.
*/
return (NULL);
}
}
}
while (lro_num --) {
if (lro_num != 0)
else
/*
* Strip off one free rx control block from the free list
*/
/*
* Put the rx control block to the work list
*/
if (lro_next == -1)
break;
}
return (mblk_head);
}
/*
* ixgbe_lro_copy - Use copy to process the received LRO packet.
*
* This function will use bcopy to process the LRO packet
* and send the copied packet upstream.
*/
static mblk_t *
{
union ixgbe_adv_rx_desc *current_rbd;
int lro_next;
uint32_t i;
/*
* Allocate buffer to receive this LRO packet
*/
return (NULL);
}
/*
* Sync up the LRO packet data received
*/
for (i = lro_num; i > 0; i--) {
DDI_FM_OK) {
return (NULL);
}
}
/*
* Copy the data received into the new cluster
*/
while (lro_num --) {
if (lro_num != 0) {
ixgbe->rx_buf_size);
} else {
}
if (lro_next == -1)
break;
}
return (mp);
}
/*
* ixgbe_lro_get_start - get the start rcb index in one LRO packet
*/
static int
{
int lro_prev;
int lro_start;
while (lro_prev != -1) {
lro_num ++;
}
return (lro_start);
}
/*
* ixgbe_lro_get_first - get the first LRO rcb index
*/
static uint32_t
{
}
return (lro_first);
}
/*
* ixgbe_rx_assoc_hcksum - Check the rx hardware checksum status and associate
* the hcksum flags.
*/
static void
{
uint32_t hcksum_flags = 0;
/*
*/
if ((status_error & IXGBE_RXD_STAT_L4CS) &&
/*
* Check IP Checksum
*/
if ((status_error & IXGBE_RXD_STAT_IPCS) &&
if (hcksum_flags != 0) {
}
}
/*
* ixgbe_ring_rx - Receive the data of one ring.
*
* This function goes throught h/w descriptor in one specified rx ring,
* receives the data if the descriptor status shows the data is ready.
* It returns a chain of mblks containing the received data, to be
* passed up to mac_rx().
*/
mblk_t *
{
union ixgbe_adv_rx_desc *current_rbd;
return (NULL);
/*
* Sync the receive descriptors before accepting the packets
*/
return (NULL);
}
/*
* Get the start point of rx bd ring which should be examined
* during this cycle.
*/
received_bytes = 0;
pkt_num = 0;
while (status_error & IXGBE_RXD_STAT_DD) {
/*
* If adapter has found errors, but the error
* is hardware checksum error, this does not discard the
* packet: let upper layer compute the checksum;
* Otherwise discard the packet.
*/
if ((status_error & IXGBE_RXDADV_ERR_FRAME_ERR_MASK) ||
((!ixgbe->lro_enable) &&
(!(status_error & IXGBE_RXD_STAT_EOP)))) {
goto rx_discard;
}
if (ixgbe->lro_enable) {
if (rsc_cnt != 0) {
if (status_error & IXGBE_RXD_STAT_EOP) {
lro_prev != -1) {
rx_next);
ixgbe->lro_pkt_count++;
pkt_len +=
}
} else {
lro_next = (status_error &
= rx_next;
goto rx_discard;
}
} else {
}
} else {
}
if ((poll_bytes != IXGBE_POLL_NULL) &&
break;
/*
* For packets with length more than the copy threshold,
* we'll first try to use the existing DMA buffer to build
* an mblk and send the mblk upstream.
*
* If the first method fails, or the packet length is less
* than the copy threshold, we'll allocate a new mblk and
* copy the packet data to the new mblk.
*/
if (lro_eop) {
} else {
}
/*
* Check h/w checksum offload status
*/
if (ixgbe->rx_hcksum_enable)
}
/*
* Reset rx descriptor read bits
*/
if (ixgbe->lro_enable) {
if (!current_rcb->lro_pkt) {
}
} else {
}
/*
* The receive function is in interrupt context, so here
* rx_limit_per_intr is used to avoid doing receiving too long
* per interrupt.
*/
break;
}
}
/*
* Update the h/w tail accordingly
*/
if (ixgbe->lro_enable) {
} else
}
return (mblk_head);
}
mblk_t *
{
if (n_bytes == 0)
return (NULL);
return (mp);
}