~victored/+junk/mt7601U-linux-driver-64bit

« back to all changes in this revision

Viewing changes to os/linux/rt_linux.c

  • Committer: Victor Martinez
  • Date: 2014-08-30 05:23:18 UTC
  • Revision ID: victoreduardm@gmail.com-20140830052318-vw5w8ug2k869byrn
Add 64-bit linux support, as per http://ubuntuforums.org/archive/index.php/t-2092888.html.

This fixes kernel panics and most connection drops.

Don't use this version in 32-bit systems.

Show diffs side-by-side

added added

removed removed

Lines of Context:
494
494
                MEM_DBG_PKT_ALLOC_INC(skb);
495
495
 
496
496
                skb_reserve(skb, 2);
497
 
                NdisMoveMemory(skb->tail, pHeader802_3, HdrLen);
 
497
                NdisMoveMemory(GET_OS_PKT_DATATAIL(skb), pHeader802_3, HdrLen);
498
498
                skb_put(skb, HdrLen);
499
 
                NdisMoveMemory(skb->tail, pData, DataSize);
 
499
                NdisMoveMemory(GET_OS_PKT_DATATAIL(skb), pData, DataSize);
500
500
                skb_put(skb, DataSize);
501
501
                skb->dev = pNetDev;     /*get_netdev_from_bssid(pAd, FromWhichBSSID); */
502
502
                pPacket = OSPKT_TO_RTPKT(skb);
644
644
        if (pClonedPkt) {
645
645
                /* set the correct dataptr and data len */
646
646
                MEM_DBG_PKT_ALLOC_INC(pClonedPkt);
647
 
                pClonedPkt->dev = pRxPkt->dev;
648
 
                pClonedPkt->data = pData;
649
 
                pClonedPkt->len = DataSize;
650
 
                pClonedPkt->tail = pClonedPkt->data + pClonedPkt->len;
 
647
 
 
648
                SET_OS_PKT_NETDEV(pClonedPkt, pRxPkt->dev);
 
649
                SET_OS_PKT_DATAPTR(pClonedPkt, pData);
 
650
                SET_OS_PKT_LEN(pClonedPkt, DataSize);
 
651
                SET_OS_PKT_DATATAIL(pClonedPkt, pData, DataSize);
 
652
 
651
653
                ASSERT(DataSize < 1530);
652
654
        }
653
655
        return pClonedPkt;
689
691
        pOSPkt = RTPKT_TO_OSPKT(pRxPacket);
690
692
 
691
693
        /*get_netdev_from_bssid(pAd, FromWhichBSSID); */
692
 
        pOSPkt->dev = pNetDev;
693
 
        pOSPkt->data = pData;
694
 
        pOSPkt->len = DataSize;
695
 
        pOSPkt->tail = pOSPkt->data + pOSPkt->len;
 
694
 
 
695
        SET_OS_PKT_NETDEV(pOSPkt, pNetDev); 
 
696
        SET_OS_PKT_DATAPTR(pOSPkt, pData);
 
697
        SET_OS_PKT_LEN(pOSPkt, DataSize);
 
698
        SET_OS_PKT_DATATAIL(pOSPkt, pData, DataSize);
696
699
 
697
700
        /* copy 802.3 header */
698
701
 
718
721
 
719
722
        pOSPkt = RTPKT_TO_OSPKT(pRxPacket);
720
723
 
721
 
        pOSPkt->dev = pNetDev;
722
 
        pOSPkt->data = pData;
723
 
        pOSPkt->len = DataSize;
724
 
        pOSPkt->tail = pOSPkt->data + pOSPkt->len;
 
724
        SET_OS_PKT_NETDEV(pOSPkt, pNetDev); 
 
725
        SET_OS_PKT_DATAPTR(pOSPkt, pData);
 
726
        SET_OS_PKT_LEN(pOSPkt, DataSize);
 
727
        SET_OS_PKT_DATATAIL(pOSPkt, pData, DataSize);
725
728
}
726
729
 
727
730
#endif /* HDR_TRANS_SUPPORT */
843
846
 
844
847
 
