aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vmxnet3
diff options
context:
space:
mode:
authorJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
committerJonathan Herman <hermanjl@cs.unc.edu>2013-01-17 16:15:55 -0500
commit8dea78da5cee153b8af9c07a2745f6c55057fe12 (patch)
treea8f4d49d63b1ecc92f2fddceba0655b2472c5bd9 /drivers/net/vmxnet3
parent406089d01562f1e2bf9f089fd7637009ebaad589 (diff)
Patched in Tegra support.
Diffstat (limited to 'drivers/net/vmxnet3')
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c207
-rw-r--r--drivers/net/vmxnet3/vmxnet3_ethtool.c48
-rw-r--r--drivers/net/vmxnet3/vmxnet3_int.h6
3 files changed, 128 insertions, 133 deletions
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index dc8913c6238..0959583feb2 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -24,7 +24,6 @@
24 * 24 *
25 */ 25 */
26 26
27#include <linux/module.h>
28#include <net/ip6_checksum.h> 27#include <net/ip6_checksum.h>
29 28
30#include "vmxnet3_int.h" 29#include "vmxnet3_int.h"
@@ -537,8 +536,11 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
537 536
538 tq->buf_info = kcalloc(tq->tx_ring.size, sizeof(tq->buf_info[0]), 537 tq->buf_info = kcalloc(tq->tx_ring.size, sizeof(tq->buf_info[0]),
539 GFP_KERNEL); 538 GFP_KERNEL);
540 if (!tq->buf_info) 539 if (!tq->buf_info) {
540 printk(KERN_ERR "%s: failed to allocate tx bufinfo\n",
541 adapter->netdev->name);
541 goto err; 542 goto err;
543 }
542 544
543 return 0; 545 return 0;
544 546
@@ -633,7 +635,7 @@ vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx,
633 635
634 dev_dbg(&adapter->netdev->dev, 636 dev_dbg(&adapter->netdev->dev,
635 "alloc_rx_buf: %d allocated, next2fill %u, next2comp " 637 "alloc_rx_buf: %d allocated, next2fill %u, next2comp "
636 "%u, uncommitted %u\n", num_allocated, ring->next2fill, 638 "%u, uncommited %u\n", num_allocated, ring->next2fill,
637 ring->next2comp, rq->uncommitted[ring_idx]); 639 ring->next2comp, rq->uncommitted[ring_idx]);
638 640
639 /* so that the device can distinguish a full ring and an empty ring */ 641 /* so that the device can distinguish a full ring and an empty ring */
@@ -652,11 +654,10 @@ vmxnet3_append_frag(struct sk_buff *skb, struct Vmxnet3_RxCompDesc *rcd,
652 654
653 BUG_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS); 655 BUG_ON(skb_shinfo(skb)->nr_frags >= MAX_SKB_FRAGS);
654 656
655 __skb_frag_set_page(frag, rbi->page); 657 frag->page = rbi->page;
656 frag->page_offset = 0; 658 frag->page_offset = 0;
657 skb_frag_size_set(frag, rcd->len); 659 frag->size = rcd->len;
658 skb->data_len += rcd->len; 660 skb->data_len += frag->size;
659 skb->truesize += PAGE_SIZE;
660 skb_shinfo(skb)->nr_frags++; 661 skb_shinfo(skb)->nr_frags++;
661} 662}
662 663
@@ -743,44 +744,29 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx *ctx,
743 } 744 }
744 745
745 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) { 746 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
746 const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i]; 747 struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i];
747 u32 buf_size;
748 748
749 buf_offset = 0; 749 tbi = tq->buf_info + tq->tx_ring.next2fill;
750 len = skb_frag_size(frag); 750 tbi->map_type = VMXNET3_MAP_PAGE;
751 while (len) { 751 tbi->dma_addr = pci_map_page(adapter->pdev, frag->page,
752 tbi = tq->buf_info + tq->tx_ring.next2fill; 752 frag->page_offset, frag->size,
753 if (len < VMXNET3_MAX_TX_BUF_SIZE) { 753 PCI_DMA_TODEVICE);
754 buf_size = len;
755 dw2 |= len;
756 } else {
757 buf_size = VMXNET3_MAX_TX_BUF_SIZE;
758 /* spec says that for TxDesc.len, 0 == 2^14 */
759 }
760 tbi->map_type = VMXNET3_MAP_PAGE;
761 tbi->dma_addr = skb_frag_dma_map(&adapter->pdev->dev, frag,
762 buf_offset, buf_size,
763 DMA_TO_DEVICE);
764
765 tbi->len = buf_size;
766 754
767 gdesc = tq->tx_ring.base + tq->tx_ring.next2fill; 755 tbi->len = frag->size;
768 BUG_ON(gdesc->txd.gen == tq->tx_ring.gen);
769 756
770 gdesc->txd.addr = cpu_to_le64(tbi->dma_addr); 757 gdesc = tq->tx_ring.base + tq->tx_ring.next2fill;
771 gdesc->dword[2] = cpu_to_le32(dw2); 758 BUG_ON(gdesc->txd.gen == tq->tx_ring.gen);
772 gdesc->dword[3] = 0;
773 759
774 dev_dbg(&adapter->netdev->dev, 760 gdesc->txd.addr = cpu_to_le64(tbi->dma_addr);
775 "txd[%u]: 0x%llu %u %u\n", 761 gdesc->dword[2] = cpu_to_le32(dw2 | frag->size);
776 tq->tx_ring.next2fill, le64_to_cpu(gdesc->txd.addr), 762 gdesc->dword[3] = 0;
777 le32_to_cpu(gdesc->dword[2]), gdesc->dword[3]);
778 vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring);
779 dw2 = tq->tx_ring.gen << VMXNET3_TXD_GEN_SHIFT;
780 763
781 len -= buf_size; 764 dev_dbg(&adapter->netdev->dev,
782 buf_offset += buf_size; 765 "txd[%u]: 0x%llu %u %u\n",
783 } 766 tq->tx_ring.next2fill, le64_to_cpu(gdesc->txd.addr),
767 le32_to_cpu(gdesc->dword[2]), gdesc->dword[3]);
768 vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring);
769 dw2 = tq->tx_ring.gen << VMXNET3_TXD_GEN_SHIFT;
784 } 770 }
785 771
786 ctx->eop_txd = gdesc; 772 ctx->eop_txd = gdesc;
@@ -828,27 +814,35 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
828 814
829 if (ctx->mss) { /* TSO */ 815 if (ctx->mss) { /* TSO */
830 ctx->eth_ip_hdr_size = skb_transport_offset(skb); 816 ctx->eth_ip_hdr_size = skb_transport_offset(skb);
831 ctx->l4_hdr_size = tcp_hdrlen(skb); 817 ctx->l4_hdr_size = ((struct tcphdr *)
818 skb_transport_header(skb))->doff * 4;
832 ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size; 819 ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size;
833 } else { 820 } else {
834 if (skb->ip_summed == CHECKSUM_PARTIAL) { 821 if (skb->ip_summed == CHECKSUM_PARTIAL) {
835 ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb); 822 ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb);
836 823
837 if (ctx->ipv4) { 824 if (ctx->ipv4) {
838 const struct iphdr *iph = ip_hdr(skb); 825 struct iphdr *iph = (struct iphdr *)
839 826 skb_network_header(skb);
840 if (iph->protocol == IPPROTO_TCP) 827 if (iph->protocol == IPPROTO_TCP)
841 ctx->l4_hdr_size = tcp_hdrlen(skb); 828 ctx->l4_hdr_size = ((struct tcphdr *)
829 skb_transport_header(skb))->doff * 4;
842 else if (iph->protocol == IPPROTO_UDP) 830 else if (iph->protocol == IPPROTO_UDP)
843 ctx->l4_hdr_size = sizeof(struct udphdr); 831 /*
832 * Use tcp header size so that bytes to
833 * be copied are more than required by
834 * the device.
835 */
836 ctx->l4_hdr_size =
837 sizeof(struct tcphdr);
844 else 838 else
845 ctx->l4_hdr_size = 0; 839 ctx->l4_hdr_size = 0;
846 } else { 840 } else {
847 /* for simplicity, don't copy L4 headers */ 841 /* for simplicity, don't copy L4 headers */
848 ctx->l4_hdr_size = 0; 842 ctx->l4_hdr_size = 0;
849 } 843 }
850 ctx->copy_size = min(ctx->eth_ip_hdr_size + 844 ctx->copy_size = ctx->eth_ip_hdr_size +
851 ctx->l4_hdr_size, skb->len); 845 ctx->l4_hdr_size;
852 } else { 846 } else {
853 ctx->eth_ip_hdr_size = 0; 847 ctx->eth_ip_hdr_size = 0;
854 ctx->l4_hdr_size = 0; 848 ctx->l4_hdr_size = 0;
@@ -885,34 +879,19 @@ static void
885vmxnet3_prepare_tso(struct sk_buff *skb, 879vmxnet3_prepare_tso(struct sk_buff *skb,
886 struct vmxnet3_tx_ctx *ctx) 880 struct vmxnet3_tx_ctx *ctx)
887{ 881{
888 struct tcphdr *tcph = tcp_hdr(skb); 882 struct tcphdr *tcph = (struct tcphdr *)skb_transport_header(skb);
889
890 if (ctx->ipv4) { 883 if (ctx->ipv4) {
891 struct iphdr *iph = ip_hdr(skb); 884 struct iphdr *iph = (struct iphdr *)skb_network_header(skb);
892
893 iph->check = 0; 885 iph->check = 0;
894 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0, 886 tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0,
895 IPPROTO_TCP, 0); 887 IPPROTO_TCP, 0);
896 } else { 888 } else {
897 struct ipv6hdr *iph = ipv6_hdr(skb); 889 struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header(skb);
898
899 tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0, 890 tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0,
900 IPPROTO_TCP, 0); 891 IPPROTO_TCP, 0);
901 } 892 }
902} 893}
903 894
904static int txd_estimate(const struct sk_buff *skb)
905{
906 int count = VMXNET3_TXD_NEEDED(skb_headlen(skb)) + 1;
907 int i;
908
909 for (i = 0; i < skb_shinfo(skb)->nr_frags; i++) {
910 const struct skb_frag_struct *frag = &skb_shinfo(skb)->frags[i];
911
912 count += VMXNET3_TXD_NEEDED(skb_frag_size(frag));
913 }
914 return count;
915}
916 895
917/* 896/*
918 * Transmits a pkt thru a given tq 897 * Transmits a pkt thru a given tq
@@ -941,7 +920,9 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
941 union Vmxnet3_GenericDesc tempTxDesc; 920 union Vmxnet3_GenericDesc tempTxDesc;
942#endif 921#endif
943 922
944 count = txd_estimate(skb); 923 /* conservatively estimate # of descriptors to use */
924 count = VMXNET3_TXD_NEEDED(skb_headlen(skb)) +
925 skb_shinfo(skb)->nr_frags + 1;
945 926
946 ctx.ipv4 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IP)); 927 ctx.ipv4 = (vlan_get_protocol(skb) == cpu_to_be16(ETH_P_IP));
947 928
@@ -1062,7 +1043,7 @@ vmxnet3_tq_xmit(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
1062#endif 1043#endif
1063 dev_dbg(&adapter->netdev->dev, 1044 dev_dbg(&adapter->netdev->dev,
1064 "txd[%u]: SOP 0x%Lx 0x%x 0x%x\n", 1045 "txd[%u]: SOP 0x%Lx 0x%x 0x%x\n",
1065 (u32)(ctx.sop_txd - 1046 (u32)((union Vmxnet3_GenericDesc *)ctx.sop_txd -
1066 tq->tx_ring.base), le64_to_cpu(gdesc->txd.addr), 1047 tq->tx_ring.base), le64_to_cpu(gdesc->txd.addr),
1067 le32_to_cpu(gdesc->dword[2]), le32_to_cpu(gdesc->dword[3])); 1048 le32_to_cpu(gdesc->dword[2]), le32_to_cpu(gdesc->dword[3]));
1068 1049
@@ -1094,10 +1075,10 @@ vmxnet3_xmit_frame(struct sk_buff *skb, struct net_device *netdev)
1094{ 1075{
1095 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1076 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
1096 1077
1097 BUG_ON(skb->queue_mapping > adapter->num_tx_queues); 1078 BUG_ON(skb->queue_mapping > adapter->num_tx_queues);
1098 return vmxnet3_tq_xmit(skb, 1079 return vmxnet3_tq_xmit(skb,
1099 &adapter->tx_queue[skb->queue_mapping], 1080 &adapter->tx_queue[skb->queue_mapping],
1100 adapter, netdev); 1081 adapter, netdev);
1101} 1082}
1102 1083
1103 1084
@@ -1243,8 +1224,8 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
1243 skb_reserve(new_skb, NET_IP_ALIGN); 1224 skb_reserve(new_skb, NET_IP_ALIGN);
1244 rbi->skb = new_skb; 1225 rbi->skb = new_skb;
1245 rbi->dma_addr = pci_map_single(adapter->pdev, 1226 rbi->dma_addr = pci_map_single(adapter->pdev,
1246 rbi->skb->data, rbi->len, 1227 rbi->skb->data, rbi->len,
1247 PCI_DMA_FROMDEVICE); 1228 PCI_DMA_FROMDEVICE);
1248 rxd->addr = cpu_to_le64(rbi->dma_addr); 1229 rxd->addr = cpu_to_le64(rbi->dma_addr);
1249 rxd->len = rbi->len; 1230 rxd->len = rbi->len;
1250 1231
@@ -1296,6 +1277,7 @@ vmxnet3_rq_rx_complete(struct vmxnet3_rx_queue *rq,
1296 skb = ctx->skb; 1277 skb = ctx->skb;
1297 if (rcd->eop) { 1278 if (rcd->eop) {
1298 skb->len += skb->data_len; 1279 skb->len += skb->data_len;
1280 skb->truesize += skb->data_len;
1299 1281
1300 vmxnet3_rx_csum(adapter, skb, 1282 vmxnet3_rx_csum(adapter, skb,
1301 (union Vmxnet3_GenericDesc *)rcd); 1283 (union Vmxnet3_GenericDesc *)rcd);
@@ -1331,14 +1313,14 @@ rcd_done:
1331 /* if needed, update the register */ 1313 /* if needed, update the register */
1332 if (unlikely(rq->shared->updateRxProd)) { 1314 if (unlikely(rq->shared->updateRxProd)) {
1333 VMXNET3_WRITE_BAR0_REG(adapter, 1315 VMXNET3_WRITE_BAR0_REG(adapter,
1334 rxprod_reg[ring_idx] + rq->qid * 8, 1316 rxprod_reg[ring_idx] + rq->qid * 8,
1335 ring->next2fill); 1317 ring->next2fill);
1336 rq->uncommitted[ring_idx] = 0; 1318 rq->uncommitted[ring_idx] = 0;
1337 } 1319 }
1338 1320
1339 vmxnet3_comp_ring_adv_next2proc(&rq->comp_ring); 1321 vmxnet3_comp_ring_adv_next2proc(&rq->comp_ring);
1340 vmxnet3_getRxComp(rcd, 1322 vmxnet3_getRxComp(rcd,
1341 &rq->comp_ring.base[rq->comp_ring.next2proc].rcd, &rxComp); 1323 &rq->comp_ring.base[rq->comp_ring.next2proc].rcd, &rxComp);
1342 } 1324 }
1343 1325
1344 return num_rxd; 1326 return num_rxd;
@@ -1536,9 +1518,11 @@ vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter)
1536 sz = sizeof(struct vmxnet3_rx_buf_info) * (rq->rx_ring[0].size + 1518 sz = sizeof(struct vmxnet3_rx_buf_info) * (rq->rx_ring[0].size +
1537 rq->rx_ring[1].size); 1519 rq->rx_ring[1].size);
1538 bi = kzalloc(sz, GFP_KERNEL); 1520 bi = kzalloc(sz, GFP_KERNEL);
1539 if (!bi) 1521 if (!bi) {
1522 printk(KERN_ERR "%s: failed to allocate rx bufinfo\n",
1523 adapter->netdev->name);
1540 goto err; 1524 goto err;
1541 1525 }
1542 rq->buf_info[0] = bi; 1526 rq->buf_info[0] = bi;
1543 rq->buf_info[1] = bi + rq->rx_ring[0].size; 1527 rq->buf_info[1] = bi + rq->rx_ring[0].size;
1544 1528
@@ -1922,7 +1906,7 @@ vmxnet3_free_irqs(struct vmxnet3_adapter *adapter)
1922 free_irq(adapter->pdev->irq, adapter->netdev); 1906 free_irq(adapter->pdev->irq, adapter->netdev);
1923 break; 1907 break;
1924 default: 1908 default:
1925 BUG(); 1909 BUG_ON(true);
1926 } 1910 }
1927} 1911}
1928 1912
@@ -1941,7 +1925,7 @@ vmxnet3_restore_vlan(struct vmxnet3_adapter *adapter)
1941} 1925}
1942 1926
1943 1927
1944static int 1928static void
1945vmxnet3_vlan_rx_add_vid(struct net_device *netdev, u16 vid) 1929vmxnet3_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
1946{ 1930{
1947 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1931 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
@@ -1958,12 +1942,10 @@ vmxnet3_vlan_rx_add_vid(struct net_device *netdev, u16 vid)
1958 } 1942 }
1959 1943
1960 set_bit(vid, adapter->active_vlans); 1944 set_bit(vid, adapter->active_vlans);
1961
1962 return 0;
1963} 1945}
1964 1946
1965 1947
1966static int 1948static void
1967vmxnet3_vlan_rx_kill_vid(struct net_device *netdev, u16 vid) 1949vmxnet3_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
1968{ 1950{
1969 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 1951 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
@@ -1980,8 +1962,6 @@ vmxnet3_vlan_rx_kill_vid(struct net_device *netdev, u16 vid)
1980 } 1962 }
1981 1963
1982 clear_bit(vid, adapter->active_vlans); 1964 clear_bit(vid, adapter->active_vlans);
1983
1984 return 0;
1985} 1965}
1986 1966
1987 1967
@@ -2182,8 +2162,7 @@ vmxnet3_setup_driver_shared(struct vmxnet3_adapter *adapter)
2182 rssConf->indTableSize = VMXNET3_RSS_IND_TABLE_SIZE; 2162 rssConf->indTableSize = VMXNET3_RSS_IND_TABLE_SIZE;
2183 get_random_bytes(&rssConf->hashKey[0], rssConf->hashKeySize); 2163 get_random_bytes(&rssConf->hashKey[0], rssConf->hashKeySize);
2184 for (i = 0; i < rssConf->indTableSize; i++) 2164 for (i = 0; i < rssConf->indTableSize; i++)
2185 rssConf->indTable[i] = ethtool_rxfh_indir_default( 2165 rssConf->indTable[i] = i % adapter->num_rx_queues;
2186 i, adapter->num_rx_queues);
2187 2166
2188 devRead->rssConfDesc.confVer = 1; 2167 devRead->rssConfDesc.confVer = 1;
2189 devRead->rssConfDesc.confLen = sizeof(*rssConf); 2168 devRead->rssConfDesc.confLen = sizeof(*rssConf);
@@ -2724,8 +2703,8 @@ vmxnet3_acquire_msix_vectors(struct vmxnet3_adapter *adapter,
2724 adapter->intr.num_intrs = vectors; 2703 adapter->intr.num_intrs = vectors;
2725 return 0; 2704 return 0;
2726 } else if (err < 0) { 2705 } else if (err < 0) {
2727 netdev_err(adapter->netdev, 2706 printk(KERN_ERR "Failed to enable MSI-X for %s, error"
2728 "Failed to enable MSI-X, error: %d\n", err); 2707 " %d\n", adapter->netdev->name, err);
2729 vectors = 0; 2708 vectors = 0;
2730 } else if (err < vector_threshold) { 2709 } else if (err < vector_threshold) {
2731 break; 2710 break;
@@ -2733,15 +2712,15 @@ vmxnet3_acquire_msix_vectors(struct vmxnet3_adapter *adapter,
2733 /* If fails to enable required number of MSI-x vectors 2712 /* If fails to enable required number of MSI-x vectors
2734 * try enabling minimum number of vectors required. 2713 * try enabling minimum number of vectors required.
2735 */ 2714 */
2736 netdev_err(adapter->netdev,
2737 "Failed to enable %d MSI-X, trying %d instead\n",
2738 vectors, vector_threshold);
2739 vectors = vector_threshold; 2715 vectors = vector_threshold;
2716 printk(KERN_ERR "Failed to enable %d MSI-X for %s, try"
2717 " %d instead\n", vectors, adapter->netdev->name,
2718 vector_threshold);
2740 } 2719 }
2741 } 2720 }
2742 2721
2743 netdev_info(adapter->netdev, 2722 printk(KERN_INFO "Number of MSI-X interrupts which can be allocatedi"
2744 "Number of MSI-X interrupts which can be allocated are lower than min threshold required.\n"); 2723 " are lower than min threshold required.\n");
2745 return err; 2724 return err;
2746} 2725}
2747 2726
@@ -2807,9 +2786,8 @@ vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter)
2807 return; 2786 return;
2808 2787
2809 /* If we cannot allocate MSIx vectors use only one rx queue */ 2788 /* If we cannot allocate MSIx vectors use only one rx queue */
2810 netdev_info(adapter->netdev, 2789 printk(KERN_INFO "Failed to enable MSI-X for %s, error %d."
2811 "Failed to enable MSI-X, error %d . Limiting #rx queues to 1, try MSI.\n", 2790 "#rx queues : 1, try MSI\n", adapter->netdev->name, err);
2812 err);
2813 2791
2814 adapter->intr.type = VMXNET3_IT_MSI; 2792 adapter->intr.type = VMXNET3_IT_MSI;
2815 } 2793 }
@@ -2885,7 +2863,7 @@ vmxnet3_reset_work(struct work_struct *data)
2885} 2863}
2886 2864
2887 2865
2888static int 2866static int __devinit
2889vmxnet3_probe_device(struct pci_dev *pdev, 2867vmxnet3_probe_device(struct pci_dev *pdev,
2890 const struct pci_device_id *id) 2868 const struct pci_device_id *id)
2891{ 2869{
@@ -2898,7 +2876,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2898 .ndo_set_features = vmxnet3_set_features, 2876 .ndo_set_features = vmxnet3_set_features,
2899 .ndo_get_stats64 = vmxnet3_get_stats64, 2877 .ndo_get_stats64 = vmxnet3_get_stats64,
2900 .ndo_tx_timeout = vmxnet3_tx_timeout, 2878 .ndo_tx_timeout = vmxnet3_tx_timeout,
2901 .ndo_set_rx_mode = vmxnet3_set_mc, 2879 .ndo_set_multicast_list = vmxnet3_set_mc,
2902 .ndo_vlan_rx_add_vid = vmxnet3_vlan_rx_add_vid, 2880 .ndo_vlan_rx_add_vid = vmxnet3_vlan_rx_add_vid,
2903 .ndo_vlan_rx_kill_vid = vmxnet3_vlan_rx_kill_vid, 2881 .ndo_vlan_rx_kill_vid = vmxnet3_vlan_rx_kill_vid,
2904#ifdef CONFIG_NET_POLL_CONTROLLER 2882#ifdef CONFIG_NET_POLL_CONTROLLER
@@ -2939,8 +2917,11 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2939 printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n", 2917 printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n",
2940 num_tx_queues, num_rx_queues); 2918 num_tx_queues, num_rx_queues);
2941 2919
2942 if (!netdev) 2920 if (!netdev) {
2921 printk(KERN_ERR "Failed to alloc ethernet device for adapter "
2922 "%s\n", pci_name(pdev));
2943 return -ENOMEM; 2923 return -ENOMEM;
2924 }
2944 2925
2945 pci_set_drvdata(pdev, netdev); 2926 pci_set_drvdata(pdev, netdev);
2946 adapter = netdev_priv(netdev); 2927 adapter = netdev_priv(netdev);
@@ -2949,11 +2930,11 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2949 2930
2950 spin_lock_init(&adapter->cmd_lock); 2931 spin_lock_init(&adapter->cmd_lock);
2951 adapter->shared = pci_alloc_consistent(adapter->pdev, 2932 adapter->shared = pci_alloc_consistent(adapter->pdev,
2952 sizeof(struct Vmxnet3_DriverShared), 2933 sizeof(struct Vmxnet3_DriverShared),
2953 &adapter->shared_pa); 2934 &adapter->shared_pa);
2954 if (!adapter->shared) { 2935 if (!adapter->shared) {
2955 printk(KERN_ERR "Failed to allocate memory for %s\n", 2936 printk(KERN_ERR "Failed to allocate memory for %s\n",
2956 pci_name(pdev)); 2937 pci_name(pdev));
2957 err = -ENOMEM; 2938 err = -ENOMEM;
2958 goto err_alloc_shared; 2939 goto err_alloc_shared;
2959 } 2940 }
@@ -2964,19 +2945,21 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2964 size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues; 2945 size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues;
2965 size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues; 2946 size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues;
2966 adapter->tqd_start = pci_alloc_consistent(adapter->pdev, size, 2947 adapter->tqd_start = pci_alloc_consistent(adapter->pdev, size,
2967 &adapter->queue_desc_pa); 2948 &adapter->queue_desc_pa);
2968 2949
2969 if (!adapter->tqd_start) { 2950 if (!adapter->tqd_start) {
2970 printk(KERN_ERR "Failed to allocate memory for %s\n", 2951 printk(KERN_ERR "Failed to allocate memory for %s\n",
2971 pci_name(pdev)); 2952 pci_name(pdev));
2972 err = -ENOMEM; 2953 err = -ENOMEM;
2973 goto err_alloc_queue_desc; 2954 goto err_alloc_queue_desc;
2974 } 2955 }
2975 adapter->rqd_start = (struct Vmxnet3_RxQueueDesc *)(adapter->tqd_start + 2956 adapter->rqd_start = (struct Vmxnet3_RxQueueDesc *)(adapter->tqd_start +
2976 adapter->num_tx_queues); 2957 adapter->num_tx_queues);
2977 2958
2978 adapter->pm_conf = kmalloc(sizeof(struct Vmxnet3_PMConf), GFP_KERNEL); 2959 adapter->pm_conf = kmalloc(sizeof(struct Vmxnet3_PMConf), GFP_KERNEL);
2979 if (adapter->pm_conf == NULL) { 2960 if (adapter->pm_conf == NULL) {
2961 printk(KERN_ERR "Failed to allocate memory for %s\n",
2962 pci_name(pdev));
2980 err = -ENOMEM; 2963 err = -ENOMEM;
2981 goto err_alloc_pm; 2964 goto err_alloc_pm;
2982 } 2965 }
@@ -2985,6 +2968,8 @@ vmxnet3_probe_device(struct pci_dev *pdev,
2985 2968
2986 adapter->rss_conf = kmalloc(sizeof(struct UPT1_RSSConf), GFP_KERNEL); 2969 adapter->rss_conf = kmalloc(sizeof(struct UPT1_RSSConf), GFP_KERNEL);
2987 if (adapter->rss_conf == NULL) { 2970 if (adapter->rss_conf == NULL) {
2971 printk(KERN_ERR "Failed to allocate memory for %s\n",
2972 pci_name(pdev));
2988 err = -ENOMEM; 2973 err = -ENOMEM;
2989 goto err_alloc_rss; 2974 goto err_alloc_rss;
2990 } 2975 }
@@ -3019,7 +3004,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
3019 3004
3020 adapter->dev_number = atomic_read(&devices_found); 3005 adapter->dev_number = atomic_read(&devices_found);
3021 3006
3022 adapter->share_intr = irq_share_mode; 3007 adapter->share_intr = irq_share_mode;
3023 if (adapter->share_intr == VMXNET3_INTR_BUDDYSHARE && 3008 if (adapter->share_intr == VMXNET3_INTR_BUDDYSHARE &&
3024 adapter->num_tx_queues != adapter->num_rx_queues) 3009 adapter->num_tx_queues != adapter->num_rx_queues)
3025 adapter->share_intr = VMXNET3_INTR_DONTSHARE; 3010 adapter->share_intr = VMXNET3_INTR_DONTSHARE;
@@ -3044,7 +3029,6 @@ vmxnet3_probe_device(struct pci_dev *pdev,
3044 netdev->watchdog_timeo = 5 * HZ; 3029 netdev->watchdog_timeo = 5 * HZ;
3045 3030
3046 INIT_WORK(&adapter->work, vmxnet3_reset_work); 3031 INIT_WORK(&adapter->work, vmxnet3_reset_work);
3047 set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state);
3048 3032
3049 if (adapter->intr.type == VMXNET3_IT_MSIX) { 3033 if (adapter->intr.type == VMXNET3_IT_MSIX) {
3050 int i; 3034 int i;
@@ -3065,10 +3049,11 @@ vmxnet3_probe_device(struct pci_dev *pdev,
3065 3049
3066 if (err) { 3050 if (err) {
3067 printk(KERN_ERR "Failed to register adapter %s\n", 3051 printk(KERN_ERR "Failed to register adapter %s\n",
3068 pci_name(pdev)); 3052 pci_name(pdev));
3069 goto err_register; 3053 goto err_register;
3070 } 3054 }
3071 3055
3056 set_bit(VMXNET3_STATE_BIT_QUIESCED, &adapter->state);
3072 vmxnet3_check_link(adapter, false); 3057 vmxnet3_check_link(adapter, false);
3073 atomic_inc(&devices_found); 3058 atomic_inc(&devices_found);
3074 return 0; 3059 return 0;
@@ -3096,7 +3081,7 @@ err_alloc_shared:
3096} 3081}
3097 3082
3098 3083
3099static void 3084static void __devexit
3100vmxnet3_remove_device(struct pci_dev *pdev) 3085vmxnet3_remove_device(struct pci_dev *pdev)
3101{ 3086{
3102 struct net_device *netdev = pci_get_drvdata(pdev); 3087 struct net_device *netdev = pci_get_drvdata(pdev);
@@ -3302,7 +3287,7 @@ static struct pci_driver vmxnet3_driver = {
3302 .name = vmxnet3_driver_name, 3287 .name = vmxnet3_driver_name,
3303 .id_table = vmxnet3_pciid_table, 3288 .id_table = vmxnet3_pciid_table,
3304 .probe = vmxnet3_probe_device, 3289 .probe = vmxnet3_probe_device,
3305 .remove = vmxnet3_remove_device, 3290 .remove = __devexit_p(vmxnet3_remove_device),
3306#ifdef CONFIG_PM 3291#ifdef CONFIG_PM
3307 .driver.pm = &vmxnet3_pm_ops, 3292 .driver.pm = &vmxnet3_pm_ops,
3308#endif 3293#endif
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index 587a218b234..27400edeef5 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -202,9 +202,14 @@ vmxnet3_get_drvinfo(struct net_device *netdev, struct ethtool_drvinfo *drvinfo)
202 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 202 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
203 203
204 strlcpy(drvinfo->driver, vmxnet3_driver_name, sizeof(drvinfo->driver)); 204 strlcpy(drvinfo->driver, vmxnet3_driver_name, sizeof(drvinfo->driver));
205 drvinfo->driver[sizeof(drvinfo->driver) - 1] = '\0';
205 206
206 strlcpy(drvinfo->version, VMXNET3_DRIVER_VERSION_REPORT, 207 strlcpy(drvinfo->version, VMXNET3_DRIVER_VERSION_REPORT,
207 sizeof(drvinfo->version)); 208 sizeof(drvinfo->version));
209 drvinfo->driver[sizeof(drvinfo->version) - 1] = '\0';
210
211 strlcpy(drvinfo->fw_version, "N/A", sizeof(drvinfo->fw_version));
212 drvinfo->fw_version[sizeof(drvinfo->fw_version) - 1] = '\0';
208 213
209 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev), 214 strlcpy(drvinfo->bus_info, pci_name(adapter->pdev),
210 ETHTOOL_BUSINFO_LEN); 215 ETHTOOL_BUSINFO_LEN);
@@ -257,11 +262,11 @@ vmxnet3_get_strings(struct net_device *netdev, u32 stringset, u8 *buf)
257 } 262 }
258} 263}
259 264
260int vmxnet3_set_features(struct net_device *netdev, netdev_features_t features) 265int vmxnet3_set_features(struct net_device *netdev, u32 features)
261{ 266{
262 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 267 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
263 unsigned long flags; 268 unsigned long flags;
264 netdev_features_t changed = features ^ netdev->features; 269 u32 changed = features ^ netdev->features;
265 270
266 if (changed & (NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_HW_VLAN_RX)) { 271 if (changed & (NETIF_F_RXCSUM | NETIF_F_LRO | NETIF_F_HW_VLAN_RX)) {
267 if (features & NETIF_F_RXCSUM) 272 if (features & NETIF_F_RXCSUM)
@@ -553,7 +558,7 @@ out:
553 558
554static int 559static int
555vmxnet3_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info, 560vmxnet3_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info,
556 u32 *rules) 561 void *rules)
557{ 562{
558 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 563 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
559 switch (info->cmd) { 564 switch (info->cmd) {
@@ -565,38 +570,44 @@ vmxnet3_get_rxnfc(struct net_device *netdev, struct ethtool_rxnfc *info,
565} 570}
566 571
567#ifdef VMXNET3_RSS 572#ifdef VMXNET3_RSS
568static u32
569vmxnet3_get_rss_indir_size(struct net_device *netdev)
570{
571 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
572 struct UPT1_RSSConf *rssConf = adapter->rss_conf;
573
574 return rssConf->indTableSize;
575}
576
577static int 573static int
578vmxnet3_get_rss_indir(struct net_device *netdev, u32 *p) 574vmxnet3_get_rss_indir(struct net_device *netdev,
575 struct ethtool_rxfh_indir *p)
579{ 576{
580 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 577 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
581 struct UPT1_RSSConf *rssConf = adapter->rss_conf; 578 struct UPT1_RSSConf *rssConf = adapter->rss_conf;
582 unsigned int n = rssConf->indTableSize; 579 unsigned int n = min_t(unsigned int, p->size, rssConf->indTableSize);
583 580
581 p->size = rssConf->indTableSize;
584 while (n--) 582 while (n--)
585 p[n] = rssConf->indTable[n]; 583 p->ring_index[n] = rssConf->indTable[n];
586 return 0; 584 return 0;
587 585
588} 586}
589 587
590static int 588static int
591vmxnet3_set_rss_indir(struct net_device *netdev, const u32 *p) 589vmxnet3_set_rss_indir(struct net_device *netdev,
590 const struct ethtool_rxfh_indir *p)
592{ 591{
593 unsigned int i; 592 unsigned int i;
594 unsigned long flags; 593 unsigned long flags;
595 struct vmxnet3_adapter *adapter = netdev_priv(netdev); 594 struct vmxnet3_adapter *adapter = netdev_priv(netdev);
596 struct UPT1_RSSConf *rssConf = adapter->rss_conf; 595 struct UPT1_RSSConf *rssConf = adapter->rss_conf;
597 596
597 if (p->size != rssConf->indTableSize)
598 return -EINVAL;
599 for (i = 0; i < rssConf->indTableSize; i++) {
600 /*
601 * Return with error code if any of the queue indices
602 * is out of range
603 */
604 if (p->ring_index[i] < 0 ||
605 p->ring_index[i] >= adapter->num_rx_queues)
606 return -EINVAL;
607 }
608
598 for (i = 0; i < rssConf->indTableSize; i++) 609 for (i = 0; i < rssConf->indTableSize; i++)
599 rssConf->indTable[i] = p[i]; 610 rssConf->indTable[i] = p->ring_index[i];
600 611
601 spin_lock_irqsave(&adapter->cmd_lock, flags); 612 spin_lock_irqsave(&adapter->cmd_lock, flags);
602 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD, 613 VMXNET3_WRITE_BAR1_REG(adapter, VMXNET3_REG_CMD,
@@ -608,7 +619,7 @@ vmxnet3_set_rss_indir(struct net_device *netdev, const u32 *p)
608} 619}
609#endif 620#endif
610 621
611static const struct ethtool_ops vmxnet3_ethtool_ops = { 622static struct ethtool_ops vmxnet3_ethtool_ops = {
612 .get_settings = vmxnet3_get_settings, 623 .get_settings = vmxnet3_get_settings,
613 .get_drvinfo = vmxnet3_get_drvinfo, 624 .get_drvinfo = vmxnet3_get_drvinfo,
614 .get_regs_len = vmxnet3_get_regs_len, 625 .get_regs_len = vmxnet3_get_regs_len,
@@ -623,7 +634,6 @@ static const struct ethtool_ops vmxnet3_ethtool_ops = {
623 .set_ringparam = vmxnet3_set_ringparam, 634 .set_ringparam = vmxnet3_set_ringparam,
624 .get_rxnfc = vmxnet3_get_rxnfc, 635 .get_rxnfc = vmxnet3_get_rxnfc,
625#ifdef VMXNET3_RSS 636#ifdef VMXNET3_RSS
626 .get_rxfh_indir_size = vmxnet3_get_rss_indir_size,
627 .get_rxfh_indir = vmxnet3_get_rss_indir, 637 .get_rxfh_indir = vmxnet3_get_rss_indir,
628 .set_rxfh_indir = vmxnet3_set_rss_indir, 638 .set_rxfh_indir = vmxnet3_set_rss_indir,
629#endif 639#endif
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index fc46a81ad53..b18eac1dcca 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -70,10 +70,10 @@
70/* 70/*
71 * Version numbers 71 * Version numbers
72 */ 72 */
73#define VMXNET3_DRIVER_VERSION_STRING "1.1.29.0-k" 73#define VMXNET3_DRIVER_VERSION_STRING "1.1.18.0-k"
74 74
75/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */ 75/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
76#define VMXNET3_DRIVER_VERSION_NUM 0x01011D00 76#define VMXNET3_DRIVER_VERSION_NUM 0x01011200
77 77
78#if defined(CONFIG_PCI_MSI) 78#if defined(CONFIG_PCI_MSI)
79 /* RSS only makes sense if MSI-X is supported. */ 79 /* RSS only makes sense if MSI-X is supported. */
@@ -401,7 +401,7 @@ void
401vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter); 401vmxnet3_rq_destroy_all(struct vmxnet3_adapter *adapter);
402 402
403int 403int
404vmxnet3_set_features(struct net_device *netdev, netdev_features_t features); 404vmxnet3_set_features(struct net_device *netdev, u32 features);
405 405
406int 406int
407vmxnet3_create_queues(struct vmxnet3_adapter *adapter, 407vmxnet3_create_queues(struct vmxnet3_adapter *adapter,