Changeset 41029 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Apr 23, 2012 6:25:08 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/DevE1000.cpp
r40998 r41029 88 88 * to allocating their buffers (see #5582). 89 89 */ 90 //#define E1K_WITH_TXD_CACHE 190 #define E1K_WITH_TXD_CACHE 1 91 91 /* End of Options ************************************************************/ 92 92 … … 98 98 * TSE packet. 99 99 */ 100 #define E1K_TXD_CACHE_SIZE 1 6u100 #define E1K_TXD_CACHE_SIZE 18u 101 101 #endif /* E1K_WITH_TXD_CACHE */ 102 102 … … 132 132 # define E1kLog2(a) LogRel(a) 133 133 # define E1kLog3(a) LogRel(a) 134 # define E1kLogX(a) LogRel(a) 134 135 //# define E1kLog3(a) do {} while (0) 135 136 # else … … 137 138 # define E1kLog2(a) do {} while (0) 138 139 # define E1kLog3(a) do {} while (0) 140 # define E1kLogX(a) do {} while (0) 139 141 # endif 140 142 #else … … 142 144 # define E1kLog2(a) Log2(a) 143 145 # define E1kLog3(a) Log3(a) 146 # define E1kLogX(x, a) LogIt(LOG_INSTANCE, x, LOG_GROUP, a) 144 147 //# define E1kLog(a) do {} while (0) 145 148 //# define E1kLog2(a) do {} while (0) … … 1066 1069 E1KTXCTX contextNormal; 1067 1070 #ifdef E1K_WITH_TXD_CACHE 1068 /** EMT/TX: Fetched TX descriptors. */1071 /** TX: Fetched TX descriptors. */ 1069 1072 E1KTXDESC aTxDescriptors[E1K_TXD_CACHE_SIZE]; 1070 /** EMT/TX: Actual number of fetched TX descriptors. */1073 /** TX: Actual number of fetched TX descriptors. */ 1071 1074 uint8_t nTxDFetched; 1072 /** EMT/TX: Index in cache of TX descriptor being processed. */1075 /** TX: Index in cache of TX descriptor being processed. */ 1073 1076 uint8_t iTxDCurrent; 1074 /** EMT/TX: Will this frame be sent as GSO. */1077 /** TX: Will this frame be sent as GSO. */ 1075 1078 bool fGSO; 1076 /** EMT/TX: Number of bytes in next packet. */1079 /** TX: Number of bytes in next packet. */ 1077 1080 uint32_t cbTxAlloc; 1078 1081 … … 1647 1650 * @thread E1000_TX 1648 1651 */ 1649 static void e1kPrintTDesc(E1KSTATE* pState, E1KTXDESC* pDesc, const char* cszDir) 1652 static void e1kPrintTDesc(E1KSTATE* pState, E1KTXDESC* pDesc, const char* cszDir, 1653 unsigned uLevel = RTLOGGRPFLAGS_LEVEL_2) 1650 1654 { 1651 1655 switch (e1kGetDescType(pDesc)) 1652 1656 { 1653 1657 case E1K_DTYP_CONTEXT: 1654 E1kLog 2(("%s %s Context Transmit Descriptor %s\n",1658 E1kLogX(uLevel, ("%s %s Context Transmit Descriptor %s\n", 1655 1659 INSTANCE(pState), cszDir, cszDir)); 1656 E1kLog 2((" IPCSS=%02X IPCSO=%02X IPCSE=%04X TUCSS=%02X TUCSO=%02X TUCSE=%04X\n",1660 E1kLogX(uLevel, (" IPCSS=%02X IPCSO=%02X IPCSE=%04X TUCSS=%02X TUCSO=%02X TUCSE=%04X\n", 1657 1661 pDesc->context.ip.u8CSS, pDesc->context.ip.u8CSO, pDesc->context.ip.u16CSE, 1658 1662 pDesc->context.tu.u8CSS, pDesc->context.tu.u8CSO, pDesc->context.tu.u16CSE)); 1659 E1kLog 2((" TUCMD:%s%s%s %s %s PAYLEN=%04x HDRLEN=%04x MSS=%04x STA: %s\n",1663 E1kLogX(uLevel, (" TUCMD:%s%s%s %s %s PAYLEN=%04x HDRLEN=%04x MSS=%04x STA: %s\n", 1660 1664 pDesc->context.dw2.fIDE ? " IDE":"", 1661 1665 pDesc->context.dw2.fRS ? " RS" :"", … … 1669 1673 break; 1670 1674 case E1K_DTYP_DATA: 1671 E1kLog 2(("%s %s Data Transmit Descriptor (%d bytes) %s\n",1675 E1kLogX(uLevel, ("%s %s Data Transmit Descriptor (%d bytes) %s\n", 1672 1676 INSTANCE(pState), cszDir, pDesc->data.cmd.u20DTALEN, cszDir)); 1673 E1kLog 2((" Address=%16LX DTALEN=%05X\n",1677 E1kLogX(uLevel, (" Address=%16LX DTALEN=%05X\n", 1674 1678 pDesc->data.u64BufAddr, 1675 1679 pDesc->data.cmd.u20DTALEN)); 1676 E1kLog 2((" DCMD:%s%s%s%s%s%s STA:%s%s%s POPTS:%s%s SPECIAL:%s VLAN=%03x PRI=%x\n",1680 E1kLogX(uLevel, (" DCMD:%s%s%s%s%s%s STA:%s%s%s POPTS:%s%s SPECIAL:%s VLAN=%03x PRI=%x\n", 1677 1681 pDesc->data.cmd.fIDE ? " IDE" :"", 1678 1682 pDesc->data.cmd.fVLE ? " VLE" :"", … … 1691 1695 break; 1692 1696 case E1K_DTYP_LEGACY: 1693 E1kLog 2(("%s %s Legacy Transmit Descriptor (%d bytes) %s\n",1697 E1kLogX(uLevel, ("%s %s Legacy Transmit Descriptor (%d bytes) %s\n", 1694 1698 INSTANCE(pState), cszDir, pDesc->legacy.cmd.u16Length, cszDir)); 1695 E1kLog 2((" Address=%16LX DTALEN=%05X\n",1699 E1kLogX(uLevel, (" Address=%16LX DTALEN=%05X\n", 1696 1700 pDesc->data.u64BufAddr, 1697 1701 pDesc->legacy.cmd.u16Length)); 1698 E1kLog 2((" CMD:%s%s%s%s%s%s STA:%s%s%s CSO=%02x CSS=%02x SPECIAL:%s VLAN=%03x PRI=%x\n",1702 E1kLogX(uLevel, (" CMD:%s%s%s%s%s%s STA:%s%s%s CSO=%02x CSS=%02x SPECIAL:%s VLAN=%03x PRI=%x\n", 1699 1703 pDesc->legacy.cmd.fIDE ? " IDE" :"", 1700 1704 pDesc->legacy.cmd.fVLE ? " VLE" :"", … … 4513 4517 return rc; 4514 4518 } 4515 /* 4516 * Process all pending descriptors. 4517 * Note! Do not process descriptors in locked state 4518 */ 4519 while (TDH != TDT && !pState->fLocked) 4520 { 4521 E1KTXDESC desc; 4522 E1kLog3(("%s About to process new TX descriptor at %08x%08x, TDLEN=%08x, TDH=%08x, TDT=%08x\n", 4523 INSTANCE(pState), TDBAH, TDBAL + TDH * sizeof(desc), TDLEN, TDH, TDT)); 4524 4525 e1kLoadDesc(pState, &desc, ((uint64_t)TDBAH << 32) + TDBAL + TDH * sizeof(desc)); 4526 rc = e1kXmitDesc(pState, &desc, ((uint64_t)TDBAH << 32) + TDBAL + TDH * sizeof(desc), fOnWorkerThread); 4527 /* If we failed to transmit descriptor we will try it again later */ 4528 if (RT_FAILURE(rc)) 4529 break; 4530 if (++TDH * sizeof(desc) >= TDLEN) 4531 TDH = 0; 4532 4533 if (e1kGetTxLen(pState) <= GET_BITS(TXDCTL, LWTHRESH)*8) 4534 { 4535 E1kLog2(("%s Low on transmit descriptors, raise ICR.TXD_LOW, len=%x thresh=%x\n", 4536 INSTANCE(pState), e1kGetTxLen(pState), GET_BITS(TXDCTL, LWTHRESH)*8)); 4537 e1kRaiseInterrupt(pState, VERR_SEM_BUSY, ICR_TXD_LOW); 4538 } 4539 4540 STAM_PROFILE_ADV_STOP(&pState->CTX_SUFF_Z(StatTransmit), a); 4541 } 4542 4543 /// @todo: uncomment: pState->uStatIntTXQE++; 4544 /// @todo: uncomment: e1kRaiseInterrupt(pState, ICR_TXQE); 4519 //rc = e1kCsTxEnter(pState, VERR_SEM_BUSY); 4520 if (RT_LIKELY(rc == VINF_SUCCESS)) 4521 { 4522 /* 4523 * Process all pending descriptors. 4524 * Note! Do not process descriptors in locked state 4525 */ 4526 while (TDH != TDT && !pState->fLocked) 4527 { 4528 E1KTXDESC desc; 4529 E1kLog3(("%s About to process new TX descriptor at %08x%08x, TDLEN=%08x, TDH=%08x, TDT=%08x\n", 4530 INSTANCE(pState), TDBAH, TDBAL + TDH * sizeof(desc), TDLEN, TDH, TDT)); 4531 4532 e1kLoadDesc(pState, &desc, ((uint64_t)TDBAH << 32) + TDBAL + TDH * sizeof(desc)); 4533 rc = e1kXmitDesc(pState, &desc, ((uint64_t)TDBAH << 32) + TDBAL + TDH * sizeof(desc), fOnWorkerThread); 4534 /* If we failed to transmit descriptor we will try it again later */ 4535 if (RT_FAILURE(rc)) 4536 break; 4537 if (++TDH * sizeof(desc) >= TDLEN) 4538 TDH = 0; 4539 4540 if (e1kGetTxLen(pState) <= GET_BITS(TXDCTL, LWTHRESH)*8) 4541 { 4542 E1kLog2(("%s Low on transmit descriptors, raise ICR.TXD_LOW, len=%x thresh=%x\n", 4543 INSTANCE(pState), e1kGetTxLen(pState), GET_BITS(TXDCTL, LWTHRESH)*8)); 4544 e1kRaiseInterrupt(pState, VERR_SEM_BUSY, ICR_TXD_LOW); 4545 } 4546 4547 STAM_PROFILE_ADV_STOP(&pState->CTX_SUFF_Z(StatTransmit), a); 4548 } 4549 4550 /// @todo: uncomment: pState->uStatIntTXQE++; 4551 /// @todo: uncomment: e1kRaiseInterrupt(pState, ICR_TXQE); 4552 //e1kCsTxLeave(pState); 4553 } 4545 4554 4546 4555 /* … … 4552 4561 } 4553 4562 #else /* E1K_WITH_TXD_CACHE */ 4563 static void e1kDumpTxDCache(E1KSTATE *pState) 4564 { 4565 for (int i = 0; i < pState->nTxDFetched; ++i) 4566 e1kPrintTDesc(pState, &pState->aTxDescriptors[i], "***", RTLOGGRPFLAGS_LEVEL_4); 4567 } 4568 4554 4569 /** 4555 4570 * Transmit pending descriptors. … … 4596 4611 } 4597 4612 uint8_t u8Remain = pState->nTxDFetched - pState->iTxDCurrent; 4613 if (RT_UNLIKELY(u8Remain == E1K_TXD_CACHE_SIZE)) 4614 { 4615 /* 4616 * The descriptor cache is full, but we were unable to find 4617 * a complete packet in it. Drop the cache and hope that 4618 * the guest driver can recover from network card error. 4619 */ 4620 Log4(("%s No complete packets in full TxD cache! " 4621 "Fetched=%d, TX len=%d. Dump follows:\n", 4622 INSTANCE(pState), pState->nTxDFetched, e1kGetTxLen(pState))); 4623 e1kDumpTxDCache(pState); 4624 pState->nTxDFetched = 0; 4625 rc = VERR_NET_IO_ERROR; 4626 goto out; 4627 } 4598 4628 if (u8Remain > 0) 4599 4629 { … … 4705 4735 { 4706 4736 E1kLogRel(("E1000: TDT write: %d descriptors to process\n", e1kGetTxLen(pState))); 4707 E1kLog(("%s e1kRegWriteTDT: %d descriptors to process , waking up E1000_TX thread\n",4737 E1kLog(("%s e1kRegWriteTDT: %d descriptors to process\n", 4708 4738 INSTANCE(pState), e1kGetTxLen(pState))); 4709 4739 e1kCsTxLeave(pState);
Note:
See TracChangeset
for help on using the changeset viewer.