Changeset 93675 in vbox for trunk/src/VBox
- Timestamp:
- Feb 10, 2022 9:45:11 AM (3 years ago)
- Location:
- trunk/src/VBox/Devices/Network
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/Dev3C501.cpp
r93668 r93675 184 184 /** Maximum number of times we report a link down to the guest (failure to send frame) */ 185 185 #define ELNK_MAX_LINKDOWN_REPORTED 3 186 187 /** Maximum number of times we postpone restoring a link that is temporarily down. */ 188 #define ELNK_MAX_LINKRST_POSTPONED 3 186 189 187 190 /** Maximum frame size we handle */ … … 392 395 /** Number of times we've reported the link down. */ 393 396 uint16_t cLinkDownReported; 397 /** Number of times we've postponed the link restore. */ 398 uint16_t cLinkRestorePostponed; 394 399 395 400 /** The "hardware" MAC address. */ … … 1665 1670 * should be considered lost. 1666 1671 */ 1667 static DECLCALLBACK(void) elnk TimerRestore(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, void *pvUser)1672 static DECLCALLBACK(void) elnkR3TimerRestore(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, void *pvUser) 1668 1673 { 1669 1674 RT_NOREF(pvUser); … … 1673 1678 1674 1679 rc = VERR_GENERAL_FAILURE; 1675 if (pThis->cLinkDownReported <= ELNK_MAX_LINKDOWN_REPORTED) 1680 1681 /* The EhterLink cards have no concept of a link state, and cables were assumed to be 1682 * permanently attached (AUI or BNC). We can simulate a disconnected cable by reporting 1683 * collisions on transmit, but a guest that waits to receive something will never know. 1684 * For that reason, the link is temporarily down, we will only postpone restoring it 1685 * a couple of times, and then reconnect regardless of whether the guest noticed 1686 * anything or not. 1687 */ 1688 if ( (pThis->cLinkDownReported <= ELNK_MAX_LINKDOWN_REPORTED) 1689 && (pThis->cLinkRestorePostponed <= ELNK_MAX_LINKRST_POSTPONED)) 1676 1690 rc = PDMDevHlpTimerSetMillies(pDevIns, hTimer, 1500); 1677 1691 if (RT_FAILURE(rc)) … … 1682 1696 LogRel(("3C501#%d: The link is back up again after the restore.\n", 1683 1697 pThis->iInstance)); 1684 LogFunc(("#%d: Clearing ERR and CERR after load.cLinkDownReported=%d\n",1698 LogFunc(("#%d: cLinkDownReported=%d\n", 1685 1699 pThis->iInstance, pThis->cLinkDownReported)); 1686 1700 pThis->Led.Actual.s.fError = 0; … … 1688 1702 } 1689 1703 else 1690 Log(("#%d elnkTimerRestore: cLinkDownReported=%d, wait another 1500ms...\n", 1691 pThis->iInstance, pThis->cLinkDownReported)); 1704 { 1705 LogFunc(("#%d: cLinkDownReported=%d, cLinkRestorePostponed=%d, wait another 1500ms...\n", 1706 pThis->iInstance, pThis->cLinkDownReported, pThis->cLinkRestorePostponed)); 1707 pThis->cLinkRestorePostponed++; 1708 } 1692 1709 1693 1710 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); … … 1700 1717 * @callback_method_impl{FNDBGFHANDLERDEV} 1701 1718 */ 1702 static DECLCALLBACK(void) elnk Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)1719 static DECLCALLBACK(void) elnkR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 1703 1720 { 1704 1721 PELNKSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PELNKSTATE); … … 1740 1757 pHlp->pfnPrintf(pHlp, " Buffer control : %s\n", apszBuffCntrl[pThis->AuxCmd.buf_ctl]); 1741 1758 pHlp->pfnPrintf(pHlp, " Interrupt state : xmit=%u recv=%u dma=%u\n", pThis->IntrState.xmit_intr, pThis->IntrState.recv_intr, pThis->IntrState.dma_intr); 1742 if (pThis->cLinkDownReported) 1759 if (pThis->fLinkTempDown) 1760 { 1743 1761 pHlp->pfnPrintf(pHlp, " Link down count : %d\n", pThis->cLinkDownReported); 1762 pHlp->pfnPrintf(pHlp, " Postpone count : %d\n", pThis->cLinkRestorePostponed); 1763 } 1744 1764 1745 1765 /* Dump the station address. */ … … 1814 1834 pThis->fLinkTempDown = true; 1815 1835 pThis->cLinkDownReported = 0; 1836 pThis->cLinkRestorePostponed = 0; 1816 1837 pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1; 1817 1838 int rc = PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerRestore, pThis->cMsLinkUpDelay); … … 1874 1895 pHlp->pfnSSMPutBool(pSSM, pThis->fISR); 1875 1896 pHlp->pfnSSMPutMem(pSSM, pThis->aStationAddr, sizeof(pThis->aStationAddr)); 1897 1898 /* Save the configured MAC address. */ 1899 pHlp->pfnSSMPutMem(pSSM, &pThis->MacConfigured, sizeof(pThis->MacConfigured)); 1876 1900 1877 1901 return VINF_SUCCESS; … … 1925 1949 pHlp->pfnSSMGetBool(pSSM, &pThis->fLinkUp); 1926 1950 pHlp->pfnSSMGetBool(pSSM, &pThis->fISR); 1951 pHlp->pfnSSMGetMem(pSSM, &pThis->aStationAddr, sizeof(pThis->aStationAddr)); 1927 1952 } 1928 1953 … … 2158 2183 pThis->fLinkTempDown = true; 2159 2184 pThis->cLinkDownReported = 0; 2185 pThis->cLinkRestorePostponed = 0; 2160 2186 pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1; 2161 2187 int rc = PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerRestore, pThis->cMsLinkUpDelay); … … 2166 2192 /* Disconnect. */ 2167 2193 pThis->cLinkDownReported = 0; 2194 pThis->cLinkRestorePostponed = 0; 2168 2195 pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1; 2169 2196 } … … 2319 2346 { 2320 2347 pThis->cLinkDownReported = 0x1000; 2348 pThis->cLinkRestorePostponed = 0x1000; 2321 2349 PDMDevHlpTimerStop(pDevIns, pThis->hTimerRestore); 2322 elnk TimerRestore(pDevIns, pThis->hTimerRestore, pThis);2350 elnkR3TimerRestore(pDevIns, pThis->hTimerRestore, pThis); 2323 2351 } 2324 2352 … … 2476 2504 LogRel(("3C501#%d: Disabling DMA\n", iInstance)); 2477 2505 2478 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, elnk TimerRestore, NULL, TMTIMER_FLAGS_NO_CRIT_SECT | TMTIMER_FLAGS_NO_RING0,2506 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, elnkR3TimerRestore, NULL, TMTIMER_FLAGS_NO_CRIT_SECT | TMTIMER_FLAGS_NO_RING0, 2479 2507 "3C501 Restore Timer", &pThis->hTimerRestore); 2480 2508 if (RT_FAILURE(rc)) … … 2506 2534 */ 2507 2535 RTStrPrintf(szTmp, sizeof(szTmp), "elnk%d", pThis->iInstance); 2508 PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "3C501 info", elnk Info);2536 PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "3C501 info", elnkR3Info); 2509 2537 2510 2538 /* -
trunk/src/VBox/Devices/Network/DevDP8390.cpp
r93601 r93675 352 352 /** Maximum number of times we report a link down to the guest (failure to send frame) */ 353 353 #define DPNIC_MAX_LINKDOWN_REPORTED 3 354 355 /** Maximum number of times we postpone restoring a link that is temporarily down. */ 356 #define DPNIC_MAX_LINKRST_POSTPONED 3 354 357 355 358 /** Maximum frame size we handle */ … … 886 889 /** Number of times we've reported the link down. */ 887 890 uint16_t cLinkDownReported; 891 /** Number of times we've postponed the link restore. */ 892 uint16_t cLinkRestorePostponed; 888 893 889 894 /** The "hardware" MAC address. */ … … 3939 3944 * should be considered lost. 3940 3945 */ 3941 static DECLCALLBACK(void) dpNic TimerRestore(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, void *pvUser)3946 static DECLCALLBACK(void) dpNicR3TimerRestore(PPDMDEVINS pDevIns, TMTIMERHANDLE hTimer, void *pvUser) 3942 3947 { 3943 3948 RT_NOREF(pvUser); … … 3947 3952 3948 3953 rc = VERR_GENERAL_FAILURE; 3949 if (pThis->cLinkDownReported <= DPNIC_MAX_LINKDOWN_REPORTED) 3954 3955 /* The DP8390 based cards have no concept of link state. Reporting collisions on all transmits 3956 * is the best approximation of a disconnected cable that we can do. Some drivers (3C503) warn 3957 * of possible disconnected cable, some don't. Many cards with DP8390 chips had permanently 3958 * attached cables (AUI or BNC) and their drivers do not expect cables to be disconnected and 3959 * re-connected at runtime. Guests which are waiting for a receive have no way to notice any 3960 * problem, therefore we only postpone restoring a link a couple of times, and then reconnect 3961 * regardless of whether the guest noticed anything or not. 3962 */ 3963 if ( (pThis->cLinkDownReported <= DPNIC_MAX_LINKDOWN_REPORTED) 3964 && (pThis->cLinkRestorePostponed <= DPNIC_MAX_LINKRST_POSTPONED)) 3950 3965 rc = PDMDevHlpTimerSetMillies(pDevIns, hTimer, 1500); 3951 3966 if (RT_FAILURE(rc)) … … 3961 3976 } 3962 3977 else 3963 LogFunc(("#%d: cLinkDownReported=%d, wait another 1500ms...\n", pThis->iInstance, pThis->cLinkDownReported)); 3978 { 3979 LogFunc(("#%d: cLinkDownReported=%d, cLinkRestorePostponed=%d, wait another 1500ms...\n", 3980 pThis->iInstance, pThis->cLinkDownReported, pThis->cLinkRestorePostponed)); 3981 pThis->cLinkRestorePostponed++; 3982 } 3964 3983 3965 3984 PDMDevHlpCritSectLeave(pDevIns, &pThis->CritSect); … … 3972 3991 * @callback_method_impl{FNDBGFHANDLERDEV} 3973 3992 */ 3974 static DECLCALLBACK(void) dpNic Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs)3993 static DECLCALLBACK(void) dpNicR3Info(PPDMDEVINS pDevIns, PCDBGFINFOHLP pHlp, const char *pszArgs) 3975 3994 { 3976 3995 PDPNICSTATE pThis = PDMDEVINS_2_DATA(pDevIns, PDPNICSTATE); … … 4106 4125 if (pThis->fMaybeOutOfSpace) 4107 4126 pHlp->pfnPrintf(pHlp, " Waiting for receive space\n"); 4108 if (pThis->cLinkDownReported) 4127 if (pThis->fLinkTempDown) 4128 { 4109 4129 pHlp->pfnPrintf(pHlp, " Link down count %d\n", pThis->cLinkDownReported); 4130 pHlp->pfnPrintf(pHlp, " Postpone count %d\n", pThis->cLinkRestorePostponed); 4131 } 4110 4132 4111 4133 if ((pThis->uDevType == DEV_WD8003) || (pThis->uDevType == DEV_WD8013)) … … 4286 4308 pThis->fLinkTempDown = true; 4287 4309 pThis->cLinkDownReported = 0; 4310 pThis->cLinkRestorePostponed = 0; 4288 4311 pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1; 4289 4312 int rc = PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerRestore, pThis->cMsLinkUpDelay); … … 4485 4508 pHlp->pfnSSMGetBool(pSSM, &pThis->ga.fGaIrq); 4486 4509 4487 /* Set IRQ and DMA based on IDCFR. */ 4488 pThis->uIsaIrq = elGetIrqFromIdcfr(pThis->ga.IDCFR); 4489 pThis->uElIsaDma = elGetDrqFromIdcfr(pThis->ga.IDCFR); 4510 /* Set IRQ and DMA based on IDCFR if this is a 3C503. */ 4511 if (pThis->uDevType == DEV_3C503) 4512 { 4513 pThis->uIsaIrq = elGetIrqFromIdcfr(pThis->ga.IDCFR); 4514 pThis->uElIsaDma = elGetDrqFromIdcfr(pThis->ga.IDCFR); 4515 } 4490 4516 } 4491 4517 … … 4751 4777 pThis->fLinkTempDown = true; 4752 4778 pThis->cLinkDownReported = 0; 4779 pThis->cLinkRestorePostponed = 0; 4753 4780 pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1; 4754 4781 int rc = PDMDevHlpTimerSetMillies(pDevIns, pThis->hTimerRestore, pThis->cMsLinkUpDelay); … … 4759 4786 /* Disconnect. */ 4760 4787 pThis->cLinkDownReported = 0; 4788 pThis->cLinkRestorePostponed = 0; 4761 4789 pThis->Led.Asserted.s.fError = pThis->Led.Actual.s.fError = 1; 4762 4790 } … … 4913 4941 { 4914 4942 pThis->cLinkDownReported = 0x1000; 4943 pThis->cLinkRestorePostponed = 0x1000; 4915 4944 PDMDevHlpTimerStop(pDevIns, pThis->hTimerRestore); 4916 dpNic TimerRestore(pDevIns, pThis->hTimerRestore, pThis);4945 dpNicR3TimerRestore(pDevIns, pThis->hTimerRestore, pThis); 4917 4946 } 4918 4947 … … 5204 5233 5205 5234 5206 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, dpNic TimerRestore, NULL, TMTIMER_FLAGS_NO_CRIT_SECT | TMTIMER_FLAGS_NO_RING0,5235 rc = PDMDevHlpTimerCreate(pDevIns, TMCLOCK_VIRTUAL, dpNicR3TimerRestore, NULL, TMTIMER_FLAGS_NO_CRIT_SECT | TMTIMER_FLAGS_NO_RING0, 5207 5236 "DPNIC Link Restore Timer", &pThis->hTimerRestore); 5208 5237 if (RT_FAILURE(rc)) … … 5234 5263 */ 5235 5264 RTStrPrintf(szTmp, sizeof(szTmp), "dpnic%d", pThis->iInstance); 5236 PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "dpnic info", dpNic Info);5265 PDMDevHlpDBGFInfoRegister(pDevIns, szTmp, "dpnic info", dpNicR3Info); 5237 5266 5238 5267 /*
Note:
See TracChangeset
for help on using the changeset viewer.