Changeset 30111 in vbox for trunk/src/VBox/HostDrivers/VBoxNetFlt/linux
- Timestamp:
- Jun 9, 2010 12:14:59 PM (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/HostDrivers/VBoxNetFlt/linux/VBoxNetFlt-linux.c
r30059 r30111 171 171 #ifdef VBOXNETFLT_WITH_QDISC 172 172 //#define QDISC_LOG(x) printk x 173 #define QDISC_LOG(x) 173 #define QDISC_LOG(x) do { } while (0) 174 174 175 175 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 20) … … 593 593 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) 594 594 pPriv->ppSaved[0] = pDev->qdisc_sleeping; 595 ASMAtomicWritePtr( (void * volatile *)&pDev->qdisc_sleeping, pNew);596 ASMAtomicWritePtr( (void * volatile *)&pDev->qdisc, pNew);595 ASMAtomicWritePtr(&pDev->qdisc_sleeping, pNew); 596 ASMAtomicWritePtr(&pDev->qdisc, pNew); 597 597 #else /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 27) */ 598 598 for (i = 0; i < pDev->num_tx_queues; i++) … … 601 601 602 602 pPriv->ppSaved[i] = pQueue->qdisc_sleeping; 603 ASMAtomicWritePtr( (void * volatile *)&pQueue->qdisc_sleeping, pNew);604 ASMAtomicWritePtr( (void * volatile *)&pQueue->qdisc, pNew);603 ASMAtomicWritePtr(&pQueue->qdisc_sleeping, pNew); 604 ASMAtomicWritePtr(&pQueue->qdisc, pNew); 605 605 if (i) 606 606 atomic_inc(&pNew->refcnt); … … 609 609 # if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) 610 610 pPriv->ppSaved[pDev->num_tx_queues] = pDev->qdisc; 611 ASMAtomicWritePtr( (void * volatile *)&pDev->qdisc, pNew);611 ASMAtomicWritePtr(&pDev->qdisc, pNew); 612 612 atomic_inc(&pNew->refcnt); 613 613 # endif /* LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) */ … … 619 619 pPriv = qdisc_priv(pExisting); 620 620 } 621 ASMAtomicWritePtr( (void * volatile *)&pPriv->pVBoxNetFlt, pThis);621 ASMAtomicWritePtr(&pPriv->pVBoxNetFlt, pThis); 622 622 QDISC_LOG(("vboxNetFltLinuxInstallQdisc: pThis=%p\n", pPriv->pVBoxNetFlt)); 623 623 } … … 631 631 struct Qdisc *pQdisc; 632 632 if (!pDev) 633 pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);633 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 634 634 if (!VALID_PTR(pDev)) 635 635 { … … 651 651 pPriv = qdisc_priv(pQdisc); 652 652 Assert(pPriv->pVBoxNetFlt == pThis); 653 ASMAtomicWritePtr( (void * volatile *)&pPriv->pVBoxNetFlt, NULL);654 655 QDISC_LOG(("vboxNetFltLinuxQdiscRemove: refcnt=%d num_tx_queues=%d\n", 653 ASMAtomicWritePtr(&pPriv->pVBoxNetFlt, NULL); 654 655 QDISC_LOG(("vboxNetFltLinuxQdiscRemove: refcnt=%d num_tx_queues=%d\n", 656 656 atomic_read(&pQdisc->refcnt), pDev->num_tx_queues)); 657 657 #if LINUX_VERSION_CODE < KERNEL_VERSION(2, 6, 27) … … 659 659 if (pPriv->ppSaved[0]) 660 660 { 661 ASMAtomicWritePtr((void * volatile *)&pDev->qdisc_sleeping, 662 pPriv->ppSaved[0]); 663 ASMAtomicWritePtr((void * volatile *)&pDev->qdisc, 664 pPriv->ppSaved[0]); 661 ASMAtomicWritePtr(&pDev->qdisc_sleeping, pPriv->ppSaved[0]); 662 ASMAtomicWritePtr(&pDev->qdisc, pPriv->ppSaved[0]); 665 663 pPriv->ppSaved[0] = NULL; 666 664 while (QDISC_IS_BUSY(pDev, pQdisc)) … … 675 673 { 676 674 Assert(pQueue->qdisc_sleeping == pQdisc); 677 ASMAtomicWritePtr((void * volatile *)&pQueue->qdisc_sleeping, 678 pPriv->ppSaved[i]); 679 ASMAtomicWritePtr((void * volatile *)&pQueue->qdisc, 680 pPriv->ppSaved[i]); 675 ASMAtomicWritePtr(&pQueue->qdisc_sleeping, pPriv->ppSaved[i]); 676 ASMAtomicWritePtr(&pQueue->qdisc, pPriv->ppSaved[i]); 681 677 pPriv->ppSaved[i] = NULL; 682 678 while (QDISC_IS_BUSY(pDev, pQdisc)) … … 687 683 /* Newer kernels store root qdisc in netdev structure as well. */ 688 684 #if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 32) 689 ASMAtomicWritePtr((void * volatile *)&pDev->qdisc, 690 pPriv->ppSaved[pDev->num_tx_queues]); 685 ASMAtomicWritePtr(&pDev->qdisc, pPriv->ppSaved[pDev->num_tx_queues]); 691 686 pPriv->ppSaved[pDev->num_tx_queues] = NULL; 692 687 while (QDISC_IS_BUSY(pDev, pQdisc)) … … 912 907 913 908 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); /* (this isn't necessary, but so what) */ 914 ASMAtomic XchgPtr((void * volatile *)&pDev->netdev_ops, pOverride);909 ASMAtomicWritePtr((void * volatile *)&pDev->netdev_ops, pOverride); 915 910 RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp); 916 911 } … … 930 925 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 931 926 if (!pDev) 932 pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);927 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 933 928 if (VALID_PTR(pDev)) 934 929 { … … 939 934 ) 940 935 { 941 ASMAtomic XchgPtr((void * volatile *)&pDev->netdev_ops, pOverride->pOrgOps);936 ASMAtomicWritePtr((void * volatile *)&pDev->netdev_ops, pOverride->pOrgOps); 942 937 ASMAtomicWriteU32(&pOverride->u32Magic, 0); 943 938 } … … 990 985 return pDev; 991 986 #else 992 return (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);987 return ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 993 988 #endif 994 989 } … … 1060 1055 * Allocate a packet and copy over the data. 1061 1056 */ 1062 pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);1057 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 1063 1058 pPkt = dev_alloc_skb(pSG->cbTotal + NET_IP_ALIGN); 1064 1059 if (RT_UNLIKELY(!pPkt)) … … 1282 1277 1283 1278 pThis = VBOX_FLT_PT_TO_INST(pPacketType); 1284 pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);1279 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 1285 1280 if (pThis->u.s.pDev != pSkbDev) 1286 1281 { … … 1820 1815 1821 1816 pSwitchPort = pThis->pSwitchPort; /* this doesn't need to be here, but it doesn't harm. */ 1822 pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);1817 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 1823 1818 if (pDev) 1824 1819 fFeatures = pDev->features; … … 1887 1882 1888 1883 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 1889 ASMAtomicUoWritePtr( (void * volatile *)&pThis->u.s.pDev, pDev);1884 ASMAtomicUoWritePtr(&pThis->u.s.pDev, pDev); 1890 1885 RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp); 1891 1886 1892 1887 Log(("vboxNetFltLinuxAttachToInterface: Device %p(%s) retained. ref=%d\n", pDev, pDev->name, atomic_read(&pDev->refcnt))); 1893 Log(("vboxNetFltLinuxAttachToInterface: Got pDev=%p pThis=%p pThis->u.s.pDev=%p\n", pDev, pThis, ASMAtomicUoReadPtr ((void * volatile *)&pThis->u.s.pDev)));1888 Log(("vboxNetFltLinuxAttachToInterface: Got pDev=%p pThis=%p pThis->u.s.pDev=%p\n", pDev, pThis, ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *))); 1894 1889 1895 1890 /* Get the mac address while we still have a valid net_device reference. */ … … 1916 1911 */ 1917 1912 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 1918 pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);1913 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 1919 1914 if (pDev) 1920 1915 { … … 1951 1946 #endif /* VBOXNETFLT_WITH_QDISC */ 1952 1947 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 1953 ASMAtomicUoWritePtr( (void * volatile *)&pThis->u.s.pDev, NULL);1948 ASMAtomicUoWritePtr(&pThis->u.s.pDev, NULL); 1954 1949 RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp); 1955 1950 dev_put(pDev); … … 1978 1973 ASMAtomicWriteBool(&pThis->u.s.fRegistered, false); 1979 1974 ASMAtomicWriteBool(&pThis->fDisconnectedFromHost, true); 1980 ASMAtomicUoWritePtr( (void * volatile *)&pThis->u.s.pDev, NULL);1975 ASMAtomicUoWritePtr(&pThis->u.s.pDev, NULL); 1981 1976 RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp); 1982 1977 … … 2068 2063 2069 2064 Log(("VBoxNetFlt: got event %s(0x%lx) on %s, pDev=%p pThis=%p pThis->u.s.pDev=%p\n", 2070 vboxNetFltLinuxGetNetDevEventName(ulEventType), ulEventType, pDev->name, pDev, pThis, ASMAtomicUoReadPtr ((void * volatile *)&pThis->u.s.pDev)));2065 vboxNetFltLinuxGetNetDevEventName(ulEventType), ulEventType, pDev->name, pDev, pThis, ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *))); 2071 2066 if ( ulEventType == NETDEV_REGISTER 2072 2067 && !strcmp(pDev->name, pThis->szName)) … … 2076 2071 else 2077 2072 { 2078 pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);2073 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 2079 2074 if (pDev == ptr) 2080 2075 { … … 2111 2106 int vboxNetFltPortOsXmit(PVBOXNETFLTINS pThis, void *pvIfData, PINTNETSG pSG, uint32_t fDst) 2112 2107 { 2113 NOREF(pvIfData);2114 2115 2108 struct net_device * pDev; 2116 2109 int err; 2117 2110 int rc = VINF_SUCCESS; 2111 NOREF(pvIfData); 2118 2112 2119 2113 LogFlow(("vboxNetFltPortOsXmit: pThis=%p (%s)\n", pThis, pThis->szName)); … … 2274 2268 2275 2269 RTSpinlockAcquireNoInts(pThis->hSpinlock, &Tmp); 2276 pDev = (struct net_device *)ASMAtomicUoReadPtr((void * volatile *)&pThis->u.s.pDev);2270 pDev = ASMAtomicUoReadPtrT(&pThis->u.s.pDev, struct net_device *); 2277 2271 fRegistered = ASMAtomicUoReadBool(&pThis->u.s.fRegistered); 2278 2272 RTSpinlockReleaseNoInts(pThis->hSpinlock, &Tmp);
Note:
See TracChangeset
for help on using the changeset viewer.