845
848
        pOSPkt = RTPKT_TO_OSPKT(pRxPacket);     /*pRxBlk->pRxPacket); */
846
 
        pOSPkt->dev = pNetDev;  /*get_netdev_from_bssid(pAd, BSS0); */
 
849
        SET_OS_PKT_NETDEV(pOSPkt, pNetDev); 
 
850
 
847
851
        if (pHeader->FC.Type == BTYPE_DATA) {
848
852
                DataSize -= LENGTH_802_11;
849
853
                if ((pHeader->FC.ToDs == 1) && (pHeader->FC.FrDs == 1))
1659
1663
void RtmpOSNetDevDetach(PNET_DEV pNetDev)
1660
1664
{
1661
1665
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
1662
 
        struct net_device_ops *pNetDevOps = (struct net_device_ops *)pNetDev->netdev_ops;
 
1666
        union {
 
1667
                const struct net_device_ops *const_ops;
 
1668
                struct net_device_ops *ops;
 
1669
        } pNetDevOps;
 
1670
        pNetDevOps.const_ops = pNetDev->netdev_ops;
1663
1671
#endif
1664
1672
        int ret;
1665
1673
 
1671
1679
                rtnl_unlock();
1672
1680
 
1673
1681
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
1674
 
        vfree(pNetDevOps);
 
1682
        vfree(pNetDevOps.ops);
1675
1683
#endif
1676
1684
}
1677
1685
 
1714
1722
         rtnl_locked = FALSE;
1715
1723
 
1716
1724
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
1717
 
        struct net_device_ops *pNetDevOps = (struct net_device_ops *)pNetDev->netdev_ops;
 
1725
        union {
 
1726
                const struct net_device_ops *const_ops;
 
1727
                struct net_device_ops *ops;
 
1728
        } pNetDevOps;
 
1729
        pNetDevOps.const_ops = pNetDev->netdev_ops;
1718
1730
#endif
1719
1731
 
1720
1732
        DBGPRINT(RT_DEBUG_TRACE, ("RtmpOSNetDevAttach()--->\n"));
1726
1738
/*              GET_PAD_FROM_NET_DEV(pAd, pNetDev); */
1727
1739
 
1728
1740
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
1729
 
                pNetDevOps->ndo_open = pDevOpHook->open;
1730
 
                pNetDevOps->ndo_stop = pDevOpHook->stop;
1731
 
                pNetDevOps->ndo_start_xmit =
 
1741
                pNetDevOps.ops->ndo_open = pDevOpHook->open;
 
1742
                pNetDevOps.ops->ndo_stop = pDevOpHook->stop;
 
1743
                pNetDevOps.ops->ndo_start_xmit =
1732
1744
                    (HARD_START_XMIT_FUNC) (pDevOpHook->xmit);
1733
 
                pNetDevOps->ndo_do_ioctl = pDevOpHook->ioctl;
 
1745
                pNetDevOps.ops->ndo_do_ioctl = pDevOpHook->ioctl;
1734
1746
#else
1735
1747
                pNetDev->open = pDevOpHook->open;
1736
1748
                pNetDev->stop = pDevOpHook->stop;
1748
1760
                 */
1749
1761
                if (pDevOpHook->get_stats)
1750
1762
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
1751
 
                        pNetDevOps->ndo_get_stats = pDevOpHook->get_stats;
 
1763
                        pNetDevOps.ops->ndo_get_stats = pDevOpHook->get_stats;
1752
1764
#else
1753
1765
                        pNetDev->get_stats = pDevOpHook->get_stats;
1754
1766
#endif
1789
1801
        }
1790
1802
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,24)
1791
1803
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,31)
1792
 
        pNetDevOps->ndo_validate_addr = NULL;
 
1804
        pNetDevOps.ops->ndo_validate_addr = NULL;
1793
1805
        /*pNetDev->netdev_ops = ops; */
1794
1806
#else
1795
1807
        pNetDev->validate_addr = NULL;
5499
5511
}
5500
5512
 
5501
5513
#endif /* OS_ABL_FUNC_SUPPORT */
5502