- Timestamp:
- Apr 8, 2010 3:49:33 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevE1000.cpp
r28089 r28102 27 27 * 28 28 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa 29 * Clara, CA 95054 USA or visit http://www.sun.com if you need 29 * Clara, CA 95054 USA or visit http://www.sun.com if you need. 30 30 * additional information or have any questions. 31 31 */ … … 57 57 #include <VBox/pdmnetifs.h> 58 58 #include <VBox/pdmnetinline.h> 59 #include <VBox/param.h> 59 60 #include <VBox/tm.h> 60 61 #include <VBox/vm.h> … … 1072 1073 STAMPROFILE StatRxOverflow; 1073 1074 STAMCOUNTER StatRxOverflowWakeup; 1075 STAMCOUNTER StatTxDescCtxNormal; 1076 STAMCOUNTER StatTxDescCtxTSE; 1074 1077 STAMCOUNTER StatTxDescLegacy; 1075 1078 STAMCOUNTER StatTxDescData; 1076 1079 STAMCOUNTER StatTxDescTSEData; 1080 STAMCOUNTER StatTxPathFallback; 1081 STAMCOUNTER StatTxPathGSO; 1082 STAMCOUNTER StatTxPathRegular; 1077 1083 STAMCOUNTER StatPHYAccesses; 1078 1084 … … 2823 2829 /* Check the header ordering and spacing: 1. Ethernet, 2. IP, 3. TCP/UDP. */ 2824 2830 if (RT_UNLIKELY( pCtx->ip.u8CSS < sizeof(RTNETETHERHDR) )) 2831 { 2832 E1kLog(("e1kSetupGsoCtx: IPCSS=%#x\n", pCtx->ip.u8CSS)); 2825 2833 return; 2834 } 2826 2835 if (RT_UNLIKELY( pCtx->tu.u8CSS < (size_t)pCtx->ip.u8CSS + (pCtx->dw2.fIP ? RTNETIPV4_MIN_LEN : RTNETIPV6_MIN_LEN) )) 2836 { 2837 E1kLog(("e1kSetupGsoCtx: TUCSS=%#x\n", pCtx->tu.u8CSS)); 2827 2838 return; 2839 } 2828 2840 if (RT_UNLIKELY( pCtx->dw2.fTCP 2829 2841 ? pCtx->dw3.u8HDRLEN < (size_t)pCtx->tu.u8CSS + RTNETTCP_MIN_LEN 2830 2842 : pCtx->dw3.u8HDRLEN != (size_t)pCtx->tu.u8CSS + RTNETUDP_MIN_LEN )) 2843 { 2844 E1kLog(("e1kSetupGsoCtx: HDRLEN=%#x TCP=%d\n", pCtx->dw3.u8HDRLEN, pCtx->dw2.fTCP)); 2831 2845 return; 2846 } 2832 2847 2833 2848 /* The end of the TCP/UDP checksum should stop at the end of the packet or at least after the headers. */ 2834 2849 if (RT_UNLIKELY( pCtx->tu.u16CSE > 0 && pCtx->tu.u16CSE <= pCtx->dw3.u8HDRLEN )) 2850 { 2851 E1kLog(("e1kSetupGsoCtx: TUCSE=%#x HDRLEN=%#x\n", pCtx->tu.u16CSE, pCtx->dw3.u8HDRLEN)); 2835 2852 return; 2853 } 2836 2854 2837 2855 /* IPv4 checksum offset. */ 2838 2856 if (RT_UNLIKELY( pCtx->dw2.fIP && pCtx->ip.u8CSO - pCtx->ip.u8CSS != RT_OFFSETOF(RTNETIPV4, ip_sum) )) 2857 { 2858 E1kLog(("e1kSetupGsoCtx: IPCSO=%#x IPCSS=%#x\n", pCtx->ip.u8CSO, pCtx->ip.u8CSS)); 2839 2859 return; 2860 } 2840 2861 2841 2862 /* TCP/UDP checksum offsets. */ … … 2843 2864 ? RT_OFFSETOF(RTNETTCP, th_sum) 2844 2865 : RT_OFFSETOF(RTNETUDP, uh_sum) ) )) 2866 { 2867 E1kLog(("e1kSetupGsoCtx: TUCSO=%#x TUCSS=%#x TCP=%d\n", pCtx->ip.u8CSO, pCtx->ip.u8CSS, pCtx->dw2.fTCP)); 2845 2868 return; 2869 } 2870 2871 /* 2872 * Because of internal networking using a 16-bit size field for GSO context 2873 * pluss frame, we have to make sure we don't exceed this. 2874 */ 2875 if (RT_UNLIKELY( pCtx->dw3.u8HDRLEN + pCtx->dw2.u20PAYLEN > VBOX_MAX_GSO_SIZE )) 2876 { 2877 E1kLog(("e1kSetupGsoCtx: HDRLEN(=%#x) + PAYLEN(=%#x) = %#x, max is %#x\n", 2878 pCtx->dw3.u8HDRLEN, pCtx->dw2.u20PAYLEN, pCtx->dw3.u8HDRLEN + pCtx->dw2.u20PAYLEN, VBOX_MAX_GSO_SIZE)); 2879 return; 2880 } 2846 2881 2847 2882 /* … … 2870 2905 pGso->cbMaxSeg = pCtx->dw3.u16MSS; 2871 2906 Assert(PDMNetGsoIsValid(pGso, sizeof(*pGso), pGso->cbMaxSeg * 5)); 2907 E1kLog2(("e1kSetupGsoCtx: mss=%#x hdr=%#x hdr1=%#x hdr2=%#x %s\n", 2908 pGso->cbMaxSeg, pGso->cbHdrs, pGso->offHdr1, pGso->offHdr2, PDMNetGsoTypeName((PDMNETWORKGSOTYPE)pGso->u8Type) )); 2872 2909 } 2873 2910 … … 2877 2914 * @param pGso The GSO context. 2878 2915 * @param pData The first data descriptor of the frame. 2879 */ 2880 DECLINLINE(bool) e1kCanDoGso(PCPDMNETWORKGSO pGso, E1KTXDAT const *pData) 2916 * @param pCtx The TSO context descriptor. 2917 */ 2918 DECLINLINE(bool) e1kCanDoGso(PCPDMNETWORKGSO pGso, E1KTXDAT const *pData, E1KTXCTX const *pCtx) 2881 2919 { 2882 2920 if (!pData->cmd.fTSE) 2921 { 2922 E1kLog2(("e1kCanDoGso: !TSE\n")); 2883 2923 return false; 2924 } 2884 2925 if (pData->cmd.fVLE) /** @todo VLAN tagging. */ 2926 { 2927 E1kLog(("e1kCanDoGso: VLE\n")); 2885 2928 return false; 2929 } 2886 2930 2887 2931 switch ((PDMNETWORKGSOTYPE)pGso->u8Type) … … 2890 2934 case PDMNETWORKGSOTYPE_IPV4_UDP: 2891 2935 if (!pData->dw3.fIXSM) 2936 { 2937 E1kLog(("e1kCanDoGso: !IXSM (IPv4)\n")); 2892 2938 return false; 2939 } 2893 2940 if (!pData->dw3.fTXSM) 2941 { 2942 E1kLog(("e1kCanDoGso: !TXSM (IPv4)\n")); 2894 2943 return false; 2944 } 2895 2945 /** @todo what more check should we perform here? Ethernet frame type? */ 2946 E1kLog2(("e1kCanDoGso: OK, IPv4\n")); 2896 2947 return true; 2897 2948 2898 2949 case PDMNETWORKGSOTYPE_IPV6_TCP: 2899 2950 case PDMNETWORKGSOTYPE_IPV6_UDP: 2900 if (pData->dw3.fIXSM) 2951 if (pData->dw3.fIXSM && pCtx->ip.u8CSO) 2952 { 2953 E1kLog(("e1kCanDoGso: IXSM (IPv6)\n")); 2901 2954 return false; 2955 } 2902 2956 if (!pData->dw3.fTXSM) 2957 { 2958 E1kLog(("e1kCanDoGso: TXSM (IPv6)\n")); 2903 2959 return false; 2960 } 2904 2961 /** @todo what more check should we perform here? Ethernet frame type? */ 2962 E1kLog2(("e1kCanDoGso: OK, IPv4\n")); 2905 2963 return true; 2906 2964 2907 2965 default: 2908 2966 Assert(pGso->u8Type == PDMNETWORKGSOTYPE_INVALID); 2967 E1kLog2(("e1kCanDoGso: e1kSetupGsoCtx failed\n")); 2909 2968 return false; 2910 2969 } … … 3005 3064 DECLINLINE(bool) e1kXmitIsGsoBuf(PDMSCATTERGATHER const *pTxSg) 3006 3065 { 3066 #if 0 3067 if (!pTxSg) 3068 E1kLog(("e1kXmitIsGsoBuf: pTxSG is NULL\n")); 3069 if (pTxSg && pTxSg->pvUser) 3070 E1kLog(("e1kXmitIsGsoBuf: pvUser is NULL\n")); 3071 #endif 3007 3072 return pTxSg && pTxSg->pvUser /* GSO indicator */; 3008 3073 } … … 3488 3553 pState->u16HdrRemain = pDesc->context.dw3.u8HDRLEN; 3489 3554 e1kSetupGsoCtx(&pState->GsoCtx, &pDesc->context); 3555 STAM_COUNTER_INC(&pState->StatTxDescCtxTSE); 3490 3556 } 3491 3557 else 3558 { 3492 3559 pState->contextNormal = pDesc->context; 3560 STAM_COUNTER_INC(&pState->StatTxDescCtxNormal); 3561 } 3493 3562 E1kLog2(("%s %s context updated: IP CSS=%02X, IP CSO=%02X, IP CSE=%04X" 3494 3563 ", TU CSS=%02X, TU CSO=%02X, TU CSE=%04X\n", INSTANCE(pState), … … 3529 3598 pState->fIPcsum ? " IP" : "", 3530 3599 pState->fTCPcsum ? " TCP/UDP" : "")); 3531 if (e1kCanDoGso(&pState->GsoCtx, &pDesc->data ))3600 if (e1kCanDoGso(&pState->GsoCtx, &pDesc->data, &pState->contextTSE)) 3532 3601 e1kXmitAllocBuf(pState, pState->contextTSE.dw2.u20PAYLEN + pState->contextTSE.dw3.u8HDRLEN, 3533 3602 true /*fExactSize*/, true /*fGso*/); … … 3545 3614 if (e1kXmitIsGsoBuf(pState->pTxSgR3)) 3546 3615 { 3616 STAM_COUNTER_INC(&pState->StatTxPathGSO); 3547 3617 bool fRc = e1kAddToFrame(pState, pDesc->data.u64BufAddr, pDesc->data.cmd.u20DTALEN); 3548 3618 if (pDesc->data.cmd.fEOP) … … 3569 3639 else if (!pDesc->data.cmd.fTSE) 3570 3640 { 3641 STAM_COUNTER_INC(&pState->StatTxPathRegular); 3571 3642 bool fRc = e1kAddToFrame(pState, pDesc->data.u64BufAddr, pDesc->data.cmd.u20DTALEN); 3572 3643 if (pDesc->data.cmd.fEOP) … … 3593 3664 } 3594 3665 else 3666 { 3667 STAM_COUNTER_INC(&pState->StatTxPathFallback); 3595 3668 e1kFallbackAddToFrame(pState, pDesc, pDesc->data.cmd.u20DTALEN); 3669 } 3596 3670 3597 3671 e1kDescReport(pState, pDesc, addr); … … 5741 5815 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTransmitSend, STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_TICKS_PER_CALL, "Profiling send transmit in HC", "/Devices/E1k%d/Transmit/Send", iInstance); 5742 5816 5817 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxDescCtxNormal, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of normal context descriptors","/Devices/E1k%d/TxDesc/ContexNormal", iInstance); 5818 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxDescCtxTSE, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of TSE context descriptors", "/Devices/E1k%d/TxDesc/ContextTSE", iInstance); 5819 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxDescData, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of TX data descriptors", "/Devices/E1k%d/TxDesc/Data", iInstance); 5743 5820 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxDescLegacy, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of TX legacy descriptors", "/Devices/E1k%d/TxDesc/Legacy", iInstance); 5744 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxDescData, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of TX data descriptors", "/Devices/E1k%d/TxDesc/Data", iInstance);5745 5821 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxDescTSEData, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of TX TSE data descriptors", "/Devices/E1k%d/TxDesc/TSEData", iInstance); 5822 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxPathFallback, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Fallback TSE descriptor path", "/Devices/E1k%d/TxPath/Fallback", iInstance); 5823 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxPathGSO, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "GSO TSE descriptor path", "/Devices/E1k%d/TxPath/GSO", iInstance); 5824 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatTxPathRegular, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Regular descriptor path", "/Devices/E1k%d/TxPath/Normal", iInstance); 5746 5825 PDMDevHlpSTAMRegisterF(pDevIns, &pState->StatPHYAccesses, STAMTYPE_COUNTER, STAMVISIBILITY_ALWAYS, STAMUNIT_OCCURENCES, "Number of PHY accesses", "/Devices/E1k%d/PHYAccesses", iInstance); 5747 5826 #endif /* VBOX_WITH_STATISTICS || E1K_REL_STATS */
Note:
See TracChangeset
for help on using the changeset viewer.