aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/myri10ge/myri10ge.c
diff options
context:
space:
mode:
authorBrice Goglin <brice@myri.com>2006-08-14 17:53:15 -0400
committerJeff Garzik <jeff@garzik.org>2006-08-19 17:45:17 -0400
commitfd6746daade513bf7f887625c107878b6aacccfd (patch)
treeee192025b75d54d2db00f6d19b8b307366af1599 /drivers/net/myri10ge/myri10ge.c
parente700f9f4a208bf6c5d2b4dd67816555930524476 (diff)
[PATCH] myri10ge: convert to netdev_alloc_skb
Convert the myri10ge driver to use netdev_alloc_skb instead of dev_alloc_skb, which requires to propagate the net_device across several functions. Signed-off-by: Brice Goglin <brice@myri.com> Signed-off-by: Jeff Garzik <jeff@garzik.org>
Diffstat (limited to 'drivers/net/myri10ge/myri10ge.c')
-rw-r--r--drivers/net/myri10ge/myri10ge.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c
index f463a2f2bdde..c0c41ca688ef 100644
--- a/drivers/net/myri10ge/myri10ge.c
+++ b/drivers/net/myri10ge/myri10ge.c
@@ -798,12 +798,13 @@ myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst,
798 * pages directly and building a fraglist in the near future. 798 * pages directly and building a fraglist in the near future.
799 */ 799 */
800 800
801static inline struct sk_buff *myri10ge_alloc_big(int bytes) 801static inline struct sk_buff *myri10ge_alloc_big(struct net_device *dev,
802 int bytes)
802{ 803{
803 struct sk_buff *skb; 804 struct sk_buff *skb;
804 unsigned long data, roundup; 805 unsigned long data, roundup;
805 806
806 skb = dev_alloc_skb(bytes + 4096 + MXGEFW_PAD); 807 skb = netdev_alloc_skb(dev, bytes + 4096 + MXGEFW_PAD);
807 if (skb == NULL) 808 if (skb == NULL)
808 return NULL; 809 return NULL;
809 810
@@ -821,12 +822,13 @@ static inline struct sk_buff *myri10ge_alloc_big(int bytes)
821 822
822/* Allocate 2x as much space as required and use whichever portion 823/* Allocate 2x as much space as required and use whichever portion
823 * does not cross a 4KB boundary */ 824 * does not cross a 4KB boundary */
824static inline struct sk_buff *myri10ge_alloc_small_safe(unsigned int bytes) 825static inline struct sk_buff *myri10ge_alloc_small_safe(struct net_device *dev,
826 unsigned int bytes)
825{ 827{
826 struct sk_buff *skb; 828 struct sk_buff *skb;
827 unsigned long data, boundary; 829 unsigned long data, boundary;
828 830
829 skb = dev_alloc_skb(2 * (bytes + MXGEFW_PAD) - 1); 831 skb = netdev_alloc_skb(dev, 2 * (bytes + MXGEFW_PAD) - 1);
830 if (unlikely(skb == NULL)) 832 if (unlikely(skb == NULL))
831 return NULL; 833 return NULL;
832 834
@@ -847,12 +849,13 @@ static inline struct sk_buff *myri10ge_alloc_small_safe(unsigned int bytes)
847 849
848/* Allocate just enough space, and verify that the allocated 850/* Allocate just enough space, and verify that the allocated
849 * space does not cross a 4KB boundary */ 851 * space does not cross a 4KB boundary */
850static inline struct sk_buff *myri10ge_alloc_small(int bytes) 852static inline struct sk_buff *myri10ge_alloc_small(struct net_device *dev,
853 int bytes)
851{ 854{
852 struct sk_buff *skb; 855 struct sk_buff *skb;
853 unsigned long roundup, data, end; 856 unsigned long roundup, data, end;
854 857
855 skb = dev_alloc_skb(bytes + 16 + MXGEFW_PAD); 858 skb = netdev_alloc_skb(dev, bytes + 16 + MXGEFW_PAD);
856 if (unlikely(skb == NULL)) 859 if (unlikely(skb == NULL))
857 return NULL; 860 return NULL;
858 861
@@ -868,15 +871,17 @@ static inline struct sk_buff *myri10ge_alloc_small(int bytes)
868 "myri10ge_alloc_small: small skb crossed 4KB boundary\n"); 871 "myri10ge_alloc_small: small skb crossed 4KB boundary\n");
869 myri10ge_skb_cross_4k = 1; 872 myri10ge_skb_cross_4k = 1;
870 dev_kfree_skb_any(skb); 873 dev_kfree_skb_any(skb);
871 skb = myri10ge_alloc_small_safe(bytes); 874 skb = myri10ge_alloc_small_safe(dev, bytes);
872 } 875 }
873 return skb; 876 return skb;
874} 877}
875 878
876static inline int 879static inline int
877myri10ge_getbuf(struct myri10ge_rx_buf *rx, struct pci_dev *pdev, int bytes, 880myri10ge_getbuf(struct myri10ge_rx_buf *rx, struct myri10ge_priv *mgp,
878 int idx) 881 int bytes, int idx)
879{ 882{
883 struct net_device *dev = mgp->dev;
884 struct pci_dev *pdev = mgp->pdev;
880 struct sk_buff *skb; 885 struct sk_buff *skb;
881 dma_addr_t bus; 886 dma_addr_t bus;
882 int len, retval = 0; 887 int len, retval = 0;
@@ -884,11 +889,11 @@ myri10ge_getbuf(struct myri10ge_rx_buf *rx, struct pci_dev *pdev, int bytes,
884 bytes += VLAN_HLEN; /* account for 802.1q vlan tag */ 889 bytes += VLAN_HLEN; /* account for 802.1q vlan tag */
885 890
886 if ((bytes + MXGEFW_PAD) > (4096 - 16) /* linux overhead */ ) 891 if ((bytes + MXGEFW_PAD) > (4096 - 16) /* linux overhead */ )
887 skb = myri10ge_alloc_big(bytes); 892 skb = myri10ge_alloc_big(dev, bytes);
888 else if (myri10ge_skb_cross_4k) 893 else if (myri10ge_skb_cross_4k)
889 skb = myri10ge_alloc_small_safe(bytes); 894 skb = myri10ge_alloc_small_safe(dev, bytes);
890 else 895 else
891 skb = myri10ge_alloc_small(bytes); 896 skb = myri10ge_alloc_small(dev, bytes);
892 897
893 if (unlikely(skb == NULL)) { 898 if (unlikely(skb == NULL)) {
894 rx->alloc_fail++; 899 rx->alloc_fail++;
@@ -951,7 +956,7 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
951 unmap_len = pci_unmap_len(&rx->info[idx], len); 956 unmap_len = pci_unmap_len(&rx->info[idx], len);
952 957
953 /* try to replace the received skb */ 958 /* try to replace the received skb */
954 if (myri10ge_getbuf(rx, mgp->pdev, bytes, idx)) { 959 if (myri10ge_getbuf(rx, mgp, bytes, idx)) {
955 /* drop the frame -- the old skbuf is re-cycled */ 960 /* drop the frame -- the old skbuf is re-cycled */
956 mgp->stats.rx_dropped += 1; 961 mgp->stats.rx_dropped += 1;
957 return 0; 962 return 0;
@@ -968,7 +973,6 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
968 skb_put(skb, len); 973 skb_put(skb, len);
969 974
970 skb->protocol = eth_type_trans(skb, mgp->dev); 975 skb->protocol = eth_type_trans(skb, mgp->dev);
971 skb->dev = mgp->dev;
972 if (mgp->csum_flag) { 976 if (mgp->csum_flag) {
973 if ((skb->protocol == ntohs(ETH_P_IP)) || 977 if ((skb->protocol == ntohs(ETH_P_IP)) ||
974 (skb->protocol == ntohs(ETH_P_IPV6))) { 978 (skb->protocol == ntohs(ETH_P_IPV6))) {
@@ -1439,7 +1443,7 @@ static int myri10ge_allocate_rings(struct net_device *dev)
1439 /* Fill the receive rings */ 1443 /* Fill the receive rings */
1440 1444
1441 for (i = 0; i <= mgp->rx_small.mask; i++) { 1445 for (i = 0; i <= mgp->rx_small.mask; i++) {
1442 status = myri10ge_getbuf(&mgp->rx_small, mgp->pdev, 1446 status = myri10ge_getbuf(&mgp->rx_small, mgp,
1443 mgp->small_bytes, i); 1447 mgp->small_bytes, i);
1444 if (status) { 1448 if (status) {
1445 printk(KERN_ERR 1449 printk(KERN_ERR
@@ -1451,8 +1455,7 @@ static int myri10ge_allocate_rings(struct net_device *dev)
1451 1455
1452 for (i = 0; i <= mgp->rx_big.mask; i++) { 1456 for (i = 0; i <= mgp->rx_big.mask; i++) {
1453 status = 1457 status =
1454 myri10ge_getbuf(&mgp->rx_big, mgp->pdev, 1458 myri10ge_getbuf(&mgp->rx_big, mgp, dev->mtu + ETH_HLEN, i);
1455 dev->mtu + ETH_HLEN, i);
1456 if (status) { 1459 if (status) {
1457 printk(KERN_ERR 1460 printk(KERN_ERR
1458 "myri10ge: %s: alloced only %d big bufs\n", 1461 "myri10ge: %s: alloced only %d big bufs\n",