VirtualBox

Changeset 41917 in vbox for trunk


Ignore:
Timestamp:
Jun 26, 2012 10:33:05 AM (13 years ago)
Author:
vboxsync
Message:

Virtio/Net: Feature negotiation and GSO handling on RX path (#5582)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevVirtioNet.cpp

    r41820 r41917  
    318318}
    319319
    320 
     320/**
     321 * Print features given in uFeatures to debug log.
     322 *
     323 * @param   pState      The device state structure.
     324 * @param   uFeatures   Descriptions of which features to print.
     325 * @param   pcszText    A string to print before the list of features.
     326 */
     327DECLINLINE(void) vnetPrintFeatures(PVNETSTATE pState, uint32_t uFeatures, const char *pcszText)
     328{
     329#ifdef DEBUG
     330    static struct
     331    {
     332        uint32_t uMask;
     333        const char *pcszDesc;
     334    } aFeatures[] = {
     335        { VNET_F_CSUM,       "host handles pkts w/ partial csum" },
     336        { VNET_F_GUEST_CSUM, "guest handles pkts w/ partial csum" },
     337        { VNET_F_MAC,        "host has given MAC address" },
     338        { VNET_F_GSO,        "host handles pkts w/ any GSO type" },
     339        { VNET_F_GUEST_TSO4, "guest can handle TSOv4 in" },
     340        { VNET_F_GUEST_TSO6, "guest can handle TSOv6 in" },
     341        { VNET_F_GUEST_ECN,  "guest can handle TSO[6] w/ ECN in" },
     342        { VNET_F_GUEST_UFO,  "guest can handle UFO in" },
     343        { VNET_F_HOST_TSO4,  "host can handle TSOv4 in" },
     344        { VNET_F_HOST_TSO6,  "host can handle TSOv6 in" },
     345        { VNET_F_HOST_ECN,   "host can handle TSO[6] w/ ECN in" },
     346        { VNET_F_HOST_UFO,   "host can handle UFO in" },
     347        { VNET_F_MRG_RXBUF,  "host can merge receive buffers" },
     348        { VNET_F_STATUS,     "virtio_net_config.status available" },
     349        { VNET_F_CTRL_VQ,    "control channel available" },
     350        { VNET_F_CTRL_RX,    "control channel RX mode support" },
     351        { VNET_F_CTRL_VLAN,  "control channel VLAN filtering" }
     352    };
     353
     354    Log3(("%s %s:\n", INSTANCE(pState), pcszText));
     355    for (unsigned i = 0; i < RT_ELEMENTS(aFeatures); ++i)
     356    {
     357        if (aFeatures[i].uMask & uFeatures)
     358            Log3(("%s --> %s\n", INSTANCE(pState), aFeatures[i].pcszDesc));
     359    }
     360#endif /* DEBUG */
     361}
    321362
    322363PDMBOTHCBDECL(uint32_t) vnetGetHostFeatures(void *pvState)
     
    340381        | VNET_F_HOST_TSO6
    341382        | VNET_F_HOST_UFO
     383        | VNET_F_GUEST_TSO4
     384        | VNET_F_GUEST_TSO6
     385        | VNET_F_GUEST_UFO
    342386#endif
    343387#ifdef VNET_WITH_MERGEABLE_RX_BUFS
     
    357401    VNETSTATE *pState = (VNETSTATE *)pvState;
    358402    LogFlow(("%s vnetSetHostFeatures: uFeatures=%x\n", INSTANCE(pState), uFeatures));
     403    vnetPrintFeatures(pState, uFeatures, "The guest negotiated the following features");
    359404}
    360405
     
    856901{
    857902    VNETSTATE *pState = RT_FROM_MEMBER(pInterface, VNETSTATE, INetworkDown);
     903
     904    if (pGso)
     905    {
     906        uint32_t uFeatures = pState->VPCI.uGuestFeatures;
     907
     908        switch (pGso->u8Type)
     909        {
     910            case PDMNETWORKGSOTYPE_IPV4_TCP:
     911                uFeatures &= VNET_F_GUEST_TSO4;
     912                break;
     913            case PDMNETWORKGSOTYPE_IPV6_TCP:
     914                uFeatures &= VNET_F_GUEST_TSO6;
     915                break;
     916            case PDMNETWORKGSOTYPE_IPV4_UDP:
     917            case PDMNETWORKGSOTYPE_IPV6_UDP:
     918                uFeatures &= VNET_F_GUEST_UFO;
     919                break;
     920            default:
     921                uFeatures = 0;
     922                break;
     923        }
     924        if (!uFeatures)
     925        {
     926            Log2(("%s vnetNetworkDown_ReceiveGso: GSO type (0x%x) not supported\n",
     927                  INSTANCE(pState), pGso->u8Type));
     928            return VERR_NOT_SUPPORTED;
     929        }
     930    }
    858931
    859932    Log2(("%s vnetNetworkDown_ReceiveGso: pvBuf=%p cb=%u pGso=%p\n",
     
    19812054         INSTANCE(pState), pState->cMsLinkUpDelay / 1000));
    19822055
     2056
     2057    vnetPrintFeatures(pState, vnetGetHostFeatures(pState), "Device supports the following features");
     2058
    19832059    /* Initialize PCI config space */
    19842060    memcpy(pState->config.mac.au8, pState->macConfigured.au8, sizeof(pState->config.mac.au8));
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette