diff options
Diffstat (limited to 'drivers/net/amd8111e.c')
| -rw-r--r-- | drivers/net/amd8111e.c | 137 |
1 files changed, 7 insertions, 130 deletions
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c index 85f7276aaba5..c54967f7942a 100644 --- a/drivers/net/amd8111e.c +++ b/drivers/net/amd8111e.c | |||
| @@ -101,9 +101,9 @@ Revision History: | |||
| 101 | 101 | ||
| 102 | #include "amd8111e.h" | 102 | #include "amd8111e.h" |
| 103 | #define MODULE_NAME "amd8111e" | 103 | #define MODULE_NAME "amd8111e" |
| 104 | #define MODULE_VERS "3.0.6" | 104 | #define MODULE_VERS "3.0.7" |
| 105 | MODULE_AUTHOR("Advanced Micro Devices, Inc."); | 105 | MODULE_AUTHOR("Advanced Micro Devices, Inc."); |
| 106 | MODULE_DESCRIPTION ("AMD8111 based 10/100 Ethernet Controller. Driver Version 3.0.6"); | 106 | MODULE_DESCRIPTION ("AMD8111 based 10/100 Ethernet Controller. Driver Version "MODULE_VERS); |
| 107 | MODULE_LICENSE("GPL"); | 107 | MODULE_LICENSE("GPL"); |
| 108 | MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl); | 108 | MODULE_DEVICE_TABLE(pci, amd8111e_pci_tbl); |
| 109 | module_param_array(speed_duplex, int, NULL, 0); | 109 | module_param_array(speed_duplex, int, NULL, 0); |
| @@ -671,11 +671,7 @@ This is the receive indication function for packets with vlan tag. | |||
| 671 | */ | 671 | */ |
| 672 | static int amd8111e_vlan_rx(struct amd8111e_priv *lp, struct sk_buff *skb, u16 vlan_tag) | 672 | static int amd8111e_vlan_rx(struct amd8111e_priv *lp, struct sk_buff *skb, u16 vlan_tag) |
| 673 | { | 673 | { |
| 674 | #ifdef CONFIG_AMD8111E_NAPI | ||
| 675 | return vlan_hwaccel_receive_skb(skb, lp->vlgrp,vlan_tag); | 674 | return vlan_hwaccel_receive_skb(skb, lp->vlgrp,vlan_tag); |
| 676 | #else | ||
| 677 | return vlan_hwaccel_rx(skb, lp->vlgrp, vlan_tag); | ||
| 678 | #endif /* CONFIG_AMD8111E_NAPI */ | ||
| 679 | } | 675 | } |
| 680 | #endif | 676 | #endif |
| 681 | 677 | ||
| @@ -722,7 +718,6 @@ static int amd8111e_tx(struct net_device *dev) | |||
| 722 | return 0; | 718 | return 0; |
| 723 | } | 719 | } |
| 724 | 720 | ||
| 725 | #ifdef CONFIG_AMD8111E_NAPI | ||
| 726 | /* This function handles the driver receive operation in polling mode */ | 721 | /* This function handles the driver receive operation in polling mode */ |
| 727 | static int amd8111e_rx_poll(struct napi_struct *napi, int budget) | 722 | static int amd8111e_rx_poll(struct napi_struct *napi, int budget) |
| 728 | { | 723 | { |
| @@ -734,7 +729,6 @@ static int amd8111e_rx_poll(struct napi_struct *napi, int budget) | |||
| 734 | int min_pkt_len, status; | 729 | int min_pkt_len, status; |
| 735 | unsigned int intr0; | 730 | unsigned int intr0; |
| 736 | int num_rx_pkt = 0; | 731 | int num_rx_pkt = 0; |
| 737 | /*int max_rx_pkt = NUM_RX_BUFFERS;*/ | ||
| 738 | short pkt_len; | 732 | short pkt_len; |
| 739 | #if AMD8111E_VLAN_TAG_USED | 733 | #if AMD8111E_VLAN_TAG_USED |
| 740 | short vtag; | 734 | short vtag; |
| @@ -850,108 +844,6 @@ rx_not_empty: | |||
| 850 | return num_rx_pkt; | 844 | return num_rx_pkt; |
| 851 | } | 845 | } |
| 852 | 846 | ||
| 853 | #else | ||
| 854 | /* | ||
| 855 | This function will check the ownership of receive buffers and descriptors. It will indicate to kernel up to half the number of maximum receive buffers in the descriptor ring, in a single receive interrupt. It will also replenish the descriptors with new skbs. | ||
| 856 | */ | ||
| 857 | static int amd8111e_rx(struct net_device *dev) | ||
| 858 | { | ||
| 859 | struct amd8111e_priv *lp = netdev_priv(dev); | ||
| 860 | struct sk_buff *skb,*new_skb; | ||
| 861 | int rx_index = lp->rx_idx & RX_RING_DR_MOD_MASK; | ||
| 862 | int min_pkt_len, status; | ||
| 863 | int num_rx_pkt = 0; | ||
| 864 | int max_rx_pkt = NUM_RX_BUFFERS; | ||
| 865 | short pkt_len; | ||
| 866 | #if AMD8111E_VLAN_TAG_USED | ||
| 867 | short vtag; | ||
| 868 | #endif | ||
| 869 | |||
| 870 | /* If we own the next entry, it's a new packet. Send it up. */ | ||
| 871 | while(++num_rx_pkt <= max_rx_pkt){ | ||
| 872 | status = le16_to_cpu(lp->rx_ring[rx_index].rx_flags); | ||
| 873 | if(status & OWN_BIT) | ||
| 874 | return 0; | ||
| 875 | |||
| 876 | /* check if err summary bit is set */ | ||
| 877 | if(status & ERR_BIT){ | ||
| 878 | /* | ||
| 879 | * There is a tricky error noted by John Murphy, | ||
| 880 | * <murf@perftech.com> to Russ Nelson: Even with full-sized | ||
| 881 | * buffers it's possible for a jabber packet to use two | ||
| 882 | * buffers, with only the last correctly noting the error. */ | ||
| 883 | /* reseting flags */ | ||
| 884 | lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; | ||
| 885 | goto err_next_pkt; | ||
| 886 | } | ||
| 887 | /* check for STP and ENP */ | ||
| 888 | if(!((status & STP_BIT) && (status & ENP_BIT))){ | ||
| 889 | /* reseting flags */ | ||
| 890 | lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; | ||
| 891 | goto err_next_pkt; | ||
| 892 | } | ||
| 893 | pkt_len = le16_to_cpu(lp->rx_ring[rx_index].msg_count) - 4; | ||
| 894 | |||
| 895 | #if AMD8111E_VLAN_TAG_USED | ||
| 896 | vtag = status & TT_MASK; | ||
| 897 | /*MAC will strip vlan tag*/ | ||
| 898 | if(lp->vlgrp != NULL && vtag !=0) | ||
| 899 | min_pkt_len =MIN_PKT_LEN - 4; | ||
| 900 | else | ||
| 901 | #endif | ||
| 902 | min_pkt_len =MIN_PKT_LEN; | ||
| 903 | |||
| 904 | if (pkt_len < min_pkt_len) { | ||
| 905 | lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; | ||
| 906 | lp->drv_rx_errors++; | ||
| 907 | goto err_next_pkt; | ||
| 908 | } | ||
| 909 | if(!(new_skb = dev_alloc_skb(lp->rx_buff_len))){ | ||
| 910 | /* if allocation fail, | ||
| 911 | ignore that pkt and go to next one */ | ||
| 912 | lp->rx_ring[rx_index].rx_flags &= RESET_RX_FLAGS; | ||
| 913 | lp->drv_rx_errors++; | ||
| 914 | goto err_next_pkt; | ||
| 915 | } | ||
| 916 | |||
| 917 | skb_reserve(new_skb, 2); | ||
| 918 | skb = lp->rx_skbuff[rx_index]; | ||
| 919 | pci_unmap_single(lp->pci_dev,lp->rx_dma_addr[rx_index], | ||
| 920 | lp->rx_buff_len-2, PCI_DMA_FROMDEVICE); | ||
| 921 | skb_put(skb, pkt_len); | ||
| 922 | lp->rx_skbuff[rx_index] = new_skb; | ||
| 923 | lp->rx_dma_addr[rx_index] = pci_map_single(lp->pci_dev, | ||
| 924 | new_skb->data, lp->rx_buff_len-2,PCI_DMA_FROMDEVICE); | ||
| 925 | |||
| 926 | skb->protocol = eth_type_trans(skb, dev); | ||
| 927 | |||
| 928 | #if AMD8111E_VLAN_TAG_USED | ||
| 929 | if(lp->vlgrp != NULL && (vtag == TT_VLAN_TAGGED)){ | ||
| 930 | amd8111e_vlan_rx(lp, skb, | ||
| 931 | le16_to_cpu(lp->rx_ring[rx_index].tag_ctrl_info)); | ||
| 932 | } else | ||
| 933 | #endif | ||
| 934 | |||
| 935 | netif_rx (skb); | ||
| 936 | /*COAL update rx coalescing parameters*/ | ||
| 937 | lp->coal_conf.rx_packets++; | ||
| 938 | lp->coal_conf.rx_bytes += pkt_len; | ||
| 939 | |||
| 940 | dev->last_rx = jiffies; | ||
| 941 | |||
| 942 | err_next_pkt: | ||
| 943 | lp->rx_ring[rx_index].buff_phy_addr | ||
| 944 | = cpu_to_le32(lp->rx_dma_addr[rx_index]); | ||
| 945 | lp->rx_ring[rx_index].buff_count = | ||
| 946 | cpu_to_le16(lp->rx_buff_len-2); | ||
| 947 | wmb(); | ||
| 948 | lp->rx_ring[rx_index].rx_flags |= cpu_to_le16(OWN_BIT); | ||
| 949 | rx_index = (++lp->rx_idx) & RX_RING_DR_MOD_MASK; | ||
| 950 | } | ||
| 951 | |||
| 952 | return 0; | ||
| 953 | } | ||
| 954 | #endif /* CONFIG_AMD8111E_NAPI */ | ||
| 955 | /* | 847 | /* |
| 956 | This function will indicate the link status to the kernel. | 848 | This function will indicate the link status to the kernel. |
| 957 | */ | 849 | */ |
| @@ -1280,29 +1172,22 @@ static irqreturn_t amd8111e_interrupt(int irq, void *dev_id) | |||
| 1280 | writel(intr0, mmio + INT0); | 1172 | writel(intr0, mmio + INT0); |
| 1281 | 1173 | ||
| 1282 | /* Check if Receive Interrupt has occurred. */ | 1174 | /* Check if Receive Interrupt has occurred. */ |
| 1283 | #ifdef CONFIG_AMD8111E_NAPI | 1175 | if (intr0 & RINT0) { |
| 1284 | if(intr0 & RINT0){ | 1176 | if (netif_rx_schedule_prep(dev, &lp->napi)) { |
| 1285 | if(netif_rx_schedule_prep(dev, &lp->napi)){ | ||
| 1286 | /* Disable receive interupts */ | 1177 | /* Disable receive interupts */ |
| 1287 | writel(RINTEN0, mmio + INTEN0); | 1178 | writel(RINTEN0, mmio + INTEN0); |
| 1288 | /* Schedule a polling routine */ | 1179 | /* Schedule a polling routine */ |
| 1289 | __netif_rx_schedule(dev, &lp->napi); | 1180 | __netif_rx_schedule(dev, &lp->napi); |
| 1290 | } | 1181 | } else if (intren0 & RINTEN0) { |
| 1291 | else if (intren0 & RINTEN0) { | ||
| 1292 | printk("************Driver bug! \ | 1182 | printk("************Driver bug! \ |
| 1293 | interrupt while in poll\n"); | 1183 | interrupt while in poll\n"); |
| 1294 | /* Fix by disable receive interrupts */ | 1184 | /* Fix by disable receive interrupts */ |
| 1295 | writel(RINTEN0, mmio + INTEN0); | 1185 | writel(RINTEN0, mmio + INTEN0); |
| 1296 | } | 1186 | } |
| 1297 | } | 1187 | } |
| 1298 | #else | 1188 | |
| 1299 | if(intr0 & RINT0){ | ||
| 1300 | amd8111e_rx(dev); | ||
| 1301 | writel(VAL2 | RDMD0, mmio + CMD0); | ||
| 1302 | } | ||
| 1303 | #endif /* CONFIG_AMD8111E_NAPI */ | ||
| 1304 | /* Check if Transmit Interrupt has occurred. */ | 1189 | /* Check if Transmit Interrupt has occurred. */ |
| 1305 | if(intr0 & TINT0) | 1190 | if (intr0 & TINT0) |
| 1306 | amd8111e_tx(dev); | 1191 | amd8111e_tx(dev); |
| 1307 | 1192 | ||
| 1308 | /* Check if Link Change Interrupt has occurred. */ | 1193 | /* Check if Link Change Interrupt has occurred. */ |
| @@ -1340,9 +1225,7 @@ static int amd8111e_close(struct net_device * dev) | |||
| 1340 | struct amd8111e_priv *lp = netdev_priv(dev); | 1225 | struct amd8111e_priv *lp = netdev_priv(dev); |
| 1341 | netif_stop_queue(dev); | 1226 | netif_stop_queue(dev); |
| 1342 | 1227 | ||
| 1343 | #ifdef CONFIG_AMD8111E_NAPI | ||
| 1344 | napi_disable(&lp->napi); | 1228 | napi_disable(&lp->napi); |
| 1345 | #endif | ||
| 1346 | 1229 | ||
| 1347 | spin_lock_irq(&lp->lock); | 1230 | spin_lock_irq(&lp->lock); |
| 1348 | 1231 | ||
| @@ -1374,9 +1257,7 @@ static int amd8111e_open(struct net_device * dev ) | |||
| 1374 | dev->name, dev)) | 1257 | dev->name, dev)) |
| 1375 | return -EAGAIN; | 1258 | return -EAGAIN; |
| 1376 | 1259 | ||
| 1377 | #ifdef CONFIG_AMD8111E_NAPI | ||
| 1378 | napi_enable(&lp->napi); | 1260 | napi_enable(&lp->napi); |
| 1379 | #endif | ||
| 1380 | 1261 | ||
| 1381 | spin_lock_irq(&lp->lock); | 1262 | spin_lock_irq(&lp->lock); |
| 1382 | 1263 | ||
| @@ -1384,9 +1265,7 @@ static int amd8111e_open(struct net_device * dev ) | |||
| 1384 | 1265 | ||
| 1385 | if(amd8111e_restart(dev)){ | 1266 | if(amd8111e_restart(dev)){ |
| 1386 | spin_unlock_irq(&lp->lock); | 1267 | spin_unlock_irq(&lp->lock); |
| 1387 | #ifdef CONFIG_AMD8111E_NAPI | ||
| 1388 | napi_disable(&lp->napi); | 1268 | napi_disable(&lp->napi); |
| 1389 | #endif | ||
| 1390 | if (dev->irq) | 1269 | if (dev->irq) |
| 1391 | free_irq(dev->irq, dev); | 1270 | free_irq(dev->irq, dev); |
| 1392 | return -ENOMEM; | 1271 | return -ENOMEM; |
| @@ -2036,9 +1915,7 @@ static int __devinit amd8111e_probe_one(struct pci_dev *pdev, | |||
| 2036 | dev->irq =pdev->irq; | 1915 | dev->irq =pdev->irq; |
| 2037 | dev->tx_timeout = amd8111e_tx_timeout; | 1916 | dev->tx_timeout = amd8111e_tx_timeout; |
| 2038 | dev->watchdog_timeo = AMD8111E_TX_TIMEOUT; | 1917 | dev->watchdog_timeo = AMD8111E_TX_TIMEOUT; |
| 2039 | #ifdef CONFIG_AMD8111E_NAPI | ||
| 2040 | netif_napi_add(dev, &lp->napi, amd8111e_rx_poll, 32); | 1918 | netif_napi_add(dev, &lp->napi, amd8111e_rx_poll, 32); |
| 2041 | #endif | ||
| 2042 | #ifdef CONFIG_NET_POLL_CONTROLLER | 1919 | #ifdef CONFIG_NET_POLL_CONTROLLER |
| 2043 | dev->poll_controller = amd8111e_poll; | 1920 | dev->poll_controller = amd8111e_poll; |
| 2044 | #endif | 1921 | #endif |
