vmxnet3_rx.c revision 62dadd654b88164ac263978699c78aa01647a39b
/*
* Copyright (C) 2007 VMware, Inc. All rights reserved.
*
* The contents of this file are subject to the terms of the Common
* Development and Distribution License (the "License") version 1.0
* and no later version. You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the License at
*
* See the License for the specific language governing permissions
* and limitations under the License.
*/
/*
* Copyright (c) 2013 by Delphix. All rights reserved.
*/
#include <vmxnet3.h>
/*
* vmxnet3_alloc_rxbuf --
*
* Allocate a new rxBuf from memory. All its fields are set except
* for its associated mblk which has to be allocated later.
*
* Results:
* A new rxBuf or NULL.
*
* Side effects:
* None.
*/
static vmxnet3_rxbuf_t *
{
int err;
if (!rxBuf) {
return (NULL);
}
canSleep)) != DDI_SUCCESS) {
return (NULL);
}
return (rxBuf);
}
/*
* vmxnet3_free_rxbuf --
*
* Free a rxBuf.
*
* Results:
* None.
*
* Side effects:
* None.
*/
static void
{
#ifndef DEBUG
#else
{
}
#endif
}
/*
* vmxnet3_put_rxpool_buf --
*
* Return a rxBuf to the pool.
*
* Results:
* B_TRUE if there was room in the pool and the rxBuf was returned,
* B_FALSE otherwise.
*
* Side effects:
* None.
*/
static boolean_t
{
}
return (returned);
}
/*
* vmxnet3_put_rxbuf --
*
* Return a rxBuf to the pool or free it.
*
* Results:
* None.
*
* Side effects:
* None.
*/
static void
{
}
/*
* vmxnet3_get_rxpool_buf --
*
* Get an unused rxBuf from the pool.
*
* Results:
* A rxBuf or NULL if there are no buffers in the pool.
*
* Side effects:
* None.
*/
static vmxnet3_rxbuf_t *
{
}
return (rxBuf);
}
/*
* vmxnet3_get_rxbuf --
*
* Get an unused rxBuf from either the pool or from memory.
* The returned rxBuf has a mblk associated with it.
*
* Results:
* A rxBuf or NULL.
*
* Side effects:
* None.
*/
static vmxnet3_rxbuf_t *
{
}
if (rxBuf) {
}
}
return (rxBuf);
}
/*
* vmxnet3_rx_populate --
*
* Populate a Rx descriptor with a new rxBuf.
*
* Results:
* DDI_SUCCESS or DDI_FAILURE.
*
* Side effects:
* None.
*/
static int
{
int ret = DDI_SUCCESS;
if (rxBuf) {
/* rxDesc->rxd.btype = 0; */
} else {
ret = DDI_FAILURE;
}
return (ret);
}
/*
* vmxnet3_rxqueue_init --
*
* Initialize a RxQueue by populating the whole Rx ring with rxBufs.
*
* Results:
* DDI_SUCCESS or DDI_FAILURE.
*
* Side effects:
* None.
*/
int
{
do {
B_TRUE) != DDI_SUCCESS) {
goto error;
}
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}
/*
* vmxnet3_rxqueue_fini --
*
* Finish a RxQueue by freeing all the related rxBufs.
*
* Results:
* DDI_SUCCESS.
*
* Side effects:
* None.
*/
void
{
unsigned int i;
/* First the rxPool */
/* Then the ring */
/*
* Here, freemsg() will trigger a call to vmxnet3_put_rxbuf()
* which will then call vmxnet3_free_rxbuf() because the
* underlying device is disabled.
*/
}
}
/*
* vmxnet3_rx_hwcksum --
*
* Determine if a received packet was checksummed by the Vmxnet3
* device and tag the mp appropriately.
*
* Results:
* None.
*
* Side effects:
* The mp may get tagged.
*/
static void
{
}
}
}
}
/*
* vmxnet3_rx_intr --
*
* Interrupt handler for Rx. Look if there are any pending Rx and
* put them in mplist.
*
* Results:
* A list of messages to pass to the MAC subystem.
*
* Side effects:
* None.
*/
mblk_t *
{
do {
/*
* H/W may be still be in the middle of
* generating this entry, so hold on until
* the gen bit is flipped.
*/
}
/* Some Rx descriptors may have been skipped */
}
/*
* Now we have a piece of the packet in the rxdIdx
* descriptor. Grab it only if we achieve to replace
* it with a fresh buffer.
*/
B_FALSE) == DDI_SUCCESS) {
/* Success, we can chain the mblk with the mp */
rxdIdx);
if (eop) {
/*
* Tag the mp if it was
* checksummed by the H/W
*/
compDesc);
} else {
}
}
} else {
/*
* Keep the same buffer, we still need
* to flip the gen bit
*/
}
} while (!eop);
if (mp) {
if (mpValid) {
*mplistTail = mp;
} else {
/* This message got holes, drop it */
}
}
}
if (rxqCtrl->updateRxProd) {
/*
* All buffers are actually available, but we can't tell that to
* the device because it may interpret that as an empty ring.
* So skip one buffer.
*/
} else {
}
}
return (mplist);
}