ixgbe_rx.c revision 13740cb230f19fcbf1a6468d1a6a0ba9a0a09c22
/*
* 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-2008 Intel Corporation. All rights reserved.
*/
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include "ixgbe_sw.h"
/* function prototypes */
#ifndef IXGBE_DEBUG
#pragma inline(ixgbe_rx_assoc_hcksum)
#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
{
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.
*/
}
/*
* 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) {
}
/*
* Allocate buffer to receive this packet
*/
"ixgbe_rx_copy: allocate buffer failed");
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.
*/
} else {
return (NULL);
}
}
/*
* Sync up the data received
*/
DDI_FM_OK) {
}
/*
* Strip off one free rx control block from the free list
*/
/*
* Put the rx control block to the work list
*/
return (mp);
}
/*
* 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) {
(void) hcksum_assoc(mp,
}
}
/*
* 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;
/*
* Sync the receive descriptors before accepting the packets
*/
}
/*
* 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) ||
!(status_error & IXGBE_RXD_STAT_EOP)) {
goto rx_discard;
}
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.
*/
/*
* Check h/w checksum offload status
*/
if (ixgbe->rx_hcksum_enable)
}
/*
* Reset rx descriptor read bits
*/
/*
* The receive function is in interrupt context, so here
* limit_per_intr is used to avoid doing receiving too long
* per interrupt.
*/
break;
}
}
/*
* Update the h/w tail accordingly
*/
}
return (mblk_head);
}
mblk_t *
{
if (n_bytes == 0)
return (mp);
return (mp);
}