third_party/virtualbox/src/VBox/Devices/Network/DevE1000.cpp
/**
 * Add descriptor's buffer to transmit frame.
 *
 * This deals with GSO and normal frames, e1kFallbackAddToFrame deals with the
 * TSE frames we cannot handle as GSO.
 *
 * @returns true on success, false on failure.
 *
 * @param   pThis       The device state structure.
 * @param   PhysAddr    The physical address of the descriptor buffer.
 * @param   cbFragment  Length of descriptor's buffer.
 * @thread  E1000_TX
 */
Add descriptor's buffer to transmit frame.
This deals with GSO and normal frames, e1kFallbackAddToFrame deals with the
TSE frames we cannot handle as GSO.

@returns true on success, false on failure.

@param   pThis       The device state structure.
@param   PhysAddr    The physical address of the descriptor buffer.
@param   cbFragment  Length of descriptor's buffer.
Add descriptor ' s buffer to transmit frame . This deals with GSO and normal frames e1kFallbackAddToFrame deals with the TSE frames we cannot handle as GSO . @returns true on success false on failure . @param pThis The device state structure . @param PhysAddr The physical address of the descriptor buffer . @param cbFragment Length of descriptor ' s buffer .
static bool e1kAddToFrame(PE1KSTATE pThis, RTGCPHYS PhysAddr, uint32_t cbFragment)
{
    PPDMSCATTERGATHER   pTxSg    = pThis->CTX_SUFF(pTxSg);
    bool const          fGso     = e1kXmitIsGsoBuf(pTxSg);
    uint32_t const      cbNewPkt = cbFragment + pThis->u16TxPktLen;
    LogFlow(("%s e1kAddToFrame: ENTER cbFragment=%d u16TxPktLen=%d cbUsed=%d cbAvailable=%d fGSO=%s\n",
             pThis->szPrf, cbFragment, pThis->u16TxPktLen, pTxSg->cbUsed, pTxSg->cbAvailable,
             fGso ? "true" : "false"));
    if (RT_UNLIKELY( !fGso && cbNewPkt > E1K_MAX_TX_PKT_SIZE ))
    {
        E1kLog(("%s Transmit packet is too large: %u > %u(max)\n", pThis->szPrf, cbNewPkt, E1K_MAX_TX_PKT_SIZE));
        return false;
    }
    if (RT_UNLIKELY( cbNewPkt > pTxSg->cbAvailable ))
    {
        E1kLog(("%s Transmit packet is too large: %u > %u(max)\n", pThis->szPrf, cbNewPkt, pTxSg->cbAvailable));
        return false;
    }
    if (RT_LIKELY(pTxSg))
    {
        Assert(pTxSg->cSegs == 1);
        if (pTxSg->cbUsed != pThis->u16TxPktLen)
            E1kLog(("%s e1kAddToFrame:  pTxSg->cbUsed=%d(0x%x) != u16TxPktLen=%d(0x%x)\n",
                    pThis->szPrf, pTxSg->cbUsed, pTxSg->cbUsed, pThis->u16TxPktLen, pThis->u16TxPktLen));
        PDMDevHlpPhysRead(pThis->CTX_SUFF(pDevIns), PhysAddr,
                          (uint8_t *)pTxSg->aSegs[0].pvSeg + pThis->u16TxPktLen, cbFragment);
        pTxSg->cbUsed = cbNewPkt;
    }
    pThis->u16TxPktLen = cbNewPkt;
    return true;
}
static bool e1kAddToFrame ( PE1KSTATE pThis , RTGCPHYS PhysAddr , uint32_t cbFragment ) { PPDMSCATTERGATHER pTxSg = pThis -> CTX_SUFF ( pTxSg ) ; bool const fGso = e1kXmitIsGsoBuf ( pTxSg ) ; uint32_t const cbNewPkt = cbFragment + pThis -> u16TxPktLen ; LogFlow ( ( " \n " , pThis -> szPrf , cbFragment , pThis -> u16TxPktLen , pTxSg -> cbUsed , pTxSg -> cbAvailable , fGso ? " " : " " ) ) ; if ( RT_UNLIKELY ( ! fGso && cbNewPkt > E1K_MAX_TX_PKT_SIZE ) ) { E1kLog ( ( " \n " , pThis -> szPrf , cbNewPkt , E1K_MAX_TX_PKT_SIZE ) ) ; return false ; } if ( RT_UNLIKELY ( cbNewPkt > pTxSg -> cbAvailable ) ) { E1kLog ( ( " \n " , pThis -> szPrf , cbNewPkt , pTxSg -> cbAvailable ) ) ; return false ; } if ( RT_LIKELY ( pTxSg ) ) { Assert ( pTxSg -> cSegs == 1 ) ; if ( pTxSg -> cbUsed != pThis -> u16TxPktLen ) E1kLog ( ( " \n " , pThis -> szPrf , pTxSg -> cbUsed , pTxSg -> cbUsed , pThis -> u16TxPktLen , pThis -> u16TxPktLen ) ) ; PDMDevHlpPhysRead ( pThis -> CTX_SUFF ( pDevIns ) , PhysAddr , ( uint8_t * ) pTxSg -> aSegs [ 0 ] . pvSeg + pThis -> u16TxPktLen , cbFragment ) ; pTxSg -> cbUsed = cbNewPkt ; } pThis -> u16TxPktLen = cbNewPkt ; return true ; }
Add descriptor's buffer to transmit frame.
Add descriptor ' s buffer to transmit frame .