diff options
author | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 12:09:52 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.osdl.org> | 2006-12-07 12:09:52 -0500 |
commit | 0a01707b289853f56d1c000057b27e243c039722 (patch) | |
tree | fe9aff3073e7232e2f786a4faf8f0974b65fdfb0 | |
parent | 2685b267bce34c9b66626cb11664509c32a761a5 (diff) | |
parent | 0ae851352a87db3f829511816a2da227860bf585 (diff) |
Merge branch 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6
* 'upstream-linus' of master.kernel.org:/pub/scm/linux/kernel/git/jgarzik/netdev-2.6: (43 commits)
[wireless] zd1211rw: workqueue-related build fixes
[netdrvr] netxen: workqueue-related build fixes
[PATCH] sky2: sparse warnings
[PATCH] skge: fix sparse warnings
[PATCH] myri10ge: write as 2 32-byte blocks in myri10ge_submit_8rx
[PATCH] sky2: receive queue watermark tweak
[PATCH] sky2: beter ram buffer partitioning
[PATCH] sky2: add comments to PCI ids
[PATCH] sky2: add PCI for 88ec033
[PATCH] AT91RM9200 Ethernet: Use dev_alloc_skb()
[PATCH] AT91RM9200 Ethernet: Add netpoll / netconsole support
[PATCH] AT91RM9200 Ethernet: Move check_timer variable and use mod_timer()
[PATCH] AT91RM9200 Ethernet: Remove 'at91_dev' and use netdev_priv()
[PATCH] ipw2200: Fix debug output endian issue
[PATCH] ipw2200: Fix a typo
[PATCH] ipw2200: Update version stamp to 1.2.0
[PATCH] ipw2200: Add IEEE80211_RADIOTAP_TSFT for promiscuous mode
[PATCH] softmac: fix unbalanced mutex_lock/unlock in ieee80211softmac_wx_set_mlme
[PATCH] softmac: Fixed handling of deassociation from AP
[PATCH] ipw2200: replace kmalloc+memset with kcalloc
...
82 files changed, 2115 insertions, 1180 deletions
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c index 11d170afa9c3..06e33786078d 100644 --- a/drivers/net/3c501.c +++ b/drivers/net/3c501.c | |||
@@ -922,7 +922,7 @@ int __init init_module(void) | |||
922 | * and then free up the resources we took when the card was found. | 922 | * and then free up the resources we took when the card was found. |
923 | */ | 923 | */ |
924 | 924 | ||
925 | void cleanup_module(void) | 925 | void __exit cleanup_module(void) |
926 | { | 926 | { |
927 | struct net_device *dev = dev_3c501; | 927 | struct net_device *dev = dev_3c501; |
928 | unregister_netdev(dev); | 928 | unregister_netdev(dev); |
diff --git a/drivers/net/3c503.c b/drivers/net/3c503.c index a34b2206132d..7e34c4f07b70 100644 --- a/drivers/net/3c503.c +++ b/drivers/net/3c503.c | |||
@@ -726,7 +726,7 @@ static void cleanup_card(struct net_device *dev) | |||
726 | iounmap(ei_status.mem); | 726 | iounmap(ei_status.mem); |
727 | } | 727 | } |
728 | 728 | ||
729 | void | 729 | void __exit |
730 | cleanup_module(void) | 730 | cleanup_module(void) |
731 | { | 731 | { |
732 | int this_dev; | 732 | int this_dev; |
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c index 458cb9cbe915..702bfb2a5e99 100644 --- a/drivers/net/3c505.c +++ b/drivers/net/3c505.c | |||
@@ -1670,7 +1670,7 @@ int __init init_module(void) | |||
1670 | return 0; | 1670 | return 0; |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | void cleanup_module(void) | 1673 | void __exit cleanup_module(void) |
1674 | { | 1674 | { |
1675 | int this_dev; | 1675 | int this_dev; |
1676 | 1676 | ||
diff --git a/drivers/net/3c507.c b/drivers/net/3c507.c index aa43563610ae..54e1d5aebed3 100644 --- a/drivers/net/3c507.c +++ b/drivers/net/3c507.c | |||
@@ -940,7 +940,7 @@ int __init init_module(void) | |||
940 | return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0; | 940 | return IS_ERR(dev_3c507) ? PTR_ERR(dev_3c507) : 0; |
941 | } | 941 | } |
942 | 942 | ||
943 | void | 943 | void __exit |
944 | cleanup_module(void) | 944 | cleanup_module(void) |
945 | { | 945 | { |
946 | struct net_device *dev = dev_3c507; | 946 | struct net_device *dev = dev_3c507; |
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c index 91849469b4f4..17d61eb0a7e5 100644 --- a/drivers/net/3c523.c +++ b/drivers/net/3c523.c | |||
@@ -1302,7 +1302,7 @@ int __init init_module(void) | |||
1302 | } else return 0; | 1302 | } else return 0; |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | void cleanup_module(void) | 1305 | void __exit cleanup_module(void) |
1306 | { | 1306 | { |
1307 | int this_dev; | 1307 | int this_dev; |
1308 | for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) { | 1308 | for (this_dev=0; this_dev<MAX_3C523_CARDS; this_dev++) { |
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c index f4aca5386add..6c7437e60bd2 100644 --- a/drivers/net/3c527.c +++ b/drivers/net/3c527.c | |||
@@ -1659,7 +1659,7 @@ int __init init_module(void) | |||
1659 | * transmit operations are allowed to start scribbling into memory. | 1659 | * transmit operations are allowed to start scribbling into memory. |
1660 | */ | 1660 | */ |
1661 | 1661 | ||
1662 | void cleanup_module(void) | 1662 | void __exit cleanup_module(void) |
1663 | { | 1663 | { |
1664 | unregister_netdev(this_device); | 1664 | unregister_netdev(this_device); |
1665 | cleanup_card(this_device); | 1665 | cleanup_card(this_device); |
diff --git a/drivers/net/ac3200.c b/drivers/net/ac3200.c index 0dca8bb9d2c7..c01f87f5bed7 100644 --- a/drivers/net/ac3200.c +++ b/drivers/net/ac3200.c | |||
@@ -405,7 +405,7 @@ static void cleanup_card(struct net_device *dev) | |||
405 | iounmap(ei_status.mem); | 405 | iounmap(ei_status.mem); |
406 | } | 406 | } |
407 | 407 | ||
408 | void | 408 | void __exit |
409 | cleanup_module(void) | 409 | cleanup_module(void) |
410 | { | 410 | { |
411 | int this_dev; | 411 | int this_dev; |
diff --git a/drivers/net/apne.c b/drivers/net/apne.c index 9164d8cd670e..d4e408169073 100644 --- a/drivers/net/apne.c +++ b/drivers/net/apne.c | |||
@@ -568,7 +568,7 @@ static irqreturn_t apne_interrupt(int irq, void *dev_id) | |||
568 | #ifdef MODULE | 568 | #ifdef MODULE |
569 | static struct net_device *apne_dev; | 569 | static struct net_device *apne_dev; |
570 | 570 | ||
571 | int init_module(void) | 571 | int __init init_module(void) |
572 | { | 572 | { |
573 | apne_dev = apne_probe(-1); | 573 | apne_dev = apne_probe(-1); |
574 | if (IS_ERR(apne_dev)) | 574 | if (IS_ERR(apne_dev)) |
@@ -576,7 +576,7 @@ int init_module(void) | |||
576 | return 0; | 576 | return 0; |
577 | } | 577 | } |
578 | 578 | ||
579 | void cleanup_module(void) | 579 | void __exit cleanup_module(void) |
580 | { | 580 | { |
581 | unregister_netdev(apne_dev); | 581 | unregister_netdev(apne_dev); |
582 | 582 | ||
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c index cc1a27ed197f..dba5e5165452 100644 --- a/drivers/net/appletalk/cops.c +++ b/drivers/net/appletalk/cops.c | |||
@@ -1041,7 +1041,7 @@ int __init init_module(void) | |||
1041 | return 0; | 1041 | return 0; |
1042 | } | 1042 | } |
1043 | 1043 | ||
1044 | void cleanup_module(void) | 1044 | void __exit cleanup_module(void) |
1045 | { | 1045 | { |
1046 | unregister_netdev(cops_dev); | 1046 | unregister_netdev(cops_dev); |
1047 | cleanup_card(cops_dev); | 1047 | cleanup_card(cops_dev); |
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c index b54b857e357e..fada15d959de 100644 --- a/drivers/net/arm/at91_ether.c +++ b/drivers/net/arm/at91_ether.c | |||
@@ -41,9 +41,6 @@ | |||
41 | #define DRV_NAME "at91_ether" | 41 | #define DRV_NAME "at91_ether" |
42 | #define DRV_VERSION "1.0" | 42 | #define DRV_VERSION "1.0" |
43 | 43 | ||
44 | static struct net_device *at91_dev; | ||
45 | |||
46 | static struct timer_list check_timer; | ||
47 | #define LINK_POLL_INTERVAL (HZ) | 44 | #define LINK_POLL_INTERVAL (HZ) |
48 | 45 | ||
49 | /* ..................................................................... */ | 46 | /* ..................................................................... */ |
@@ -146,7 +143,7 @@ static void read_phy(unsigned char phy_addr, unsigned char address, unsigned int | |||
146 | */ | 143 | */ |
147 | static void update_linkspeed(struct net_device *dev, int silent) | 144 | static void update_linkspeed(struct net_device *dev, int silent) |
148 | { | 145 | { |
149 | struct at91_private *lp = (struct at91_private *) dev->priv; | 146 | struct at91_private *lp = netdev_priv(dev); |
150 | unsigned int bmsr, bmcr, lpa, mac_cfg; | 147 | unsigned int bmsr, bmcr, lpa, mac_cfg; |
151 | unsigned int speed, duplex; | 148 | unsigned int speed, duplex; |
152 | 149 | ||
@@ -199,7 +196,7 @@ static void update_linkspeed(struct net_device *dev, int silent) | |||
199 | static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id) | 196 | static irqreturn_t at91ether_phy_interrupt(int irq, void *dev_id) |
200 | { | 197 | { |
201 | struct net_device *dev = (struct net_device *) dev_id; | 198 | struct net_device *dev = (struct net_device *) dev_id; |
202 | struct at91_private *lp = (struct at91_private *) dev->priv; | 199 | struct at91_private *lp = netdev_priv(dev); |
203 | unsigned int phy; | 200 | unsigned int phy; |
204 | 201 | ||
205 | /* | 202 | /* |
@@ -242,7 +239,7 @@ done: | |||
242 | */ | 239 | */ |
243 | static void enable_phyirq(struct net_device *dev) | 240 | static void enable_phyirq(struct net_device *dev) |
244 | { | 241 | { |
245 | struct at91_private *lp = (struct at91_private *) dev->priv; | 242 | struct at91_private *lp = netdev_priv(dev); |
246 | unsigned int dsintr, irq_number; | 243 | unsigned int dsintr, irq_number; |
247 | int status; | 244 | int status; |
248 | 245 | ||
@@ -252,8 +249,7 @@ static void enable_phyirq(struct net_device *dev) | |||
252 | * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L), | 249 | * PHY doesn't have an IRQ pin (RTL8201, DP83847, AC101L), |
253 | * or board does not have it connected. | 250 | * or board does not have it connected. |
254 | */ | 251 | */ |
255 | check_timer.expires = jiffies + LINK_POLL_INTERVAL; | 252 | mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL); |
256 | add_timer(&check_timer); | ||
257 | return; | 253 | return; |
258 | } | 254 | } |
259 | 255 | ||
@@ -294,13 +290,13 @@ static void enable_phyirq(struct net_device *dev) | |||
294 | */ | 290 | */ |
295 | static void disable_phyirq(struct net_device *dev) | 291 | static void disable_phyirq(struct net_device *dev) |
296 | { | 292 | { |
297 | struct at91_private *lp = (struct at91_private *) dev->priv; | 293 | struct at91_private *lp = netdev_priv(dev); |
298 | unsigned int dsintr; | 294 | unsigned int dsintr; |
299 | unsigned int irq_number; | 295 | unsigned int irq_number; |
300 | 296 | ||
301 | irq_number = lp->board_data.phy_irq_pin; | 297 | irq_number = lp->board_data.phy_irq_pin; |
302 | if (!irq_number) { | 298 | if (!irq_number) { |
303 | del_timer_sync(&check_timer); | 299 | del_timer_sync(&lp->check_timer); |
304 | return; | 300 | return; |
305 | } | 301 | } |
306 | 302 | ||
@@ -340,7 +336,7 @@ static void disable_phyirq(struct net_device *dev) | |||
340 | #if 0 | 336 | #if 0 |
341 | static void reset_phy(struct net_device *dev) | 337 | static void reset_phy(struct net_device *dev) |
342 | { | 338 | { |
343 | struct at91_private *lp = (struct at91_private *) dev->priv; | 339 | struct at91_private *lp = netdev_priv(dev); |
344 | unsigned int bmcr; | 340 | unsigned int bmcr; |
345 | 341 | ||
346 | spin_lock_irq(&lp->lock); | 342 | spin_lock_irq(&lp->lock); |
@@ -362,13 +358,13 @@ static void reset_phy(struct net_device *dev) | |||
362 | static void at91ether_check_link(unsigned long dev_id) | 358 | static void at91ether_check_link(unsigned long dev_id) |
363 | { | 359 | { |
364 | struct net_device *dev = (struct net_device *) dev_id; | 360 | struct net_device *dev = (struct net_device *) dev_id; |
361 | struct at91_private *lp = netdev_priv(dev); | ||
365 | 362 | ||
366 | enable_mdi(); | 363 | enable_mdi(); |
367 | update_linkspeed(dev, 1); | 364 | update_linkspeed(dev, 1); |
368 | disable_mdi(); | 365 | disable_mdi(); |
369 | 366 | ||
370 | check_timer.expires = jiffies + LINK_POLL_INTERVAL; | 367 | mod_timer(&lp->check_timer, jiffies + LINK_POLL_INTERVAL); |
371 | add_timer(&check_timer); | ||
372 | } | 368 | } |
373 | 369 | ||
374 | /* ......................... ADDRESS MANAGEMENT ........................ */ | 370 | /* ......................... ADDRESS MANAGEMENT ........................ */ |
@@ -590,7 +586,7 @@ static void mdio_write(struct net_device *dev, int phy_id, int location, int val | |||
590 | 586 | ||
591 | static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 587 | static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
592 | { | 588 | { |
593 | struct at91_private *lp = (struct at91_private *) dev->priv; | 589 | struct at91_private *lp = netdev_priv(dev); |
594 | int ret; | 590 | int ret; |
595 | 591 | ||
596 | spin_lock_irq(&lp->lock); | 592 | spin_lock_irq(&lp->lock); |
@@ -611,7 +607,7 @@ static int at91ether_get_settings(struct net_device *dev, struct ethtool_cmd *cm | |||
611 | 607 | ||
612 | static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) | 608 | static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) |
613 | { | 609 | { |
614 | struct at91_private *lp = (struct at91_private *) dev->priv; | 610 | struct at91_private *lp = netdev_priv(dev); |
615 | int ret; | 611 | int ret; |
616 | 612 | ||
617 | spin_lock_irq(&lp->lock); | 613 | spin_lock_irq(&lp->lock); |
@@ -627,7 +623,7 @@ static int at91ether_set_settings(struct net_device *dev, struct ethtool_cmd *cm | |||
627 | 623 | ||
628 | static int at91ether_nwayreset(struct net_device *dev) | 624 | static int at91ether_nwayreset(struct net_device *dev) |
629 | { | 625 | { |
630 | struct at91_private *lp = (struct at91_private *) dev->priv; | 626 | struct at91_private *lp = netdev_priv(dev); |
631 | int ret; | 627 | int ret; |
632 | 628 | ||
633 | spin_lock_irq(&lp->lock); | 629 | spin_lock_irq(&lp->lock); |
@@ -658,7 +654,7 @@ static const struct ethtool_ops at91ether_ethtool_ops = { | |||
658 | 654 | ||
659 | static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | 655 | static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) |
660 | { | 656 | { |
661 | struct at91_private *lp = (struct at91_private *) dev->priv; | 657 | struct at91_private *lp = netdev_priv(dev); |
662 | int res; | 658 | int res; |
663 | 659 | ||
664 | if (!netif_running(dev)) | 660 | if (!netif_running(dev)) |
@@ -680,7 +676,7 @@ static int at91ether_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
680 | */ | 676 | */ |
681 | static void at91ether_start(struct net_device *dev) | 677 | static void at91ether_start(struct net_device *dev) |
682 | { | 678 | { |
683 | struct at91_private *lp = (struct at91_private *) dev->priv; | 679 | struct at91_private *lp = netdev_priv(dev); |
684 | struct recv_desc_bufs *dlist, *dlist_phys; | 680 | struct recv_desc_bufs *dlist, *dlist_phys; |
685 | int i; | 681 | int i; |
686 | unsigned long ctl; | 682 | unsigned long ctl; |
@@ -712,7 +708,7 @@ static void at91ether_start(struct net_device *dev) | |||
712 | */ | 708 | */ |
713 | static int at91ether_open(struct net_device *dev) | 709 | static int at91ether_open(struct net_device *dev) |
714 | { | 710 | { |
715 | struct at91_private *lp = (struct at91_private *) dev->priv; | 711 | struct at91_private *lp = netdev_priv(dev); |
716 | unsigned long ctl; | 712 | unsigned long ctl; |
717 | 713 | ||
718 | if (!is_valid_ether_addr(dev->dev_addr)) | 714 | if (!is_valid_ether_addr(dev->dev_addr)) |
@@ -752,7 +748,7 @@ static int at91ether_open(struct net_device *dev) | |||
752 | */ | 748 | */ |
753 | static int at91ether_close(struct net_device *dev) | 749 | static int at91ether_close(struct net_device *dev) |
754 | { | 750 | { |
755 | struct at91_private *lp = (struct at91_private *) dev->priv; | 751 | struct at91_private *lp = netdev_priv(dev); |
756 | unsigned long ctl; | 752 | unsigned long ctl; |
757 | 753 | ||
758 | /* Disable Receiver and Transmitter */ | 754 | /* Disable Receiver and Transmitter */ |
@@ -779,7 +775,7 @@ static int at91ether_close(struct net_device *dev) | |||
779 | */ | 775 | */ |
780 | static int at91ether_tx(struct sk_buff *skb, struct net_device *dev) | 776 | static int at91ether_tx(struct sk_buff *skb, struct net_device *dev) |
781 | { | 777 | { |
782 | struct at91_private *lp = (struct at91_private *) dev->priv; | 778 | struct at91_private *lp = netdev_priv(dev); |
783 | 779 | ||
784 | if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) { | 780 | if (at91_emac_read(AT91_EMAC_TSR) & AT91_EMAC_TSR_BNQ) { |
785 | netif_stop_queue(dev); | 781 | netif_stop_queue(dev); |
@@ -811,7 +807,7 @@ static int at91ether_tx(struct sk_buff *skb, struct net_device *dev) | |||
811 | */ | 807 | */ |
812 | static struct net_device_stats *at91ether_stats(struct net_device *dev) | 808 | static struct net_device_stats *at91ether_stats(struct net_device *dev) |
813 | { | 809 | { |
814 | struct at91_private *lp = (struct at91_private *) dev->priv; | 810 | struct at91_private *lp = netdev_priv(dev); |
815 | int ale, lenerr, seqe, lcol, ecol; | 811 | int ale, lenerr, seqe, lcol, ecol; |
816 | 812 | ||
817 | if (netif_running(dev)) { | 813 | if (netif_running(dev)) { |
@@ -847,7 +843,7 @@ static struct net_device_stats *at91ether_stats(struct net_device *dev) | |||
847 | */ | 843 | */ |
848 | static void at91ether_rx(struct net_device *dev) | 844 | static void at91ether_rx(struct net_device *dev) |
849 | { | 845 | { |
850 | struct at91_private *lp = (struct at91_private *) dev->priv; | 846 | struct at91_private *lp = netdev_priv(dev); |
851 | struct recv_desc_bufs *dlist; | 847 | struct recv_desc_bufs *dlist; |
852 | unsigned char *p_recv; | 848 | unsigned char *p_recv; |
853 | struct sk_buff *skb; | 849 | struct sk_buff *skb; |
@@ -857,14 +853,13 @@ static void at91ether_rx(struct net_device *dev) | |||
857 | while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) { | 853 | while (dlist->descriptors[lp->rxBuffIndex].addr & EMAC_DESC_DONE) { |
858 | p_recv = dlist->recv_buf[lp->rxBuffIndex]; | 854 | p_recv = dlist->recv_buf[lp->rxBuffIndex]; |
859 | pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */ | 855 | pktlen = dlist->descriptors[lp->rxBuffIndex].size & 0x7ff; /* Length of frame including FCS */ |
860 | skb = alloc_skb(pktlen + 2, GFP_ATOMIC); | 856 | skb = dev_alloc_skb(pktlen + 2); |
861 | if (skb != NULL) { | 857 | if (skb != NULL) { |
862 | skb_reserve(skb, 2); | 858 | skb_reserve(skb, 2); |
863 | memcpy(skb_put(skb, pktlen), p_recv, pktlen); | 859 | memcpy(skb_put(skb, pktlen), p_recv, pktlen); |
864 | 860 | ||
865 | skb->dev = dev; | 861 | skb->dev = dev; |
866 | skb->protocol = eth_type_trans(skb, dev); | 862 | skb->protocol = eth_type_trans(skb, dev); |
867 | skb->len = pktlen; | ||
868 | dev->last_rx = jiffies; | 863 | dev->last_rx = jiffies; |
869 | lp->stats.rx_bytes += pktlen; | 864 | lp->stats.rx_bytes += pktlen; |
870 | netif_rx(skb); | 865 | netif_rx(skb); |
@@ -891,7 +886,7 @@ static void at91ether_rx(struct net_device *dev) | |||
891 | static irqreturn_t at91ether_interrupt(int irq, void *dev_id) | 886 | static irqreturn_t at91ether_interrupt(int irq, void *dev_id) |
892 | { | 887 | { |
893 | struct net_device *dev = (struct net_device *) dev_id; | 888 | struct net_device *dev = (struct net_device *) dev_id; |
894 | struct at91_private *lp = (struct at91_private *) dev->priv; | 889 | struct at91_private *lp = netdev_priv(dev); |
895 | unsigned long intstatus, ctl; | 890 | unsigned long intstatus, ctl; |
896 | 891 | ||
897 | /* MAC Interrupt Status register indicates what interrupts are pending. | 892 | /* MAC Interrupt Status register indicates what interrupts are pending. |
@@ -927,6 +922,17 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id) | |||
927 | return IRQ_HANDLED; | 922 | return IRQ_HANDLED; |
928 | } | 923 | } |
929 | 924 | ||
925 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
926 | static void at91ether_poll_controller(struct net_device *dev) | ||
927 | { | ||
928 | unsigned long flags; | ||
929 | |||
930 | local_irq_save(flags); | ||
931 | at91ether_interrupt(dev->irq, dev); | ||
932 | local_irq_restore(flags); | ||
933 | } | ||
934 | #endif | ||
935 | |||
930 | /* | 936 | /* |
931 | * Initialize the ethernet interface | 937 | * Initialize the ethernet interface |
932 | */ | 938 | */ |
@@ -939,9 +945,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
939 | unsigned int val; | 945 | unsigned int val; |
940 | int res; | 946 | int res; |
941 | 947 | ||
942 | if (at91_dev) /* already initialized */ | ||
943 | return 0; | ||
944 | |||
945 | dev = alloc_etherdev(sizeof(struct at91_private)); | 948 | dev = alloc_etherdev(sizeof(struct at91_private)); |
946 | if (!dev) | 949 | if (!dev) |
947 | return -ENOMEM; | 950 | return -ENOMEM; |
@@ -957,7 +960,7 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
957 | } | 960 | } |
958 | 961 | ||
959 | /* Allocate memory for DMA Receive descriptors */ | 962 | /* Allocate memory for DMA Receive descriptors */ |
960 | lp = (struct at91_private *)dev->priv; | 963 | lp = netdev_priv(dev); |
961 | lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL); | 964 | lp->dlist = (struct recv_desc_bufs *) dma_alloc_coherent(NULL, sizeof(struct recv_desc_bufs), (dma_addr_t *) &lp->dlist_phys, GFP_KERNEL); |
962 | if (lp->dlist == NULL) { | 965 | if (lp->dlist == NULL) { |
963 | free_irq(dev->irq, dev); | 966 | free_irq(dev->irq, dev); |
@@ -979,6 +982,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
979 | dev->set_mac_address = set_mac_address; | 982 | dev->set_mac_address = set_mac_address; |
980 | dev->ethtool_ops = &at91ether_ethtool_ops; | 983 | dev->ethtool_ops = &at91ether_ethtool_ops; |
981 | dev->do_ioctl = at91ether_ioctl; | 984 | dev->do_ioctl = at91ether_ioctl; |
985 | #ifdef CONFIG_NET_POLL_CONTROLLER | ||
986 | dev->poll_controller = at91ether_poll_controller; | ||
987 | #endif | ||
982 | 988 | ||
983 | SET_NETDEV_DEV(dev, &pdev->dev); | 989 | SET_NETDEV_DEV(dev, &pdev->dev); |
984 | 990 | ||
@@ -1024,7 +1030,6 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
1024 | dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); | 1030 | dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); |
1025 | return res; | 1031 | return res; |
1026 | } | 1032 | } |
1027 | at91_dev = dev; | ||
1028 | 1033 | ||
1029 | /* Determine current link speed */ | 1034 | /* Determine current link speed */ |
1030 | spin_lock_irq(&lp->lock); | 1035 | spin_lock_irq(&lp->lock); |
@@ -1036,9 +1041,9 @@ static int __init at91ether_setup(unsigned long phy_type, unsigned short phy_add | |||
1036 | 1041 | ||
1037 | /* If board has no PHY IRQ, use a timer to poll the PHY */ | 1042 | /* If board has no PHY IRQ, use a timer to poll the PHY */ |
1038 | if (!lp->board_data.phy_irq_pin) { | 1043 | if (!lp->board_data.phy_irq_pin) { |
1039 | init_timer(&check_timer); | 1044 | init_timer(&lp->check_timer); |
1040 | check_timer.data = (unsigned long)dev; | 1045 | lp->check_timer.data = (unsigned long)dev; |
1041 | check_timer.function = at91ether_check_link; | 1046 | lp->check_timer.function = at91ether_check_link; |
1042 | } | 1047 | } |
1043 | 1048 | ||
1044 | /* Display ethernet banner */ | 1049 | /* Display ethernet banner */ |
@@ -1115,15 +1120,16 @@ static int __init at91ether_probe(struct platform_device *pdev) | |||
1115 | 1120 | ||
1116 | static int __devexit at91ether_remove(struct platform_device *pdev) | 1121 | static int __devexit at91ether_remove(struct platform_device *pdev) |
1117 | { | 1122 | { |
1118 | struct at91_private *lp = (struct at91_private *) at91_dev->priv; | 1123 | struct net_device *dev = platform_get_drvdata(pdev); |
1124 | struct at91_private *lp = netdev_priv(dev); | ||
1119 | 1125 | ||
1120 | unregister_netdev(at91_dev); | 1126 | unregister_netdev(dev); |
1121 | free_irq(at91_dev->irq, at91_dev); | 1127 | free_irq(dev->irq, dev); |
1122 | dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); | 1128 | dma_free_coherent(NULL, sizeof(struct recv_desc_bufs), lp->dlist, (dma_addr_t)lp->dlist_phys); |
1123 | clk_put(lp->ether_clk); | 1129 | clk_put(lp->ether_clk); |
1124 | 1130 | ||
1125 | free_netdev(at91_dev); | 1131 | platform_set_drvdata(pdev, NULL); |
1126 | at91_dev = NULL; | 1132 | free_netdev(dev); |
1127 | return 0; | 1133 | return 0; |
1128 | } | 1134 | } |
1129 | 1135 | ||
@@ -1131,8 +1137,8 @@ static int __devexit at91ether_remove(struct platform_device *pdev) | |||
1131 | 1137 | ||
1132 | static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg) | 1138 | static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg) |
1133 | { | 1139 | { |
1134 | struct at91_private *lp = (struct at91_private *) at91_dev->priv; | ||
1135 | struct net_device *net_dev = platform_get_drvdata(pdev); | 1140 | struct net_device *net_dev = platform_get_drvdata(pdev); |
1141 | struct at91_private *lp = netdev_priv(net_dev); | ||
1136 | int phy_irq = lp->board_data.phy_irq_pin; | 1142 | int phy_irq = lp->board_data.phy_irq_pin; |
1137 | 1143 | ||
1138 | if (netif_running(net_dev)) { | 1144 | if (netif_running(net_dev)) { |
@@ -1149,8 +1155,8 @@ static int at91ether_suspend(struct platform_device *pdev, pm_message_t mesg) | |||
1149 | 1155 | ||
1150 | static int at91ether_resume(struct platform_device *pdev) | 1156 | static int at91ether_resume(struct platform_device *pdev) |
1151 | { | 1157 | { |
1152 | struct at91_private *lp = (struct at91_private *) at91_dev->priv; | ||
1153 | struct net_device *net_dev = platform_get_drvdata(pdev); | 1158 | struct net_device *net_dev = platform_get_drvdata(pdev); |
1159 | struct at91_private *lp = netdev_priv(net_dev); | ||
1154 | int phy_irq = lp->board_data.phy_irq_pin; | 1160 | int phy_irq = lp->board_data.phy_irq_pin; |
1155 | 1161 | ||
1156 | if (netif_running(net_dev)) { | 1162 | if (netif_running(net_dev)) { |
diff --git a/drivers/net/arm/at91_ether.h b/drivers/net/arm/at91_ether.h index d1e72e02be3a..b6b665de2ea0 100644 --- a/drivers/net/arm/at91_ether.h +++ b/drivers/net/arm/at91_ether.h | |||
@@ -87,6 +87,7 @@ struct at91_private | |||
87 | spinlock_t lock; /* lock for MDI interface */ | 87 | spinlock_t lock; /* lock for MDI interface */ |
88 | short phy_media; /* media interface type */ | 88 | short phy_media; /* media interface type */ |
89 | unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */ | 89 | unsigned short phy_address; /* 5-bit MDI address of PHY (0..31) */ |
90 | struct timer_list check_timer; /* Poll link status */ | ||
90 | 91 | ||
91 | /* Transmit */ | 92 | /* Transmit */ |
92 | struct sk_buff *skb; /* holds skb until xmit interrupt completes */ | 93 | struct sk_buff *skb; /* holds skb until xmit interrupt completes */ |
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c index f3478a30e778..d6da3ce9ad79 100644 --- a/drivers/net/arm/ether1.c +++ b/drivers/net/arm/ether1.c | |||
@@ -254,7 +254,7 @@ ether1_readbuffer (struct net_device *dev, void *data, unsigned int start, unsig | |||
254 | } while (thislen); | 254 | } while (thislen); |
255 | } | 255 | } |
256 | 256 | ||
257 | static int __init | 257 | static int __devinit |
258 | ether1_ramtest(struct net_device *dev, unsigned char byte) | 258 | ether1_ramtest(struct net_device *dev, unsigned char byte) |
259 | { | 259 | { |
260 | unsigned char *buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL); | 260 | unsigned char *buffer = kmalloc (BUFFER_SIZE, GFP_KERNEL); |
@@ -308,7 +308,7 @@ ether1_reset (struct net_device *dev) | |||
308 | return BUS_16; | 308 | return BUS_16; |
309 | } | 309 | } |
310 | 310 | ||
311 | static int __init | 311 | static int __devinit |
312 | ether1_init_2(struct net_device *dev) | 312 | ether1_init_2(struct net_device *dev) |
313 | { | 313 | { |
314 | int i; | 314 | int i; |
@@ -986,7 +986,7 @@ ether1_setmulticastlist (struct net_device *dev) | |||
986 | 986 | ||
987 | /* ------------------------------------------------------------------------- */ | 987 | /* ------------------------------------------------------------------------- */ |
988 | 988 | ||
989 | static void __init ether1_banner(void) | 989 | static void __devinit ether1_banner(void) |
990 | { | 990 | { |
991 | static unsigned int version_printed = 0; | 991 | static unsigned int version_printed = 0; |
992 | 992 | ||
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c index 84686c8a5bc2..4fc234785d56 100644 --- a/drivers/net/arm/ether3.c +++ b/drivers/net/arm/ether3.c | |||
@@ -198,7 +198,7 @@ static inline void ether3_ledon(struct net_device *dev) | |||
198 | * Read the ethernet address string from the on board rom. | 198 | * Read the ethernet address string from the on board rom. |
199 | * This is an ascii string!!! | 199 | * This is an ascii string!!! |
200 | */ | 200 | */ |
201 | static int __init | 201 | static int __devinit |
202 | ether3_addr(char *addr, struct expansion_card *ec) | 202 | ether3_addr(char *addr, struct expansion_card *ec) |
203 | { | 203 | { |
204 | struct in_chunk_dir cd; | 204 | struct in_chunk_dir cd; |
@@ -223,7 +223,7 @@ ether3_addr(char *addr, struct expansion_card *ec) | |||
223 | 223 | ||
224 | /* --------------------------------------------------------------------------- */ | 224 | /* --------------------------------------------------------------------------- */ |
225 | 225 | ||
226 | static int __init | 226 | static int __devinit |
227 | ether3_ramtest(struct net_device *dev, unsigned char byte) | 227 | ether3_ramtest(struct net_device *dev, unsigned char byte) |
228 | { | 228 | { |
229 | unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL); | 229 | unsigned char *buffer = kmalloc(RX_END, GFP_KERNEL); |
@@ -272,7 +272,7 @@ ether3_ramtest(struct net_device *dev, unsigned char byte) | |||
272 | 272 | ||
273 | /* ------------------------------------------------------------------------------- */ | 273 | /* ------------------------------------------------------------------------------- */ |
274 | 274 | ||
275 | static int __init ether3_init_2(struct net_device *dev) | 275 | static int __devinit ether3_init_2(struct net_device *dev) |
276 | { | 276 | { |
277 | int i; | 277 | int i; |
278 | 278 | ||
@@ -765,7 +765,7 @@ static void ether3_tx(struct net_device *dev) | |||
765 | } | 765 | } |
766 | } | 766 | } |
767 | 767 | ||
768 | static void __init ether3_banner(void) | 768 | static void __devinit ether3_banner(void) |
769 | { | 769 | { |
770 | static unsigned version_printed = 0; | 770 | static unsigned version_printed = 0; |
771 | 771 | ||
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c index 8620a5b470f5..56ae8babd919 100644 --- a/drivers/net/at1700.c +++ b/drivers/net/at1700.c | |||
@@ -908,7 +908,7 @@ int __init init_module(void) | |||
908 | return 0; | 908 | return 0; |
909 | } | 909 | } |
910 | 910 | ||
911 | void | 911 | void __exit |
912 | cleanup_module(void) | 912 | cleanup_module(void) |
913 | { | 913 | { |
914 | unregister_netdev(dev_at1700); | 914 | unregister_netdev(dev_at1700); |
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c index d79489e46249..7e37ac86a69a 100644 --- a/drivers/net/atarilance.c +++ b/drivers/net/atarilance.c | |||
@@ -1179,7 +1179,7 @@ static int lance_set_mac_address( struct net_device *dev, void *addr ) | |||
1179 | #ifdef MODULE | 1179 | #ifdef MODULE |
1180 | static struct net_device *atarilance_dev; | 1180 | static struct net_device *atarilance_dev; |
1181 | 1181 | ||
1182 | int init_module(void) | 1182 | int __init init_module(void) |
1183 | { | 1183 | { |
1184 | atarilance_dev = atarilance_probe(-1); | 1184 | atarilance_dev = atarilance_probe(-1); |
1185 | if (IS_ERR(atarilance_dev)) | 1185 | if (IS_ERR(atarilance_dev)) |
@@ -1187,7 +1187,7 @@ int init_module(void) | |||
1187 | return 0; | 1187 | return 0; |
1188 | } | 1188 | } |
1189 | 1189 | ||
1190 | void cleanup_module(void) | 1190 | void __exit cleanup_module(void) |
1191 | { | 1191 | { |
1192 | unregister_netdev(atarilance_dev); | 1192 | unregister_netdev(atarilance_dev); |
1193 | free_irq(atarilance_dev->irq, atarilance_dev); | 1193 | free_irq(atarilance_dev->irq, atarilance_dev); |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index 488d8ed9e740..6482aed4bb7c 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -3684,7 +3684,7 @@ static int bond_do_ioctl(struct net_device *bond_dev, struct ifreq *ifr, int cmd | |||
3684 | mii->val_out = 0; | 3684 | mii->val_out = 0; |
3685 | read_lock_bh(&bond->lock); | 3685 | read_lock_bh(&bond->lock); |
3686 | read_lock(&bond->curr_slave_lock); | 3686 | read_lock(&bond->curr_slave_lock); |
3687 | if (bond->curr_active_slave) { | 3687 | if (netif_carrier_ok(bond->dev)) { |
3688 | mii->val_out = BMSR_LSTATUS; | 3688 | mii->val_out = BMSR_LSTATUS; |
3689 | } | 3689 | } |
3690 | read_unlock(&bond->curr_slave_lock); | 3690 | read_unlock(&bond->curr_slave_lock); |
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index dec70c2b374a..4612f71a7106 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c | |||
@@ -1974,7 +1974,7 @@ out: | |||
1974 | return ret; | 1974 | return ret; |
1975 | } | 1975 | } |
1976 | 1976 | ||
1977 | void | 1977 | void __exit |
1978 | cleanup_module(void) | 1978 | cleanup_module(void) |
1979 | { | 1979 | { |
1980 | unregister_netdev(dev_cs89x0); | 1980 | unregister_netdev(dev_cs89x0); |
diff --git a/drivers/net/declance.c b/drivers/net/declance.c index 00e2a8a134d7..4ae0fed7122e 100644 --- a/drivers/net/declance.c +++ b/drivers/net/declance.c | |||
@@ -40,6 +40,10 @@ | |||
40 | * | 40 | * |
41 | * v0.009: Module support fixes, multiple interfaces support, various | 41 | * v0.009: Module support fixes, multiple interfaces support, various |
42 | * bits. macro | 42 | * bits. macro |
43 | * | ||
44 | * v0.010: Fixes for the PMAD mapping of the LANCE buffer and for the | ||
45 | * PMAX requirement to only use halfword accesses to the | ||
46 | * buffer. macro | ||
43 | */ | 47 | */ |
44 | 48 | ||
45 | #include <linux/crc32.h> | 49 | #include <linux/crc32.h> |
@@ -54,6 +58,7 @@ | |||
54 | #include <linux/spinlock.h> | 58 | #include <linux/spinlock.h> |
55 | #include <linux/stddef.h> | 59 | #include <linux/stddef.h> |
56 | #include <linux/string.h> | 60 | #include <linux/string.h> |
61 | #include <linux/types.h> | ||
57 | 62 | ||
58 | #include <asm/addrspace.h> | 63 | #include <asm/addrspace.h> |
59 | #include <asm/system.h> | 64 | #include <asm/system.h> |
@@ -67,7 +72,7 @@ | |||
67 | #include <asm/dec/tc.h> | 72 | #include <asm/dec/tc.h> |
68 | 73 | ||
69 | static char version[] __devinitdata = | 74 | static char version[] __devinitdata = |
70 | "declance.c: v0.009 by Linux MIPS DECstation task force\n"; | 75 | "declance.c: v0.010 by Linux MIPS DECstation task force\n"; |
71 | 76 | ||
72 | MODULE_AUTHOR("Linux MIPS DECstation task force"); | 77 | MODULE_AUTHOR("Linux MIPS DECstation task force"); |
73 | MODULE_DESCRIPTION("DEC LANCE (DECstation onboard, PMAD-xx) driver"); | 78 | MODULE_DESCRIPTION("DEC LANCE (DECstation onboard, PMAD-xx) driver"); |
@@ -110,24 +115,25 @@ MODULE_LICENSE("GPL"); | |||
110 | #define LE_C3_BCON 0x1 /* Byte control */ | 115 | #define LE_C3_BCON 0x1 /* Byte control */ |
111 | 116 | ||
112 | /* Receive message descriptor 1 */ | 117 | /* Receive message descriptor 1 */ |
113 | #define LE_R1_OWN 0x80 /* Who owns the entry */ | 118 | #define LE_R1_OWN 0x8000 /* Who owns the entry */ |
114 | #define LE_R1_ERR 0x40 /* Error: if FRA, OFL, CRC or BUF is set */ | 119 | #define LE_R1_ERR 0x4000 /* Error: if FRA, OFL, CRC or BUF is set */ |
115 | #define LE_R1_FRA 0x20 /* FRA: Frame error */ | 120 | #define LE_R1_FRA 0x2000 /* FRA: Frame error */ |
116 | #define LE_R1_OFL 0x10 /* OFL: Frame overflow */ | 121 | #define LE_R1_OFL 0x1000 /* OFL: Frame overflow */ |
117 | #define LE_R1_CRC 0x08 /* CRC error */ | 122 | #define LE_R1_CRC 0x0800 /* CRC error */ |
118 | #define LE_R1_BUF 0x04 /* BUF: Buffer error */ | 123 | #define LE_R1_BUF 0x0400 /* BUF: Buffer error */ |
119 | #define LE_R1_SOP 0x02 /* Start of packet */ | 124 | #define LE_R1_SOP 0x0200 /* Start of packet */ |
120 | #define LE_R1_EOP 0x01 /* End of packet */ | 125 | #define LE_R1_EOP 0x0100 /* End of packet */ |
121 | #define LE_R1_POK 0x03 /* Packet is complete: SOP + EOP */ | 126 | #define LE_R1_POK 0x0300 /* Packet is complete: SOP + EOP */ |
122 | 127 | ||
123 | #define LE_T1_OWN 0x80 /* Lance owns the packet */ | 128 | /* Transmit message descriptor 1 */ |
124 | #define LE_T1_ERR 0x40 /* Error summary */ | 129 | #define LE_T1_OWN 0x8000 /* Lance owns the packet */ |
125 | #define LE_T1_EMORE 0x10 /* Error: more than one retry needed */ | 130 | #define LE_T1_ERR 0x4000 /* Error summary */ |
126 | #define LE_T1_EONE 0x08 /* Error: one retry needed */ | 131 | #define LE_T1_EMORE 0x1000 /* Error: more than one retry needed */ |
127 | #define LE_T1_EDEF 0x04 /* Error: deferred */ | 132 | #define LE_T1_EONE 0x0800 /* Error: one retry needed */ |
128 | #define LE_T1_SOP 0x02 /* Start of packet */ | 133 | #define LE_T1_EDEF 0x0400 /* Error: deferred */ |
129 | #define LE_T1_EOP 0x01 /* End of packet */ | 134 | #define LE_T1_SOP 0x0200 /* Start of packet */ |
130 | #define LE_T1_POK 0x03 /* Packet is complete: SOP + EOP */ | 135 | #define LE_T1_EOP 0x0100 /* End of packet */ |
136 | #define LE_T1_POK 0x0300 /* Packet is complete: SOP + EOP */ | ||
131 | 137 | ||
132 | #define LE_T3_BUF 0x8000 /* Buffer error */ | 138 | #define LE_T3_BUF 0x8000 /* Buffer error */ |
133 | #define LE_T3_UFL 0x4000 /* Error underflow */ | 139 | #define LE_T3_UFL 0x4000 /* Error underflow */ |
@@ -156,69 +162,57 @@ MODULE_LICENSE("GPL"); | |||
156 | #undef TEST_HITS | 162 | #undef TEST_HITS |
157 | #define ZERO 0 | 163 | #define ZERO 0 |
158 | 164 | ||
159 | /* The DS2000/3000 have a linear 64 KB buffer. | 165 | /* |
160 | 166 | * The DS2100/3100 have a linear 64 kB buffer which supports halfword | |
161 | * The PMAD-AA has 128 kb buffer on-board. | 167 | * accesses only. Each halfword of the buffer is word-aligned in the |
168 | * CPU address space. | ||
162 | * | 169 | * |
163 | * The IOASIC LANCE devices use a shared memory region. This region as seen | 170 | * The PMAD-AA has a 128 kB buffer on-board. |
164 | * from the CPU is (max) 128 KB long and has to be on an 128 KB boundary. | ||
165 | * The LANCE sees this as a 64 KB long continuous memory region. | ||
166 | * | 171 | * |
167 | * The LANCE's DMA address is used as an index in this buffer and DMA takes | 172 | * The IOASIC LANCE devices use a shared memory region. This region |
168 | * place in bursts of eight 16-Bit words which are packed into four 32-Bit words | 173 | * as seen from the CPU is (max) 128 kB long and has to be on an 128 kB |
169 | * by the IOASIC. This leads to a strange padding: 16 bytes of valid data followed | 174 | * boundary. The LANCE sees this as a 64 kB long continuous memory |
170 | * by a 16 byte gap :-(. | 175 | * region. |
176 | * | ||
177 | * The LANCE's DMA address is used as an index in this buffer and DMA | ||
178 | * takes place in bursts of eight 16-bit words which are packed into | ||
179 | * four 32-bit words by the IOASIC. This leads to a strange padding: | ||
180 | * 16 bytes of valid data followed by a 16 byte gap :-(. | ||
171 | */ | 181 | */ |
172 | 182 | ||
173 | struct lance_rx_desc { | 183 | struct lance_rx_desc { |
174 | unsigned short rmd0; /* low address of packet */ | 184 | unsigned short rmd0; /* low address of packet */ |
175 | short gap0; | 185 | unsigned short rmd1; /* high address of packet |
176 | unsigned char rmd1_hadr; /* high address of packet */ | 186 | and descriptor bits */ |
177 | unsigned char rmd1_bits; /* descriptor bits */ | ||
178 | short gap1; | ||
179 | short length; /* 2s complement (negative!) | 187 | short length; /* 2s complement (negative!) |
180 | of buffer length */ | 188 | of buffer length */ |
181 | short gap2; | ||
182 | unsigned short mblength; /* actual number of bytes received */ | 189 | unsigned short mblength; /* actual number of bytes received */ |
183 | short gap3; | ||
184 | }; | 190 | }; |
185 | 191 | ||
186 | struct lance_tx_desc { | 192 | struct lance_tx_desc { |
187 | unsigned short tmd0; /* low address of packet */ | 193 | unsigned short tmd0; /* low address of packet */ |
188 | short gap0; | 194 | unsigned short tmd1; /* high address of packet |
189 | unsigned char tmd1_hadr; /* high address of packet */ | 195 | and descriptor bits */ |
190 | unsigned char tmd1_bits; /* descriptor bits */ | ||
191 | short gap1; | ||
192 | short length; /* 2s complement (negative!) | 196 | short length; /* 2s complement (negative!) |
193 | of buffer length */ | 197 | of buffer length */ |
194 | short gap2; | ||
195 | unsigned short misc; | 198 | unsigned short misc; |
196 | short gap3; | ||
197 | }; | 199 | }; |
198 | 200 | ||
199 | 201 | ||
200 | /* First part of the LANCE initialization block, described in databook. */ | 202 | /* First part of the LANCE initialization block, described in databook. */ |
201 | struct lance_init_block { | 203 | struct lance_init_block { |
202 | unsigned short mode; /* pre-set mode (reg. 15) */ | 204 | unsigned short mode; /* pre-set mode (reg. 15) */ |
203 | short gap0; | ||
204 | 205 | ||
205 | unsigned char phys_addr[12]; /* physical ethernet address | 206 | unsigned short phys_addr[3]; /* physical ethernet address */ |
206 | only 0, 1, 4, 5, 8, 9 are valid | 207 | unsigned short filter[4]; /* multicast filter */ |
207 | 2, 3, 6, 7, 10, 11 are gaps */ | ||
208 | unsigned short filter[8]; /* multicast filter | ||
209 | only 0, 2, 4, 6 are valid | ||
210 | 1, 3, 5, 7 are gaps */ | ||
211 | 208 | ||
212 | /* Receive and transmit ring base, along with extra bits. */ | 209 | /* Receive and transmit ring base, along with extra bits. */ |
213 | unsigned short rx_ptr; /* receive descriptor addr */ | 210 | unsigned short rx_ptr; /* receive descriptor addr */ |
214 | short gap1; | ||
215 | unsigned short rx_len; /* receive len and high addr */ | 211 | unsigned short rx_len; /* receive len and high addr */ |
216 | short gap2; | ||
217 | unsigned short tx_ptr; /* transmit descriptor addr */ | 212 | unsigned short tx_ptr; /* transmit descriptor addr */ |
218 | short gap3; | ||
219 | unsigned short tx_len; /* transmit len and high addr */ | 213 | unsigned short tx_len; /* transmit len and high addr */ |
220 | short gap4; | 214 | |
221 | short gap5[8]; | 215 | short gap[4]; |
222 | 216 | ||
223 | /* The buffer descriptors */ | 217 | /* The buffer descriptors */ |
224 | struct lance_rx_desc brx_ring[RX_RING_SIZE]; | 218 | struct lance_rx_desc brx_ring[RX_RING_SIZE]; |
@@ -226,15 +220,28 @@ struct lance_init_block { | |||
226 | }; | 220 | }; |
227 | 221 | ||
228 | #define BUF_OFFSET_CPU sizeof(struct lance_init_block) | 222 | #define BUF_OFFSET_CPU sizeof(struct lance_init_block) |
229 | #define BUF_OFFSET_LNC (sizeof(struct lance_init_block)>>1) | 223 | #define BUF_OFFSET_LNC sizeof(struct lance_init_block) |
230 | 224 | ||
231 | #define libdesc_offset(rt, elem) \ | 225 | #define shift_off(off, type) \ |
232 | ((__u32)(((unsigned long)(&(((struct lance_init_block *)0)->rt[elem]))))) | 226 | (type == ASIC_LANCE || type == PMAX_LANCE ? off << 1 : off) |
233 | 227 | ||
234 | /* | 228 | #define lib_off(rt, type) \ |
235 | * This works *only* for the ring descriptors | 229 | shift_off(offsetof(struct lance_init_block, rt), type) |
236 | */ | 230 | |
237 | #define LANCE_ADDR(x) (CPHYSADDR(x) >> 1) | 231 | #define lib_ptr(ib, rt, type) \ |
232 | ((volatile u16 *)((u8 *)(ib) + lib_off(rt, type))) | ||
233 | |||
234 | #define rds_off(rt, type) \ | ||
235 | shift_off(offsetof(struct lance_rx_desc, rt), type) | ||
236 | |||
237 | #define rds_ptr(rd, rt, type) \ | ||
238 | ((volatile u16 *)((u8 *)(rd) + rds_off(rt, type))) | ||
239 | |||
240 | #define tds_off(rt, type) \ | ||
241 | shift_off(offsetof(struct lance_tx_desc, rt), type) | ||
242 | |||
243 | #define tds_ptr(td, rt, type) \ | ||
244 | ((volatile u16 *)((u8 *)(td) + tds_off(rt, type))) | ||
238 | 245 | ||
239 | struct lance_private { | 246 | struct lance_private { |
240 | struct net_device *next; | 247 | struct net_device *next; |
@@ -242,7 +249,6 @@ struct lance_private { | |||
242 | int slot; | 249 | int slot; |
243 | int dma_irq; | 250 | int dma_irq; |
244 | volatile struct lance_regs *ll; | 251 | volatile struct lance_regs *ll; |
245 | volatile struct lance_init_block *init_block; | ||
246 | 252 | ||
247 | spinlock_t lock; | 253 | spinlock_t lock; |
248 | 254 | ||
@@ -260,8 +266,8 @@ struct lance_private { | |||
260 | char *tx_buf_ptr_cpu[TX_RING_SIZE]; | 266 | char *tx_buf_ptr_cpu[TX_RING_SIZE]; |
261 | 267 | ||
262 | /* Pointers to the ring buffers as seen from the LANCE */ | 268 | /* Pointers to the ring buffers as seen from the LANCE */ |
263 | char *rx_buf_ptr_lnc[RX_RING_SIZE]; | 269 | uint rx_buf_ptr_lnc[RX_RING_SIZE]; |
264 | char *tx_buf_ptr_lnc[TX_RING_SIZE]; | 270 | uint tx_buf_ptr_lnc[TX_RING_SIZE]; |
265 | }; | 271 | }; |
266 | 272 | ||
267 | #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\ | 273 | #define TX_BUFFS_AVAIL ((lp->tx_old<=lp->tx_new)?\ |
@@ -294,7 +300,7 @@ static inline void writereg(volatile unsigned short *regptr, short value) | |||
294 | static void load_csrs(struct lance_private *lp) | 300 | static void load_csrs(struct lance_private *lp) |
295 | { | 301 | { |
296 | volatile struct lance_regs *ll = lp->ll; | 302 | volatile struct lance_regs *ll = lp->ll; |
297 | int leptr; | 303 | uint leptr; |
298 | 304 | ||
299 | /* The address space as seen from the LANCE | 305 | /* The address space as seen from the LANCE |
300 | * begins at address 0. HK | 306 | * begins at address 0. HK |
@@ -316,12 +322,14 @@ static void load_csrs(struct lance_private *lp) | |||
316 | * Our specialized copy routines | 322 | * Our specialized copy routines |
317 | * | 323 | * |
318 | */ | 324 | */ |
319 | void cp_to_buf(const int type, void *to, const void *from, int len) | 325 | static void cp_to_buf(const int type, void *to, const void *from, int len) |
320 | { | 326 | { |
321 | unsigned short *tp, *fp, clen; | 327 | unsigned short *tp, *fp, clen; |
322 | unsigned char *rtp, *rfp; | 328 | unsigned char *rtp, *rfp; |
323 | 329 | ||
324 | if (type == PMAX_LANCE) { | 330 | if (type == PMAD_LANCE) { |
331 | memcpy(to, from, len); | ||
332 | } else if (type == PMAX_LANCE) { | ||
325 | clen = len >> 1; | 333 | clen = len >> 1; |
326 | tp = (unsigned short *) to; | 334 | tp = (unsigned short *) to; |
327 | fp = (unsigned short *) from; | 335 | fp = (unsigned short *) from; |
@@ -370,12 +378,14 @@ void cp_to_buf(const int type, void *to, const void *from, int len) | |||
370 | iob(); | 378 | iob(); |
371 | } | 379 | } |
372 | 380 | ||
373 | void cp_from_buf(const int type, void *to, const void *from, int len) | 381 | static void cp_from_buf(const int type, void *to, const void *from, int len) |
374 | { | 382 | { |
375 | unsigned short *tp, *fp, clen; | 383 | unsigned short *tp, *fp, clen; |
376 | unsigned char *rtp, *rfp; | 384 | unsigned char *rtp, *rfp; |
377 | 385 | ||
378 | if (type == PMAX_LANCE) { | 386 | if (type == PMAD_LANCE) { |
387 | memcpy(to, from, len); | ||
388 | } else if (type == PMAX_LANCE) { | ||
379 | clen = len >> 1; | 389 | clen = len >> 1; |
380 | tp = (unsigned short *) to; | 390 | tp = (unsigned short *) to; |
381 | fp = (unsigned short *) from; | 391 | fp = (unsigned short *) from; |
@@ -431,12 +441,10 @@ void cp_from_buf(const int type, void *to, const void *from, int len) | |||
431 | static void lance_init_ring(struct net_device *dev) | 441 | static void lance_init_ring(struct net_device *dev) |
432 | { | 442 | { |
433 | struct lance_private *lp = netdev_priv(dev); | 443 | struct lance_private *lp = netdev_priv(dev); |
434 | volatile struct lance_init_block *ib; | 444 | volatile u16 *ib = (volatile u16 *)dev->mem_start; |
435 | int leptr; | 445 | uint leptr; |
436 | int i; | 446 | int i; |
437 | 447 | ||
438 | ib = (struct lance_init_block *) (dev->mem_start); | ||
439 | |||
440 | /* Lock out other processes while setting up hardware */ | 448 | /* Lock out other processes while setting up hardware */ |
441 | netif_stop_queue(dev); | 449 | netif_stop_queue(dev); |
442 | lp->rx_new = lp->tx_new = 0; | 450 | lp->rx_new = lp->tx_new = 0; |
@@ -445,55 +453,64 @@ static void lance_init_ring(struct net_device *dev) | |||
445 | /* Copy the ethernet address to the lance init block. | 453 | /* Copy the ethernet address to the lance init block. |
446 | * XXX bit 0 of the physical address registers has to be zero | 454 | * XXX bit 0 of the physical address registers has to be zero |
447 | */ | 455 | */ |
448 | ib->phys_addr[0] = dev->dev_addr[0]; | 456 | *lib_ptr(ib, phys_addr[0], lp->type) = (dev->dev_addr[1] << 8) | |
449 | ib->phys_addr[1] = dev->dev_addr[1]; | 457 | dev->dev_addr[0]; |
450 | ib->phys_addr[4] = dev->dev_addr[2]; | 458 | *lib_ptr(ib, phys_addr[1], lp->type) = (dev->dev_addr[3] << 8) | |
451 | ib->phys_addr[5] = dev->dev_addr[3]; | 459 | dev->dev_addr[2]; |
452 | ib->phys_addr[8] = dev->dev_addr[4]; | 460 | *lib_ptr(ib, phys_addr[2], lp->type) = (dev->dev_addr[5] << 8) | |
453 | ib->phys_addr[9] = dev->dev_addr[5]; | 461 | dev->dev_addr[4]; |
454 | /* Setup the initialization block */ | 462 | /* Setup the initialization block */ |
455 | 463 | ||
456 | /* Setup rx descriptor pointer */ | 464 | /* Setup rx descriptor pointer */ |
457 | leptr = LANCE_ADDR(libdesc_offset(brx_ring, 0)); | 465 | leptr = offsetof(struct lance_init_block, brx_ring); |
458 | ib->rx_len = (LANCE_LOG_RX_BUFFERS << 13) | (leptr >> 16); | 466 | *lib_ptr(ib, rx_len, lp->type) = (LANCE_LOG_RX_BUFFERS << 13) | |
459 | ib->rx_ptr = leptr; | 467 | (leptr >> 16); |
468 | *lib_ptr(ib, rx_ptr, lp->type) = leptr; | ||
460 | if (ZERO) | 469 | if (ZERO) |
461 | printk("RX ptr: %8.8x(%8.8x)\n", leptr, libdesc_offset(brx_ring, 0)); | 470 | printk("RX ptr: %8.8x(%8.8x)\n", |
471 | leptr, lib_off(brx_ring, lp->type)); | ||
462 | 472 | ||
463 | /* Setup tx descriptor pointer */ | 473 | /* Setup tx descriptor pointer */ |
464 | leptr = LANCE_ADDR(libdesc_offset(btx_ring, 0)); | 474 | leptr = offsetof(struct lance_init_block, btx_ring); |
465 | ib->tx_len = (LANCE_LOG_TX_BUFFERS << 13) | (leptr >> 16); | 475 | *lib_ptr(ib, tx_len, lp->type) = (LANCE_LOG_TX_BUFFERS << 13) | |
466 | ib->tx_ptr = leptr; | 476 | (leptr >> 16); |
477 | *lib_ptr(ib, tx_ptr, lp->type) = leptr; | ||
467 | if (ZERO) | 478 | if (ZERO) |
468 | printk("TX ptr: %8.8x(%8.8x)\n", leptr, libdesc_offset(btx_ring, 0)); | 479 | printk("TX ptr: %8.8x(%8.8x)\n", |
480 | leptr, lib_off(btx_ring, lp->type)); | ||
469 | 481 | ||
470 | if (ZERO) | 482 | if (ZERO) |
471 | printk("TX rings:\n"); | 483 | printk("TX rings:\n"); |
472 | 484 | ||
473 | /* Setup the Tx ring entries */ | 485 | /* Setup the Tx ring entries */ |
474 | for (i = 0; i < TX_RING_SIZE; i++) { | 486 | for (i = 0; i < TX_RING_SIZE; i++) { |
475 | leptr = (int) lp->tx_buf_ptr_lnc[i]; | 487 | leptr = lp->tx_buf_ptr_lnc[i]; |
476 | ib->btx_ring[i].tmd0 = leptr; | 488 | *lib_ptr(ib, btx_ring[i].tmd0, lp->type) = leptr; |
477 | ib->btx_ring[i].tmd1_hadr = leptr >> 16; | 489 | *lib_ptr(ib, btx_ring[i].tmd1, lp->type) = (leptr >> 16) & |
478 | ib->btx_ring[i].tmd1_bits = 0; | 490 | 0xff; |
479 | ib->btx_ring[i].length = 0xf000; /* The ones required by tmd2 */ | 491 | *lib_ptr(ib, btx_ring[i].length, lp->type) = 0xf000; |
480 | ib->btx_ring[i].misc = 0; | 492 | /* The ones required by tmd2 */ |
493 | *lib_ptr(ib, btx_ring[i].misc, lp->type) = 0; | ||
481 | if (i < 3 && ZERO) | 494 | if (i < 3 && ZERO) |
482 | printk("%d: 0x%8.8x(0x%8.8x)\n", i, leptr, (int) lp->tx_buf_ptr_cpu[i]); | 495 | printk("%d: 0x%8.8x(0x%8.8x)\n", |
496 | i, leptr, (uint)lp->tx_buf_ptr_cpu[i]); | ||
483 | } | 497 | } |
484 | 498 | ||
485 | /* Setup the Rx ring entries */ | 499 | /* Setup the Rx ring entries */ |
486 | if (ZERO) | 500 | if (ZERO) |
487 | printk("RX rings:\n"); | 501 | printk("RX rings:\n"); |
488 | for (i = 0; i < RX_RING_SIZE; i++) { | 502 | for (i = 0; i < RX_RING_SIZE; i++) { |
489 | leptr = (int) lp->rx_buf_ptr_lnc[i]; | 503 | leptr = lp->rx_buf_ptr_lnc[i]; |
490 | ib->brx_ring[i].rmd0 = leptr; | 504 | *lib_ptr(ib, brx_ring[i].rmd0, lp->type) = leptr; |
491 | ib->brx_ring[i].rmd1_hadr = leptr >> 16; | 505 | *lib_ptr(ib, brx_ring[i].rmd1, lp->type) = ((leptr >> 16) & |
492 | ib->brx_ring[i].rmd1_bits = LE_R1_OWN; | 506 | 0xff) | |
493 | ib->brx_ring[i].length = -RX_BUFF_SIZE | 0xf000; | 507 | LE_R1_OWN; |
494 | ib->brx_ring[i].mblength = 0; | 508 | *lib_ptr(ib, brx_ring[i].length, lp->type) = -RX_BUFF_SIZE | |
509 | 0xf000; | ||
510 | *lib_ptr(ib, brx_ring[i].mblength, lp->type) = 0; | ||
495 | if (i < 3 && ZERO) | 511 | if (i < 3 && ZERO) |
496 | printk("%d: 0x%8.8x(0x%8.8x)\n", i, leptr, (int) lp->rx_buf_ptr_cpu[i]); | 512 | printk("%d: 0x%8.8x(0x%8.8x)\n", |
513 | i, leptr, (uint)lp->rx_buf_ptr_cpu[i]); | ||
497 | } | 514 | } |
498 | iob(); | 515 | iob(); |
499 | } | 516 | } |
@@ -511,11 +528,13 @@ static int init_restart_lance(struct lance_private *lp) | |||
511 | udelay(10); | 528 | udelay(10); |
512 | } | 529 | } |
513 | if ((i == 100) || (ll->rdp & LE_C0_ERR)) { | 530 | if ((i == 100) || (ll->rdp & LE_C0_ERR)) { |
514 | printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp); | 531 | printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", |
532 | i, ll->rdp); | ||
515 | return -1; | 533 | return -1; |
516 | } | 534 | } |
517 | if ((ll->rdp & LE_C0_ERR)) { | 535 | if ((ll->rdp & LE_C0_ERR)) { |
518 | printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", i, ll->rdp); | 536 | printk("LANCE unopened after %d ticks, csr0=%4.4x.\n", |
537 | i, ll->rdp); | ||
519 | return -1; | 538 | return -1; |
520 | } | 539 | } |
521 | writereg(&ll->rdp, LE_C0_IDON); | 540 | writereg(&ll->rdp, LE_C0_IDON); |
@@ -528,12 +547,11 @@ static int init_restart_lance(struct lance_private *lp) | |||
528 | static int lance_rx(struct net_device *dev) | 547 | static int lance_rx(struct net_device *dev) |
529 | { | 548 | { |
530 | struct lance_private *lp = netdev_priv(dev); | 549 | struct lance_private *lp = netdev_priv(dev); |
531 | volatile struct lance_init_block *ib; | 550 | volatile u16 *ib = (volatile u16 *)dev->mem_start; |
532 | volatile struct lance_rx_desc *rd = 0; | 551 | volatile u16 *rd; |
533 | unsigned char bits; | 552 | unsigned short bits; |
534 | int len = 0; | 553 | int entry, len; |
535 | struct sk_buff *skb = 0; | 554 | struct sk_buff *skb; |
536 | ib = (struct lance_init_block *) (dev->mem_start); | ||
537 | 555 | ||
538 | #ifdef TEST_HITS | 556 | #ifdef TEST_HITS |
539 | { | 557 | { |
@@ -542,19 +560,22 @@ static int lance_rx(struct net_device *dev) | |||
542 | printk("["); | 560 | printk("["); |
543 | for (i = 0; i < RX_RING_SIZE; i++) { | 561 | for (i = 0; i < RX_RING_SIZE; i++) { |
544 | if (i == lp->rx_new) | 562 | if (i == lp->rx_new) |
545 | printk("%s", ib->brx_ring[i].rmd1_bits & | 563 | printk("%s", *lib_ptr(ib, brx_ring[i].rmd1, |
564 | lp->type) & | ||
546 | LE_R1_OWN ? "_" : "X"); | 565 | LE_R1_OWN ? "_" : "X"); |
547 | else | 566 | else |
548 | printk("%s", ib->brx_ring[i].rmd1_bits & | 567 | printk("%s", *lib_ptr(ib, brx_ring[i].rmd1, |
568 | lp->type) & | ||
549 | LE_R1_OWN ? "." : "1"); | 569 | LE_R1_OWN ? "." : "1"); |
550 | } | 570 | } |
551 | printk("]"); | 571 | printk("]"); |
552 | } | 572 | } |
553 | #endif | 573 | #endif |
554 | 574 | ||
555 | for (rd = &ib->brx_ring[lp->rx_new]; | 575 | for (rd = lib_ptr(ib, brx_ring[lp->rx_new], lp->type); |
556 | !((bits = rd->rmd1_bits) & LE_R1_OWN); | 576 | !((bits = *rds_ptr(rd, rmd1, lp->type)) & LE_R1_OWN); |
557 | rd = &ib->brx_ring[lp->rx_new]) { | 577 | rd = lib_ptr(ib, brx_ring[lp->rx_new], lp->type)) { |
578 | entry = lp->rx_new; | ||
558 | 579 | ||
559 | /* We got an incomplete frame? */ | 580 | /* We got an incomplete frame? */ |
560 | if ((bits & LE_R1_POK) != LE_R1_POK) { | 581 | if ((bits & LE_R1_POK) != LE_R1_POK) { |
@@ -575,16 +596,18 @@ static int lance_rx(struct net_device *dev) | |||
575 | if (bits & LE_R1_EOP) | 596 | if (bits & LE_R1_EOP) |
576 | lp->stats.rx_errors++; | 597 | lp->stats.rx_errors++; |
577 | } else { | 598 | } else { |
578 | len = (rd->mblength & 0xfff) - 4; | 599 | len = (*rds_ptr(rd, mblength, lp->type) & 0xfff) - 4; |
579 | skb = dev_alloc_skb(len + 2); | 600 | skb = dev_alloc_skb(len + 2); |
580 | 601 | ||
581 | if (skb == 0) { | 602 | if (skb == 0) { |
582 | printk("%s: Memory squeeze, deferring packet.\n", | 603 | printk("%s: Memory squeeze, deferring packet.\n", |
583 | dev->name); | 604 | dev->name); |
584 | lp->stats.rx_dropped++; | 605 | lp->stats.rx_dropped++; |
585 | rd->mblength = 0; | 606 | *rds_ptr(rd, mblength, lp->type) = 0; |
586 | rd->rmd1_bits = LE_R1_OWN; | 607 | *rds_ptr(rd, rmd1, lp->type) = |
587 | lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK; | 608 | ((lp->rx_buf_ptr_lnc[entry] >> 16) & |
609 | 0xff) | LE_R1_OWN; | ||
610 | lp->rx_new = (entry + 1) & RX_RING_MOD_MASK; | ||
588 | return 0; | 611 | return 0; |
589 | } | 612 | } |
590 | lp->stats.rx_bytes += len; | 613 | lp->stats.rx_bytes += len; |
@@ -594,8 +617,7 @@ static int lance_rx(struct net_device *dev) | |||
594 | skb_put(skb, len); /* make room */ | 617 | skb_put(skb, len); /* make room */ |
595 | 618 | ||
596 | cp_from_buf(lp->type, skb->data, | 619 | cp_from_buf(lp->type, skb->data, |
597 | (char *)lp->rx_buf_ptr_cpu[lp->rx_new], | 620 | (char *)lp->rx_buf_ptr_cpu[entry], len); |
598 | len); | ||
599 | 621 | ||
600 | skb->protocol = eth_type_trans(skb, dev); | 622 | skb->protocol = eth_type_trans(skb, dev); |
601 | netif_rx(skb); | 623 | netif_rx(skb); |
@@ -604,10 +626,11 @@ static int lance_rx(struct net_device *dev) | |||
604 | } | 626 | } |
605 | 627 | ||
606 | /* Return the packet to the pool */ | 628 | /* Return the packet to the pool */ |
607 | rd->mblength = 0; | 629 | *rds_ptr(rd, mblength, lp->type) = 0; |
608 | rd->length = -RX_BUFF_SIZE | 0xf000; | 630 | *rds_ptr(rd, length, lp->type) = -RX_BUFF_SIZE | 0xf000; |
609 | rd->rmd1_bits = LE_R1_OWN; | 631 | *rds_ptr(rd, rmd1, lp->type) = |
610 | lp->rx_new = (lp->rx_new + 1) & RX_RING_MOD_MASK; | 632 | ((lp->rx_buf_ptr_lnc[entry] >> 16) & 0xff) | LE_R1_OWN; |
633 | lp->rx_new = (entry + 1) & RX_RING_MOD_MASK; | ||
611 | } | 634 | } |
612 | return 0; | 635 | return 0; |
613 | } | 636 | } |
@@ -615,24 +638,24 @@ static int lance_rx(struct net_device *dev) | |||
615 | static void lance_tx(struct net_device *dev) | 638 | static void lance_tx(struct net_device *dev) |
616 | { | 639 | { |
617 | struct lance_private *lp = netdev_priv(dev); | 640 | struct lance_private *lp = netdev_priv(dev); |
618 | volatile struct lance_init_block *ib; | 641 | volatile u16 *ib = (volatile u16 *)dev->mem_start; |
619 | volatile struct lance_regs *ll = lp->ll; | 642 | volatile struct lance_regs *ll = lp->ll; |
620 | volatile struct lance_tx_desc *td; | 643 | volatile u16 *td; |
621 | int i, j; | 644 | int i, j; |
622 | int status; | 645 | int status; |
623 | ib = (struct lance_init_block *) (dev->mem_start); | 646 | |
624 | j = lp->tx_old; | 647 | j = lp->tx_old; |
625 | 648 | ||
626 | spin_lock(&lp->lock); | 649 | spin_lock(&lp->lock); |
627 | 650 | ||
628 | for (i = j; i != lp->tx_new; i = j) { | 651 | for (i = j; i != lp->tx_new; i = j) { |
629 | td = &ib->btx_ring[i]; | 652 | td = lib_ptr(ib, btx_ring[i], lp->type); |
630 | /* If we hit a packet not owned by us, stop */ | 653 | /* If we hit a packet not owned by us, stop */ |
631 | if (td->tmd1_bits & LE_T1_OWN) | 654 | if (*tds_ptr(td, tmd1, lp->type) & LE_T1_OWN) |
632 | break; | 655 | break; |
633 | 656 | ||
634 | if (td->tmd1_bits & LE_T1_ERR) { | 657 | if (*tds_ptr(td, tmd1, lp->type) & LE_T1_ERR) { |
635 | status = td->misc; | 658 | status = *tds_ptr(td, misc, lp->type); |
636 | 659 | ||
637 | lp->stats.tx_errors++; | 660 | lp->stats.tx_errors++; |
638 | if (status & LE_T3_RTY) | 661 | if (status & LE_T3_RTY) |
@@ -667,18 +690,19 @@ static void lance_tx(struct net_device *dev) | |||
667 | init_restart_lance(lp); | 690 | init_restart_lance(lp); |
668 | goto out; | 691 | goto out; |
669 | } | 692 | } |
670 | } else if ((td->tmd1_bits & LE_T1_POK) == LE_T1_POK) { | 693 | } else if ((*tds_ptr(td, tmd1, lp->type) & LE_T1_POK) == |
694 | LE_T1_POK) { | ||
671 | /* | 695 | /* |
672 | * So we don't count the packet more than once. | 696 | * So we don't count the packet more than once. |
673 | */ | 697 | */ |
674 | td->tmd1_bits &= ~(LE_T1_POK); | 698 | *tds_ptr(td, tmd1, lp->type) &= ~(LE_T1_POK); |
675 | 699 | ||
676 | /* One collision before packet was sent. */ | 700 | /* One collision before packet was sent. */ |
677 | if (td->tmd1_bits & LE_T1_EONE) | 701 | if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EONE) |
678 | lp->stats.collisions++; | 702 | lp->stats.collisions++; |
679 | 703 | ||
680 | /* More than one collision, be optimistic. */ | 704 | /* More than one collision, be optimistic. */ |
681 | if (td->tmd1_bits & LE_T1_EMORE) | 705 | if (*tds_ptr(td, tmd1, lp->type) & LE_T1_EMORE) |
682 | lp->stats.collisions += 2; | 706 | lp->stats.collisions += 2; |
683 | 707 | ||
684 | lp->stats.tx_packets++; | 708 | lp->stats.tx_packets++; |
@@ -752,7 +776,7 @@ struct net_device *last_dev = 0; | |||
752 | 776 | ||
753 | static int lance_open(struct net_device *dev) | 777 | static int lance_open(struct net_device *dev) |
754 | { | 778 | { |
755 | volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); | 779 | volatile u16 *ib = (volatile u16 *)dev->mem_start; |
756 | struct lance_private *lp = netdev_priv(dev); | 780 | struct lance_private *lp = netdev_priv(dev); |
757 | volatile struct lance_regs *ll = lp->ll; | 781 | volatile struct lance_regs *ll = lp->ll; |
758 | int status = 0; | 782 | int status = 0; |
@@ -769,11 +793,11 @@ static int lance_open(struct net_device *dev) | |||
769 | * | 793 | * |
770 | * BTW it is common bug in all lance drivers! --ANK | 794 | * BTW it is common bug in all lance drivers! --ANK |
771 | */ | 795 | */ |
772 | ib->mode = 0; | 796 | *lib_ptr(ib, mode, lp->type) = 0; |
773 | ib->filter [0] = 0; | 797 | *lib_ptr(ib, filter[0], lp->type) = 0; |
774 | ib->filter [2] = 0; | 798 | *lib_ptr(ib, filter[1], lp->type) = 0; |
775 | ib->filter [4] = 0; | 799 | *lib_ptr(ib, filter[2], lp->type) = 0; |
776 | ib->filter [6] = 0; | 800 | *lib_ptr(ib, filter[3], lp->type) = 0; |
777 | 801 | ||
778 | lance_init_ring(dev); | 802 | lance_init_ring(dev); |
779 | load_csrs(lp); | 803 | load_csrs(lp); |
@@ -874,12 +898,10 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
874 | { | 898 | { |
875 | struct lance_private *lp = netdev_priv(dev); | 899 | struct lance_private *lp = netdev_priv(dev); |
876 | volatile struct lance_regs *ll = lp->ll; | 900 | volatile struct lance_regs *ll = lp->ll; |
877 | volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); | 901 | volatile u16 *ib = (volatile u16 *)dev->mem_start; |
878 | int entry, skblen, len; | 902 | int entry, len; |
879 | 903 | ||
880 | skblen = skb->len; | 904 | len = skb->len; |
881 | |||
882 | len = skblen; | ||
883 | 905 | ||
884 | if (len < ETH_ZLEN) { | 906 | if (len < ETH_ZLEN) { |
885 | if (skb_padto(skb, ETH_ZLEN)) | 907 | if (skb_padto(skb, ETH_ZLEN)) |
@@ -889,23 +911,17 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
889 | 911 | ||
890 | lp->stats.tx_bytes += len; | 912 | lp->stats.tx_bytes += len; |
891 | 913 | ||
892 | entry = lp->tx_new & TX_RING_MOD_MASK; | 914 | entry = lp->tx_new; |
893 | ib->btx_ring[entry].length = (-len); | 915 | *lib_ptr(ib, btx_ring[entry].length, lp->type) = (-len); |
894 | ib->btx_ring[entry].misc = 0; | 916 | *lib_ptr(ib, btx_ring[entry].misc, lp->type) = 0; |
895 | |||
896 | cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data, | ||
897 | skblen); | ||
898 | 917 | ||
899 | /* Clear the slack of the packet, do I need this? */ | 918 | cp_to_buf(lp->type, (char *)lp->tx_buf_ptr_cpu[entry], skb->data, len); |
900 | /* For a firewall it's a good idea - AC */ | ||
901 | /* | ||
902 | if (len != skblen) | ||
903 | memset ((char *) &ib->tx_buf [entry][skblen], 0, (len - skblen) << 1); | ||
904 | */ | ||
905 | 919 | ||
906 | /* Now, give the packet to the lance */ | 920 | /* Now, give the packet to the lance */ |
907 | ib->btx_ring[entry].tmd1_bits = (LE_T1_POK | LE_T1_OWN); | 921 | *lib_ptr(ib, btx_ring[entry].tmd1, lp->type) = |
908 | lp->tx_new = (lp->tx_new + 1) & TX_RING_MOD_MASK; | 922 | ((lp->tx_buf_ptr_lnc[entry] >> 16) & 0xff) | |
923 | (LE_T1_POK | LE_T1_OWN); | ||
924 | lp->tx_new = (entry + 1) & TX_RING_MOD_MASK; | ||
909 | 925 | ||
910 | if (TX_BUFFS_AVAIL <= 0) | 926 | if (TX_BUFFS_AVAIL <= 0) |
911 | netif_stop_queue(dev); | 927 | netif_stop_queue(dev); |
@@ -930,8 +946,8 @@ static struct net_device_stats *lance_get_stats(struct net_device *dev) | |||
930 | 946 | ||
931 | static void lance_load_multicast(struct net_device *dev) | 947 | static void lance_load_multicast(struct net_device *dev) |
932 | { | 948 | { |
933 | volatile struct lance_init_block *ib = (struct lance_init_block *) (dev->mem_start); | 949 | struct lance_private *lp = netdev_priv(dev); |
934 | volatile u16 *mcast_table = (u16 *) & ib->filter; | 950 | volatile u16 *ib = (volatile u16 *)dev->mem_start; |
935 | struct dev_mc_list *dmi = dev->mc_list; | 951 | struct dev_mc_list *dmi = dev->mc_list; |
936 | char *addrs; | 952 | char *addrs; |
937 | int i; | 953 | int i; |
@@ -939,17 +955,17 @@ static void lance_load_multicast(struct net_device *dev) | |||
939 | 955 | ||
940 | /* set all multicast bits */ | 956 | /* set all multicast bits */ |
941 | if (dev->flags & IFF_ALLMULTI) { | 957 | if (dev->flags & IFF_ALLMULTI) { |
942 | ib->filter[0] = 0xffff; | 958 | *lib_ptr(ib, filter[0], lp->type) = 0xffff; |
943 | ib->filter[2] = 0xffff; | 959 | *lib_ptr(ib, filter[1], lp->type) = 0xffff; |
944 | ib->filter[4] = 0xffff; | 960 | *lib_ptr(ib, filter[2], lp->type) = 0xffff; |
945 | ib->filter[6] = 0xffff; | 961 | *lib_ptr(ib, filter[3], lp->type) = 0xffff; |
946 | return; | 962 | return; |
947 | } | 963 | } |
948 | /* clear the multicast filter */ | 964 | /* clear the multicast filter */ |
949 | ib->filter[0] = 0; | 965 | *lib_ptr(ib, filter[0], lp->type) = 0; |
950 | ib->filter[2] = 0; | 966 | *lib_ptr(ib, filter[1], lp->type) = 0; |
951 | ib->filter[4] = 0; | 967 | *lib_ptr(ib, filter[2], lp->type) = 0; |
952 | ib->filter[6] = 0; | 968 | *lib_ptr(ib, filter[3], lp->type) = 0; |
953 | 969 | ||
954 | /* Add addresses */ | 970 | /* Add addresses */ |
955 | for (i = 0; i < dev->mc_count; i++) { | 971 | for (i = 0; i < dev->mc_count; i++) { |
@@ -962,7 +978,7 @@ static void lance_load_multicast(struct net_device *dev) | |||
962 | 978 | ||
963 | crc = ether_crc_le(ETH_ALEN, addrs); | 979 | crc = ether_crc_le(ETH_ALEN, addrs); |
964 | crc = crc >> 26; | 980 | crc = crc >> 26; |
965 | mcast_table[2 * (crc >> 4)] |= 1 << (crc & 0xf); | 981 | *lib_ptr(ib, filter[crc >> 4], lp->type) |= 1 << (crc & 0xf); |
966 | } | 982 | } |
967 | return; | 983 | return; |
968 | } | 984 | } |
@@ -970,11 +986,9 @@ static void lance_load_multicast(struct net_device *dev) | |||
970 | static void lance_set_multicast(struct net_device *dev) | 986 | static void lance_set_multicast(struct net_device *dev) |
971 | { | 987 | { |
972 | struct lance_private *lp = netdev_priv(dev); | 988 | struct lance_private *lp = netdev_priv(dev); |
973 | volatile struct lance_init_block *ib; | 989 | volatile u16 *ib = (volatile u16 *)dev->mem_start; |
974 | volatile struct lance_regs *ll = lp->ll; | 990 | volatile struct lance_regs *ll = lp->ll; |
975 | 991 | ||
976 | ib = (struct lance_init_block *) (dev->mem_start); | ||
977 | |||
978 | if (!netif_running(dev)) | 992 | if (!netif_running(dev)) |
979 | return; | 993 | return; |
980 | 994 | ||
@@ -992,9 +1006,9 @@ static void lance_set_multicast(struct net_device *dev) | |||
992 | lance_init_ring(dev); | 1006 | lance_init_ring(dev); |
993 | 1007 | ||
994 | if (dev->flags & IFF_PROMISC) { | 1008 | if (dev->flags & IFF_PROMISC) { |
995 | ib->mode |= LE_MO_PROM; | 1009 | *lib_ptr(ib, mode, lp->type) |= LE_MO_PROM; |
996 | } else { | 1010 | } else { |
997 | ib->mode &= ~LE_MO_PROM; | 1011 | *lib_ptr(ib, mode, lp->type) &= ~LE_MO_PROM; |
998 | lance_load_multicast(dev); | 1012 | lance_load_multicast(dev); |
999 | } | 1013 | } |
1000 | load_csrs(lp); | 1014 | load_csrs(lp); |
@@ -1051,7 +1065,6 @@ static int __init dec_lance_init(const int type, const int slot) | |||
1051 | lp->type = type; | 1065 | lp->type = type; |
1052 | lp->slot = slot; | 1066 | lp->slot = slot; |
1053 | switch (type) { | 1067 | switch (type) { |
1054 | #ifdef CONFIG_TC | ||
1055 | case ASIC_LANCE: | 1068 | case ASIC_LANCE: |
1056 | dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE); | 1069 | dev->base_addr = CKSEG1ADDR(dec_kn_slot_base + IOASIC_LANCE); |
1057 | 1070 | ||
@@ -1073,20 +1086,20 @@ static int __init dec_lance_init(const int type, const int slot) | |||
1073 | */ | 1086 | */ |
1074 | for (i = 0; i < RX_RING_SIZE; i++) { | 1087 | for (i = 0; i < RX_RING_SIZE; i++) { |
1075 | lp->rx_buf_ptr_cpu[i] = | 1088 | lp->rx_buf_ptr_cpu[i] = |
1076 | (char *)(dev->mem_start + BUF_OFFSET_CPU + | 1089 | (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU + |
1077 | 2 * i * RX_BUFF_SIZE); | 1090 | 2 * i * RX_BUFF_SIZE); |
1078 | lp->rx_buf_ptr_lnc[i] = | 1091 | lp->rx_buf_ptr_lnc[i] = |
1079 | (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); | 1092 | (BUF_OFFSET_LNC + i * RX_BUFF_SIZE); |
1080 | } | 1093 | } |
1081 | for (i = 0; i < TX_RING_SIZE; i++) { | 1094 | for (i = 0; i < TX_RING_SIZE; i++) { |
1082 | lp->tx_buf_ptr_cpu[i] = | 1095 | lp->tx_buf_ptr_cpu[i] = |
1083 | (char *)(dev->mem_start + BUF_OFFSET_CPU + | 1096 | (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU + |
1084 | 2 * RX_RING_SIZE * RX_BUFF_SIZE + | 1097 | 2 * RX_RING_SIZE * RX_BUFF_SIZE + |
1085 | 2 * i * TX_BUFF_SIZE); | 1098 | 2 * i * TX_BUFF_SIZE); |
1086 | lp->tx_buf_ptr_lnc[i] = | 1099 | lp->tx_buf_ptr_lnc[i] = |
1087 | (char *)(BUF_OFFSET_LNC + | 1100 | (BUF_OFFSET_LNC + |
1088 | RX_RING_SIZE * RX_BUFF_SIZE + | 1101 | RX_RING_SIZE * RX_BUFF_SIZE + |
1089 | i * TX_BUFF_SIZE); | 1102 | i * TX_BUFF_SIZE); |
1090 | } | 1103 | } |
1091 | 1104 | ||
1092 | /* Setup I/O ASIC LANCE DMA. */ | 1105 | /* Setup I/O ASIC LANCE DMA. */ |
@@ -1095,11 +1108,12 @@ static int __init dec_lance_init(const int type, const int slot) | |||
1095 | CPHYSADDR(dev->mem_start) << 3); | 1108 | CPHYSADDR(dev->mem_start) << 3); |
1096 | 1109 | ||
1097 | break; | 1110 | break; |
1098 | 1111 | #ifdef CONFIG_TC | |
1099 | case PMAD_LANCE: | 1112 | case PMAD_LANCE: |
1100 | claim_tc_card(slot); | 1113 | claim_tc_card(slot); |
1101 | 1114 | ||
1102 | dev->mem_start = CKSEG1ADDR(get_tc_base_addr(slot)); | 1115 | dev->mem_start = CKSEG1ADDR(get_tc_base_addr(slot)); |
1116 | dev->mem_end = dev->mem_start + 0x100000; | ||
1103 | dev->base_addr = dev->mem_start + 0x100000; | 1117 | dev->base_addr = dev->mem_start + 0x100000; |
1104 | dev->irq = get_tc_irq_nr(slot); | 1118 | dev->irq = get_tc_irq_nr(slot); |
1105 | esar_base = dev->mem_start + 0x1c0002; | 1119 | esar_base = dev->mem_start + 0x1c0002; |
@@ -1110,7 +1124,7 @@ static int __init dec_lance_init(const int type, const int slot) | |||
1110 | (char *)(dev->mem_start + BUF_OFFSET_CPU + | 1124 | (char *)(dev->mem_start + BUF_OFFSET_CPU + |
1111 | i * RX_BUFF_SIZE); | 1125 | i * RX_BUFF_SIZE); |
1112 | lp->rx_buf_ptr_lnc[i] = | 1126 | lp->rx_buf_ptr_lnc[i] = |
1113 | (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); | 1127 | (BUF_OFFSET_LNC + i * RX_BUFF_SIZE); |
1114 | } | 1128 | } |
1115 | for (i = 0; i < TX_RING_SIZE; i++) { | 1129 | for (i = 0; i < TX_RING_SIZE; i++) { |
1116 | lp->tx_buf_ptr_cpu[i] = | 1130 | lp->tx_buf_ptr_cpu[i] = |
@@ -1118,18 +1132,18 @@ static int __init dec_lance_init(const int type, const int slot) | |||
1118 | RX_RING_SIZE * RX_BUFF_SIZE + | 1132 | RX_RING_SIZE * RX_BUFF_SIZE + |
1119 | i * TX_BUFF_SIZE); | 1133 | i * TX_BUFF_SIZE); |
1120 | lp->tx_buf_ptr_lnc[i] = | 1134 | lp->tx_buf_ptr_lnc[i] = |
1121 | (char *)(BUF_OFFSET_LNC + | 1135 | (BUF_OFFSET_LNC + |
1122 | RX_RING_SIZE * RX_BUFF_SIZE + | 1136 | RX_RING_SIZE * RX_BUFF_SIZE + |
1123 | i * TX_BUFF_SIZE); | 1137 | i * TX_BUFF_SIZE); |
1124 | } | 1138 | } |
1125 | 1139 | ||
1126 | break; | 1140 | break; |
1127 | #endif | 1141 | #endif |
1128 | |||
1129 | case PMAX_LANCE: | 1142 | case PMAX_LANCE: |
1130 | dev->irq = dec_interrupt[DEC_IRQ_LANCE]; | 1143 | dev->irq = dec_interrupt[DEC_IRQ_LANCE]; |
1131 | dev->base_addr = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE); | 1144 | dev->base_addr = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE); |
1132 | dev->mem_start = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE_MEM); | 1145 | dev->mem_start = CKSEG1ADDR(KN01_SLOT_BASE + KN01_LANCE_MEM); |
1146 | dev->mem_end = dev->mem_start + KN01_SLOT_SIZE; | ||
1133 | esar_base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_ESAR + 1); | 1147 | esar_base = CKSEG1ADDR(KN01_SLOT_BASE + KN01_ESAR + 1); |
1134 | lp->dma_irq = -1; | 1148 | lp->dma_irq = -1; |
1135 | 1149 | ||
@@ -1138,20 +1152,20 @@ static int __init dec_lance_init(const int type, const int slot) | |||
1138 | */ | 1152 | */ |
1139 | for (i = 0; i < RX_RING_SIZE; i++) { | 1153 | for (i = 0; i < RX_RING_SIZE; i++) { |
1140 | lp->rx_buf_ptr_cpu[i] = | 1154 | lp->rx_buf_ptr_cpu[i] = |
1141 | (char *)(dev->mem_start + BUF_OFFSET_CPU + | 1155 | (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU + |
1142 | 2 * i * RX_BUFF_SIZE); | 1156 | 2 * i * RX_BUFF_SIZE); |
1143 | lp->rx_buf_ptr_lnc[i] = | 1157 | lp->rx_buf_ptr_lnc[i] = |
1144 | (char *)(BUF_OFFSET_LNC + i * RX_BUFF_SIZE); | 1158 | (BUF_OFFSET_LNC + i * RX_BUFF_SIZE); |
1145 | } | 1159 | } |
1146 | for (i = 0; i < TX_RING_SIZE; i++) { | 1160 | for (i = 0; i < TX_RING_SIZE; i++) { |
1147 | lp->tx_buf_ptr_cpu[i] = | 1161 | lp->tx_buf_ptr_cpu[i] = |
1148 | (char *)(dev->mem_start + BUF_OFFSET_CPU + | 1162 | (char *)(dev->mem_start + 2 * BUF_OFFSET_CPU + |
1149 | 2 * RX_RING_SIZE * RX_BUFF_SIZE + | 1163 | 2 * RX_RING_SIZE * RX_BUFF_SIZE + |
1150 | 2 * i * TX_BUFF_SIZE); | 1164 | 2 * i * TX_BUFF_SIZE); |
1151 | lp->tx_buf_ptr_lnc[i] = | 1165 | lp->tx_buf_ptr_lnc[i] = |
1152 | (char *)(BUF_OFFSET_LNC + | 1166 | (BUF_OFFSET_LNC + |
1153 | RX_RING_SIZE * RX_BUFF_SIZE + | 1167 | RX_RING_SIZE * RX_BUFF_SIZE + |
1154 | i * TX_BUFF_SIZE); | 1168 | i * TX_BUFF_SIZE); |
1155 | } | 1169 | } |
1156 | 1170 | ||
1157 | break; | 1171 | break; |
@@ -1279,10 +1293,8 @@ static int __init dec_lance_probe(void) | |||
1279 | /* Then handle onboard devices. */ | 1293 | /* Then handle onboard devices. */ |
1280 | if (dec_interrupt[DEC_IRQ_LANCE] >= 0) { | 1294 | if (dec_interrupt[DEC_IRQ_LANCE] >= 0) { |
1281 | if (dec_interrupt[DEC_IRQ_LANCE_MERR] >= 0) { | 1295 | if (dec_interrupt[DEC_IRQ_LANCE_MERR] >= 0) { |
1282 | #ifdef CONFIG_TC | ||
1283 | if (dec_lance_init(ASIC_LANCE, -1) >= 0) | 1296 | if (dec_lance_init(ASIC_LANCE, -1) >= 0) |
1284 | count++; | 1297 | count++; |
1285 | #endif | ||
1286 | } else if (!TURBOCHANNEL) { | 1298 | } else if (!TURBOCHANNEL) { |
1287 | if (dec_lance_init(PMAX_LANCE, -1) >= 0) | 1299 | if (dec_lance_init(PMAX_LANCE, -1) >= 0) |
1288 | count++; | 1300 | count++; |
diff --git a/drivers/net/e2100.c b/drivers/net/e2100.c index d39e8480ca56..c62d9c6363c6 100644 --- a/drivers/net/e2100.c +++ b/drivers/net/e2100.c | |||
@@ -463,7 +463,7 @@ static void cleanup_card(struct net_device *dev) | |||
463 | release_region(dev->base_addr, E21_IO_EXTENT); | 463 | release_region(dev->base_addr, E21_IO_EXTENT); |
464 | } | 464 | } |
465 | 465 | ||
466 | void | 466 | void __exit |
467 | cleanup_module(void) | 467 | cleanup_module(void) |
468 | { | 468 | { |
469 | int this_dev; | 469 | int this_dev; |
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c index a4eb0dc99ecf..b4463094c93a 100644 --- a/drivers/net/eepro.c +++ b/drivers/net/eepro.c | |||
@@ -1827,7 +1827,7 @@ int __init init_module(void) | |||
1827 | return n_eepro ? 0 : -ENODEV; | 1827 | return n_eepro ? 0 : -ENODEV; |
1828 | } | 1828 | } |
1829 | 1829 | ||
1830 | void | 1830 | void __exit |
1831 | cleanup_module(void) | 1831 | cleanup_module(void) |
1832 | { | 1832 | { |
1833 | int i; | 1833 | int i; |
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c index e14be020e562..4a50fcb5ad6b 100644 --- a/drivers/net/eexpress.c +++ b/drivers/net/eexpress.c | |||
@@ -1719,7 +1719,7 @@ int __init init_module(void) | |||
1719 | return -ENXIO; | 1719 | return -ENXIO; |
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | void cleanup_module(void) | 1722 | void __exit cleanup_module(void) |
1723 | { | 1723 | { |
1724 | int this_dev; | 1724 | int this_dev; |
1725 | 1725 | ||
diff --git a/drivers/net/es3210.c b/drivers/net/es3210.c index fd7b32a24ea4..2d2ea94a00bb 100644 --- a/drivers/net/es3210.c +++ b/drivers/net/es3210.c | |||
@@ -455,7 +455,7 @@ static void cleanup_card(struct net_device *dev) | |||
455 | iounmap(ei_status.mem); | 455 | iounmap(ei_status.mem); |
456 | } | 456 | } |
457 | 457 | ||
458 | void | 458 | void __exit |
459 | cleanup_module(void) | 459 | cleanup_module(void) |
460 | { | 460 | { |
461 | int this_dev; | 461 | int this_dev; |
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c index b7b8bc2a6307..93283e386f3a 100644 --- a/drivers/net/eth16i.c +++ b/drivers/net/eth16i.c | |||
@@ -1475,7 +1475,7 @@ int __init init_module(void) | |||
1475 | return -ENXIO; | 1475 | return -ENXIO; |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | void cleanup_module(void) | 1478 | void __exit cleanup_module(void) |
1479 | { | 1479 | { |
1480 | int this_dev; | 1480 | int this_dev; |
1481 | 1481 | ||
diff --git a/drivers/net/hp-plus.c b/drivers/net/hp-plus.c index 6abcfd2a4b28..99a36cc3f8df 100644 --- a/drivers/net/hp-plus.c +++ b/drivers/net/hp-plus.c | |||
@@ -482,7 +482,7 @@ static void cleanup_card(struct net_device *dev) | |||
482 | release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); | 482 | release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); |
483 | } | 483 | } |
484 | 484 | ||
485 | void | 485 | void __exit |
486 | cleanup_module(void) | 486 | cleanup_module(void) |
487 | { | 487 | { |
488 | int this_dev; | 488 | int this_dev; |
diff --git a/drivers/net/hp.c b/drivers/net/hp.c index 29470970aa27..635b13c2e2aa 100644 --- a/drivers/net/hp.c +++ b/drivers/net/hp.c | |||
@@ -444,7 +444,7 @@ static void cleanup_card(struct net_device *dev) | |||
444 | release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); | 444 | release_region(dev->base_addr - NIC_OFFSET, HP_IO_EXTENT); |
445 | } | 445 | } |
446 | 446 | ||
447 | void | 447 | void __exit |
448 | cleanup_module(void) | 448 | cleanup_module(void) |
449 | { | 449 | { |
450 | int this_dev; | 450 | int this_dev; |
diff --git a/drivers/net/lance.c b/drivers/net/lance.c index 4256c13c73c2..a3843320dbe1 100644 --- a/drivers/net/lance.c +++ b/drivers/net/lance.c | |||
@@ -368,7 +368,7 @@ static void cleanup_card(struct net_device *dev) | |||
368 | kfree(lp); | 368 | kfree(lp); |
369 | } | 369 | } |
370 | 370 | ||
371 | void cleanup_module(void) | 371 | void __exit cleanup_module(void) |
372 | { | 372 | { |
373 | int this_dev; | 373 | int this_dev; |
374 | 374 | ||
diff --git a/drivers/net/lne390.c b/drivers/net/lne390.c index 5795ee116205..0a08d0c4e7b4 100644 --- a/drivers/net/lne390.c +++ b/drivers/net/lne390.c | |||
@@ -440,7 +440,7 @@ static void cleanup_card(struct net_device *dev) | |||
440 | iounmap(ei_status.mem); | 440 | iounmap(ei_status.mem); |
441 | } | 441 | } |
442 | 442 | ||
443 | void cleanup_module(void) | 443 | void __exit cleanup_module(void) |
444 | { | 444 | { |
445 | int this_dev; | 445 | int this_dev; |
446 | 446 | ||
diff --git a/drivers/net/mv643xx_eth.c b/drivers/net/mv643xx_eth.c index d9f48bb04b05..c41ae4286eea 100644 --- a/drivers/net/mv643xx_eth.c +++ b/drivers/net/mv643xx_eth.c | |||
@@ -1100,7 +1100,7 @@ static void eth_tx_fill_frag_descs(struct mv643xx_private *mp, | |||
1100 | ETH_TX_ENABLE_INTERRUPT; | 1100 | ETH_TX_ENABLE_INTERRUPT; |
1101 | mp->tx_skb[tx_index] = skb; | 1101 | mp->tx_skb[tx_index] = skb; |
1102 | } else | 1102 | } else |
1103 | mp->tx_skb[tx_index] = 0; | 1103 | mp->tx_skb[tx_index] = NULL; |
1104 | 1104 | ||
1105 | desc = &mp->p_tx_desc_area[tx_index]; | 1105 | desc = &mp->p_tx_desc_area[tx_index]; |
1106 | desc->l4i_chk = 0; | 1106 | desc->l4i_chk = 0; |
@@ -1136,7 +1136,7 @@ static void eth_tx_submit_descs_for_skb(struct mv643xx_private *mp, | |||
1136 | eth_tx_fill_frag_descs(mp, skb); | 1136 | eth_tx_fill_frag_descs(mp, skb); |
1137 | 1137 | ||
1138 | length = skb_headlen(skb); | 1138 | length = skb_headlen(skb); |
1139 | mp->tx_skb[tx_index] = 0; | 1139 | mp->tx_skb[tx_index] = NULL; |
1140 | } else { | 1140 | } else { |
1141 | cmd_sts |= ETH_ZERO_PADDING | | 1141 | cmd_sts |= ETH_ZERO_PADDING | |
1142 | ETH_TX_LAST_DESC | | 1142 | ETH_TX_LAST_DESC | |
diff --git a/drivers/net/mvme147.c b/drivers/net/mvme147.c index 56a82d8ee8f5..e246d00bba6d 100644 --- a/drivers/net/mvme147.c +++ b/drivers/net/mvme147.c | |||
@@ -184,7 +184,7 @@ static int m147lance_close(struct net_device *dev) | |||
184 | MODULE_LICENSE("GPL"); | 184 | MODULE_LICENSE("GPL"); |
185 | 185 | ||
186 | static struct net_device *dev_mvme147_lance; | 186 | static struct net_device *dev_mvme147_lance; |
187 | int init_module(void) | 187 | int __init init_module(void) |
188 | { | 188 | { |
189 | dev_mvme147_lance = mvme147lance_probe(-1); | 189 | dev_mvme147_lance = mvme147lance_probe(-1); |
190 | if (IS_ERR(dev_mvme147_lance)) | 190 | if (IS_ERR(dev_mvme147_lance)) |
@@ -192,7 +192,7 @@ int init_module(void) | |||
192 | return 0; | 192 | return 0; |
193 | } | 193 | } |
194 | 194 | ||
195 | void cleanup_module(void) | 195 | void __exit cleanup_module(void) |
196 | { | 196 | { |
197 | struct m147lance_private *lp = dev_mvme147_lance->priv; | 197 | struct m147lance_private *lp = dev_mvme147_lance->priv; |
198 | unregister_netdev(dev_mvme147_lance); | 198 | unregister_netdev(dev_mvme147_lance); |
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index 38df42802386..81f127a78afa 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -89,7 +89,7 @@ MODULE_LICENSE("Dual BSD/GPL"); | |||
89 | #define MYRI10GE_EEPROM_STRINGS_SIZE 256 | 89 | #define MYRI10GE_EEPROM_STRINGS_SIZE 256 |
90 | #define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2) | 90 | #define MYRI10GE_MAX_SEND_DESC_TSO ((65536 / 2048) * 2) |
91 | 91 | ||
92 | #define MYRI10GE_NO_CONFIRM_DATA 0xffffffff | 92 | #define MYRI10GE_NO_CONFIRM_DATA htonl(0xffffffff) |
93 | #define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff | 93 | #define MYRI10GE_NO_RESPONSE_RESULT 0xffffffff |
94 | 94 | ||
95 | struct myri10ge_rx_buffer_state { | 95 | struct myri10ge_rx_buffer_state { |
@@ -156,8 +156,8 @@ struct myri10ge_priv { | |||
156 | int sram_size; | 156 | int sram_size; |
157 | unsigned long board_span; | 157 | unsigned long board_span; |
158 | unsigned long iomem_base; | 158 | unsigned long iomem_base; |
159 | u32 __iomem *irq_claim; | 159 | __be32 __iomem *irq_claim; |
160 | u32 __iomem *irq_deassert; | 160 | __be32 __iomem *irq_deassert; |
161 | char *mac_addr_string; | 161 | char *mac_addr_string; |
162 | struct mcp_cmd_response *cmd; | 162 | struct mcp_cmd_response *cmd; |
163 | dma_addr_t cmd_bus; | 163 | dma_addr_t cmd_bus; |
@@ -165,10 +165,10 @@ struct myri10ge_priv { | |||
165 | dma_addr_t fw_stats_bus; | 165 | dma_addr_t fw_stats_bus; |
166 | struct pci_dev *pdev; | 166 | struct pci_dev *pdev; |
167 | int msi_enabled; | 167 | int msi_enabled; |
168 | unsigned int link_state; | 168 | __be32 link_state; |
169 | unsigned int rdma_tags_available; | 169 | unsigned int rdma_tags_available; |
170 | int intr_coal_delay; | 170 | int intr_coal_delay; |
171 | u32 __iomem *intr_coal_delay_ptr; | 171 | __be32 __iomem *intr_coal_delay_ptr; |
172 | int mtrr; | 172 | int mtrr; |
173 | int wake_queue; | 173 | int wake_queue; |
174 | int stop_queue; | 174 | int stop_queue; |
@@ -273,6 +273,11 @@ MODULE_PARM_DESC(myri10ge_debug, "Debug level (0=none,...,16=all)"); | |||
273 | 273 | ||
274 | #define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8) | 274 | #define myri10ge_pio_copy(to,from,size) __iowrite64_copy(to,from,size/8) |
275 | 275 | ||
276 | static inline void put_be32(__be32 val, __be32 __iomem *p) | ||
277 | { | ||
278 | __raw_writel((__force __u32)val, (__force void __iomem *)p); | ||
279 | } | ||
280 | |||
276 | static int | 281 | static int |
277 | myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, | 282 | myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, |
278 | struct myri10ge_cmd *data, int atomic) | 283 | struct myri10ge_cmd *data, int atomic) |
@@ -296,7 +301,7 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, | |||
296 | 301 | ||
297 | buf->response_addr.low = htonl(dma_low); | 302 | buf->response_addr.low = htonl(dma_low); |
298 | buf->response_addr.high = htonl(dma_high); | 303 | buf->response_addr.high = htonl(dma_high); |
299 | response->result = MYRI10GE_NO_RESPONSE_RESULT; | 304 | response->result = htonl(MYRI10GE_NO_RESPONSE_RESULT); |
300 | mb(); | 305 | mb(); |
301 | myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf)); | 306 | myri10ge_pio_copy(cmd_addr, buf, sizeof(*buf)); |
302 | 307 | ||
@@ -311,14 +316,14 @@ myri10ge_send_cmd(struct myri10ge_priv *mgp, u32 cmd, | |||
311 | * (1ms will be enough for those commands) */ | 316 | * (1ms will be enough for those commands) */ |
312 | for (sleep_total = 0; | 317 | for (sleep_total = 0; |
313 | sleep_total < 1000 | 318 | sleep_total < 1000 |
314 | && response->result == MYRI10GE_NO_RESPONSE_RESULT; | 319 | && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT); |
315 | sleep_total += 10) | 320 | sleep_total += 10) |
316 | udelay(10); | 321 | udelay(10); |
317 | } else { | 322 | } else { |
318 | /* use msleep for most command */ | 323 | /* use msleep for most command */ |
319 | for (sleep_total = 0; | 324 | for (sleep_total = 0; |
320 | sleep_total < 15 | 325 | sleep_total < 15 |
321 | && response->result == MYRI10GE_NO_RESPONSE_RESULT; | 326 | && response->result == htonl(MYRI10GE_NO_RESPONSE_RESULT); |
322 | sleep_total++) | 327 | sleep_total++) |
323 | msleep(1); | 328 | msleep(1); |
324 | } | 329 | } |
@@ -393,7 +398,7 @@ abort: | |||
393 | static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) | 398 | static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) |
394 | { | 399 | { |
395 | char __iomem *submit; | 400 | char __iomem *submit; |
396 | u32 buf[16]; | 401 | __be32 buf[16]; |
397 | u32 dma_low, dma_high; | 402 | u32 dma_low, dma_high; |
398 | int i; | 403 | int i; |
399 | 404 | ||
@@ -410,7 +415,7 @@ static void myri10ge_dummy_rdma(struct myri10ge_priv *mgp, int enable) | |||
410 | 415 | ||
411 | buf[0] = htonl(dma_high); /* confirm addr MSW */ | 416 | buf[0] = htonl(dma_high); /* confirm addr MSW */ |
412 | buf[1] = htonl(dma_low); /* confirm addr LSW */ | 417 | buf[1] = htonl(dma_low); /* confirm addr LSW */ |
413 | buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA); /* confirm data */ | 418 | buf[2] = MYRI10GE_NO_CONFIRM_DATA; /* confirm data */ |
414 | buf[3] = htonl(dma_high); /* dummy addr MSW */ | 419 | buf[3] = htonl(dma_high); /* dummy addr MSW */ |
415 | buf[4] = htonl(dma_low); /* dummy addr LSW */ | 420 | buf[4] = htonl(dma_low); /* dummy addr LSW */ |
416 | buf[5] = htonl(enable); /* enable? */ | 421 | buf[5] = htonl(enable); /* enable? */ |
@@ -479,7 +484,7 @@ static int myri10ge_load_hotplug_firmware(struct myri10ge_priv *mgp, u32 * size) | |||
479 | } | 484 | } |
480 | 485 | ||
481 | /* check id */ | 486 | /* check id */ |
482 | hdr_offset = ntohl(*(u32 *) (fw->data + MCP_HEADER_PTR_OFFSET)); | 487 | hdr_offset = ntohl(*(__be32 *) (fw->data + MCP_HEADER_PTR_OFFSET)); |
483 | if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) { | 488 | if ((hdr_offset & 3) || hdr_offset + sizeof(*hdr) > fw->size) { |
484 | dev_err(dev, "Bad firmware file\n"); | 489 | dev_err(dev, "Bad firmware file\n"); |
485 | status = -EINVAL; | 490 | status = -EINVAL; |
@@ -550,7 +555,7 @@ static int myri10ge_adopt_running_firmware(struct myri10ge_priv *mgp) | |||
550 | static int myri10ge_load_firmware(struct myri10ge_priv *mgp) | 555 | static int myri10ge_load_firmware(struct myri10ge_priv *mgp) |
551 | { | 556 | { |
552 | char __iomem *submit; | 557 | char __iomem *submit; |
553 | u32 buf[16]; | 558 | __be32 buf[16]; |
554 | u32 dma_low, dma_high, size; | 559 | u32 dma_low, dma_high, size; |
555 | int status, i; | 560 | int status, i; |
556 | 561 | ||
@@ -600,7 +605,7 @@ static int myri10ge_load_firmware(struct myri10ge_priv *mgp) | |||
600 | 605 | ||
601 | buf[0] = htonl(dma_high); /* confirm addr MSW */ | 606 | buf[0] = htonl(dma_high); /* confirm addr MSW */ |
602 | buf[1] = htonl(dma_low); /* confirm addr LSW */ | 607 | buf[1] = htonl(dma_low); /* confirm addr LSW */ |
603 | buf[2] = htonl(MYRI10GE_NO_CONFIRM_DATA); /* confirm data */ | 608 | buf[2] = MYRI10GE_NO_CONFIRM_DATA; /* confirm data */ |
604 | 609 | ||
605 | /* FIX: All newest firmware should un-protect the bottom of | 610 | /* FIX: All newest firmware should un-protect the bottom of |
606 | * the sram before handoff. However, the very first interfaces | 611 | * the sram before handoff. However, the very first interfaces |
@@ -705,21 +710,21 @@ static int myri10ge_reset(struct myri10ge_priv *mgp) | |||
705 | 710 | ||
706 | status |= | 711 | status |= |
707 | myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); | 712 | myri10ge_send_cmd(mgp, MXGEFW_CMD_GET_IRQ_ACK_OFFSET, &cmd, 0); |
708 | mgp->irq_claim = (__iomem u32 *) (mgp->sram + cmd.data0); | 713 | mgp->irq_claim = (__iomem __be32 *) (mgp->sram + cmd.data0); |
709 | if (!mgp->msi_enabled) { | 714 | if (!mgp->msi_enabled) { |
710 | status |= myri10ge_send_cmd | 715 | status |= myri10ge_send_cmd |
711 | (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0); | 716 | (mgp, MXGEFW_CMD_GET_IRQ_DEASSERT_OFFSET, &cmd, 0); |
712 | mgp->irq_deassert = (__iomem u32 *) (mgp->sram + cmd.data0); | 717 | mgp->irq_deassert = (__iomem __be32 *) (mgp->sram + cmd.data0); |
713 | 718 | ||
714 | } | 719 | } |
715 | status |= myri10ge_send_cmd | 720 | status |= myri10ge_send_cmd |
716 | (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0); | 721 | (mgp, MXGEFW_CMD_GET_INTR_COAL_DELAY_OFFSET, &cmd, 0); |
717 | mgp->intr_coal_delay_ptr = (__iomem u32 *) (mgp->sram + cmd.data0); | 722 | mgp->intr_coal_delay_ptr = (__iomem __be32 *) (mgp->sram + cmd.data0); |
718 | if (status != 0) { | 723 | if (status != 0) { |
719 | dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n"); | 724 | dev_err(&mgp->pdev->dev, "failed set interrupt parameters\n"); |
720 | return status; | 725 | return status; |
721 | } | 726 | } |
722 | __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); | 727 | put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); |
723 | 728 | ||
724 | /* Run a small DMA test. | 729 | /* Run a small DMA test. |
725 | * The magic multipliers to the length tell the firmware | 730 | * The magic multipliers to the length tell the firmware |
@@ -786,14 +791,16 @@ static inline void | |||
786 | myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst, | 791 | myri10ge_submit_8rx(struct mcp_kreq_ether_recv __iomem * dst, |
787 | struct mcp_kreq_ether_recv *src) | 792 | struct mcp_kreq_ether_recv *src) |
788 | { | 793 | { |
789 | u32 low; | 794 | __be32 low; |
790 | 795 | ||
791 | low = src->addr_low; | 796 | low = src->addr_low; |
792 | src->addr_low = DMA_32BIT_MASK; | 797 | src->addr_low = htonl(DMA_32BIT_MASK); |
793 | myri10ge_pio_copy(dst, src, 8 * sizeof(*src)); | 798 | myri10ge_pio_copy(dst, src, 4 * sizeof(*src)); |
799 | mb(); | ||
800 | myri10ge_pio_copy(dst + 4, src + 4, 4 * sizeof(*src)); | ||
794 | mb(); | 801 | mb(); |
795 | src->addr_low = low; | 802 | src->addr_low = low; |
796 | __raw_writel(low, &dst->addr_low); | 803 | put_be32(low, &dst->addr_low); |
797 | mb(); | 804 | mb(); |
798 | } | 805 | } |
799 | 806 | ||
@@ -939,11 +946,11 @@ done: | |||
939 | return retval; | 946 | return retval; |
940 | } | 947 | } |
941 | 948 | ||
942 | static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum) | 949 | static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, __wsum hw_csum) |
943 | { | 950 | { |
944 | struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data); | 951 | struct vlan_hdr *vh = (struct vlan_hdr *)(skb->data); |
945 | 952 | ||
946 | if ((skb->protocol == ntohs(ETH_P_8021Q)) && | 953 | if ((skb->protocol == htons(ETH_P_8021Q)) && |
947 | (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) || | 954 | (vh->h_vlan_encapsulated_proto == htons(ETH_P_IP) || |
948 | vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) { | 955 | vh->h_vlan_encapsulated_proto == htons(ETH_P_IPV6))) { |
949 | skb->csum = hw_csum; | 956 | skb->csum = hw_csum; |
@@ -953,7 +960,7 @@ static inline void myri10ge_vlan_ip_csum(struct sk_buff *skb, u16 hw_csum) | |||
953 | 960 | ||
954 | static inline unsigned long | 961 | static inline unsigned long |
955 | myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, | 962 | myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, |
956 | int bytes, int len, int csum) | 963 | int bytes, int len, __wsum csum) |
957 | { | 964 | { |
958 | dma_addr_t bus; | 965 | dma_addr_t bus; |
959 | struct sk_buff *skb; | 966 | struct sk_buff *skb; |
@@ -986,12 +993,12 @@ myri10ge_rx_done(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx, | |||
986 | 993 | ||
987 | skb->protocol = eth_type_trans(skb, mgp->dev); | 994 | skb->protocol = eth_type_trans(skb, mgp->dev); |
988 | if (mgp->csum_flag) { | 995 | if (mgp->csum_flag) { |
989 | if ((skb->protocol == ntohs(ETH_P_IP)) || | 996 | if ((skb->protocol == htons(ETH_P_IP)) || |
990 | (skb->protocol == ntohs(ETH_P_IPV6))) { | 997 | (skb->protocol == htons(ETH_P_IPV6))) { |
991 | skb->csum = ntohs((u16) csum); | 998 | skb->csum = csum; |
992 | skb->ip_summed = CHECKSUM_COMPLETE; | 999 | skb->ip_summed = CHECKSUM_COMPLETE; |
993 | } else | 1000 | } else |
994 | myri10ge_vlan_ip_csum(skb, ntohs((u16) csum)); | 1001 | myri10ge_vlan_ip_csum(skb, csum); |
995 | } | 1002 | } |
996 | 1003 | ||
997 | netif_receive_skb(skb); | 1004 | netif_receive_skb(skb); |
@@ -1060,12 +1067,12 @@ static inline void myri10ge_clean_rx_done(struct myri10ge_priv *mgp, int *limit) | |||
1060 | int idx = rx_done->idx; | 1067 | int idx = rx_done->idx; |
1061 | int cnt = rx_done->cnt; | 1068 | int cnt = rx_done->cnt; |
1062 | u16 length; | 1069 | u16 length; |
1063 | u16 checksum; | 1070 | __wsum checksum; |
1064 | 1071 | ||
1065 | while (rx_done->entry[idx].length != 0 && *limit != 0) { | 1072 | while (rx_done->entry[idx].length != 0 && *limit != 0) { |
1066 | length = ntohs(rx_done->entry[idx].length); | 1073 | length = ntohs(rx_done->entry[idx].length); |
1067 | rx_done->entry[idx].length = 0; | 1074 | rx_done->entry[idx].length = 0; |
1068 | checksum = ntohs(rx_done->entry[idx].checksum); | 1075 | checksum = csum_unfold(rx_done->entry[idx].checksum); |
1069 | if (length <= mgp->small_bytes) | 1076 | if (length <= mgp->small_bytes) |
1070 | rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small, | 1077 | rx_ok = myri10ge_rx_done(mgp, &mgp->rx_small, |
1071 | mgp->small_bytes, | 1078 | mgp->small_bytes, |
@@ -1142,7 +1149,7 @@ static int myri10ge_poll(struct net_device *netdev, int *budget) | |||
1142 | 1149 | ||
1143 | if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) { | 1150 | if (rx_done->entry[rx_done->idx].length == 0 || !netif_running(netdev)) { |
1144 | netif_rx_complete(netdev); | 1151 | netif_rx_complete(netdev); |
1145 | __raw_writel(htonl(3), mgp->irq_claim); | 1152 | put_be32(htonl(3), mgp->irq_claim); |
1146 | return 0; | 1153 | return 0; |
1147 | } | 1154 | } |
1148 | return 1; | 1155 | return 1; |
@@ -1166,7 +1173,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg) | |||
1166 | netif_rx_schedule(mgp->dev); | 1173 | netif_rx_schedule(mgp->dev); |
1167 | 1174 | ||
1168 | if (!mgp->msi_enabled) { | 1175 | if (!mgp->msi_enabled) { |
1169 | __raw_writel(0, mgp->irq_deassert); | 1176 | put_be32(0, mgp->irq_deassert); |
1170 | if (!myri10ge_deassert_wait) | 1177 | if (!myri10ge_deassert_wait) |
1171 | stats->valid = 0; | 1178 | stats->valid = 0; |
1172 | mb(); | 1179 | mb(); |
@@ -1195,7 +1202,7 @@ static irqreturn_t myri10ge_intr(int irq, void *arg) | |||
1195 | 1202 | ||
1196 | myri10ge_check_statblock(mgp); | 1203 | myri10ge_check_statblock(mgp); |
1197 | 1204 | ||
1198 | __raw_writel(htonl(3), mgp->irq_claim + 1); | 1205 | put_be32(htonl(3), mgp->irq_claim + 1); |
1199 | return (IRQ_HANDLED); | 1206 | return (IRQ_HANDLED); |
1200 | } | 1207 | } |
1201 | 1208 | ||
@@ -1233,7 +1240,7 @@ myri10ge_set_coalesce(struct net_device *netdev, struct ethtool_coalesce *coal) | |||
1233 | struct myri10ge_priv *mgp = netdev_priv(netdev); | 1240 | struct myri10ge_priv *mgp = netdev_priv(netdev); |
1234 | 1241 | ||
1235 | mgp->intr_coal_delay = coal->rx_coalesce_usecs; | 1242 | mgp->intr_coal_delay = coal->rx_coalesce_usecs; |
1236 | __raw_writel(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); | 1243 | put_be32(htonl(mgp->intr_coal_delay), mgp->intr_coal_delay_ptr); |
1237 | return 0; | 1244 | return 0; |
1238 | } | 1245 | } |
1239 | 1246 | ||
@@ -1748,7 +1755,7 @@ static int myri10ge_open(struct net_device *dev) | |||
1748 | goto abort_with_rings; | 1755 | goto abort_with_rings; |
1749 | } | 1756 | } |
1750 | 1757 | ||
1751 | mgp->link_state = -1; | 1758 | mgp->link_state = htonl(~0U); |
1752 | mgp->rdma_tags_available = 15; | 1759 | mgp->rdma_tags_available = 15; |
1753 | 1760 | ||
1754 | netif_poll_enable(mgp->dev); /* must happen prior to any irq */ | 1761 | netif_poll_enable(mgp->dev); /* must happen prior to any irq */ |
@@ -1876,7 +1883,7 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src, | |||
1876 | 1883 | ||
1877 | /* re-write the last 32-bits with the valid flags */ | 1884 | /* re-write the last 32-bits with the valid flags */ |
1878 | src->flags = last_flags; | 1885 | src->flags = last_flags; |
1879 | __raw_writel(*((u32 *) src + 3), (u32 __iomem *) dst + 3); | 1886 | put_be32(*((__be32 *) src + 3), (__be32 __iomem *) dst + 3); |
1880 | tx->req += cnt; | 1887 | tx->req += cnt; |
1881 | mb(); | 1888 | mb(); |
1882 | } | 1889 | } |
@@ -1919,7 +1926,8 @@ static int myri10ge_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1919 | struct myri10ge_tx_buf *tx = &mgp->tx; | 1926 | struct myri10ge_tx_buf *tx = &mgp->tx; |
1920 | struct skb_frag_struct *frag; | 1927 | struct skb_frag_struct *frag; |
1921 | dma_addr_t bus; | 1928 | dma_addr_t bus; |
1922 | u32 low, high_swapped; | 1929 | u32 low; |
1930 | __be32 high_swapped; | ||
1923 | unsigned int len; | 1931 | unsigned int len; |
1924 | int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments; | 1932 | int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments; |
1925 | u16 pseudo_hdr_offset, cksum_offset; | 1933 | u16 pseudo_hdr_offset, cksum_offset; |
@@ -1964,7 +1972,6 @@ again: | |||
1964 | cksum_offset = 0; | 1972 | cksum_offset = 0; |
1965 | pseudo_hdr_offset = 0; | 1973 | pseudo_hdr_offset = 0; |
1966 | } else { | 1974 | } else { |
1967 | pseudo_hdr_offset = htons(pseudo_hdr_offset); | ||
1968 | odd_flag = MXGEFW_FLAGS_ALIGN_ODD; | 1975 | odd_flag = MXGEFW_FLAGS_ALIGN_ODD; |
1969 | flags |= MXGEFW_FLAGS_CKSUM; | 1976 | flags |= MXGEFW_FLAGS_CKSUM; |
1970 | } | 1977 | } |
@@ -1986,7 +1993,7 @@ again: | |||
1986 | /* for TSO, pseudo_hdr_offset holds mss. | 1993 | /* for TSO, pseudo_hdr_offset holds mss. |
1987 | * The firmware figures out where to put | 1994 | * The firmware figures out where to put |
1988 | * the checksum by parsing the header. */ | 1995 | * the checksum by parsing the header. */ |
1989 | pseudo_hdr_offset = htons(mss); | 1996 | pseudo_hdr_offset = mss; |
1990 | } else | 1997 | } else |
1991 | #endif /*NETIF_F_TSO */ | 1998 | #endif /*NETIF_F_TSO */ |
1992 | /* Mark small packets, and pad out tiny packets */ | 1999 | /* Mark small packets, and pad out tiny packets */ |
@@ -2086,7 +2093,7 @@ again: | |||
2086 | #endif /* NETIF_F_TSO */ | 2093 | #endif /* NETIF_F_TSO */ |
2087 | req->addr_high = high_swapped; | 2094 | req->addr_high = high_swapped; |
2088 | req->addr_low = htonl(low); | 2095 | req->addr_low = htonl(low); |
2089 | req->pseudo_hdr_offset = pseudo_hdr_offset; | 2096 | req->pseudo_hdr_offset = htons(pseudo_hdr_offset); |
2090 | req->pad = 0; /* complete solid 16-byte block; does this matter? */ | 2097 | req->pad = 0; /* complete solid 16-byte block; does this matter? */ |
2091 | req->rdma_count = 1; | 2098 | req->rdma_count = 1; |
2092 | req->length = htons(seglen); | 2099 | req->length = htons(seglen); |
@@ -2199,6 +2206,7 @@ static void myri10ge_set_multicast_list(struct net_device *dev) | |||
2199 | struct myri10ge_cmd cmd; | 2206 | struct myri10ge_cmd cmd; |
2200 | struct myri10ge_priv *mgp; | 2207 | struct myri10ge_priv *mgp; |
2201 | struct dev_mc_list *mc_list; | 2208 | struct dev_mc_list *mc_list; |
2209 | __be32 data[2] = {0, 0}; | ||
2202 | int err; | 2210 | int err; |
2203 | 2211 | ||
2204 | mgp = netdev_priv(dev); | 2212 | mgp = netdev_priv(dev); |
@@ -2237,10 +2245,9 @@ static void myri10ge_set_multicast_list(struct net_device *dev) | |||
2237 | 2245 | ||
2238 | /* Walk the multicast list, and add each address */ | 2246 | /* Walk the multicast list, and add each address */ |
2239 | for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) { | 2247 | for (mc_list = dev->mc_list; mc_list != NULL; mc_list = mc_list->next) { |
2240 | memcpy(&cmd.data0, &mc_list->dmi_addr, 4); | 2248 | memcpy(data, &mc_list->dmi_addr, 6); |
2241 | memcpy(&cmd.data1, ((char *)&mc_list->dmi_addr) + 4, 2); | 2249 | cmd.data0 = ntohl(data[0]); |
2242 | cmd.data0 = htonl(cmd.data0); | 2250 | cmd.data1 = ntohl(data[1]); |
2243 | cmd.data1 = htonl(cmd.data1); | ||
2244 | err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP, | 2251 | err = myri10ge_send_cmd(mgp, MXGEFW_JOIN_MULTICAST_GROUP, |
2245 | &cmd, 1); | 2252 | &cmd, 1); |
2246 | 2253 | ||
diff --git a/drivers/net/myri10ge/myri10ge_mcp.h b/drivers/net/myri10ge/myri10ge_mcp.h index 9519ae7cd5ec..29463b301a84 100644 --- a/drivers/net/myri10ge/myri10ge_mcp.h +++ b/drivers/net/myri10ge/myri10ge_mcp.h | |||
@@ -6,23 +6,23 @@ | |||
6 | 6 | ||
7 | /* 8 Bytes */ | 7 | /* 8 Bytes */ |
8 | struct mcp_dma_addr { | 8 | struct mcp_dma_addr { |
9 | u32 high; | 9 | __be32 high; |
10 | u32 low; | 10 | __be32 low; |
11 | }; | 11 | }; |
12 | 12 | ||
13 | /* 4 Bytes */ | 13 | /* 4 Bytes */ |
14 | struct mcp_slot { | 14 | struct mcp_slot { |
15 | u16 checksum; | 15 | __sum16 checksum; |
16 | u16 length; | 16 | __be16 length; |
17 | }; | 17 | }; |
18 | 18 | ||
19 | /* 64 Bytes */ | 19 | /* 64 Bytes */ |
20 | struct mcp_cmd { | 20 | struct mcp_cmd { |
21 | u32 cmd; | 21 | __be32 cmd; |
22 | u32 data0; /* will be low portion if data > 32 bits */ | 22 | __be32 data0; /* will be low portion if data > 32 bits */ |
23 | /* 8 */ | 23 | /* 8 */ |
24 | u32 data1; /* will be high portion if data > 32 bits */ | 24 | __be32 data1; /* will be high portion if data > 32 bits */ |
25 | u32 data2; /* currently unused.. */ | 25 | __be32 data2; /* currently unused.. */ |
26 | /* 16 */ | 26 | /* 16 */ |
27 | struct mcp_dma_addr response_addr; | 27 | struct mcp_dma_addr response_addr; |
28 | /* 24 */ | 28 | /* 24 */ |
@@ -31,8 +31,8 @@ struct mcp_cmd { | |||
31 | 31 | ||
32 | /* 8 Bytes */ | 32 | /* 8 Bytes */ |
33 | struct mcp_cmd_response { | 33 | struct mcp_cmd_response { |
34 | u32 data; | 34 | __be32 data; |
35 | u32 result; | 35 | __be32 result; |
36 | }; | 36 | }; |
37 | 37 | ||
38 | /* | 38 | /* |
@@ -73,10 +73,10 @@ union mcp_pso_or_cumlen { | |||
73 | 73 | ||
74 | /* 16 Bytes */ | 74 | /* 16 Bytes */ |
75 | struct mcp_kreq_ether_send { | 75 | struct mcp_kreq_ether_send { |
76 | u32 addr_high; | 76 | __be32 addr_high; |
77 | u32 addr_low; | 77 | __be32 addr_low; |
78 | u16 pseudo_hdr_offset; | 78 | __be16 pseudo_hdr_offset; |
79 | u16 length; | 79 | __be16 length; |
80 | u8 pad; | 80 | u8 pad; |
81 | u8 rdma_count; | 81 | u8 rdma_count; |
82 | u8 cksum_offset; /* where to start computing cksum */ | 82 | u8 cksum_offset; /* where to start computing cksum */ |
@@ -85,8 +85,8 @@ struct mcp_kreq_ether_send { | |||
85 | 85 | ||
86 | /* 8 Bytes */ | 86 | /* 8 Bytes */ |
87 | struct mcp_kreq_ether_recv { | 87 | struct mcp_kreq_ether_recv { |
88 | u32 addr_high; | 88 | __be32 addr_high; |
89 | u32 addr_low; | 89 | __be32 addr_low; |
90 | }; | 90 | }; |
91 | 91 | ||
92 | /* Commands */ | 92 | /* Commands */ |
@@ -219,19 +219,19 @@ enum myri10ge_mcp_cmd_status { | |||
219 | 219 | ||
220 | struct mcp_irq_data { | 220 | struct mcp_irq_data { |
221 | /* add new counters at the beginning */ | 221 | /* add new counters at the beginning */ |
222 | u32 future_use[5]; | 222 | __be32 future_use[5]; |
223 | u32 dropped_multicast_filtered; | 223 | __be32 dropped_multicast_filtered; |
224 | /* 40 Bytes */ | 224 | /* 40 Bytes */ |
225 | u32 send_done_count; | 225 | __be32 send_done_count; |
226 | 226 | ||
227 | u32 link_up; | 227 | __be32 link_up; |
228 | u32 dropped_link_overflow; | 228 | __be32 dropped_link_overflow; |
229 | u32 dropped_link_error_or_filtered; | 229 | __be32 dropped_link_error_or_filtered; |
230 | u32 dropped_runt; | 230 | __be32 dropped_runt; |
231 | u32 dropped_overrun; | 231 | __be32 dropped_overrun; |
232 | u32 dropped_no_small_buffer; | 232 | __be32 dropped_no_small_buffer; |
233 | u32 dropped_no_big_buffer; | 233 | __be32 dropped_no_big_buffer; |
234 | u32 rdma_tags_available; | 234 | __be32 rdma_tags_available; |
235 | 235 | ||
236 | u8 tx_stopped; | 236 | u8 tx_stopped; |
237 | u8 link_down; | 237 | u8 link_down; |
diff --git a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h index 487f7792fd46..16a810dd6d51 100644 --- a/drivers/net/myri10ge/myri10ge_mcp_gen_header.h +++ b/drivers/net/myri10ge/myri10ge_mcp_gen_header.h | |||
@@ -36,7 +36,7 @@ | |||
36 | struct mcp_gen_header { | 36 | struct mcp_gen_header { |
37 | /* the first 4 fields are filled at compile time */ | 37 | /* the first 4 fields are filled at compile time */ |
38 | unsigned header_length; | 38 | unsigned header_length; |
39 | unsigned mcp_type; | 39 | __be32 mcp_type; |
40 | char version[128]; | 40 | char version[128]; |
41 | unsigned mcp_globals; /* pointer to mcp-type specific structure */ | 41 | unsigned mcp_globals; /* pointer to mcp-type specific structure */ |
42 | 42 | ||
diff --git a/drivers/net/ne.c b/drivers/net/ne.c index 787aa4221528..a5c4199e2754 100644 --- a/drivers/net/ne.c +++ b/drivers/net/ne.c | |||
@@ -867,7 +867,7 @@ static void cleanup_card(struct net_device *dev) | |||
867 | release_region(dev->base_addr, NE_IO_EXTENT); | 867 | release_region(dev->base_addr, NE_IO_EXTENT); |
868 | } | 868 | } |
869 | 869 | ||
870 | void cleanup_module(void) | 870 | void __exit cleanup_module(void) |
871 | { | 871 | { |
872 | int this_dev; | 872 | int this_dev; |
873 | 873 | ||
diff --git a/drivers/net/ne2.c b/drivers/net/ne2.c index 5fccfea66d87..089b5bb702fc 100644 --- a/drivers/net/ne2.c +++ b/drivers/net/ne2.c | |||
@@ -813,7 +813,7 @@ static void cleanup_card(struct net_device *dev) | |||
813 | release_region(dev->base_addr, NE_IO_EXTENT); | 813 | release_region(dev->base_addr, NE_IO_EXTENT); |
814 | } | 814 | } |
815 | 815 | ||
816 | void cleanup_module(void) | 816 | void __exit cleanup_module(void) |
817 | { | 817 | { |
818 | int this_dev; | 818 | int this_dev; |
819 | 819 | ||
diff --git a/drivers/net/netxen/netxen_nic.h b/drivers/net/netxen/netxen_nic.h index 9c588af8ab74..b5410bee5f21 100644 --- a/drivers/net/netxen/netxen_nic.h +++ b/drivers/net/netxen/netxen_nic.h | |||
@@ -1,25 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
8 | * of the License, or (at your option) any later version. | 8 | * of the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, but | 10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -63,40 +63,68 @@ | |||
63 | 63 | ||
64 | #include "netxen_nic_hw.h" | 64 | #include "netxen_nic_hw.h" |
65 | 65 | ||
66 | #define NETXEN_NIC_BUILD_NO "5" | 66 | #define NETXEN_NIC_BUILD_NO "1" |
67 | #define _NETXEN_NIC_LINUX_MAJOR 2 | 67 | #define _NETXEN_NIC_LINUX_MAJOR 3 |
68 | #define _NETXEN_NIC_LINUX_MINOR 3 | 68 | #define _NETXEN_NIC_LINUX_MINOR 3 |
69 | #define _NETXEN_NIC_LINUX_SUBVERSION 59 | 69 | #define _NETXEN_NIC_LINUX_SUBVERSION 2 |
70 | #define NETXEN_NIC_LINUX_VERSIONID "2.3.59" "-" NETXEN_NIC_BUILD_NO | 70 | #define NETXEN_NIC_LINUX_VERSIONID "3.3.2" "-" NETXEN_NIC_BUILD_NO |
71 | #define NETXEN_NIC_FW_VERSIONID "2.3.59" | 71 | #define NETXEN_NIC_FW_VERSIONID "3.3.2" |
72 | 72 | ||
73 | #define RCV_DESC_RINGSIZE \ | 73 | #define RCV_DESC_RINGSIZE \ |
74 | (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) | 74 | (sizeof(struct rcv_desc) * adapter->max_rx_desc_count) |
75 | #define STATUS_DESC_RINGSIZE \ | 75 | #define STATUS_DESC_RINGSIZE \ |
76 | (sizeof(struct status_desc)* adapter->max_rx_desc_count) | 76 | (sizeof(struct status_desc)* adapter->max_rx_desc_count) |
77 | #define LRO_DESC_RINGSIZE \ | ||
78 | (sizeof(rcvDesc_t) * adapter->max_lro_rx_desc_count) | ||
77 | #define TX_RINGSIZE \ | 79 | #define TX_RINGSIZE \ |
78 | (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) | 80 | (sizeof(struct netxen_cmd_buffer) * adapter->max_tx_desc_count) |
79 | #define RCV_BUFFSIZE \ | 81 | #define RCV_BUFFSIZE \ |
80 | (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) | 82 | (sizeof(struct netxen_rx_buffer) * rcv_desc->max_rx_desc_count) |
81 | #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) | 83 | #define find_diff_among(a,b,range) ((a)<(b)?((b)-(a)):((b)+(range)-(a))) |
82 | 84 | ||
83 | #define NETXEN_NETDEV_STATUS 0x1 | 85 | #define NETXEN_NETDEV_STATUS 0x1 |
86 | #define NETXEN_RCV_PRODUCER_OFFSET 0 | ||
87 | #define NETXEN_RCV_PEG_DB_ID 2 | ||
88 | #define NETXEN_HOST_DUMMY_DMA_SIZE 1024 | ||
84 | 89 | ||
85 | #define ADDR_IN_WINDOW1(off) \ | 90 | #define ADDR_IN_WINDOW1(off) \ |
86 | ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 | 91 | ((off > NETXEN_CRB_PCIX_HOST2) && (off < NETXEN_CRB_MAX)) ? 1 : 0 |
92 | /* | ||
93 | * In netxen_nic_down(), we must wait for any pending callback requests into | ||
94 | * netxen_watchdog_task() to complete; eg otherwise the watchdog_timer could be | ||
95 | * reenabled right after it is deleted in netxen_nic_down(). FLUSH_SCHEDULED_WORK() | ||
96 | * does this synchronization. | ||
97 | * | ||
98 | * Normally, schedule_work()/flush_scheduled_work() could have worked, but | ||
99 | * netxen_nic_close() is invoked with kernel rtnl lock held. netif_carrier_off() | ||
100 | * call in netxen_nic_close() triggers a schedule_work(&linkwatch_work), and a | ||
101 | * subsequent call to flush_scheduled_work() in netxen_nic_down() would cause | ||
102 | * linkwatch_event() to be executed which also attempts to acquire the rtnl | ||
103 | * lock thus causing a deadlock. | ||
104 | */ | ||
105 | |||
106 | #define SCHEDULE_WORK(tp) queue_work(netxen_workq, tp) | ||
107 | #define FLUSH_SCHEDULED_WORK() flush_workqueue(netxen_workq) | ||
108 | extern struct workqueue_struct *netxen_workq; | ||
87 | 109 | ||
88 | /* | 110 | /* |
89 | * normalize a 64MB crb address to 32MB PCI window | 111 | * normalize a 64MB crb address to 32MB PCI window |
90 | * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 | 112 | * To use NETXEN_CRB_NORMALIZE, window _must_ be set to 1 |
91 | */ | 113 | */ |
92 | #define NETXEN_CRB_NORMAL(reg) \ | 114 | #define NETXEN_CRB_NORMAL(reg) \ |
93 | (reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST | 115 | ((reg) - NETXEN_CRB_PCIX_HOST2 + NETXEN_CRB_PCIX_HOST) |
94 | 116 | ||
95 | #define NETXEN_CRB_NORMALIZE(adapter, reg) \ | 117 | #define NETXEN_CRB_NORMALIZE(adapter, reg) \ |
96 | pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) | 118 | pci_base_offset(adapter, NETXEN_CRB_NORMAL(reg)) |
97 | 119 | ||
120 | #define DB_NORMALIZE(adapter, off) \ | ||
121 | (adapter->ahw.db_base + (off)) | ||
122 | |||
123 | #define NX_P2_C0 0x24 | ||
124 | #define NX_P2_C1 0x25 | ||
125 | |||
98 | #define FIRST_PAGE_GROUP_START 0 | 126 | #define FIRST_PAGE_GROUP_START 0 |
99 | #define FIRST_PAGE_GROUP_END 0x400000 | 127 | #define FIRST_PAGE_GROUP_END 0x100000 |
100 | 128 | ||
101 | #define SECOND_PAGE_GROUP_START 0x4000000 | 129 | #define SECOND_PAGE_GROUP_START 0x4000000 |
102 | #define SECOND_PAGE_GROUP_END 0x66BC000 | 130 | #define SECOND_PAGE_GROUP_END 0x66BC000 |
@@ -108,11 +136,13 @@ | |||
108 | #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START | 136 | #define SECOND_PAGE_GROUP_SIZE SECOND_PAGE_GROUP_END - SECOND_PAGE_GROUP_START |
109 | #define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START | 137 | #define THIRD_PAGE_GROUP_SIZE THIRD_PAGE_GROUP_END - THIRD_PAGE_GROUP_START |
110 | 138 | ||
111 | #define MAX_RX_BUFFER_LENGTH 2000 | 139 | #define MAX_RX_BUFFER_LENGTH 1760 |
112 | #define MAX_RX_JUMBO_BUFFER_LENGTH 9046 | 140 | #define MAX_RX_JUMBO_BUFFER_LENGTH 9046 |
113 | #define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - NET_IP_ALIGN) | 141 | #define MAX_RX_LRO_BUFFER_LENGTH ((48*1024)-512) |
142 | #define RX_DMA_MAP_LEN (MAX_RX_BUFFER_LENGTH - 2) | ||
114 | #define RX_JUMBO_DMA_MAP_LEN \ | 143 | #define RX_JUMBO_DMA_MAP_LEN \ |
115 | (MAX_RX_JUMBO_BUFFER_LENGTH - NET_IP_ALIGN) | 144 | (MAX_RX_JUMBO_BUFFER_LENGTH - 2) |
145 | #define RX_LRO_DMA_MAP_LEN (MAX_RX_LRO_BUFFER_LENGTH - 2) | ||
116 | #define NETXEN_ROM_ROUNDUP 0x80000000ULL | 146 | #define NETXEN_ROM_ROUNDUP 0x80000000ULL |
117 | 147 | ||
118 | /* | 148 | /* |
@@ -151,30 +181,38 @@ enum { | |||
151 | /* Host writes the following to notify that it has done the init-handshake */ | 181 | /* Host writes the following to notify that it has done the init-handshake */ |
152 | #define PHAN_INITIALIZE_ACK 0xf00f | 182 | #define PHAN_INITIALIZE_ACK 0xf00f |
153 | 183 | ||
154 | #define NUM_RCV_DESC_RINGS 2 /* No of Rcv Descriptor contexts */ | 184 | #define NUM_RCV_DESC_RINGS 3 /* No of Rcv Descriptor contexts */ |
155 | 185 | ||
156 | /* descriptor types */ | 186 | /* descriptor types */ |
157 | #define RCV_DESC_NORMAL 0x01 | 187 | #define RCV_DESC_NORMAL 0x01 |
158 | #define RCV_DESC_JUMBO 0x02 | 188 | #define RCV_DESC_JUMBO 0x02 |
189 | #define RCV_DESC_LRO 0x04 | ||
159 | #define RCV_DESC_NORMAL_CTXID 0 | 190 | #define RCV_DESC_NORMAL_CTXID 0 |
160 | #define RCV_DESC_JUMBO_CTXID 1 | 191 | #define RCV_DESC_JUMBO_CTXID 1 |
192 | #define RCV_DESC_LRO_CTXID 2 | ||
161 | 193 | ||
162 | #define RCV_DESC_TYPE(ID) \ | 194 | #define RCV_DESC_TYPE(ID) \ |
163 | ((ID == RCV_DESC_JUMBO_CTXID) ? RCV_DESC_JUMBO : RCV_DESC_NORMAL) | 195 | ((ID == RCV_DESC_JUMBO_CTXID) \ |
196 | ? RCV_DESC_JUMBO \ | ||
197 | : ((ID == RCV_DESC_LRO_CTXID) \ | ||
198 | ? RCV_DESC_LRO : \ | ||
199 | (RCV_DESC_NORMAL))) | ||
164 | 200 | ||
165 | #define MAX_CMD_DESCRIPTORS 1024 | 201 | #define MAX_CMD_DESCRIPTORS 1024 |
166 | #define MAX_RCV_DESCRIPTORS 32768 | 202 | #define MAX_RCV_DESCRIPTORS 32768 |
167 | #define MAX_JUMBO_RCV_DESCRIPTORS 1024 | 203 | #define MAX_JUMBO_RCV_DESCRIPTORS 4096 |
204 | #define MAX_LRO_RCV_DESCRIPTORS 2048 | ||
168 | #define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS | 205 | #define MAX_RCVSTATUS_DESCRIPTORS MAX_RCV_DESCRIPTORS |
169 | #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS | 206 | #define MAX_JUMBO_RCV_DESC MAX_JUMBO_RCV_DESCRIPTORS |
170 | #define MAX_RCV_DESC MAX_RCV_DESCRIPTORS | 207 | #define MAX_RCV_DESC MAX_RCV_DESCRIPTORS |
171 | #define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS | 208 | #define MAX_RCVSTATUS_DESC MAX_RCV_DESCRIPTORS |
172 | #define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS) | ||
173 | #define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8) | 209 | #define MAX_EPG_DESCRIPTORS (MAX_CMD_DESCRIPTORS * 8) |
174 | 210 | #define NUM_RCV_DESC (MAX_RCV_DESC + MAX_JUMBO_RCV_DESCRIPTORS + \ | |
211 | MAX_LRO_RCV_DESCRIPTORS) | ||
175 | #define MIN_TX_COUNT 4096 | 212 | #define MIN_TX_COUNT 4096 |
176 | #define MIN_RX_COUNT 4096 | 213 | #define MIN_RX_COUNT 4096 |
177 | 214 | #define NETXEN_CTX_SIGNATURE 0xdee0 | |
215 | #define NETXEN_RCV_PRODUCER(ringid) (ringid) | ||
178 | #define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */ | 216 | #define MAX_FRAME_SIZE 0x10000 /* 64K MAX size for LSO */ |
179 | 217 | ||
180 | #define PHAN_PEG_RCV_INITIALIZED 0xff01 | 218 | #define PHAN_PEG_RCV_INITIALIZED 0xff01 |
@@ -186,6 +224,67 @@ enum { | |||
186 | #define get_index_range(index,length,count) \ | 224 | #define get_index_range(index,length,count) \ |
187 | (((index) + (count)) & ((length) - 1)) | 225 | (((index) + (count)) & ((length) - 1)) |
188 | 226 | ||
227 | #define MPORT_SINGLE_FUNCTION_MODE 0x1111 | ||
228 | |||
229 | extern unsigned long long netxen_dma_mask; | ||
230 | |||
231 | /* | ||
232 | * NetXen host-peg signal message structure | ||
233 | * | ||
234 | * Bit 0-1 : peg_id => 0x2 for tx and 01 for rx | ||
235 | * Bit 2 : priv_id => must be 1 | ||
236 | * Bit 3-17 : count => for doorbell | ||
237 | * Bit 18-27 : ctx_id => Context id | ||
238 | * Bit 28-31 : opcode | ||
239 | */ | ||
240 | |||
241 | typedef u32 netxen_ctx_msg; | ||
242 | |||
243 | #define _netxen_set_bits(config_word, start, bits, val) {\ | ||
244 | unsigned long long mask = (((1ULL << (bits)) - 1) << (start)); \ | ||
245 | unsigned long long value = (val); \ | ||
246 | (config_word) &= ~mask; \ | ||
247 | (config_word) |= (((value) << (start)) & mask); \ | ||
248 | } | ||
249 | |||
250 | #define netxen_set_msg_peg_id(config_word, val) \ | ||
251 | _netxen_set_bits(config_word, 0, 2, val) | ||
252 | #define netxen_set_msg_privid(config_word) \ | ||
253 | set_bit(2, (unsigned long*)&config_word) | ||
254 | #define netxen_set_msg_count(config_word, val) \ | ||
255 | _netxen_set_bits(config_word, 3, 15, val) | ||
256 | #define netxen_set_msg_ctxid(config_word, val) \ | ||
257 | _netxen_set_bits(config_word, 18, 10, val) | ||
258 | #define netxen_set_msg_opcode(config_word, val) \ | ||
259 | _netxen_set_bits(config_word, 28, 4, val) | ||
260 | |||
261 | struct netxen_rcv_context { | ||
262 | u32 rcv_ring_addr_lo; | ||
263 | u32 rcv_ring_addr_hi; | ||
264 | u32 rcv_ring_size; | ||
265 | u32 rsrvd; | ||
266 | }; | ||
267 | |||
268 | struct netxen_ring_ctx { | ||
269 | |||
270 | /* one command ring */ | ||
271 | u64 cmd_consumer_offset; | ||
272 | u32 cmd_ring_addr_lo; | ||
273 | u32 cmd_ring_addr_hi; | ||
274 | u32 cmd_ring_size; | ||
275 | u32 rsrvd; | ||
276 | |||
277 | /* three receive rings */ | ||
278 | struct netxen_rcv_context rcv_ctx[3]; | ||
279 | |||
280 | /* one status ring */ | ||
281 | u32 sts_ring_addr_lo; | ||
282 | u32 sts_ring_addr_hi; | ||
283 | u32 sts_ring_size; | ||
284 | |||
285 | u32 ctx_id; | ||
286 | } __attribute__ ((aligned(64))); | ||
287 | |||
189 | /* | 288 | /* |
190 | * Following data structures describe the descriptors that will be used. | 289 | * Following data structures describe the descriptors that will be used. |
191 | * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when | 290 | * Added fileds of tcpHdrSize and ipHdrSize, The driver needs to do it only when |
@@ -203,22 +302,32 @@ enum { | |||
203 | #define FLAGS_IPSEC_SA_DELETE 0x08 | 302 | #define FLAGS_IPSEC_SA_DELETE 0x08 |
204 | #define FLAGS_VLAN_TAGGED 0x10 | 303 | #define FLAGS_VLAN_TAGGED 0x10 |
205 | 304 | ||
206 | #define CMD_DESC_TOTAL_LENGTH(cmd_desc) \ | 305 | #define netxen_set_cmd_desc_port(cmd_desc, var) \ |
207 | ((cmd_desc)->length_tcp_hdr & 0x00FFFFFF) | 306 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) |
208 | #define CMD_DESC_TCP_HDR_OFFSET(cmd_desc) \ | ||
209 | (((cmd_desc)->length_tcp_hdr >> 24) & 0x0FF) | ||
210 | #define CMD_DESC_PORT(cmd_desc) ((cmd_desc)->port_ctxid & 0x0F) | ||
211 | #define CMD_DESC_CTX_ID(cmd_desc) (((cmd_desc)->port_ctxid >> 4) & 0x0F) | ||
212 | 307 | ||
213 | #define CMD_DESC_TOTAL_LENGTH_WRT(cmd_desc, var) \ | 308 | #define netxen_set_cmd_desc_flags(cmd_desc, val) \ |
214 | ((cmd_desc)->length_tcp_hdr |= ((var) & 0x00FFFFFF)) | 309 | _netxen_set_bits((cmd_desc)->flags_opcode, 0, 7, val) |
215 | #define CMD_DESC_TCP_HDR_OFFSET_WRT(cmd_desc, var) \ | 310 | #define netxen_set_cmd_desc_opcode(cmd_desc, val) \ |
216 | ((cmd_desc)->length_tcp_hdr |= (((var) << 24) & 0xFF000000)) | 311 | _netxen_set_bits((cmd_desc)->flags_opcode, 7, 6, val) |
217 | #define CMD_DESC_PORT_WRT(cmd_desc, var) \ | 312 | |
218 | ((cmd_desc)->port_ctxid |= ((var) & 0x0F)) | 313 | #define netxen_set_cmd_desc_num_of_buff(cmd_desc, val) \ |
314 | _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 0, 8, val); | ||
315 | #define netxen_set_cmd_desc_totallength(cmd_desc, val) \ | ||
316 | _netxen_set_bits((cmd_desc)->num_of_buffers_total_length, 8, 24, val); | ||
317 | |||
318 | #define netxen_get_cmd_desc_opcode(cmd_desc) \ | ||
319 | (((cmd_desc)->flags_opcode >> 7) & 0x003F) | ||
320 | #define netxen_get_cmd_desc_totallength(cmd_desc) \ | ||
321 | (((cmd_desc)->num_of_buffers_total_length >> 8) & 0x0FFFFFF) | ||
219 | 322 | ||
220 | struct cmd_desc_type0 { | 323 | struct cmd_desc_type0 { |
221 | u64 netxen_next; /* for fragments handled by Phantom */ | 324 | u8 tcp_hdr_offset; /* For LSO only */ |
325 | u8 ip_hdr_offset; /* For LSO only */ | ||
326 | /* Bit pattern: 0-6 flags, 7-12 opcode, 13-15 unused */ | ||
327 | u16 flags_opcode; | ||
328 | /* Bit pattern: 0-7 total number of segments, | ||
329 | 8-31 Total size of the packet */ | ||
330 | u32 num_of_buffers_total_length; | ||
222 | union { | 331 | union { |
223 | struct { | 332 | struct { |
224 | u32 addr_low_part2; | 333 | u32 addr_low_part2; |
@@ -227,13 +336,6 @@ struct cmd_desc_type0 { | |||
227 | u64 addr_buffer2; | 336 | u64 addr_buffer2; |
228 | }; | 337 | }; |
229 | 338 | ||
230 | /* Bit pattern: 0-23 total length, 24-32 tcp header offset */ | ||
231 | u32 length_tcp_hdr; | ||
232 | u8 ip_hdr_offset; /* For LSO only */ | ||
233 | u8 num_of_buffers; /* total number of segments */ | ||
234 | u8 flags; /* as defined above */ | ||
235 | u8 opcode; | ||
236 | |||
237 | u16 reference_handle; /* changed to u16 to add mss */ | 339 | u16 reference_handle; /* changed to u16 to add mss */ |
238 | u16 mss; /* passed by NDIS_PACKET for LSO */ | 340 | u16 mss; /* passed by NDIS_PACKET for LSO */ |
239 | /* Bit pattern 0-3 port, 0-3 ctx id */ | 341 | /* Bit pattern 0-3 port, 0-3 ctx id */ |
@@ -248,7 +350,6 @@ struct cmd_desc_type0 { | |||
248 | }; | 350 | }; |
249 | u64 addr_buffer3; | 351 | u64 addr_buffer3; |
250 | }; | 352 | }; |
251 | |||
252 | union { | 353 | union { |
253 | struct { | 354 | struct { |
254 | u32 addr_low_part1; | 355 | u32 addr_low_part1; |
@@ -270,6 +371,8 @@ struct cmd_desc_type0 { | |||
270 | u64 addr_buffer4; | 371 | u64 addr_buffer4; |
271 | }; | 372 | }; |
272 | 373 | ||
374 | u64 unused; | ||
375 | |||
273 | } __attribute__ ((aligned(64))); | 376 | } __attribute__ ((aligned(64))); |
274 | 377 | ||
275 | /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ | 378 | /* Note: sizeof(rcv_desc) should always be a mutliple of 2 */ |
@@ -296,22 +399,49 @@ struct rcv_desc { | |||
296 | #define NETXEN_PROT_UNKNOWN (0) | 399 | #define NETXEN_PROT_UNKNOWN (0) |
297 | 400 | ||
298 | /* Note: sizeof(status_desc) should always be a mutliple of 2 */ | 401 | /* Note: sizeof(status_desc) should always be a mutliple of 2 */ |
299 | #define STATUS_DESC_PORT(status_desc) \ | 402 | |
300 | ((status_desc)->port_status_type_op & 0x0F) | 403 | #define netxen_get_sts_desc_lro_cnt(status_desc) \ |
301 | #define STATUS_DESC_STATUS(status_desc) \ | 404 | ((status_desc)->lro & 0x7F) |
302 | (((status_desc)->port_status_type_op >> 4) & 0x0F) | 405 | #define netxen_get_sts_desc_lro_last_frag(status_desc) \ |
303 | #define STATUS_DESC_TYPE(status_desc) \ | 406 | (((status_desc)->lro & 0x80) >> 7) |
304 | (((status_desc)->port_status_type_op >> 8) & 0x0F) | 407 | |
305 | #define STATUS_DESC_OPCODE(status_desc) \ | 408 | #define netxen_get_sts_port(status_desc) \ |
306 | (((status_desc)->port_status_type_op >> 12) & 0x0F) | 409 | ((status_desc)->status_desc_data & 0x0F) |
410 | #define netxen_get_sts_status(status_desc) \ | ||
411 | (((status_desc)->status_desc_data >> 4) & 0x0F) | ||
412 | #define netxen_get_sts_type(status_desc) \ | ||
413 | (((status_desc)->status_desc_data >> 8) & 0x0F) | ||
414 | #define netxen_get_sts_totallength(status_desc) \ | ||
415 | (((status_desc)->status_desc_data >> 12) & 0xFFFF) | ||
416 | #define netxen_get_sts_refhandle(status_desc) \ | ||
417 | (((status_desc)->status_desc_data >> 28) & 0xFFFF) | ||
418 | #define netxen_get_sts_prot(status_desc) \ | ||
419 | (((status_desc)->status_desc_data >> 44) & 0x0F) | ||
420 | #define netxen_get_sts_owner(status_desc) \ | ||
421 | (((status_desc)->status_desc_data >> 56) & 0x03) | ||
422 | #define netxen_get_sts_opcode(status_desc) \ | ||
423 | (((status_desc)->status_desc_data >> 58) & 0x03F) | ||
424 | |||
425 | #define netxen_clear_sts_owner(status_desc) \ | ||
426 | ((status_desc)->status_desc_data &= \ | ||
427 | ~(((unsigned long long)3) << 56 )) | ||
428 | #define netxen_set_sts_owner(status_desc, val) \ | ||
429 | ((status_desc)->status_desc_data |= \ | ||
430 | (((unsigned long long)((val) & 0x3)) << 56 )) | ||
307 | 431 | ||
308 | struct status_desc { | 432 | struct status_desc { |
309 | /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-15 opcode */ | 433 | /* Bit pattern: 0-3 port, 4-7 status, 8-11 type, 12-27 total_length |
310 | u16 port_status_type_op; | 434 | 28-43 reference_handle, 44-47 protocol, 48-52 unused |
311 | u16 total_length; /* NIC mode */ | 435 | 53-55 desc_cnt, 56-57 owner, 58-63 opcode |
312 | u16 reference_handle; /* handle for the associated packet */ | 436 | */ |
313 | /* Bit pattern: 0-1 owner, 2-5 protocol */ | 437 | u64 status_desc_data; |
314 | u16 owner; /* Owner of the descriptor */ | 438 | u32 hash_value; |
439 | u8 hash_type; | ||
440 | u8 msg_type; | ||
441 | u8 unused; | ||
442 | /* Bit pattern: 0-6 lro_count indicates frag sequence, | ||
443 | 7 last_frag indicates last frag */ | ||
444 | u8 lro; | ||
315 | } __attribute__ ((aligned(8))); | 445 | } __attribute__ ((aligned(8))); |
316 | 446 | ||
317 | enum { | 447 | enum { |
@@ -559,11 +689,12 @@ typedef enum { | |||
559 | #define PRIMARY_START (BOOTLD_START) | 689 | #define PRIMARY_START (BOOTLD_START) |
560 | #define FLASH_CRBINIT_SIZE (0x4000) | 690 | #define FLASH_CRBINIT_SIZE (0x4000) |
561 | #define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info)) | 691 | #define FLASH_BRDCFG_SIZE (sizeof(struct netxen_board_info)) |
562 | #define FLASH_USER_SIZE (sizeof(netxen_user_info)/sizeof(u32)) | 692 | #define FLASH_USER_SIZE (sizeof(struct netxen_user_info)/sizeof(u32)) |
563 | #define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START) | 693 | #define FLASH_SECONDARY_SIZE (USER_START-SECONDARY_START) |
564 | #define NUM_PRIMARY_SECTORS (0x20) | 694 | #define NUM_PRIMARY_SECTORS (0x20) |
565 | #define NUM_CONFIG_SECTORS (1) | 695 | #define NUM_CONFIG_SECTORS (1) |
566 | #define PFX "netxen: " | 696 | #define PFX "NetXen: " |
697 | extern char netxen_nic_driver_name[]; | ||
567 | 698 | ||
568 | /* Note: Make sure to not call this before adapter->port is valid */ | 699 | /* Note: Make sure to not call this before adapter->port is valid */ |
569 | #if !defined(NETXEN_DEBUG) | 700 | #if !defined(NETXEN_DEBUG) |
@@ -572,7 +703,7 @@ typedef enum { | |||
572 | #else | 703 | #else |
573 | #define DPRINTK(klevel, fmt, args...) do { \ | 704 | #define DPRINTK(klevel, fmt, args...) do { \ |
574 | printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\ | 705 | printk(KERN_##klevel PFX "%s: %s: " fmt, __FUNCTION__,\ |
575 | (adapter != NULL && adapter->port != NULL && \ | 706 | (adapter != NULL && \ |
576 | adapter->port[0] != NULL && \ | 707 | adapter->port[0] != NULL && \ |
577 | adapter->port[0]->netdev != NULL) ? \ | 708 | adapter->port[0]->netdev != NULL) ? \ |
578 | adapter->port[0]->netdev->name : NULL, \ | 709 | adapter->port[0]->netdev->name : NULL, \ |
@@ -609,7 +740,6 @@ struct netxen_cmd_buffer { | |||
609 | u8 frag_count; | 740 | u8 frag_count; |
610 | unsigned long time_stamp; | 741 | unsigned long time_stamp; |
611 | u32 state; | 742 | u32 state; |
612 | u32 no_of_descriptors; | ||
613 | }; | 743 | }; |
614 | 744 | ||
615 | /* In rx_buffer, we do not need multiple fragments as is a single buffer */ | 745 | /* In rx_buffer, we do not need multiple fragments as is a single buffer */ |
@@ -618,6 +748,9 @@ struct netxen_rx_buffer { | |||
618 | u64 dma; | 748 | u64 dma; |
619 | u16 ref_handle; | 749 | u16 ref_handle; |
620 | u16 state; | 750 | u16 state; |
751 | u32 lro_expected_frags; | ||
752 | u32 lro_current_frags; | ||
753 | u32 lro_length; | ||
621 | }; | 754 | }; |
622 | 755 | ||
623 | /* Board types */ | 756 | /* Board types */ |
@@ -633,6 +766,8 @@ struct netxen_hardware_context { | |||
633 | void __iomem *pci_base0; | 766 | void __iomem *pci_base0; |
634 | void __iomem *pci_base1; | 767 | void __iomem *pci_base1; |
635 | void __iomem *pci_base2; | 768 | void __iomem *pci_base2; |
769 | void __iomem *db_base; | ||
770 | unsigned long db_len; | ||
636 | 771 | ||
637 | u8 revision_id; | 772 | u8 revision_id; |
638 | u16 board_type; | 773 | u16 board_type; |
@@ -642,14 +777,13 @@ struct netxen_hardware_context { | |||
642 | u32 qg_linksup; | 777 | u32 qg_linksup; |
643 | /* Address of cmd ring in Phantom */ | 778 | /* Address of cmd ring in Phantom */ |
644 | struct cmd_desc_type0 *cmd_desc_head; | 779 | struct cmd_desc_type0 *cmd_desc_head; |
645 | char *pauseaddr; | ||
646 | struct pci_dev *cmd_desc_pdev; | 780 | struct pci_dev *cmd_desc_pdev; |
647 | dma_addr_t cmd_desc_phys_addr; | 781 | dma_addr_t cmd_desc_phys_addr; |
648 | dma_addr_t pause_physaddr; | ||
649 | struct pci_dev *pause_pdev; | ||
650 | struct netxen_adapter *adapter; | 782 | struct netxen_adapter *adapter; |
651 | }; | 783 | }; |
652 | 784 | ||
785 | #define RCV_RING_LRO RCV_DESC_LRO | ||
786 | |||
653 | #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ | 787 | #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ |
654 | #define ETHERNET_FCS_SIZE 4 | 788 | #define ETHERNET_FCS_SIZE 4 |
655 | 789 | ||
@@ -702,8 +836,13 @@ struct netxen_recv_context { | |||
702 | }; | 836 | }; |
703 | 837 | ||
704 | #define NETXEN_NIC_MSI_ENABLED 0x02 | 838 | #define NETXEN_NIC_MSI_ENABLED 0x02 |
839 | #define NETXEN_DMA_MASK 0xfffffffe | ||
840 | #define NETXEN_DB_MAPSIZE_BYTES 0x1000 | ||
705 | 841 | ||
706 | struct netxen_drvops; | 842 | struct netxen_dummy_dma { |
843 | void *addr; | ||
844 | dma_addr_t phys_addr; | ||
845 | }; | ||
707 | 846 | ||
708 | struct netxen_adapter { | 847 | struct netxen_adapter { |
709 | struct netxen_hardware_context ahw; | 848 | struct netxen_hardware_context ahw; |
@@ -720,12 +859,13 @@ struct netxen_adapter { | |||
720 | u32 curr_window; | 859 | u32 curr_window; |
721 | 860 | ||
722 | u32 cmd_producer; | 861 | u32 cmd_producer; |
723 | u32 cmd_consumer; | 862 | u32 *cmd_consumer; |
724 | 863 | ||
725 | u32 last_cmd_consumer; | 864 | u32 last_cmd_consumer; |
726 | u32 max_tx_desc_count; | 865 | u32 max_tx_desc_count; |
727 | u32 max_rx_desc_count; | 866 | u32 max_rx_desc_count; |
728 | u32 max_jumbo_rx_desc_count; | 867 | u32 max_jumbo_rx_desc_count; |
868 | u32 max_lro_rx_desc_count; | ||
729 | /* Num of instances active on cmd buffer ring */ | 869 | /* Num of instances active on cmd buffer ring */ |
730 | u32 proc_cmd_buf_counter; | 870 | u32 proc_cmd_buf_counter; |
731 | 871 | ||
@@ -747,8 +887,27 @@ struct netxen_adapter { | |||
747 | struct netxen_recv_context recv_ctx[MAX_RCV_CTX]; | 887 | struct netxen_recv_context recv_ctx[MAX_RCV_CTX]; |
748 | 888 | ||
749 | int is_up; | 889 | int is_up; |
750 | int work_done; | 890 | int number; |
751 | struct netxen_drvops *ops; | 891 | struct netxen_dummy_dma dummy_dma; |
892 | |||
893 | /* Context interface shared between card and host */ | ||
894 | struct netxen_ring_ctx *ctx_desc; | ||
895 | struct pci_dev *ctx_desc_pdev; | ||
896 | dma_addr_t ctx_desc_phys_addr; | ||
897 | int (*enable_phy_interrupts) (struct netxen_adapter *, int); | ||
898 | int (*disable_phy_interrupts) (struct netxen_adapter *, int); | ||
899 | void (*handle_phy_intr) (struct netxen_adapter *); | ||
900 | int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t); | ||
901 | int (*set_mtu) (struct netxen_port *, int); | ||
902 | int (*set_promisc) (struct netxen_adapter *, int, | ||
903 | netxen_niu_prom_mode_t); | ||
904 | int (*unset_promisc) (struct netxen_adapter *, int, | ||
905 | netxen_niu_prom_mode_t); | ||
906 | int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *); | ||
907 | int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val); | ||
908 | int (*init_port) (struct netxen_adapter *, int); | ||
909 | void (*init_niu) (struct netxen_adapter *); | ||
910 | int (*stop_port) (struct netxen_adapter *, int); | ||
752 | }; /* netxen_adapter structure */ | 911 | }; /* netxen_adapter structure */ |
753 | 912 | ||
754 | /* Max number of xmit producer threads that can run simultaneously */ | 913 | /* Max number of xmit producer threads that can run simultaneously */ |
@@ -830,25 +989,6 @@ static inline void __iomem *pci_base(struct netxen_adapter *adapter, | |||
830 | return NULL; | 989 | return NULL; |
831 | } | 990 | } |
832 | 991 | ||
833 | struct netxen_drvops { | ||
834 | int (*enable_phy_interrupts) (struct netxen_adapter *, int); | ||
835 | int (*disable_phy_interrupts) (struct netxen_adapter *, int); | ||
836 | void (*handle_phy_intr) (struct netxen_adapter *); | ||
837 | int (*macaddr_set) (struct netxen_port *, netxen_ethernet_macaddr_t); | ||
838 | int (*set_mtu) (struct netxen_port *, int); | ||
839 | int (*set_promisc) (struct netxen_adapter *, int, | ||
840 | netxen_niu_prom_mode_t); | ||
841 | int (*unset_promisc) (struct netxen_adapter *, int, | ||
842 | netxen_niu_prom_mode_t); | ||
843 | int (*phy_read) (struct netxen_adapter *, long phy, long reg, u32 *); | ||
844 | int (*phy_write) (struct netxen_adapter *, long phy, long reg, u32 val); | ||
845 | int (*init_port) (struct netxen_adapter *, int); | ||
846 | void (*init_niu) (struct netxen_adapter *); | ||
847 | int (*stop_port) (struct netxen_adapter *, int); | ||
848 | }; | ||
849 | |||
850 | extern char netxen_nic_driver_name[]; | ||
851 | |||
852 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 992 | int netxen_niu_xgbe_enable_phy_interrupts(struct netxen_adapter *adapter, |
853 | int port); | 993 | int port); |
854 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, | 994 | int netxen_niu_gbe_enable_phy_interrupts(struct netxen_adapter *adapter, |
@@ -887,10 +1027,20 @@ int netxen_nic_hw_read_wx(struct netxen_adapter *adapter, u64 off, void *data, | |||
887 | int len); | 1027 | int len); |
888 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, | 1028 | int netxen_nic_hw_write_wx(struct netxen_adapter *adapter, u64 off, void *data, |
889 | int len); | 1029 | int len); |
1030 | int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1031 | void *data, int len); | ||
1032 | int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1033 | void *data, int len); | ||
1034 | int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, | ||
1035 | u64 off, void *data, int size); | ||
1036 | int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter, | ||
1037 | u64 off, void *data, int size); | ||
890 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, | 1038 | void netxen_crb_writelit_adapter(struct netxen_adapter *adapter, |
891 | unsigned long off, int data); | 1039 | unsigned long off, int data); |
892 | 1040 | ||
893 | /* Functions from netxen_nic_init.c */ | 1041 | /* Functions from netxen_nic_init.c */ |
1042 | void netxen_free_adapter_offload(struct netxen_adapter *adapter); | ||
1043 | int netxen_initialize_adapter_offload(struct netxen_adapter *adapter); | ||
894 | void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); | 1044 | void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val); |
895 | void netxen_load_firmware(struct netxen_adapter *adapter); | 1045 | void netxen_load_firmware(struct netxen_adapter *adapter); |
896 | int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); | 1046 | int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose); |
@@ -925,7 +1075,9 @@ int netxen_nic_tx_has_work(struct netxen_adapter *adapter); | |||
925 | void netxen_watchdog_task(struct work_struct *work); | 1075 | void netxen_watchdog_task(struct work_struct *work); |
926 | void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, | 1076 | void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, |
927 | u32 ringid); | 1077 | u32 ringid); |
928 | void netxen_process_cmd_ring(unsigned long data); | 1078 | void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, u32 ctx, |
1079 | u32 ringid); | ||
1080 | int netxen_process_cmd_ring(unsigned long data); | ||
929 | u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); | 1081 | u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctx, int max); |
930 | void netxen_nic_set_multi(struct net_device *netdev); | 1082 | void netxen_nic_set_multi(struct net_device *netdev); |
931 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); | 1083 | int netxen_nic_change_mtu(struct net_device *netdev, int new_mtu); |
@@ -1019,7 +1171,6 @@ static inline void get_brd_name_by_type(u32 type, char *name) | |||
1019 | 1171 | ||
1020 | int netxen_is_flash_supported(struct netxen_adapter *adapter); | 1172 | int netxen_is_flash_supported(struct netxen_adapter *adapter); |
1021 | int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]); | 1173 | int netxen_get_flash_mac_addr(struct netxen_adapter *adapter, u64 mac[]); |
1022 | |||
1023 | extern void netxen_change_ringparam(struct netxen_adapter *adapter); | 1174 | extern void netxen_change_ringparam(struct netxen_adapter *adapter); |
1024 | extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, | 1175 | extern int netxen_rom_fast_read(struct netxen_adapter *adapter, int addr, |
1025 | int *valp); | 1176 | int *valp); |
diff --git a/drivers/net/netxen/netxen_nic_ethtool.c b/drivers/net/netxen/netxen_nic_ethtool.c index 9a914aeba5bc..2ab4885cc950 100644 --- a/drivers/net/netxen/netxen_nic_ethtool.c +++ b/drivers/net/netxen/netxen_nic_ethtool.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
8 | * of the License, or (at your option) any later version. | 8 | * of the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, but | 10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -118,7 +118,7 @@ netxen_nic_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *drvinfo) | |||
118 | u32 fw_minor = 0; | 118 | u32 fw_minor = 0; |
119 | u32 fw_build = 0; | 119 | u32 fw_build = 0; |
120 | 120 | ||
121 | strncpy(drvinfo->driver, "netxen_nic", 32); | 121 | strncpy(drvinfo->driver, netxen_nic_driver_name, 32); |
122 | strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); | 122 | strncpy(drvinfo->version, NETXEN_NIC_LINUX_VERSIONID, 32); |
123 | fw_major = readl(NETXEN_CRB_NORMALIZE(adapter, | 123 | fw_major = readl(NETXEN_CRB_NORMALIZE(adapter, |
124 | NETXEN_FW_VERSION_MAJOR)); | 124 | NETXEN_FW_VERSION_MAJOR)); |
@@ -210,7 +210,6 @@ netxen_nic_get_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
210 | printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", | 210 | printk(KERN_ERR "netxen-nic: Unsupported board model %d\n", |
211 | (netxen_brdtype_t) boardinfo->board_type); | 211 | (netxen_brdtype_t) boardinfo->board_type); |
212 | return -EIO; | 212 | return -EIO; |
213 | |||
214 | } | 213 | } |
215 | 214 | ||
216 | return 0; | 215 | return 0; |
@@ -226,18 +225,18 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
226 | /* read which mode */ | 225 | /* read which mode */ |
227 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 226 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
228 | /* autonegotiation */ | 227 | /* autonegotiation */ |
229 | if (adapter->ops->phy_write | 228 | if (adapter->phy_write |
230 | && adapter->ops->phy_write(adapter, port->portnum, | 229 | && adapter->phy_write(adapter, port->portnum, |
231 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, | 230 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
232 | (__le32) ecmd->autoneg) != 0) | 231 | (__le32) ecmd->autoneg) != 0) |
233 | return -EIO; | 232 | return -EIO; |
234 | else | 233 | else |
235 | port->link_autoneg = ecmd->autoneg; | 234 | port->link_autoneg = ecmd->autoneg; |
236 | 235 | ||
237 | if (adapter->ops->phy_read | 236 | if (adapter->phy_read |
238 | && adapter->ops->phy_read(adapter, port->portnum, | 237 | && adapter->phy_read(adapter, port->portnum, |
239 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 238 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
240 | &status) != 0) | 239 | &status) != 0) |
241 | return -EIO; | 240 | return -EIO; |
242 | 241 | ||
243 | /* speed */ | 242 | /* speed */ |
@@ -257,10 +256,10 @@ netxen_nic_set_settings(struct net_device *dev, struct ethtool_cmd *ecmd) | |||
257 | netxen_clear_phy_duplex(status); | 256 | netxen_clear_phy_duplex(status); |
258 | if (ecmd->duplex == DUPLEX_FULL) | 257 | if (ecmd->duplex == DUPLEX_FULL) |
259 | netxen_set_phy_duplex(status); | 258 | netxen_set_phy_duplex(status); |
260 | if (adapter->ops->phy_write | 259 | if (adapter->phy_write |
261 | && adapter->ops->phy_write(adapter, port->portnum, | 260 | && adapter->phy_write(adapter, port->portnum, |
262 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 261 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
263 | *((int *)&status)) != 0) | 262 | *((int *)&status)) != 0) |
264 | return -EIO; | 263 | return -EIO; |
265 | else { | 264 | else { |
266 | port->link_speed = ecmd->speed; | 265 | port->link_speed = ecmd->speed; |
@@ -422,10 +421,10 @@ static u32 netxen_nic_get_link(struct net_device *dev) | |||
422 | 421 | ||
423 | /* read which mode */ | 422 | /* read which mode */ |
424 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { | 423 | if (adapter->ahw.board_type == NETXEN_NIC_GBE) { |
425 | if (adapter->ops->phy_read | 424 | if (adapter->phy_read |
426 | && adapter->ops->phy_read(adapter, port->portnum, | 425 | && adapter->phy_read(adapter, port->portnum, |
427 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 426 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
428 | &status) != 0) | 427 | &status) != 0) |
429 | return -EIO; | 428 | return -EIO; |
430 | else | 429 | else |
431 | return (netxen_get_phy_link(status)); | 430 | return (netxen_get_phy_link(status)); |
@@ -460,20 +459,22 @@ netxen_nic_get_ringparam(struct net_device *dev, struct ethtool_ringparam *ring) | |||
460 | { | 459 | { |
461 | struct netxen_port *port = netdev_priv(dev); | 460 | struct netxen_port *port = netdev_priv(dev); |
462 | struct netxen_adapter *adapter = port->adapter; | 461 | struct netxen_adapter *adapter = port->adapter; |
463 | int i, j; | 462 | int i; |
464 | 463 | ||
465 | ring->rx_pending = 0; | 464 | ring->rx_pending = 0; |
465 | ring->rx_jumbo_pending = 0; | ||
466 | for (i = 0; i < MAX_RCV_CTX; ++i) { | 466 | for (i = 0; i < MAX_RCV_CTX; ++i) { |
467 | for (j = 0; j < NUM_RCV_DESC_RINGS; j++) | 467 | ring->rx_pending += adapter->recv_ctx[i]. |
468 | ring->rx_pending += | 468 | rcv_desc[RCV_DESC_NORMAL_CTXID].rcv_pending; |
469 | adapter->recv_ctx[i].rcv_desc[j].rcv_pending; | 469 | ring->rx_jumbo_pending += adapter->recv_ctx[i]. |
470 | rcv_desc[RCV_DESC_JUMBO_CTXID].rcv_pending; | ||
470 | } | 471 | } |
471 | 472 | ||
472 | ring->rx_max_pending = adapter->max_rx_desc_count; | 473 | ring->rx_max_pending = adapter->max_rx_desc_count; |
473 | ring->tx_max_pending = adapter->max_tx_desc_count; | 474 | ring->tx_max_pending = adapter->max_tx_desc_count; |
475 | ring->rx_jumbo_max_pending = adapter->max_jumbo_rx_desc_count; | ||
474 | ring->rx_mini_max_pending = 0; | 476 | ring->rx_mini_max_pending = 0; |
475 | ring->rx_mini_pending = 0; | 477 | ring->rx_mini_pending = 0; |
476 | ring->rx_jumbo_max_pending = 0; | ||
477 | ring->rx_jumbo_pending = 0; | 478 | ring->rx_jumbo_pending = 0; |
478 | } | 479 | } |
479 | 480 | ||
@@ -526,10 +527,10 @@ netxen_nic_set_pauseparam(struct net_device *dev, | |||
526 | *(u32 *) (&val)); | 527 | *(u32 *) (&val)); |
527 | /* set autoneg */ | 528 | /* set autoneg */ |
528 | autoneg = pause->autoneg; | 529 | autoneg = pause->autoneg; |
529 | if (adapter->ops->phy_write | 530 | if (adapter->phy_write |
530 | && adapter->ops->phy_write(adapter, port->portnum, | 531 | && adapter->phy_write(adapter, port->portnum, |
531 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, | 532 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
532 | (__le32) autoneg) != 0) | 533 | (__le32) autoneg) != 0) |
533 | return -EIO; | 534 | return -EIO; |
534 | else { | 535 | else { |
535 | port->link_autoneg = pause->autoneg; | 536 | port->link_autoneg = pause->autoneg; |
diff --git a/drivers/net/netxen/netxen_nic_hdr.h b/drivers/net/netxen/netxen_nic_hdr.h index 72c6ec4ee2a0..fe8b675f9e72 100644 --- a/drivers/net/netxen/netxen_nic_hdr.h +++ b/drivers/net/netxen/netxen_nic_hdr.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
@@ -16,10 +16,10 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
diff --git a/drivers/net/netxen/netxen_nic_hw.c b/drivers/net/netxen/netxen_nic_hw.c index 105c24f0ad4c..9147b6048dfb 100644 --- a/drivers/net/netxen/netxen_nic_hw.c +++ b/drivers/net/netxen/netxen_nic_hw.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
@@ -16,10 +16,10 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -42,7 +42,7 @@ | |||
42 | 42 | ||
43 | #define NETXEN_FLASH_BASE (BOOTLD_START) | 43 | #define NETXEN_FLASH_BASE (BOOTLD_START) |
44 | #define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE) | 44 | #define NETXEN_PHANTOM_MEM_BASE (NETXEN_FLASH_BASE) |
45 | #define NETXEN_MAX_MTU 8000 | 45 | #define NETXEN_MAX_MTU 8000 + NETXEN_ENET_HEADER_SIZE + NETXEN_ETH_FCS_SIZE |
46 | #define NETXEN_MIN_MTU 64 | 46 | #define NETXEN_MIN_MTU 64 |
47 | #define NETXEN_ETH_FCS_SIZE 4 | 47 | #define NETXEN_ETH_FCS_SIZE 4 |
48 | #define NETXEN_ENET_HEADER_SIZE 14 | 48 | #define NETXEN_ENET_HEADER_SIZE 14 |
@@ -81,8 +81,8 @@ int netxen_nic_set_mac(struct net_device *netdev, void *p) | |||
81 | DPRINTK(INFO, "valid ether addr\n"); | 81 | DPRINTK(INFO, "valid ether addr\n"); |
82 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); | 82 | memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); |
83 | 83 | ||
84 | if (adapter->ops->macaddr_set) | 84 | if (adapter->macaddr_set) |
85 | adapter->ops->macaddr_set(port, addr->sa_data); | 85 | adapter->macaddr_set(port, addr->sa_data); |
86 | 86 | ||
87 | return 0; | 87 | return 0; |
88 | } | 88 | } |
@@ -99,17 +99,17 @@ void netxen_nic_set_multi(struct net_device *netdev) | |||
99 | 99 | ||
100 | mc_ptr = netdev->mc_list; | 100 | mc_ptr = netdev->mc_list; |
101 | if (netdev->flags & IFF_PROMISC) { | 101 | if (netdev->flags & IFF_PROMISC) { |
102 | if (adapter->ops->set_promisc) | 102 | if (adapter->set_promisc) |
103 | adapter->ops->set_promisc(adapter, | 103 | adapter->set_promisc(adapter, |
104 | port->portnum, | 104 | port->portnum, |
105 | NETXEN_NIU_PROMISC_MODE); | 105 | NETXEN_NIU_PROMISC_MODE); |
106 | } else { | 106 | } else { |
107 | if (adapter->ops->unset_promisc && | 107 | if (adapter->unset_promisc && |
108 | adapter->ahw.boardcfg.board_type | 108 | adapter->ahw.boardcfg.board_type |
109 | != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) | 109 | != NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) |
110 | adapter->ops->unset_promisc(adapter, | 110 | adapter->unset_promisc(adapter, |
111 | port->portnum, | 111 | port->portnum, |
112 | NETXEN_NIU_NON_PROMISC_MODE); | 112 | NETXEN_NIU_NON_PROMISC_MODE); |
113 | } | 113 | } |
114 | if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { | 114 | if (adapter->ahw.board_type == NETXEN_NIC_XGBE) { |
115 | netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03); | 115 | netxen_nic_mcr_set_mode_select(netxen_mac_addr_cntl_data, 0x03); |
@@ -160,8 +160,8 @@ int netxen_nic_change_mtu(struct net_device *netdev, int mtu) | |||
160 | return -EINVAL; | 160 | return -EINVAL; |
161 | } | 161 | } |
162 | 162 | ||
163 | if (adapter->ops->set_mtu) | 163 | if (adapter->set_mtu) |
164 | adapter->ops->set_mtu(port, mtu); | 164 | adapter->set_mtu(port, mtu); |
165 | netdev->mtu = mtu; | 165 | netdev->mtu = mtu; |
166 | 166 | ||
167 | return 0; | 167 | return 0; |
@@ -176,22 +176,18 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
176 | struct netxen_hardware_context *hw = &adapter->ahw; | 176 | struct netxen_hardware_context *hw = &adapter->ahw; |
177 | u32 state = 0; | 177 | u32 state = 0; |
178 | void *addr; | 178 | void *addr; |
179 | void *pause_addr; | ||
180 | int loops = 0, err = 0; | 179 | int loops = 0, err = 0; |
181 | int ctx, ring; | 180 | int ctx, ring; |
182 | u32 card_cmdring = 0; | 181 | u32 card_cmdring = 0; |
183 | struct netxen_rcv_desc_crb *rcv_desc_crb = NULL; | ||
184 | struct netxen_recv_context *recv_ctx; | 182 | struct netxen_recv_context *recv_ctx; |
185 | struct netxen_rcv_desc_ctx *rcv_desc; | 183 | struct netxen_rcv_desc_ctx *rcv_desc; |
186 | 184 | ||
187 | DPRINTK(INFO, "crb_base: %lx %lx", NETXEN_PCI_CRBSPACE, | 185 | DPRINTK(INFO, "crb_base: %lx %x", NETXEN_PCI_CRBSPACE, |
188 | PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE)); | 186 | PCI_OFFSET_SECOND_RANGE(adapter, NETXEN_PCI_CRBSPACE)); |
189 | DPRINTK(INFO, "cam base: %lx %lx", NETXEN_CRB_CAM, | 187 | DPRINTK(INFO, "cam base: %lx %x", NETXEN_CRB_CAM, |
190 | pci_base_offset(adapter, NETXEN_CRB_CAM)); | 188 | pci_base_offset(adapter, NETXEN_CRB_CAM)); |
191 | DPRINTK(INFO, "cam RAM: %lx %lx", NETXEN_CAM_RAM_BASE, | 189 | DPRINTK(INFO, "cam RAM: %lx %x", NETXEN_CAM_RAM_BASE, |
192 | pci_base_offset(adapter, NETXEN_CAM_RAM_BASE)); | 190 | pci_base_offset(adapter, NETXEN_CAM_RAM_BASE)); |
193 | DPRINTK(INFO, "NIC base:%lx %lx\n", NIC_CRB_BASE_PORT1, | ||
194 | pci_base_offset(adapter, NIC_CRB_BASE_PORT1)); | ||
195 | 191 | ||
196 | /* Window 1 call */ | 192 | /* Window 1 call */ |
197 | card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING)); | 193 | card_cmdring = readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_CMDRING)); |
@@ -226,33 +222,42 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
226 | DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n"); | 222 | DPRINTK(INFO, "Recieve Peg ready too. starting stuff\n"); |
227 | 223 | ||
228 | addr = netxen_alloc(adapter->ahw.pdev, | 224 | addr = netxen_alloc(adapter->ahw.pdev, |
229 | sizeof(struct cmd_desc_type0) * | 225 | sizeof(struct netxen_ring_ctx) + |
230 | adapter->max_tx_desc_count, | 226 | sizeof(uint32_t), |
231 | &hw->cmd_desc_phys_addr, &hw->cmd_desc_pdev); | 227 | (dma_addr_t *) & adapter->ctx_desc_phys_addr, |
228 | &adapter->ctx_desc_pdev); | ||
232 | 229 | ||
230 | printk("ctx_desc_phys_addr: 0x%llx\n", | ||
231 | (u64) adapter->ctx_desc_phys_addr); | ||
233 | if (addr == NULL) { | 232 | if (addr == NULL) { |
234 | DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); | 233 | DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); |
235 | return -ENOMEM; | 234 | err = -ENOMEM; |
235 | return err; | ||
236 | } | 236 | } |
237 | memset(addr, 0, sizeof(struct netxen_ring_ctx)); | ||
238 | adapter->ctx_desc = (struct netxen_ring_ctx *)addr; | ||
239 | adapter->ctx_desc->cmd_consumer_offset = adapter->ctx_desc_phys_addr | ||
240 | + sizeof(struct netxen_ring_ctx); | ||
241 | adapter->cmd_consumer = (uint32_t *) (((char *)addr) + | ||
242 | sizeof(struct netxen_ring_ctx)); | ||
243 | |||
244 | addr = pci_alloc_consistent(adapter->ahw.pdev, | ||
245 | sizeof(struct cmd_desc_type0) * | ||
246 | adapter->max_tx_desc_count, | ||
247 | (dma_addr_t *) & hw->cmd_desc_phys_addr); | ||
248 | printk("cmd_desc_phys_addr: 0x%llx\n", (u64) hw->cmd_desc_phys_addr); | ||
237 | 249 | ||
238 | pause_addr = netxen_alloc(adapter->ahw.pdev, 512, | 250 | if (addr == NULL) { |
239 | (dma_addr_t *) & hw->pause_physaddr, | 251 | DPRINTK(ERR, "bad return from pci_alloc_consistent\n"); |
240 | &hw->pause_pdev); | 252 | netxen_free_hw_resources(adapter); |
241 | if (pause_addr == NULL) { | ||
242 | DPRINTK(1, ERR, "bad return from pci_alloc_consistent\n"); | ||
243 | return -ENOMEM; | 253 | return -ENOMEM; |
244 | } | 254 | } |
245 | 255 | ||
246 | hw->pauseaddr = (char *)pause_addr; | 256 | adapter->ctx_desc->cmd_ring_addr_lo = |
247 | { | 257 | hw->cmd_desc_phys_addr & 0xffffffffUL; |
248 | u64 *ptr = (u64 *) pause_addr; | 258 | adapter->ctx_desc->cmd_ring_addr_hi = |
249 | *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR; | 259 | ((u64) hw->cmd_desc_phys_addr >> 32); |
250 | *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR; | 260 | adapter->ctx_desc->cmd_ring_size = adapter->max_tx_desc_count; |
251 | *ptr++ = NETXEN_NIC_UNIT_PAUSE_ADDR; | ||
252 | *ptr++ = NETXEN_NIC_ZERO_PAUSE_ADDR; | ||
253 | *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR1; | ||
254 | *ptr++ = NETXEN_NIC_EPG_PAUSE_ADDR2; | ||
255 | } | ||
256 | 261 | ||
257 | hw->cmd_desc_head = (struct cmd_desc_type0 *)addr; | 262 | hw->cmd_desc_head = (struct cmd_desc_type0 *)addr; |
258 | 263 | ||
@@ -273,6 +278,12 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
273 | return err; | 278 | return err; |
274 | } | 279 | } |
275 | rcv_desc->desc_head = (struct rcv_desc *)addr; | 280 | rcv_desc->desc_head = (struct rcv_desc *)addr; |
281 | adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_lo = | ||
282 | rcv_desc->phys_addr & 0xffffffffUL; | ||
283 | adapter->ctx_desc->rcv_ctx[ring].rcv_ring_addr_hi = | ||
284 | ((u64) rcv_desc->phys_addr >> 32); | ||
285 | adapter->ctx_desc->rcv_ctx[ring].rcv_ring_size = | ||
286 | rcv_desc->max_rx_desc_count; | ||
276 | } | 287 | } |
277 | 288 | ||
278 | addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE, | 289 | addr = netxen_alloc(adapter->ahw.pdev, STATUS_DESC_RINGSIZE, |
@@ -286,47 +297,21 @@ int netxen_nic_hw_resources(struct netxen_adapter *adapter) | |||
286 | return err; | 297 | return err; |
287 | } | 298 | } |
288 | recv_ctx->rcv_status_desc_head = (struct status_desc *)addr; | 299 | recv_ctx->rcv_status_desc_head = (struct status_desc *)addr; |
289 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { | 300 | adapter->ctx_desc->sts_ring_addr_lo = |
290 | rcv_desc = &recv_ctx->rcv_desc[ring]; | 301 | recv_ctx->rcv_status_desc_phys_addr & 0xffffffffUL; |
291 | rcv_desc_crb = | 302 | adapter->ctx_desc->sts_ring_addr_hi = |
292 | &recv_crb_registers[ctx].rcv_desc_crb[ring]; | 303 | ((u64) recv_ctx->rcv_status_desc_phys_addr >> 32); |
293 | DPRINTK(INFO, "ring #%d crb global ring reg 0x%x\n", | 304 | adapter->ctx_desc->sts_ring_size = adapter->max_rx_desc_count; |
294 | ring, rcv_desc_crb->crb_globalrcv_ring); | ||
295 | /* Window = 1 */ | ||
296 | writel(lower32(rcv_desc->phys_addr), | ||
297 | NETXEN_CRB_NORMALIZE(adapter, | ||
298 | rcv_desc_crb-> | ||
299 | crb_globalrcv_ring)); | ||
300 | DPRINTK(INFO, "GLOBAL_RCV_RING ctx %d, addr 0x%x" | ||
301 | " val 0x%llx," | ||
302 | " virt %p\n", ctx, | ||
303 | rcv_desc_crb->crb_globalrcv_ring, | ||
304 | (unsigned long long)rcv_desc->phys_addr, | ||
305 | +rcv_desc->desc_head); | ||
306 | } | ||
307 | 305 | ||
308 | /* Window = 1 */ | ||
309 | writel(lower32(recv_ctx->rcv_status_desc_phys_addr), | ||
310 | NETXEN_CRB_NORMALIZE(adapter, | ||
311 | recv_crb_registers[ctx]. | ||
312 | crb_rcvstatus_ring)); | ||
313 | DPRINTK(INFO, "RCVSTATUS_RING, ctx %d, addr 0x%x," | ||
314 | " val 0x%x,virt%p\n", | ||
315 | ctx, | ||
316 | recv_crb_registers[ctx].crb_rcvstatus_ring, | ||
317 | (unsigned long long)recv_ctx->rcv_status_desc_phys_addr, | ||
318 | recv_ctx->rcv_status_desc_head); | ||
319 | } | 306 | } |
320 | /* Window = 1 */ | 307 | /* Window = 1 */ |
321 | writel(lower32(hw->pause_physaddr), | 308 | |
322 | NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_LO)); | 309 | writel(lower32(adapter->ctx_desc_phys_addr), |
323 | writel(upper32(hw->pause_physaddr), | 310 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_LO)); |
324 | NETXEN_CRB_NORMALIZE(adapter, CRB_PAUSE_ADDR_HI)); | 311 | writel(upper32(adapter->ctx_desc_phys_addr), |
325 | 312 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_ADDR_REG_HI)); | |
326 | writel(lower32(hw->cmd_desc_phys_addr), | 313 | writel(NETXEN_CTX_SIGNATURE, |
327 | NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); | 314 | NETXEN_CRB_NORMALIZE(adapter, CRB_CTX_SIGNATURE_REG)); |
328 | writel(upper32(hw->cmd_desc_phys_addr), | ||
329 | NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_HI)); | ||
330 | return err; | 315 | return err; |
331 | } | 316 | } |
332 | 317 | ||
@@ -336,6 +321,15 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) | |||
336 | struct netxen_rcv_desc_ctx *rcv_desc; | 321 | struct netxen_rcv_desc_ctx *rcv_desc; |
337 | int ctx, ring; | 322 | int ctx, ring; |
338 | 323 | ||
324 | if (adapter->ctx_desc != NULL) { | ||
325 | pci_free_consistent(adapter->ctx_desc_pdev, | ||
326 | sizeof(struct netxen_ring_ctx) + | ||
327 | sizeof(uint32_t), | ||
328 | adapter->ctx_desc, | ||
329 | adapter->ctx_desc_phys_addr); | ||
330 | adapter->ctx_desc = NULL; | ||
331 | } | ||
332 | |||
339 | if (adapter->ahw.cmd_desc_head != NULL) { | 333 | if (adapter->ahw.cmd_desc_head != NULL) { |
340 | pci_free_consistent(adapter->ahw.cmd_desc_pdev, | 334 | pci_free_consistent(adapter->ahw.cmd_desc_pdev, |
341 | sizeof(struct cmd_desc_type0) * | 335 | sizeof(struct cmd_desc_type0) * |
@@ -344,11 +338,9 @@ void netxen_free_hw_resources(struct netxen_adapter *adapter) | |||
344 | adapter->ahw.cmd_desc_phys_addr); | 338 | adapter->ahw.cmd_desc_phys_addr); |
345 | adapter->ahw.cmd_desc_head = NULL; | 339 | adapter->ahw.cmd_desc_head = NULL; |
346 | } | 340 | } |
347 | if (adapter->ahw.pauseaddr != NULL) { | 341 | /* Special handling: there are 2 ports on this board */ |
348 | pci_free_consistent(adapter->ahw.pause_pdev, 512, | 342 | if (adapter->ahw.boardcfg.board_type == NETXEN_BRDTYPE_P2_SB31_10G_IMEZ) { |
349 | adapter->ahw.pauseaddr, | 343 | adapter->ahw.max_ports = 2; |
350 | adapter->ahw.pause_physaddr); | ||
351 | adapter->ahw.pauseaddr = NULL; | ||
352 | } | 344 | } |
353 | 345 | ||
354 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { | 346 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
@@ -383,19 +375,22 @@ void netxen_tso_check(struct netxen_adapter *adapter, | |||
383 | desc->total_hdr_length = sizeof(struct ethhdr) + | 375 | desc->total_hdr_length = sizeof(struct ethhdr) + |
384 | ((skb->nh.iph)->ihl * sizeof(u32)) + | 376 | ((skb->nh.iph)->ihl * sizeof(u32)) + |
385 | ((skb->h.th)->doff * sizeof(u32)); | 377 | ((skb->h.th)->doff * sizeof(u32)); |
386 | desc->opcode = TX_TCP_LSO; | 378 | netxen_set_cmd_desc_opcode(desc, TX_TCP_LSO); |
387 | } else if (skb->ip_summed == CHECKSUM_COMPLETE) { | 379 | } else if (skb->ip_summed == CHECKSUM_COMPLETE) { |
388 | if (skb->nh.iph->protocol == IPPROTO_TCP) { | 380 | if (skb->nh.iph->protocol == IPPROTO_TCP) { |
389 | desc->opcode = TX_TCP_PKT; | 381 | netxen_set_cmd_desc_opcode(desc, TX_TCP_PKT); |
390 | } else if (skb->nh.iph->protocol == IPPROTO_UDP) { | 382 | } else if (skb->nh.iph->protocol == IPPROTO_UDP) { |
391 | desc->opcode = TX_UDP_PKT; | 383 | netxen_set_cmd_desc_opcode(desc, TX_UDP_PKT); |
392 | } else { | 384 | } else { |
393 | return; | 385 | return; |
394 | } | 386 | } |
395 | } | 387 | } |
396 | adapter->stats.xmitcsummed++; | 388 | adapter->stats.xmitcsummed++; |
397 | CMD_DESC_TCP_HDR_OFFSET_WRT(desc, skb->h.raw - skb->data); | 389 | desc->tcp_hdr_offset = skb->h.raw - skb->data; |
398 | desc->length_tcp_hdr = cpu_to_le32(desc->length_tcp_hdr); | 390 | netxen_set_cmd_desc_totallength(desc, |
391 | cpu_to_le32 | ||
392 | (netxen_get_cmd_desc_totallength | ||
393 | (desc))); | ||
399 | desc->ip_hdr_offset = skb->nh.raw - skb->data; | 394 | desc->ip_hdr_offset = skb->nh.raw - skb->data; |
400 | } | 395 | } |
401 | 396 | ||
@@ -648,7 +643,7 @@ void netxen_nic_reg_write(struct netxen_adapter *adapter, u64 off, u32 val) | |||
648 | 643 | ||
649 | addr = NETXEN_CRB_NORMALIZE(adapter, off); | 644 | addr = NETXEN_CRB_NORMALIZE(adapter, off); |
650 | DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n", | 645 | DPRINTK(INFO, "writing to base %lx offset %llx addr %p data %x\n", |
651 | pci_base(adapter, off), off, addr); | 646 | pci_base(adapter, off), off, addr, val); |
652 | writel(val, addr); | 647 | writel(val, addr); |
653 | 648 | ||
654 | } | 649 | } |
@@ -660,7 +655,7 @@ int netxen_nic_reg_read(struct netxen_adapter *adapter, u64 off) | |||
660 | 655 | ||
661 | addr = NETXEN_CRB_NORMALIZE(adapter, off); | 656 | addr = NETXEN_CRB_NORMALIZE(adapter, off); |
662 | DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n", | 657 | DPRINTK(INFO, "reading from base %lx offset %llx addr %p\n", |
663 | adapter->ahw.pci_base, off, addr); | 658 | pci_base(adapter, off), off, addr); |
664 | val = readl(addr); | 659 | val = readl(addr); |
665 | writel(val, addr); | 660 | writel(val, addr); |
666 | 661 | ||
@@ -848,8 +843,8 @@ void netxen_nic_stop_all_ports(struct netxen_adapter *adapter) | |||
848 | 843 | ||
849 | for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) { | 844 | for (port_nr = 0; port_nr < adapter->ahw.max_ports; port_nr++) { |
850 | port = adapter->port[port_nr]; | 845 | port = adapter->port[port_nr]; |
851 | if (adapter->ops->stop_port) | 846 | if (adapter->stop_port) |
852 | adapter->ops->stop_port(adapter, port->portnum); | 847 | adapter->stop_port(adapter, port->portnum); |
853 | } | 848 | } |
854 | } | 849 | } |
855 | 850 | ||
@@ -873,13 +868,13 @@ void netxen_nic_set_link_parameters(struct netxen_port *port) | |||
873 | { | 868 | { |
874 | struct netxen_adapter *adapter = port->adapter; | 869 | struct netxen_adapter *adapter = port->adapter; |
875 | __le32 status; | 870 | __le32 status; |
876 | u16 autoneg; | 871 | __le32 autoneg; |
877 | __le32 mode; | 872 | __le32 mode; |
878 | 873 | ||
879 | netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode); | 874 | netxen_nic_read_w0(adapter, NETXEN_NIU_MODE, &mode); |
880 | if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ | 875 | if (netxen_get_niu_enable_ge(mode)) { /* Gb 10/100/1000 Mbps mode */ |
881 | if (adapter->ops->phy_read | 876 | if (adapter->phy_read |
882 | && adapter->ops-> | 877 | && adapter-> |
883 | phy_read(adapter, port->portnum, | 878 | phy_read(adapter, port->portnum, |
884 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 879 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
885 | &status) == 0) { | 880 | &status) == 0) { |
@@ -909,11 +904,11 @@ void netxen_nic_set_link_parameters(struct netxen_port *port) | |||
909 | port->link_duplex = -1; | 904 | port->link_duplex = -1; |
910 | break; | 905 | break; |
911 | } | 906 | } |
912 | if (adapter->ops->phy_read | 907 | if (adapter->phy_read |
913 | && adapter->ops-> | 908 | && adapter-> |
914 | phy_read(adapter, port->portnum, | 909 | phy_read(adapter, port->portnum, |
915 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, | 910 | NETXEN_NIU_GB_MII_MGMT_ADDR_AUTONEG, |
916 | (__le32 *) & autoneg) != 0) | 911 | &autoneg) != 0) |
917 | port->link_autoneg = autoneg; | 912 | port->link_autoneg = autoneg; |
918 | } else | 913 | } else |
919 | goto link_down; | 914 | goto link_down; |
@@ -1008,3 +1003,291 @@ int netxen_crb_read_val(struct netxen_adapter *adapter, unsigned long off) | |||
1008 | netxen_nic_hw_read_wx(adapter, off, &data, 4); | 1003 | netxen_nic_hw_read_wx(adapter, off, &data, 4); |
1009 | return data; | 1004 | return data; |
1010 | } | 1005 | } |
1006 | |||
1007 | int netxen_nic_hw_write_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1008 | void *data, int len) | ||
1009 | { | ||
1010 | void *addr; | ||
1011 | u64 offset = off; | ||
1012 | u8 *mem_ptr = NULL; | ||
1013 | unsigned long mem_base; | ||
1014 | unsigned long mem_page; | ||
1015 | |||
1016 | if (ADDR_IN_WINDOW1(off)) { | ||
1017 | addr = NETXEN_CRB_NORMALIZE(adapter, off); | ||
1018 | if (!addr) { | ||
1019 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1020 | offset = NETXEN_CRB_NORMAL(off); | ||
1021 | mem_page = offset & PAGE_MASK; | ||
1022 | if (mem_page != ((offset + len - 1) & PAGE_MASK)) | ||
1023 | mem_ptr = | ||
1024 | ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1025 | else | ||
1026 | mem_ptr = | ||
1027 | ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1028 | if (mem_ptr == 0UL) { | ||
1029 | return 1; | ||
1030 | } | ||
1031 | addr = mem_ptr; | ||
1032 | addr += offset & (PAGE_SIZE - 1); | ||
1033 | } | ||
1034 | } else { | ||
1035 | addr = pci_base_offset(adapter, off); | ||
1036 | if (!addr) { | ||
1037 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1038 | mem_page = off & PAGE_MASK; | ||
1039 | if (mem_page != ((off + len - 1) & PAGE_MASK)) | ||
1040 | mem_ptr = | ||
1041 | ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1042 | else | ||
1043 | mem_ptr = | ||
1044 | ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1045 | if (mem_ptr == 0UL) { | ||
1046 | return 1; | ||
1047 | } | ||
1048 | addr = mem_ptr; | ||
1049 | addr += off & (PAGE_SIZE - 1); | ||
1050 | } | ||
1051 | netxen_nic_pci_change_crbwindow(adapter, 0); | ||
1052 | } | ||
1053 | switch (len) { | ||
1054 | case 1: | ||
1055 | writeb(*(u8 *) data, addr); | ||
1056 | break; | ||
1057 | case 2: | ||
1058 | writew(*(u16 *) data, addr); | ||
1059 | break; | ||
1060 | case 4: | ||
1061 | writel(*(u32 *) data, addr); | ||
1062 | break; | ||
1063 | case 8: | ||
1064 | writeq(*(u64 *) data, addr); | ||
1065 | break; | ||
1066 | default: | ||
1067 | DPRINTK(INFO, | ||
1068 | "writing data %lx to offset %llx, num words=%d\n", | ||
1069 | *(unsigned long *)data, off, (len >> 3)); | ||
1070 | |||
1071 | netxen_nic_hw_block_write64((u64 __iomem *) data, addr, | ||
1072 | (len >> 3)); | ||
1073 | break; | ||
1074 | } | ||
1075 | |||
1076 | if (!ADDR_IN_WINDOW1(off)) | ||
1077 | netxen_nic_pci_change_crbwindow(adapter, 1); | ||
1078 | if (mem_ptr) | ||
1079 | iounmap(mem_ptr); | ||
1080 | return 0; | ||
1081 | } | ||
1082 | |||
1083 | int netxen_nic_hw_read_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1084 | void *data, int len) | ||
1085 | { | ||
1086 | void *addr; | ||
1087 | u64 offset; | ||
1088 | u8 *mem_ptr = NULL; | ||
1089 | unsigned long mem_base; | ||
1090 | unsigned long mem_page; | ||
1091 | |||
1092 | if (ADDR_IN_WINDOW1(off)) { | ||
1093 | addr = NETXEN_CRB_NORMALIZE(adapter, off); | ||
1094 | if (!addr) { | ||
1095 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1096 | offset = NETXEN_CRB_NORMAL(off); | ||
1097 | mem_page = offset & PAGE_MASK; | ||
1098 | if (mem_page != ((offset + len - 1) & PAGE_MASK)) | ||
1099 | mem_ptr = | ||
1100 | ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1101 | else | ||
1102 | mem_ptr = | ||
1103 | ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1104 | if (mem_ptr == 0UL) { | ||
1105 | *(u8 *) data = 0; | ||
1106 | return 1; | ||
1107 | } | ||
1108 | addr = mem_ptr; | ||
1109 | addr += offset & (PAGE_SIZE - 1); | ||
1110 | } | ||
1111 | } else { | ||
1112 | addr = pci_base_offset(adapter, off); | ||
1113 | if (!addr) { | ||
1114 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1115 | mem_page = off & PAGE_MASK; | ||
1116 | if (mem_page != ((off + len - 1) & PAGE_MASK)) | ||
1117 | mem_ptr = | ||
1118 | ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1119 | else | ||
1120 | mem_ptr = | ||
1121 | ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1122 | if (mem_ptr == 0UL) | ||
1123 | return 1; | ||
1124 | addr = mem_ptr; | ||
1125 | addr += off & (PAGE_SIZE - 1); | ||
1126 | } | ||
1127 | netxen_nic_pci_change_crbwindow(adapter, 0); | ||
1128 | } | ||
1129 | switch (len) { | ||
1130 | case 1: | ||
1131 | *(u8 *) data = readb(addr); | ||
1132 | break; | ||
1133 | case 2: | ||
1134 | *(u16 *) data = readw(addr); | ||
1135 | break; | ||
1136 | case 4: | ||
1137 | *(u32 *) data = readl(addr); | ||
1138 | break; | ||
1139 | case 8: | ||
1140 | *(u64 *) data = readq(addr); | ||
1141 | break; | ||
1142 | default: | ||
1143 | netxen_nic_hw_block_read64((u64 __iomem *) data, addr, | ||
1144 | (len >> 3)); | ||
1145 | break; | ||
1146 | } | ||
1147 | if (!ADDR_IN_WINDOW1(off)) | ||
1148 | netxen_nic_pci_change_crbwindow(adapter, 1); | ||
1149 | if (mem_ptr) | ||
1150 | iounmap(mem_ptr); | ||
1151 | return 0; | ||
1152 | } | ||
1153 | |||
1154 | int netxen_nic_pci_mem_write_ioctl(struct netxen_adapter *adapter, u64 off, | ||
1155 | void *data, int size) | ||
1156 | { | ||
1157 | void *addr; | ||
1158 | int ret = 0; | ||
1159 | u8 *mem_ptr = NULL; | ||
1160 | unsigned long mem_base; | ||
1161 | unsigned long mem_page; | ||
1162 | |||
1163 | if (data == NULL || off > (128 * 1024 * 1024)) { | ||
1164 | printk(KERN_ERR "%s: data: %p off:%llx\n", | ||
1165 | netxen_nic_driver_name, data, off); | ||
1166 | return 1; | ||
1167 | } | ||
1168 | off = netxen_nic_pci_set_window(adapter, off); | ||
1169 | /* Corner case : Malicious user tried to break the driver by reading | ||
1170 | last few bytes in ranges and tries to read further addresses. | ||
1171 | */ | ||
1172 | if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) { | ||
1173 | printk(KERN_ERR "%s: Invalid access to memory address range" | ||
1174 | " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off, | ||
1175 | off + size); | ||
1176 | return 1; | ||
1177 | } | ||
1178 | addr = pci_base_offset(adapter, off); | ||
1179 | DPRINTK(INFO, "writing data %llx to offset %llx\n", | ||
1180 | *(unsigned long long *)data, off); | ||
1181 | if (!addr) { | ||
1182 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1183 | mem_page = off & PAGE_MASK; | ||
1184 | /* Map two pages whenever user tries to access addresses in two | ||
1185 | consecutive pages. | ||
1186 | */ | ||
1187 | if (mem_page != ((off + size - 1) & PAGE_MASK)) | ||
1188 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1189 | else | ||
1190 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1191 | if (mem_ptr == 0UL) { | ||
1192 | return 1; | ||
1193 | } | ||
1194 | addr = mem_ptr; | ||
1195 | addr += off & (PAGE_SIZE - 1); | ||
1196 | } | ||
1197 | switch (size) { | ||
1198 | case 1: | ||
1199 | writeb(*(u8 *) data, addr); | ||
1200 | break; | ||
1201 | case 2: | ||
1202 | writew(*(u16 *) data, addr); | ||
1203 | break; | ||
1204 | case 4: | ||
1205 | writel(*(u32 *) data, addr); | ||
1206 | break; | ||
1207 | case 8: | ||
1208 | writeq(*(u64 *) data, addr); | ||
1209 | break; | ||
1210 | default: | ||
1211 | DPRINTK(INFO, | ||
1212 | "writing data %lx to offset %llx, num words=%d\n", | ||
1213 | *(unsigned long *)data, off, (size >> 3)); | ||
1214 | |||
1215 | netxen_nic_hw_block_write64((u64 __iomem *) data, addr, | ||
1216 | (size >> 3)); | ||
1217 | break; | ||
1218 | } | ||
1219 | |||
1220 | if (mem_ptr) | ||
1221 | iounmap(mem_ptr); | ||
1222 | DPRINTK(INFO, "wrote %llx\n", *(unsigned long long *)data); | ||
1223 | |||
1224 | return ret; | ||
1225 | } | ||
1226 | |||
1227 | int netxen_nic_pci_mem_read_ioctl(struct netxen_adapter *adapter, | ||
1228 | u64 off, void *data, int size) | ||
1229 | { | ||
1230 | void *addr; | ||
1231 | int ret = 0; | ||
1232 | u8 *mem_ptr = NULL; | ||
1233 | unsigned long mem_base; | ||
1234 | unsigned long mem_page; | ||
1235 | |||
1236 | if (data == NULL || off > (128 * 1024 * 1024)) { | ||
1237 | printk(KERN_ERR "%s: data: %p off:%llx\n", | ||
1238 | netxen_nic_driver_name, data, off); | ||
1239 | return 1; | ||
1240 | } | ||
1241 | off = netxen_nic_pci_set_window(adapter, off); | ||
1242 | /* Corner case : Malicious user tried to break the driver by reading | ||
1243 | last few bytes in ranges and tries to read further addresses. | ||
1244 | */ | ||
1245 | if (!pci_base(adapter, off + size - 1) && pci_base(adapter, off)) { | ||
1246 | printk(KERN_ERR "%s: Invalid access to memory address range" | ||
1247 | " 0x%llx - 0x%llx\n", netxen_nic_driver_name, off, | ||
1248 | off + size); | ||
1249 | return 1; | ||
1250 | } | ||
1251 | addr = pci_base_offset(adapter, off); | ||
1252 | if (!addr) { | ||
1253 | mem_base = pci_resource_start(adapter->ahw.pdev, 0); | ||
1254 | mem_page = off & PAGE_MASK; | ||
1255 | /* Map two pages whenever user tries to access addresses in two | ||
1256 | consecutive pages. | ||
1257 | */ | ||
1258 | if (mem_page != ((off + size - 1) & PAGE_MASK)) | ||
1259 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE * 2); | ||
1260 | else | ||
1261 | mem_ptr = ioremap(mem_base + mem_page, PAGE_SIZE); | ||
1262 | if (mem_ptr == 0UL) { | ||
1263 | *(u8 *) data = 0; | ||
1264 | return 1; | ||
1265 | } | ||
1266 | addr = mem_ptr; | ||
1267 | addr += off & (PAGE_SIZE - 1); | ||
1268 | } | ||
1269 | switch (size) { | ||
1270 | case 1: | ||
1271 | *(u8 *) data = readb(addr); | ||
1272 | break; | ||
1273 | case 2: | ||
1274 | *(u16 *) data = readw(addr); | ||
1275 | break; | ||
1276 | case 4: | ||
1277 | *(u32 *) data = readl(addr); | ||
1278 | break; | ||
1279 | case 8: | ||
1280 | *(u64 *) data = readq(addr); | ||
1281 | break; | ||
1282 | default: | ||
1283 | netxen_nic_hw_block_read64((u64 __iomem *) data, addr, | ||
1284 | (size >> 3)); | ||
1285 | break; | ||
1286 | } | ||
1287 | |||
1288 | if (mem_ptr) | ||
1289 | iounmap(mem_ptr); | ||
1290 | DPRINTK(INFO, "read %llx\n", *(unsigned long long *)data); | ||
1291 | |||
1292 | return ret; | ||
1293 | } | ||
diff --git a/drivers/net/netxen/netxen_nic_hw.h b/drivers/net/netxen/netxen_nic_hw.h index 201a636b7ab8..0685633a9c1e 100644 --- a/drivers/net/netxen/netxen_nic_hw.h +++ b/drivers/net/netxen/netxen_nic_hw.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
@@ -16,10 +16,10 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -83,8 +83,8 @@ struct netxen_adapter; | |||
83 | #define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20) | 83 | #define NETXEN_PCI_MAPSIZE_BYTES (NETXEN_PCI_MAPSIZE << 20) |
84 | 84 | ||
85 | #define NETXEN_NIC_LOCKED_READ_REG(X, Y) \ | 85 | #define NETXEN_NIC_LOCKED_READ_REG(X, Y) \ |
86 | addr = pci_base_offset(adapter, (X)); \ | 86 | addr = pci_base_offset(adapter, X); \ |
87 | *(u32 *)Y = readl(addr); | 87 | *(u32 *)Y = readl((void __iomem*) addr); |
88 | 88 | ||
89 | struct netxen_port; | 89 | struct netxen_port; |
90 | void netxen_nic_set_link_parameters(struct netxen_port *port); | 90 | void netxen_nic_set_link_parameters(struct netxen_port *port); |
diff --git a/drivers/net/netxen/netxen_nic_init.c b/drivers/net/netxen/netxen_nic_init.c index eae18236aefa..869725f0bb18 100644 --- a/drivers/net/netxen/netxen_nic_init.c +++ b/drivers/net/netxen/netxen_nic_init.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
8 | * of the License, or (at your option) any later version. | 8 | * of the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, but | 10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -137,6 +137,8 @@ int netxen_init_firmware(struct netxen_adapter *adapter) | |||
137 | return err; | 137 | return err; |
138 | } | 138 | } |
139 | /* Window 1 call */ | 139 | /* Window 1 call */ |
140 | writel(MPORT_SINGLE_FUNCTION_MODE, | ||
141 | NETXEN_CRB_NORMALIZE(adapter, CRB_MPORT_MODE)); | ||
140 | writel(PHAN_INITIALIZE_ACK, | 142 | writel(PHAN_INITIALIZE_ACK, |
141 | NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); | 143 | NETXEN_CRB_NORMALIZE(adapter, CRB_CMDPEG_STATE)); |
142 | 144 | ||
@@ -184,15 +186,12 @@ void netxen_initialize_adapter_sw(struct netxen_adapter *adapter) | |||
184 | for (i = 0; i < num_rx_bufs; i++) { | 186 | for (i = 0; i < num_rx_bufs; i++) { |
185 | rx_buf->ref_handle = i; | 187 | rx_buf->ref_handle = i; |
186 | rx_buf->state = NETXEN_BUFFER_FREE; | 188 | rx_buf->state = NETXEN_BUFFER_FREE; |
187 | |||
188 | DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:" | 189 | DPRINTK(INFO, "Rx buf:ctx%d i(%d) rx_buf:" |
189 | "%p\n", ctxid, i, rx_buf); | 190 | "%p\n", ctxid, i, rx_buf); |
190 | rx_buf++; | 191 | rx_buf++; |
191 | } | 192 | } |
192 | } | 193 | } |
193 | } | 194 | } |
194 | DPRINTK(INFO, "initialized buffers for %s and %s\n", | ||
195 | "adapter->free_cmd_buf_list", "adapter->free_rxbuf"); | ||
196 | } | 195 | } |
197 | 196 | ||
198 | void netxen_initialize_adapter_hw(struct netxen_adapter *adapter) | 197 | void netxen_initialize_adapter_hw(struct netxen_adapter *adapter) |
@@ -212,37 +211,36 @@ void netxen_initialize_adapter_hw(struct netxen_adapter *adapter) | |||
212 | 211 | ||
213 | void netxen_initialize_adapter_ops(struct netxen_adapter *adapter) | 212 | void netxen_initialize_adapter_ops(struct netxen_adapter *adapter) |
214 | { | 213 | { |
215 | struct netxen_drvops *ops = adapter->ops; | ||
216 | switch (adapter->ahw.board_type) { | 214 | switch (adapter->ahw.board_type) { |
217 | case NETXEN_NIC_GBE: | 215 | case NETXEN_NIC_GBE: |
218 | ops->enable_phy_interrupts = | 216 | adapter->enable_phy_interrupts = |
219 | netxen_niu_gbe_enable_phy_interrupts; | 217 | netxen_niu_gbe_enable_phy_interrupts; |
220 | ops->disable_phy_interrupts = | 218 | adapter->disable_phy_interrupts = |
221 | netxen_niu_gbe_disable_phy_interrupts; | 219 | netxen_niu_gbe_disable_phy_interrupts; |
222 | ops->handle_phy_intr = netxen_nic_gbe_handle_phy_intr; | 220 | adapter->handle_phy_intr = netxen_nic_gbe_handle_phy_intr; |
223 | ops->macaddr_set = netxen_niu_macaddr_set; | 221 | adapter->macaddr_set = netxen_niu_macaddr_set; |
224 | ops->set_mtu = netxen_nic_set_mtu_gb; | 222 | adapter->set_mtu = netxen_nic_set_mtu_gb; |
225 | ops->set_promisc = netxen_niu_set_promiscuous_mode; | 223 | adapter->set_promisc = netxen_niu_set_promiscuous_mode; |
226 | ops->unset_promisc = netxen_niu_set_promiscuous_mode; | 224 | adapter->unset_promisc = netxen_niu_set_promiscuous_mode; |
227 | ops->phy_read = netxen_niu_gbe_phy_read; | 225 | adapter->phy_read = netxen_niu_gbe_phy_read; |
228 | ops->phy_write = netxen_niu_gbe_phy_write; | 226 | adapter->phy_write = netxen_niu_gbe_phy_write; |
229 | ops->init_port = netxen_niu_gbe_init_port; | 227 | adapter->init_port = netxen_niu_gbe_init_port; |
230 | ops->init_niu = netxen_nic_init_niu_gb; | 228 | adapter->init_niu = netxen_nic_init_niu_gb; |
231 | ops->stop_port = netxen_niu_disable_gbe_port; | 229 | adapter->stop_port = netxen_niu_disable_gbe_port; |
232 | break; | 230 | break; |
233 | 231 | ||
234 | case NETXEN_NIC_XGBE: | 232 | case NETXEN_NIC_XGBE: |
235 | ops->enable_phy_interrupts = | 233 | adapter->enable_phy_interrupts = |
236 | netxen_niu_xgbe_enable_phy_interrupts; | 234 | netxen_niu_xgbe_enable_phy_interrupts; |
237 | ops->disable_phy_interrupts = | 235 | adapter->disable_phy_interrupts = |
238 | netxen_niu_xgbe_disable_phy_interrupts; | 236 | netxen_niu_xgbe_disable_phy_interrupts; |
239 | ops->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr; | 237 | adapter->handle_phy_intr = netxen_nic_xgbe_handle_phy_intr; |
240 | ops->macaddr_set = netxen_niu_xg_macaddr_set; | 238 | adapter->macaddr_set = netxen_niu_xg_macaddr_set; |
241 | ops->set_mtu = netxen_nic_set_mtu_xgb; | 239 | adapter->set_mtu = netxen_nic_set_mtu_xgb; |
242 | ops->init_port = netxen_niu_xg_init_port; | 240 | adapter->init_port = netxen_niu_xg_init_port; |
243 | ops->set_promisc = netxen_niu_xg_set_promiscuous_mode; | 241 | adapter->set_promisc = netxen_niu_xg_set_promiscuous_mode; |
244 | ops->unset_promisc = netxen_niu_xg_set_promiscuous_mode; | 242 | adapter->unset_promisc = netxen_niu_xg_set_promiscuous_mode; |
245 | ops->stop_port = netxen_niu_disable_xg_port; | 243 | adapter->stop_port = netxen_niu_disable_xg_port; |
246 | break; | 244 | break; |
247 | 245 | ||
248 | default: | 246 | default: |
@@ -383,8 +381,8 @@ int netxen_rom_wip_poll(struct netxen_adapter *adapter) | |||
383 | return 0; | 381 | return 0; |
384 | } | 382 | } |
385 | 383 | ||
386 | static inline int do_rom_fast_write(struct netxen_adapter *adapter, | 384 | static inline int do_rom_fast_write(struct netxen_adapter *adapter, int addr, |
387 | int addr, int data) | 385 | int data) |
388 | { | 386 | { |
389 | if (netxen_rom_wren(adapter)) { | 387 | if (netxen_rom_wren(adapter)) { |
390 | return -1; | 388 | return -1; |
@@ -622,6 +620,43 @@ int netxen_pinit_from_rom(struct netxen_adapter *adapter, int verbose) | |||
622 | return 0; | 620 | return 0; |
623 | } | 621 | } |
624 | 622 | ||
623 | int netxen_initialize_adapter_offload(struct netxen_adapter *adapter) | ||
624 | { | ||
625 | uint64_t addr; | ||
626 | uint32_t hi; | ||
627 | uint32_t lo; | ||
628 | |||
629 | adapter->dummy_dma.addr = | ||
630 | pci_alloc_consistent(adapter->ahw.pdev, | ||
631 | NETXEN_HOST_DUMMY_DMA_SIZE, | ||
632 | &adapter->dummy_dma.phys_addr); | ||
633 | if (adapter->dummy_dma.addr == NULL) { | ||
634 | printk("%s: ERROR: Could not allocate dummy DMA memory\n", | ||
635 | __FUNCTION__); | ||
636 | return -ENOMEM; | ||
637 | } | ||
638 | |||
639 | addr = (uint64_t) adapter->dummy_dma.phys_addr; | ||
640 | hi = (addr >> 32) & 0xffffffff; | ||
641 | lo = addr & 0xffffffff; | ||
642 | |||
643 | writel(hi, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_DUMMY_BUF_ADDR_HI)); | ||
644 | writel(lo, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_DUMMY_BUF_ADDR_LO)); | ||
645 | |||
646 | return 0; | ||
647 | } | ||
648 | |||
649 | void netxen_free_adapter_offload(struct netxen_adapter *adapter) | ||
650 | { | ||
651 | if (adapter->dummy_dma.addr) { | ||
652 | pci_free_consistent(adapter->ahw.pdev, | ||
653 | NETXEN_HOST_DUMMY_DMA_SIZE, | ||
654 | adapter->dummy_dma.addr, | ||
655 | adapter->dummy_dma.phys_addr); | ||
656 | adapter->dummy_dma.addr = NULL; | ||
657 | } | ||
658 | } | ||
659 | |||
625 | void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) | 660 | void netxen_phantom_init(struct netxen_adapter *adapter, int pegtune_val) |
626 | { | 661 | { |
627 | u32 val = 0; | 662 | u32 val = 0; |
@@ -656,7 +691,8 @@ int netxen_nic_rx_has_work(struct netxen_adapter *adapter) | |||
656 | desc_head = recv_ctx->rcv_status_desc_head; | 691 | desc_head = recv_ctx->rcv_status_desc_head; |
657 | desc = &desc_head[consumer]; | 692 | desc = &desc_head[consumer]; |
658 | 693 | ||
659 | if (((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST)) | 694 | if (((le16_to_cpu(netxen_get_sts_owner(desc))) |
695 | & STATUS_OWNER_HOST)) | ||
660 | return 1; | 696 | return 1; |
661 | } | 697 | } |
662 | 698 | ||
@@ -735,8 +771,8 @@ void netxen_watchdog_task(struct work_struct *work) | |||
735 | netif_wake_queue(netdev); | 771 | netif_wake_queue(netdev); |
736 | } | 772 | } |
737 | 773 | ||
738 | if (adapter->ops->handle_phy_intr) | 774 | if (adapter->handle_phy_intr) |
739 | adapter->ops->handle_phy_intr(adapter); | 775 | adapter->handle_phy_intr(adapter); |
740 | mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); | 776 | mod_timer(&adapter->watchdog_timer, jiffies + 2 * HZ); |
741 | } | 777 | } |
742 | 778 | ||
@@ -749,19 +785,19 @@ void | |||
749 | netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, | 785 | netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, |
750 | struct status_desc *desc) | 786 | struct status_desc *desc) |
751 | { | 787 | { |
752 | struct netxen_port *port = adapter->port[STATUS_DESC_PORT(desc)]; | 788 | struct netxen_port *port = adapter->port[netxen_get_sts_port(desc)]; |
753 | struct pci_dev *pdev = port->pdev; | 789 | struct pci_dev *pdev = port->pdev; |
754 | struct net_device *netdev = port->netdev; | 790 | struct net_device *netdev = port->netdev; |
755 | int index = le16_to_cpu(desc->reference_handle); | 791 | int index = le16_to_cpu(netxen_get_sts_refhandle(desc)); |
756 | struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); | 792 | struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctxid]); |
757 | struct netxen_rx_buffer *buffer; | 793 | struct netxen_rx_buffer *buffer; |
758 | struct sk_buff *skb; | 794 | struct sk_buff *skb; |
759 | u32 length = le16_to_cpu(desc->total_length); | 795 | u32 length = le16_to_cpu(netxen_get_sts_totallength(desc)); |
760 | u32 desc_ctx; | 796 | u32 desc_ctx; |
761 | struct netxen_rcv_desc_ctx *rcv_desc; | 797 | struct netxen_rcv_desc_ctx *rcv_desc; |
762 | int ret; | 798 | int ret; |
763 | 799 | ||
764 | desc_ctx = STATUS_DESC_TYPE(desc); | 800 | desc_ctx = netxen_get_sts_type(desc); |
765 | if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { | 801 | if (unlikely(desc_ctx >= NUM_RCV_DESC_RINGS)) { |
766 | printk("%s: %s Bad Rcv descriptor ring\n", | 802 | printk("%s: %s Bad Rcv descriptor ring\n", |
767 | netxen_nic_driver_name, netdev->name); | 803 | netxen_nic_driver_name, netdev->name); |
@@ -769,20 +805,49 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, | |||
769 | } | 805 | } |
770 | 806 | ||
771 | rcv_desc = &recv_ctx->rcv_desc[desc_ctx]; | 807 | rcv_desc = &recv_ctx->rcv_desc[desc_ctx]; |
808 | if (unlikely(index > rcv_desc->max_rx_desc_count)) { | ||
809 | DPRINTK(ERR, "Got a buffer index:%x Max is %x\n", | ||
810 | index, rcv_desc->max_rx_desc_count); | ||
811 | return; | ||
812 | } | ||
772 | buffer = &rcv_desc->rx_buf_arr[index]; | 813 | buffer = &rcv_desc->rx_buf_arr[index]; |
814 | if (desc_ctx == RCV_DESC_LRO_CTXID) { | ||
815 | buffer->lro_current_frags++; | ||
816 | if (netxen_get_sts_desc_lro_last_frag(desc)) { | ||
817 | buffer->lro_expected_frags = | ||
818 | netxen_get_sts_desc_lro_cnt(desc); | ||
819 | buffer->lro_length = length; | ||
820 | } | ||
821 | if (buffer->lro_current_frags != buffer->lro_expected_frags) { | ||
822 | if (buffer->lro_expected_frags != 0) { | ||
823 | printk("LRO: (refhandle:%x) recv frag." | ||
824 | "wait for last. flags: %x expected:%d" | ||
825 | "have:%d\n", index, | ||
826 | netxen_get_sts_desc_lro_last_frag(desc), | ||
827 | buffer->lro_expected_frags, | ||
828 | buffer->lro_current_frags); | ||
829 | } | ||
830 | return; | ||
831 | } | ||
832 | } | ||
773 | 833 | ||
774 | pci_unmap_single(pdev, buffer->dma, rcv_desc->dma_size, | 834 | pci_unmap_single(pdev, buffer->dma, rcv_desc->dma_size, |
775 | PCI_DMA_FROMDEVICE); | 835 | PCI_DMA_FROMDEVICE); |
776 | 836 | ||
777 | skb = (struct sk_buff *)buffer->skb; | 837 | skb = (struct sk_buff *)buffer->skb; |
778 | 838 | ||
779 | if (likely(STATUS_DESC_STATUS(desc) == STATUS_CKSUM_OK)) { | 839 | if (likely(netxen_get_sts_status(desc) == STATUS_CKSUM_OK)) { |
780 | port->stats.csummed++; | 840 | port->stats.csummed++; |
781 | skb->ip_summed = CHECKSUM_UNNECESSARY; | 841 | skb->ip_summed = CHECKSUM_UNNECESSARY; |
782 | } else | 842 | } |
783 | skb->ip_summed = CHECKSUM_NONE; | ||
784 | skb->dev = netdev; | 843 | skb->dev = netdev; |
785 | skb_put(skb, length); | 844 | if (desc_ctx == RCV_DESC_LRO_CTXID) { |
845 | /* True length was only available on the last pkt */ | ||
846 | skb_put(skb, buffer->lro_length); | ||
847 | } else { | ||
848 | skb_put(skb, length); | ||
849 | } | ||
850 | |||
786 | skb->protocol = eth_type_trans(skb, netdev); | 851 | skb->protocol = eth_type_trans(skb, netdev); |
787 | 852 | ||
788 | ret = netif_receive_skb(skb); | 853 | ret = netif_receive_skb(skb); |
@@ -828,6 +893,8 @@ netxen_process_rcv(struct netxen_adapter *adapter, int ctxid, | |||
828 | adapter->stats.post_called++; | 893 | adapter->stats.post_called++; |
829 | buffer->skb = NULL; | 894 | buffer->skb = NULL; |
830 | buffer->state = NETXEN_BUFFER_FREE; | 895 | buffer->state = NETXEN_BUFFER_FREE; |
896 | buffer->lro_current_frags = 0; | ||
897 | buffer->lro_expected_frags = 0; | ||
831 | 898 | ||
832 | port->stats.no_rcv++; | 899 | port->stats.no_rcv++; |
833 | port->stats.rxbytes += length; | 900 | port->stats.rxbytes += length; |
@@ -840,6 +907,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) | |||
840 | struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; | 907 | struct status_desc *desc_head = recv_ctx->rcv_status_desc_head; |
841 | struct status_desc *desc; /* used to read status desc here */ | 908 | struct status_desc *desc; /* used to read status desc here */ |
842 | u32 consumer = recv_ctx->status_rx_consumer; | 909 | u32 consumer = recv_ctx->status_rx_consumer; |
910 | u32 producer = 0; | ||
843 | int count = 0, ring; | 911 | int count = 0, ring; |
844 | 912 | ||
845 | DPRINTK(INFO, "procesing receive\n"); | 913 | DPRINTK(INFO, "procesing receive\n"); |
@@ -851,18 +919,22 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) | |||
851 | */ | 919 | */ |
852 | while (count < max) { | 920 | while (count < max) { |
853 | desc = &desc_head[consumer]; | 921 | desc = &desc_head[consumer]; |
854 | if (!((le16_to_cpu(desc->owner)) & STATUS_OWNER_HOST)) { | 922 | if (! |
855 | DPRINTK(ERR, "desc %p ownedby %x\n", desc, desc->owner); | 923 | (le16_to_cpu(netxen_get_sts_owner(desc)) & |
924 | STATUS_OWNER_HOST)) { | ||
925 | DPRINTK(ERR, "desc %p ownedby %x\n", desc, | ||
926 | netxen_get_sts_owner(desc)); | ||
856 | break; | 927 | break; |
857 | } | 928 | } |
858 | netxen_process_rcv(adapter, ctxid, desc); | 929 | netxen_process_rcv(adapter, ctxid, desc); |
859 | desc->owner = STATUS_OWNER_PHANTOM; | 930 | netxen_clear_sts_owner(desc); |
931 | netxen_set_sts_owner(desc, STATUS_OWNER_PHANTOM); | ||
860 | consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1); | 932 | consumer = (consumer + 1) & (adapter->max_rx_desc_count - 1); |
861 | count++; | 933 | count++; |
862 | } | 934 | } |
863 | if (count) { | 935 | if (count) { |
864 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { | 936 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) { |
865 | netxen_post_rx_buffers(adapter, ctxid, ring); | 937 | netxen_post_rx_buffers_nodb(adapter, ctxid, ring); |
866 | } | 938 | } |
867 | } | 939 | } |
868 | 940 | ||
@@ -870,6 +942,7 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) | |||
870 | if (count) { | 942 | if (count) { |
871 | adapter->stats.process_rcv++; | 943 | adapter->stats.process_rcv++; |
872 | recv_ctx->status_rx_consumer = consumer; | 944 | recv_ctx->status_rx_consumer = consumer; |
945 | recv_ctx->status_rx_producer = producer; | ||
873 | 946 | ||
874 | /* Window = 1 */ | 947 | /* Window = 1 */ |
875 | writel(consumer, | 948 | writel(consumer, |
@@ -882,12 +955,13 @@ u32 netxen_process_rcv_ring(struct netxen_adapter *adapter, int ctxid, int max) | |||
882 | } | 955 | } |
883 | 956 | ||
884 | /* Process Command status ring */ | 957 | /* Process Command status ring */ |
885 | void netxen_process_cmd_ring(unsigned long data) | 958 | int netxen_process_cmd_ring(unsigned long data) |
886 | { | 959 | { |
887 | u32 last_consumer; | 960 | u32 last_consumer; |
888 | u32 consumer; | 961 | u32 consumer; |
889 | struct netxen_adapter *adapter = (struct netxen_adapter *)data; | 962 | struct netxen_adapter *adapter = (struct netxen_adapter *)data; |
890 | int count = 0; | 963 | int count1 = 0; |
964 | int count2 = 0; | ||
891 | struct netxen_cmd_buffer *buffer; | 965 | struct netxen_cmd_buffer *buffer; |
892 | struct netxen_port *port; /* port #1 */ | 966 | struct netxen_port *port; /* port #1 */ |
893 | struct netxen_port *nport; | 967 | struct netxen_port *nport; |
@@ -896,6 +970,7 @@ void netxen_process_cmd_ring(unsigned long data) | |||
896 | u32 i; | 970 | u32 i; |
897 | struct sk_buff *skb = NULL; | 971 | struct sk_buff *skb = NULL; |
898 | int p; | 972 | int p; |
973 | int done; | ||
899 | 974 | ||
900 | spin_lock(&adapter->tx_lock); | 975 | spin_lock(&adapter->tx_lock); |
901 | last_consumer = adapter->last_cmd_consumer; | 976 | last_consumer = adapter->last_cmd_consumer; |
@@ -905,14 +980,13 @@ void netxen_process_cmd_ring(unsigned long data) | |||
905 | * number as part of the descriptor. This way we will be able to get | 980 | * number as part of the descriptor. This way we will be able to get |
906 | * the netdev which is associated with that device. | 981 | * the netdev which is associated with that device. |
907 | */ | 982 | */ |
908 | consumer = | ||
909 | readl(NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET)); | ||
910 | 983 | ||
984 | consumer = *(adapter->cmd_consumer); | ||
911 | if (last_consumer == consumer) { /* Ring is empty */ | 985 | if (last_consumer == consumer) { /* Ring is empty */ |
912 | DPRINTK(INFO, "last_consumer %d == consumer %d\n", | 986 | DPRINTK(INFO, "last_consumer %d == consumer %d\n", |
913 | last_consumer, consumer); | 987 | last_consumer, consumer); |
914 | spin_unlock(&adapter->tx_lock); | 988 | spin_unlock(&adapter->tx_lock); |
915 | return; | 989 | return 1; |
916 | } | 990 | } |
917 | 991 | ||
918 | adapter->proc_cmd_buf_counter++; | 992 | adapter->proc_cmd_buf_counter++; |
@@ -923,7 +997,7 @@ void netxen_process_cmd_ring(unsigned long data) | |||
923 | */ | 997 | */ |
924 | spin_unlock(&adapter->tx_lock); | 998 | spin_unlock(&adapter->tx_lock); |
925 | 999 | ||
926 | while ((last_consumer != consumer) && (count < MAX_STATUS_HANDLE)) { | 1000 | while ((last_consumer != consumer) && (count1 < MAX_STATUS_HANDLE)) { |
927 | buffer = &adapter->cmd_buf_arr[last_consumer]; | 1001 | buffer = &adapter->cmd_buf_arr[last_consumer]; |
928 | port = adapter->port[buffer->port]; | 1002 | port = adapter->port[buffer->port]; |
929 | pdev = port->pdev; | 1003 | pdev = port->pdev; |
@@ -949,24 +1023,24 @@ void netxen_process_cmd_ring(unsigned long data) | |||
949 | && netif_carrier_ok(port->netdev)) | 1023 | && netif_carrier_ok(port->netdev)) |
950 | && ((jiffies - port->netdev->trans_start) > | 1024 | && ((jiffies - port->netdev->trans_start) > |
951 | port->netdev->watchdog_timeo)) { | 1025 | port->netdev->watchdog_timeo)) { |
952 | schedule_work(&port->adapter->tx_timeout_task); | 1026 | SCHEDULE_WORK(&port->adapter->tx_timeout_task); |
953 | } | 1027 | } |
954 | 1028 | ||
955 | last_consumer = get_next_index(last_consumer, | 1029 | last_consumer = get_next_index(last_consumer, |
956 | adapter->max_tx_desc_count); | 1030 | adapter->max_tx_desc_count); |
957 | count++; | 1031 | count1++; |
958 | } | 1032 | } |
959 | adapter->stats.noxmitdone += count; | 1033 | adapter->stats.noxmitdone += count1; |
960 | 1034 | ||
961 | count = 0; | 1035 | count2 = 0; |
962 | spin_lock(&adapter->tx_lock); | 1036 | spin_lock(&adapter->tx_lock); |
963 | if ((--adapter->proc_cmd_buf_counter) == 0) { | 1037 | if ((--adapter->proc_cmd_buf_counter) == 0) { |
964 | adapter->last_cmd_consumer = last_consumer; | 1038 | adapter->last_cmd_consumer = last_consumer; |
965 | while ((adapter->last_cmd_consumer != consumer) | 1039 | while ((adapter->last_cmd_consumer != consumer) |
966 | && (count < MAX_STATUS_HANDLE)) { | 1040 | && (count2 < MAX_STATUS_HANDLE)) { |
967 | buffer = | 1041 | buffer = |
968 | &adapter->cmd_buf_arr[adapter->last_cmd_consumer]; | 1042 | &adapter->cmd_buf_arr[adapter->last_cmd_consumer]; |
969 | count++; | 1043 | count2++; |
970 | if (buffer->skb) | 1044 | if (buffer->skb) |
971 | break; | 1045 | break; |
972 | else | 1046 | else |
@@ -975,7 +1049,7 @@ void netxen_process_cmd_ring(unsigned long data) | |||
975 | adapter->max_tx_desc_count); | 1049 | adapter->max_tx_desc_count); |
976 | } | 1050 | } |
977 | } | 1051 | } |
978 | if (count) { | 1052 | if (count1 || count2) { |
979 | for (p = 0; p < adapter->ahw.max_ports; p++) { | 1053 | for (p = 0; p < adapter->ahw.max_ports; p++) { |
980 | nport = adapter->port[p]; | 1054 | nport = adapter->port[p]; |
981 | if (netif_queue_stopped(nport->netdev) | 1055 | if (netif_queue_stopped(nport->netdev) |
@@ -985,10 +1059,30 @@ void netxen_process_cmd_ring(unsigned long data) | |||
985 | } | 1059 | } |
986 | } | 1060 | } |
987 | } | 1061 | } |
1062 | /* | ||
1063 | * If everything is freed up to consumer then check if the ring is full | ||
1064 | * If the ring is full then check if more needs to be freed and | ||
1065 | * schedule the call back again. | ||
1066 | * | ||
1067 | * This happens when there are 2 CPUs. One could be freeing and the | ||
1068 | * other filling it. If the ring is full when we get out of here and | ||
1069 | * the card has already interrupted the host then the host can miss the | ||
1070 | * interrupt. | ||
1071 | * | ||
1072 | * There is still a possible race condition and the host could miss an | ||
1073 | * interrupt. The card has to take care of this. | ||
1074 | */ | ||
1075 | if (adapter->last_cmd_consumer == consumer && | ||
1076 | (((adapter->cmd_producer + 1) % | ||
1077 | adapter->max_tx_desc_count) == adapter->last_cmd_consumer)) { | ||
1078 | consumer = *(adapter->cmd_consumer); | ||
1079 | } | ||
1080 | done = (adapter->last_cmd_consumer == consumer); | ||
988 | 1081 | ||
989 | spin_unlock(&adapter->tx_lock); | 1082 | spin_unlock(&adapter->tx_lock); |
990 | DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer, | 1083 | DPRINTK(INFO, "last consumer is %d in %s\n", last_consumer, |
991 | __FUNCTION__); | 1084 | __FUNCTION__); |
1085 | return (done); | ||
992 | } | 1086 | } |
993 | 1087 | ||
994 | /* | 1088 | /* |
@@ -1000,17 +1094,16 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1000 | struct sk_buff *skb; | 1094 | struct sk_buff *skb; |
1001 | struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); | 1095 | struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); |
1002 | struct netxen_rcv_desc_ctx *rcv_desc = NULL; | 1096 | struct netxen_rcv_desc_ctx *rcv_desc = NULL; |
1003 | struct netxen_recv_crb *crbarea = &recv_crb_registers[ctx]; | 1097 | uint producer; |
1004 | struct netxen_rcv_desc_crb *rcv_desc_crb = NULL; | ||
1005 | u32 producer; | ||
1006 | struct rcv_desc *pdesc; | 1098 | struct rcv_desc *pdesc; |
1007 | struct netxen_rx_buffer *buffer; | 1099 | struct netxen_rx_buffer *buffer; |
1008 | int count = 0; | 1100 | int count = 0; |
1009 | int index = 0; | 1101 | int index = 0; |
1102 | netxen_ctx_msg msg = 0; | ||
1103 | dma_addr_t dma; | ||
1010 | 1104 | ||
1011 | adapter->stats.post_called++; | 1105 | adapter->stats.post_called++; |
1012 | rcv_desc = &recv_ctx->rcv_desc[ringid]; | 1106 | rcv_desc = &recv_ctx->rcv_desc[ringid]; |
1013 | rcv_desc_crb = &crbarea->rcv_desc_crb[ringid]; | ||
1014 | 1107 | ||
1015 | producer = rcv_desc->producer; | 1108 | producer = rcv_desc->producer; |
1016 | index = rcv_desc->begin_alloc; | 1109 | index = rcv_desc->begin_alloc; |
@@ -1020,6 +1113,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1020 | skb = dev_alloc_skb(rcv_desc->skb_size); | 1113 | skb = dev_alloc_skb(rcv_desc->skb_size); |
1021 | if (unlikely(!skb)) { | 1114 | if (unlikely(!skb)) { |
1022 | /* | 1115 | /* |
1116 | * TODO | ||
1023 | * We need to schedule the posting of buffers to the pegs. | 1117 | * We need to schedule the posting of buffers to the pegs. |
1024 | */ | 1118 | */ |
1025 | rcv_desc->begin_alloc = index; | 1119 | rcv_desc->begin_alloc = index; |
@@ -1027,9 +1121,105 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1027 | " allocated only %d buffers\n", count); | 1121 | " allocated only %d buffers\n", count); |
1028 | break; | 1122 | break; |
1029 | } | 1123 | } |
1124 | |||
1030 | count++; /* now there should be no failure */ | 1125 | count++; /* now there should be no failure */ |
1031 | pdesc = &rcv_desc->desc_head[producer]; | 1126 | pdesc = &rcv_desc->desc_head[producer]; |
1032 | skb_reserve(skb, NET_IP_ALIGN); | 1127 | |
1128 | #if defined(XGB_DEBUG) | ||
1129 | *(unsigned long *)(skb->head) = 0xc0debabe; | ||
1130 | if (skb_is_nonlinear(skb)) { | ||
1131 | printk("Allocated SKB @%p is nonlinear\n"); | ||
1132 | } | ||
1133 | #endif | ||
1134 | skb_reserve(skb, 2); | ||
1135 | /* This will be setup when we receive the | ||
1136 | * buffer after it has been filled FSL TBD TBD | ||
1137 | * skb->dev = netdev; | ||
1138 | */ | ||
1139 | dma = pci_map_single(pdev, skb->data, rcv_desc->dma_size, | ||
1140 | PCI_DMA_FROMDEVICE); | ||
1141 | pdesc->addr_buffer = dma; | ||
1142 | buffer->skb = skb; | ||
1143 | buffer->state = NETXEN_BUFFER_BUSY; | ||
1144 | buffer->dma = dma; | ||
1145 | /* make a rcv descriptor */ | ||
1146 | pdesc->reference_handle = buffer->ref_handle; | ||
1147 | pdesc->buffer_length = rcv_desc->dma_size; | ||
1148 | DPRINTK(INFO, "done writing descripter\n"); | ||
1149 | producer = | ||
1150 | get_next_index(producer, rcv_desc->max_rx_desc_count); | ||
1151 | index = get_next_index(index, rcv_desc->max_rx_desc_count); | ||
1152 | buffer = &rcv_desc->rx_buf_arr[index]; | ||
1153 | } | ||
1154 | /* if we did allocate buffers, then write the count to Phantom */ | ||
1155 | if (count) { | ||
1156 | rcv_desc->begin_alloc = index; | ||
1157 | rcv_desc->rcv_pending += count; | ||
1158 | adapter->stats.lastposted = count; | ||
1159 | adapter->stats.posted += count; | ||
1160 | rcv_desc->producer = producer; | ||
1161 | if (rcv_desc->rcv_free >= 32) { | ||
1162 | rcv_desc->rcv_free = 0; | ||
1163 | /* Window = 1 */ | ||
1164 | writel((producer - 1) & | ||
1165 | (rcv_desc->max_rx_desc_count - 1), | ||
1166 | NETXEN_CRB_NORMALIZE(adapter, | ||
1167 | recv_crb_registers[0]. | ||
1168 | rcv_desc_crb[ringid]. | ||
1169 | crb_rcv_producer_offset)); | ||
1170 | /* | ||
1171 | * Write a doorbell msg to tell phanmon of change in | ||
1172 | * receive ring producer | ||
1173 | */ | ||
1174 | netxen_set_msg_peg_id(msg, NETXEN_RCV_PEG_DB_ID); | ||
1175 | netxen_set_msg_privid(msg); | ||
1176 | netxen_set_msg_count(msg, | ||
1177 | ((producer - | ||
1178 | 1) & (rcv_desc-> | ||
1179 | max_rx_desc_count - 1))); | ||
1180 | netxen_set_msg_ctxid(msg, 0); | ||
1181 | netxen_set_msg_opcode(msg, NETXEN_RCV_PRODUCER(ringid)); | ||
1182 | writel(msg, | ||
1183 | DB_NORMALIZE(adapter, | ||
1184 | NETXEN_RCV_PRODUCER_OFFSET)); | ||
1185 | } | ||
1186 | } | ||
1187 | } | ||
1188 | |||
1189 | void netxen_post_rx_buffers_nodb(struct netxen_adapter *adapter, uint32_t ctx, | ||
1190 | uint32_t ringid) | ||
1191 | { | ||
1192 | struct pci_dev *pdev = adapter->ahw.pdev; | ||
1193 | struct sk_buff *skb; | ||
1194 | struct netxen_recv_context *recv_ctx = &(adapter->recv_ctx[ctx]); | ||
1195 | struct netxen_rcv_desc_ctx *rcv_desc = NULL; | ||
1196 | u32 producer; | ||
1197 | struct rcv_desc *pdesc; | ||
1198 | struct netxen_rx_buffer *buffer; | ||
1199 | int count = 0; | ||
1200 | int index = 0; | ||
1201 | |||
1202 | adapter->stats.post_called++; | ||
1203 | rcv_desc = &recv_ctx->rcv_desc[ringid]; | ||
1204 | |||
1205 | producer = rcv_desc->producer; | ||
1206 | index = rcv_desc->begin_alloc; | ||
1207 | buffer = &rcv_desc->rx_buf_arr[index]; | ||
1208 | /* We can start writing rx descriptors into the phantom memory. */ | ||
1209 | while (buffer->state == NETXEN_BUFFER_FREE) { | ||
1210 | skb = dev_alloc_skb(rcv_desc->skb_size); | ||
1211 | if (unlikely(!skb)) { | ||
1212 | /* | ||
1213 | * We need to schedule the posting of buffers to the pegs. | ||
1214 | */ | ||
1215 | rcv_desc->begin_alloc = index; | ||
1216 | DPRINTK(ERR, "netxen_post_rx_buffers_nodb: " | ||
1217 | " allocated only %d buffers\n", count); | ||
1218 | break; | ||
1219 | } | ||
1220 | count++; /* now there should be no failure */ | ||
1221 | pdesc = &rcv_desc->desc_head[producer]; | ||
1222 | skb_reserve(skb, 2); | ||
1033 | /* | 1223 | /* |
1034 | * This will be setup when we receive the | 1224 | * This will be setup when we receive the |
1035 | * buffer after it has been filled | 1225 | * buffer after it has been filled |
@@ -1040,6 +1230,7 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1040 | buffer->dma = pci_map_single(pdev, skb->data, | 1230 | buffer->dma = pci_map_single(pdev, skb->data, |
1041 | rcv_desc->dma_size, | 1231 | rcv_desc->dma_size, |
1042 | PCI_DMA_FROMDEVICE); | 1232 | PCI_DMA_FROMDEVICE); |
1233 | |||
1043 | /* make a rcv descriptor */ | 1234 | /* make a rcv descriptor */ |
1044 | pdesc->reference_handle = le16_to_cpu(buffer->ref_handle); | 1235 | pdesc->reference_handle = le16_to_cpu(buffer->ref_handle); |
1045 | pdesc->buffer_length = le16_to_cpu(rcv_desc->dma_size); | 1236 | pdesc->buffer_length = le16_to_cpu(rcv_desc->dma_size); |
@@ -1064,7 +1255,8 @@ void netxen_post_rx_buffers(struct netxen_adapter *adapter, u32 ctx, u32 ringid) | |||
1064 | writel((producer - 1) & | 1255 | writel((producer - 1) & |
1065 | (rcv_desc->max_rx_desc_count - 1), | 1256 | (rcv_desc->max_rx_desc_count - 1), |
1066 | NETXEN_CRB_NORMALIZE(adapter, | 1257 | NETXEN_CRB_NORMALIZE(adapter, |
1067 | rcv_desc_crb-> | 1258 | recv_crb_registers[0]. |
1259 | rcv_desc_crb[ringid]. | ||
1068 | crb_rcv_producer_offset)); | 1260 | crb_rcv_producer_offset)); |
1069 | wmb(); | 1261 | wmb(); |
1070 | } | 1262 | } |
@@ -1197,8 +1389,8 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data, | |||
1197 | 1389 | ||
1198 | switch (data.cmd) { | 1390 | switch (data.cmd) { |
1199 | case netxen_nic_cmd_pci_read: | 1391 | case netxen_nic_cmd_pci_read: |
1200 | if ((retval = netxen_nic_hw_read_wx(adapter, data.off, | 1392 | if ((retval = netxen_nic_hw_read_ioctl(adapter, data.off, |
1201 | &(data.u), data.size))) | 1393 | &(data.u), data.size))) |
1202 | goto error_out; | 1394 | goto error_out; |
1203 | if (copy_to_user | 1395 | if (copy_to_user |
1204 | ((void __user *)&(up_data->u), &(data.u), data.size)) { | 1396 | ((void __user *)&(up_data->u), &(data.u), data.size)) { |
@@ -1211,8 +1403,35 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data, | |||
1211 | break; | 1403 | break; |
1212 | 1404 | ||
1213 | case netxen_nic_cmd_pci_write: | 1405 | case netxen_nic_cmd_pci_write: |
1214 | data.rv = netxen_nic_hw_write_wx(adapter, data.off, &(data.u), | 1406 | if ((retval = netxen_nic_hw_write_ioctl(adapter, data.off, |
1215 | data.size); | 1407 | &(data.u), data.size))) |
1408 | goto error_out; | ||
1409 | data.rv = 0; | ||
1410 | break; | ||
1411 | |||
1412 | case netxen_nic_cmd_pci_mem_read: | ||
1413 | if (netxen_nic_pci_mem_read_ioctl(adapter, data.off, &(data.u), | ||
1414 | data.size)) { | ||
1415 | DPRINTK(ERR, "Failed to read the data.\n"); | ||
1416 | retval = -EFAULT; | ||
1417 | goto error_out; | ||
1418 | } | ||
1419 | if (copy_to_user | ||
1420 | ((void __user *)&(up_data->u), &(data.u), data.size)) { | ||
1421 | DPRINTK(ERR, "bad copy to userland: %d\n", | ||
1422 | (int)sizeof(data)); | ||
1423 | retval = -EFAULT; | ||
1424 | goto error_out; | ||
1425 | } | ||
1426 | data.rv = 0; | ||
1427 | break; | ||
1428 | |||
1429 | case netxen_nic_cmd_pci_mem_write: | ||
1430 | if ((retval = netxen_nic_pci_mem_write_ioctl(adapter, data.off, | ||
1431 | &(data.u), | ||
1432 | data.size))) | ||
1433 | goto error_out; | ||
1434 | data.rv = 0; | ||
1216 | break; | 1435 | break; |
1217 | 1436 | ||
1218 | case netxen_nic_cmd_pci_config_read: | 1437 | case netxen_nic_cmd_pci_config_read: |
@@ -1297,7 +1516,7 @@ netxen_nic_do_ioctl(struct netxen_adapter *adapter, void *u_data, | |||
1297 | retval = -EOPNOTSUPP; | 1516 | retval = -EOPNOTSUPP; |
1298 | goto error_out; | 1517 | goto error_out; |
1299 | } | 1518 | } |
1300 | put_user(data.rv, (u16 __user *) (&(up_data->rv))); | 1519 | put_user(data.rv, (&(up_data->rv))); |
1301 | DPRINTK(INFO, "done ioctl for %p well.\n", adapter); | 1520 | DPRINTK(INFO, "done ioctl for %p well.\n", adapter); |
1302 | 1521 | ||
1303 | error_out: | 1522 | error_out: |
diff --git a/drivers/net/netxen/netxen_nic_ioctl.h b/drivers/net/netxen/netxen_nic_ioctl.h index 23e53adbf123..1221fa527552 100644 --- a/drivers/net/netxen/netxen_nic_ioctl.h +++ b/drivers/net/netxen/netxen_nic_ioctl.h | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
@@ -16,10 +16,10 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -36,7 +36,7 @@ | |||
36 | #define NETXEN_NIC_CMD (NETXEN_CMD_START + 1) | 36 | #define NETXEN_NIC_CMD (NETXEN_CMD_START + 1) |
37 | #define NETXEN_NIC_NAME (NETXEN_CMD_START + 2) | 37 | #define NETXEN_NIC_NAME (NETXEN_CMD_START + 2) |
38 | #define NETXEN_NIC_NAME_LEN 16 | 38 | #define NETXEN_NIC_NAME_LEN 16 |
39 | #define NETXEN_NIC_NAME_RSP "NETXEN" | 39 | #define NETXEN_NIC_NAME_RSP "NETXEN-UNM" |
40 | 40 | ||
41 | typedef enum { | 41 | typedef enum { |
42 | netxen_nic_cmd_none = 0, | 42 | netxen_nic_cmd_none = 0, |
diff --git a/drivers/net/netxen/netxen_nic_isr.c b/drivers/net/netxen/netxen_nic_isr.c index ae180fee8008..1b45f50fa6aa 100644 --- a/drivers/net/netxen/netxen_nic_isr.c +++ b/drivers/net/netxen/netxen_nic_isr.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
@@ -16,10 +16,10 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -68,8 +68,7 @@ struct net_device_stats *netxen_nic_get_stats(struct net_device *netdev) | |||
68 | void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno, | 68 | void netxen_indicate_link_status(struct netxen_adapter *adapter, u32 portno, |
69 | u32 link) | 69 | u32 link) |
70 | { | 70 | { |
71 | struct netxen_port *pport = adapter->port[portno]; | 71 | struct net_device *netdev = (adapter->port[portno])->netdev; |
72 | struct net_device *netdev = pport->netdev; | ||
73 | 72 | ||
74 | if (link) | 73 | if (link) |
75 | netif_carrier_on(netdev); | 74 | netif_carrier_on(netdev); |
@@ -84,46 +83,41 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno, | |||
84 | struct netxen_port *port; | 83 | struct netxen_port *port; |
85 | 84 | ||
86 | /* This should clear the interrupt source */ | 85 | /* This should clear the interrupt source */ |
87 | if (adapter->ops->phy_read) | 86 | if (adapter->phy_read) |
88 | adapter->ops->phy_read(adapter, portno, | 87 | adapter->phy_read(adapter, portno, |
89 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, | 88 | NETXEN_NIU_GB_MII_MGMT_ADDR_INT_STATUS, |
90 | &int_src); | 89 | &int_src); |
91 | if (int_src == 0) { | 90 | if (int_src == 0) { |
92 | DPRINTK(INFO, "No phy interrupts for port #%d\n", portno); | 91 | DPRINTK(INFO, "No phy interrupts for port #%d\n", portno); |
93 | return; | 92 | return; |
94 | } | 93 | } |
95 | if (adapter->ops->disable_phy_interrupts) | 94 | if (adapter->disable_phy_interrupts) |
96 | adapter->ops->disable_phy_interrupts(adapter, portno); | 95 | adapter->disable_phy_interrupts(adapter, portno); |
97 | 96 | ||
98 | port = adapter->port[portno]; | 97 | port = adapter->port[portno]; |
99 | 98 | ||
100 | if (netxen_get_phy_int_jabber(int_src)) | 99 | if (netxen_get_phy_int_jabber(int_src)) |
101 | DPRINTK(INFO, "NetXen: %s Jabber interrupt \n", | 100 | DPRINTK(INFO, "Jabber interrupt \n"); |
102 | port->netdev->name); | ||
103 | 101 | ||
104 | if (netxen_get_phy_int_polarity_changed(int_src)) | 102 | if (netxen_get_phy_int_polarity_changed(int_src)) |
105 | DPRINTK(INFO, "NetXen: %s POLARITY CHANGED int \n", | 103 | DPRINTK(INFO, "POLARITY CHANGED int \n"); |
106 | port->netdev->name); | ||
107 | 104 | ||
108 | if (netxen_get_phy_int_energy_detect(int_src)) | 105 | if (netxen_get_phy_int_energy_detect(int_src)) |
109 | DPRINTK(INFO, "NetXen: %s ENERGY DETECT INT \n", | 106 | DPRINTK(INFO, "ENERGY DETECT INT \n"); |
110 | port->netdev->name); | ||
111 | 107 | ||
112 | if (netxen_get_phy_int_downshift(int_src)) | 108 | if (netxen_get_phy_int_downshift(int_src)) |
113 | DPRINTK(INFO, "NetXen: %s DOWNSHIFT INT \n", | 109 | DPRINTK(INFO, "DOWNSHIFT INT \n"); |
114 | port->netdev->name); | ||
115 | /* write it down later.. */ | 110 | /* write it down later.. */ |
116 | if ((netxen_get_phy_int_speed_changed(int_src)) | 111 | if ((netxen_get_phy_int_speed_changed(int_src)) |
117 | || (netxen_get_phy_int_link_status_changed(int_src))) { | 112 | || (netxen_get_phy_int_link_status_changed(int_src))) { |
118 | __le32 status; | 113 | __le32 status; |
119 | 114 | ||
120 | DPRINTK(INFO, "NetXen: %s SPEED CHANGED OR" | 115 | DPRINTK(INFO, "SPEED CHANGED OR LINK STATUS CHANGED \n"); |
121 | " LINK STATUS CHANGED \n", port->netdev->name); | ||
122 | 116 | ||
123 | if (adapter->ops->phy_read | 117 | if (adapter->phy_read |
124 | && adapter->ops->phy_read(adapter, portno, | 118 | && adapter->phy_read(adapter, portno, |
125 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, | 119 | NETXEN_NIU_GB_MII_MGMT_ADDR_PHY_STATUS, |
126 | &status) == 0) { | 120 | &status) == 0) { |
127 | if (netxen_get_phy_int_link_status_changed(int_src)) { | 121 | if (netxen_get_phy_int_link_status_changed(int_src)) { |
128 | if (netxen_get_phy_link(status)) { | 122 | if (netxen_get_phy_link(status)) { |
129 | netxen_niu_gbe_init_port(adapter, | 123 | netxen_niu_gbe_init_port(adapter, |
@@ -143,8 +137,8 @@ void netxen_handle_port_int(struct netxen_adapter *adapter, u32 portno, | |||
143 | } | 137 | } |
144 | } | 138 | } |
145 | } | 139 | } |
146 | if (adapter->ops->enable_phy_interrupts) | 140 | if (adapter->enable_phy_interrupts) |
147 | adapter->ops->enable_phy_interrupts(adapter, portno); | 141 | adapter->enable_phy_interrupts(adapter, portno); |
148 | } | 142 | } |
149 | 143 | ||
150 | void netxen_nic_isr_other(struct netxen_adapter *adapter) | 144 | void netxen_nic_isr_other(struct netxen_adapter *adapter) |
@@ -159,8 +153,7 @@ void netxen_nic_isr_other(struct netxen_adapter *adapter) | |||
159 | 153 | ||
160 | qg_linksup = adapter->ahw.qg_linksup; | 154 | qg_linksup = adapter->ahw.qg_linksup; |
161 | adapter->ahw.qg_linksup = val; | 155 | adapter->ahw.qg_linksup = val; |
162 | DPRINTK(1, INFO, "%s: link update 0x%08x\n", netxen_nic_driver_name, | 156 | DPRINTK(INFO, "link update 0x%08x\n", val); |
163 | val); | ||
164 | for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) { | 157 | for (portno = 0; portno < NETXEN_NIU_MAX_GBE_PORTS; portno++) { |
165 | linkup = val & 1; | 158 | linkup = val & 1; |
166 | if (linkup != (qg_linksup & 1)) { | 159 | if (linkup != (qg_linksup & 1)) { |
diff --git a/drivers/net/netxen/netxen_nic_main.c b/drivers/net/netxen/netxen_nic_main.c index df0bb36a1cfb..575b71b67202 100644 --- a/drivers/net/netxen/netxen_nic_main.c +++ b/drivers/net/netxen/netxen_nic_main.c | |||
@@ -1,25 +1,25 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
8 | * of the License, or (at your option) any later version. | 8 | * of the License, or (at your option) any later version. |
9 | * | 9 | * |
10 | * This program is distributed in the hope that it will be useful, but | 10 | * This program is distributed in the hope that it will be useful, but |
11 | * WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | * WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | * GNU General Public License for more details. | 13 | * GNU General Public License for more details. |
14 | * | 14 | * |
15 | * You should have received a copy of the GNU General Public License | 15 | * You should have received a copy of the GNU General Public License |
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -32,6 +32,7 @@ | |||
32 | */ | 32 | */ |
33 | 33 | ||
34 | #include <linux/vmalloc.h> | 34 | #include <linux/vmalloc.h> |
35 | #include <linux/highmem.h> | ||
35 | #include "netxen_nic_hw.h" | 36 | #include "netxen_nic_hw.h" |
36 | 37 | ||
37 | #include "netxen_nic.h" | 38 | #include "netxen_nic.h" |
@@ -48,14 +49,21 @@ MODULE_DESCRIPTION("NetXen Multi port (1/10) Gigabit Network Driver"); | |||
48 | MODULE_LICENSE("GPL"); | 49 | MODULE_LICENSE("GPL"); |
49 | MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); | 50 | MODULE_VERSION(NETXEN_NIC_LINUX_VERSIONID); |
50 | 51 | ||
51 | char netxen_nic_driver_name[] = "netxen"; | 52 | char netxen_nic_driver_name[] = "netxen-nic"; |
52 | static char netxen_nic_driver_string[] = "NetXen Network Driver version " | 53 | static char netxen_nic_driver_string[] = "NetXen Network Driver version " |
53 | NETXEN_NIC_LINUX_VERSIONID; | 54 | NETXEN_NIC_LINUX_VERSIONID; |
54 | 55 | ||
56 | struct netxen_adapter *g_adapter = NULL; | ||
57 | |||
55 | #define NETXEN_NETDEV_WEIGHT 120 | 58 | #define NETXEN_NETDEV_WEIGHT 120 |
56 | #define NETXEN_ADAPTER_UP_MAGIC 777 | 59 | #define NETXEN_ADAPTER_UP_MAGIC 777 |
57 | #define NETXEN_NIC_PEG_TUNE 0 | 60 | #define NETXEN_NIC_PEG_TUNE 0 |
58 | 61 | ||
62 | u8 nx_p2_id = NX_P2_C0; | ||
63 | |||
64 | #define DMA_32BIT_MASK 0x00000000ffffffffULL | ||
65 | #define DMA_35BIT_MASK 0x00000007ffffffffULL | ||
66 | |||
59 | /* Local functions to NetXen NIC driver */ | 67 | /* Local functions to NetXen NIC driver */ |
60 | static int __devinit netxen_nic_probe(struct pci_dev *pdev, | 68 | static int __devinit netxen_nic_probe(struct pci_dev *pdev, |
61 | const struct pci_device_id *ent); | 69 | const struct pci_device_id *ent); |
@@ -87,6 +95,9 @@ static struct pci_device_id netxen_pci_tbl[] __devinitdata = { | |||
87 | 95 | ||
88 | MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); | 96 | MODULE_DEVICE_TABLE(pci, netxen_pci_tbl); |
89 | 97 | ||
98 | struct workqueue_struct *netxen_workq; | ||
99 | static void netxen_watchdog(unsigned long); | ||
100 | |||
90 | /* | 101 | /* |
91 | * netxen_nic_probe() | 102 | * netxen_nic_probe() |
92 | * | 103 | * |
@@ -105,20 +116,28 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
105 | struct net_device *netdev = NULL; | 116 | struct net_device *netdev = NULL; |
106 | struct netxen_adapter *adapter = NULL; | 117 | struct netxen_adapter *adapter = NULL; |
107 | struct netxen_port *port = NULL; | 118 | struct netxen_port *port = NULL; |
108 | u8 *mem_ptr0 = NULL; | 119 | void __iomem *mem_ptr0 = NULL; |
109 | u8 *mem_ptr1 = NULL; | 120 | void __iomem *mem_ptr1 = NULL; |
110 | u8 *mem_ptr2 = NULL; | 121 | void __iomem *mem_ptr2 = NULL; |
111 | 122 | ||
112 | unsigned long mem_base, mem_len; | 123 | u8 *db_ptr = NULL; |
124 | unsigned long mem_base, mem_len, db_base, db_len; | ||
113 | int pci_using_dac, i, err; | 125 | int pci_using_dac, i, err; |
114 | int ring; | 126 | int ring; |
115 | struct netxen_recv_context *recv_ctx = NULL; | 127 | struct netxen_recv_context *recv_ctx = NULL; |
116 | struct netxen_rcv_desc_ctx *rcv_desc = NULL; | 128 | struct netxen_rcv_desc_ctx *rcv_desc = NULL; |
117 | struct netxen_cmd_buffer *cmd_buf_arr = NULL; | 129 | struct netxen_cmd_buffer *cmd_buf_arr = NULL; |
118 | u64 mac_addr[FLASH_NUM_PORTS + 1]; | 130 | u64 mac_addr[FLASH_NUM_PORTS + 1]; |
119 | int valid_mac; | 131 | int valid_mac = 0; |
132 | static int netxen_cards_found = 0; | ||
120 | 133 | ||
121 | printk(KERN_INFO "%s \n", netxen_nic_driver_string); | 134 | printk(KERN_INFO "%s \n", netxen_nic_driver_string); |
135 | /* In current scheme, we use only PCI function 0 */ | ||
136 | if (PCI_FUNC(pdev->devfn) != 0) { | ||
137 | DPRINTK(ERR, "NetXen function %d will not be enabled.\n", | ||
138 | PCI_FUNC(pdev->devfn)); | ||
139 | return -ENODEV; | ||
140 | } | ||
122 | if ((err = pci_enable_device(pdev))) | 141 | if ((err = pci_enable_device(pdev))) |
123 | return err; | 142 | return err; |
124 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { | 143 | if (!(pci_resource_flags(pdev, 0) & IORESOURCE_MEM)) { |
@@ -130,10 +149,12 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
130 | goto err_out_disable_pdev; | 149 | goto err_out_disable_pdev; |
131 | 150 | ||
132 | pci_set_master(pdev); | 151 | pci_set_master(pdev); |
133 | if ((pci_set_dma_mask(pdev, DMA_64BIT_MASK) == 0) && | 152 | pci_read_config_byte(pdev, PCI_REVISION_ID, &nx_p2_id); |
134 | (pci_set_consistent_dma_mask(pdev, DMA_64BIT_MASK) == 0)) | 153 | if (nx_p2_id == NX_P2_C1 && |
154 | (pci_set_dma_mask(pdev, DMA_35BIT_MASK) == 0) && | ||
155 | (pci_set_consistent_dma_mask(pdev, DMA_35BIT_MASK) == 0)) { | ||
135 | pci_using_dac = 1; | 156 | pci_using_dac = 1; |
136 | else { | 157 | } else { |
137 | if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) || | 158 | if ((err = pci_set_dma_mask(pdev, DMA_32BIT_MASK)) || |
138 | (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) | 159 | (err = pci_set_consistent_dma_mask(pdev, DMA_32BIT_MASK))) |
139 | goto err_out_free_res; | 160 | goto err_out_free_res; |
@@ -153,21 +174,34 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
153 | ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); | 174 | ioremap(mem_base + THIRD_PAGE_GROUP_START, THIRD_PAGE_GROUP_SIZE); |
154 | 175 | ||
155 | if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) { | 176 | if ((mem_ptr0 == 0UL) || (mem_ptr1 == 0UL) || (mem_ptr2 == 0UL)) { |
156 | DPRINTK(1, ERR, | 177 | DPRINTK(ERR, |
157 | "Cannot remap adapter memory aborting.:" | 178 | "Cannot remap adapter memory aborting.:" |
158 | "0 -> %p, 1 -> %p, 2 -> %p\n", | 179 | "0 -> %p, 1 -> %p, 2 -> %p\n", |
159 | mem_ptr0, mem_ptr1, mem_ptr2); | 180 | mem_ptr0, mem_ptr1, mem_ptr2); |
160 | 181 | ||
161 | err = -EIO; | 182 | err = -EIO; |
162 | if (mem_ptr0) | 183 | goto err_out_iounmap; |
163 | iounmap(mem_ptr0); | 184 | } |
164 | if (mem_ptr1) | 185 | db_base = pci_resource_start(pdev, 4); /* doorbell is on bar 4 */ |
165 | iounmap(mem_ptr1); | 186 | db_len = pci_resource_len(pdev, 4); |
166 | if (mem_ptr2) | 187 | |
167 | iounmap(mem_ptr2); | 188 | if (db_len == 0) { |
168 | 189 | printk(KERN_ERR "%s: doorbell is disabled\n", | |
169 | goto err_out_free_res; | 190 | netxen_nic_driver_name); |
191 | err = -EIO; | ||
192 | goto err_out_iounmap; | ||
193 | } | ||
194 | DPRINTK(INFO, "doorbell ioremap from %lx a size of %lx\n", db_base, | ||
195 | db_len); | ||
196 | |||
197 | db_ptr = ioremap(db_base, NETXEN_DB_MAPSIZE_BYTES); | ||
198 | if (db_ptr == 0UL) { | ||
199 | printk(KERN_ERR "%s: Failed to allocate doorbell map.", | ||
200 | netxen_nic_driver_name); | ||
201 | err = -EIO; | ||
202 | goto err_out_iounmap; | ||
170 | } | 203 | } |
204 | DPRINTK(INFO, "doorbell ioremaped at %p\n", db_ptr); | ||
171 | 205 | ||
172 | /* | 206 | /* |
173 | * Allocate a adapter structure which will manage all the initialization | 207 | * Allocate a adapter structure which will manage all the initialization |
@@ -183,17 +217,24 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
183 | netxen_nic_driver_name, | 217 | netxen_nic_driver_name, |
184 | (int)sizeof(struct netxen_adapter)); | 218 | (int)sizeof(struct netxen_adapter)); |
185 | err = -ENOMEM; | 219 | err = -ENOMEM; |
186 | goto err_out_iounmap; | 220 | goto err_out_dbunmap; |
187 | } | 221 | } |
188 | 222 | ||
223 | if (netxen_cards_found == 0) { | ||
224 | g_adapter = adapter; | ||
225 | } | ||
189 | adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS; | 226 | adapter->max_tx_desc_count = MAX_CMD_DESCRIPTORS; |
190 | adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS; | 227 | adapter->max_rx_desc_count = MAX_RCV_DESCRIPTORS; |
191 | adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; | 228 | adapter->max_jumbo_rx_desc_count = MAX_JUMBO_RCV_DESCRIPTORS; |
229 | adapter->max_lro_rx_desc_count = MAX_LRO_RCV_DESCRIPTORS; | ||
192 | 230 | ||
193 | pci_set_drvdata(pdev, adapter); | 231 | pci_set_drvdata(pdev, adapter); |
194 | 232 | ||
195 | cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE); | 233 | cmd_buf_arr = (struct netxen_cmd_buffer *)vmalloc(TX_RINGSIZE); |
196 | if (cmd_buf_arr == NULL) { | 234 | if (cmd_buf_arr == NULL) { |
235 | printk(KERN_ERR | ||
236 | "%s: Could not allocate cmd_buf_arr memory:%d\n", | ||
237 | netxen_nic_driver_name, (int)TX_RINGSIZE); | ||
197 | err = -ENOMEM; | 238 | err = -ENOMEM; |
198 | goto err_out_free_adapter; | 239 | goto err_out_free_adapter; |
199 | } | 240 | } |
@@ -220,11 +261,23 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
220 | rcv_desc->skb_size = MAX_RX_JUMBO_BUFFER_LENGTH; | 261 | rcv_desc->skb_size = MAX_RX_JUMBO_BUFFER_LENGTH; |
221 | break; | 262 | break; |
222 | 263 | ||
264 | case RCV_RING_LRO: | ||
265 | rcv_desc->max_rx_desc_count = | ||
266 | adapter->max_lro_rx_desc_count; | ||
267 | rcv_desc->flags = RCV_DESC_LRO; | ||
268 | rcv_desc->dma_size = RX_LRO_DMA_MAP_LEN; | ||
269 | rcv_desc->skb_size = MAX_RX_LRO_BUFFER_LENGTH; | ||
270 | break; | ||
271 | |||
223 | } | 272 | } |
224 | rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *) | 273 | rcv_desc->rx_buf_arr = (struct netxen_rx_buffer *) |
225 | vmalloc(RCV_BUFFSIZE); | 274 | vmalloc(RCV_BUFFSIZE); |
226 | 275 | ||
227 | if (rcv_desc->rx_buf_arr == NULL) { | 276 | if (rcv_desc->rx_buf_arr == NULL) { |
277 | printk(KERN_ERR "%s: Could not allocate" | ||
278 | "rcv_desc->rx_buf_arr memory:%d\n", | ||
279 | netxen_nic_driver_name, | ||
280 | (int)RCV_BUFFSIZE); | ||
228 | err = -ENOMEM; | 281 | err = -ENOMEM; |
229 | goto err_out_free_rx_buffer; | 282 | goto err_out_free_rx_buffer; |
230 | } | 283 | } |
@@ -233,30 +286,21 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
233 | 286 | ||
234 | } | 287 | } |
235 | 288 | ||
236 | adapter->ops = kzalloc(sizeof(struct netxen_drvops), GFP_KERNEL); | ||
237 | if (adapter->ops == NULL) { | ||
238 | printk(KERN_ERR | ||
239 | "%s: Could not allocate memory for adapter->ops:%d\n", | ||
240 | netxen_nic_driver_name, | ||
241 | (int)sizeof(struct netxen_adapter)); | ||
242 | err = -ENOMEM; | ||
243 | goto err_out_free_rx_buffer; | ||
244 | } | ||
245 | |||
246 | adapter->cmd_buf_arr = cmd_buf_arr; | 289 | adapter->cmd_buf_arr = cmd_buf_arr; |
247 | adapter->ahw.pci_base0 = mem_ptr0; | 290 | adapter->ahw.pci_base0 = mem_ptr0; |
248 | adapter->ahw.pci_base1 = mem_ptr1; | 291 | adapter->ahw.pci_base1 = mem_ptr1; |
249 | adapter->ahw.pci_base2 = mem_ptr2; | 292 | adapter->ahw.pci_base2 = mem_ptr2; |
293 | adapter->ahw.db_base = db_ptr; | ||
294 | adapter->ahw.db_len = db_len; | ||
250 | spin_lock_init(&adapter->tx_lock); | 295 | spin_lock_init(&adapter->tx_lock); |
251 | spin_lock_init(&adapter->lock); | 296 | spin_lock_init(&adapter->lock); |
297 | netxen_initialize_adapter_sw(adapter); /* initialize the buffers in adapter */ | ||
252 | #ifdef CONFIG_IA64 | 298 | #ifdef CONFIG_IA64 |
253 | netxen_pinit_from_rom(adapter, 0); | 299 | netxen_pinit_from_rom(adapter, 0); |
254 | udelay(500); | 300 | udelay(500); |
255 | netxen_load_firmware(adapter); | 301 | netxen_load_firmware(adapter); |
256 | #endif | 302 | #endif |
257 | 303 | ||
258 | /* initialize the buffers in adapter */ | ||
259 | netxen_initialize_adapter_sw(adapter); | ||
260 | /* | 304 | /* |
261 | * Set the CRB window to invalid. If any register in window 0 is | 305 | * Set the CRB window to invalid. If any register in window 0 is |
262 | * accessed it should set the window to 0 and then reset it to 1. | 306 | * accessed it should set the window to 0 and then reset it to 1. |
@@ -277,7 +321,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
277 | INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); | 321 | INIT_WORK(&adapter->watchdog_task, netxen_watchdog_task); |
278 | adapter->ahw.pdev = pdev; | 322 | adapter->ahw.pdev = pdev; |
279 | adapter->proc_cmd_buf_counter = 0; | 323 | adapter->proc_cmd_buf_counter = 0; |
280 | pci_read_config_byte(pdev, PCI_REVISION_ID, &adapter->ahw.revision_id); | 324 | adapter->ahw.revision_id = nx_p2_id; |
281 | 325 | ||
282 | if (pci_enable_msi(pdev)) { | 326 | if (pci_enable_msi(pdev)) { |
283 | adapter->flags &= ~NETXEN_NIC_MSI_ENABLED; | 327 | adapter->flags &= ~NETXEN_NIC_MSI_ENABLED; |
@@ -299,6 +343,12 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
299 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET)); | 343 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_CONSUMER_OFFSET)); |
300 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); | 344 | writel(0, NETXEN_CRB_NORMALIZE(adapter, CRB_HOST_CMD_ADDR_LO)); |
301 | 345 | ||
346 | /* do this before waking up pegs so that we have valid dummy dma addr */ | ||
347 | err = netxen_initialize_adapter_offload(adapter); | ||
348 | if (err) { | ||
349 | goto err_out_free_dev; | ||
350 | } | ||
351 | |||
302 | /* Unlock the HW, prompting the boot sequence */ | 352 | /* Unlock the HW, prompting the boot sequence */ |
303 | writel(1, | 353 | writel(1, |
304 | NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); | 354 | NETXEN_CRB_NORMALIZE(adapter, NETXEN_ROMUSB_GLB_PEGTUNE_DONE)); |
@@ -307,6 +357,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
307 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); | 357 | netxen_phantom_init(adapter, NETXEN_NIC_PEG_TUNE); |
308 | 358 | ||
309 | /* initialize the all the ports */ | 359 | /* initialize the all the ports */ |
360 | adapter->active_ports = 0; | ||
310 | 361 | ||
311 | for (i = 0; i < adapter->ahw.max_ports; i++) { | 362 | for (i = 0; i < adapter->ahw.max_ports; i++) { |
312 | netdev = alloc_etherdev(sizeof(struct netxen_port)); | 363 | netdev = alloc_etherdev(sizeof(struct netxen_port)); |
@@ -372,10 +423,9 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
372 | netdev->dev_addr[4], | 423 | netdev->dev_addr[4], |
373 | netdev->dev_addr[5]); | 424 | netdev->dev_addr[5]); |
374 | } else { | 425 | } else { |
375 | if (adapter->ops->macaddr_set) | 426 | if (adapter->macaddr_set) |
376 | adapter->ops->macaddr_set(port, | 427 | adapter->macaddr_set(port, |
377 | netdev-> | 428 | netdev->dev_addr); |
378 | dev_addr); | ||
379 | } | 429 | } |
380 | } | 430 | } |
381 | adapter->netdev = netdev; | 431 | adapter->netdev = netdev; |
@@ -391,7 +441,6 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
391 | goto err_out_free_dev; | 441 | goto err_out_free_dev; |
392 | } | 442 | } |
393 | adapter->port_count++; | 443 | adapter->port_count++; |
394 | adapter->active_ports = 0; | ||
395 | adapter->port[i] = port; | 444 | adapter->port[i] = port; |
396 | } | 445 | } |
397 | 446 | ||
@@ -412,6 +461,7 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
412 | break; | 461 | break; |
413 | } | 462 | } |
414 | 463 | ||
464 | adapter->number = netxen_cards_found; | ||
415 | adapter->driver_mismatch = 0; | 465 | adapter->driver_mismatch = 0; |
416 | 466 | ||
417 | return 0; | 467 | return 0; |
@@ -426,7 +476,8 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
426 | free_netdev(port->netdev); | 476 | free_netdev(port->netdev); |
427 | } | 477 | } |
428 | } | 478 | } |
429 | kfree(adapter->ops); | 479 | |
480 | netxen_free_adapter_offload(adapter); | ||
430 | 481 | ||
431 | err_out_free_rx_buffer: | 482 | err_out_free_rx_buffer: |
432 | for (i = 0; i < MAX_RCV_CTX; ++i) { | 483 | for (i = 0; i < MAX_RCV_CTX; ++i) { |
@@ -439,19 +490,23 @@ netxen_nic_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
439 | } | 490 | } |
440 | } | 491 | } |
441 | } | 492 | } |
442 | |||
443 | vfree(cmd_buf_arr); | 493 | vfree(cmd_buf_arr); |
444 | 494 | ||
445 | kfree(adapter->port); | ||
446 | |||
447 | err_out_free_adapter: | 495 | err_out_free_adapter: |
448 | pci_set_drvdata(pdev, NULL); | 496 | pci_set_drvdata(pdev, NULL); |
449 | kfree(adapter); | 497 | kfree(adapter); |
450 | 498 | ||
499 | err_out_dbunmap: | ||
500 | if (db_ptr) | ||
501 | iounmap(db_ptr); | ||
502 | |||
451 | err_out_iounmap: | 503 | err_out_iounmap: |
452 | iounmap(mem_ptr0); | 504 | if (mem_ptr0) |
453 | iounmap(mem_ptr1); | 505 | iounmap(mem_ptr0); |
454 | iounmap(mem_ptr2); | 506 | if (mem_ptr1) |
507 | iounmap(mem_ptr1); | ||
508 | if (mem_ptr2) | ||
509 | iounmap(mem_ptr2); | ||
455 | 510 | ||
456 | err_out_free_res: | 511 | err_out_free_res: |
457 | pci_release_regions(pdev); | 512 | pci_release_regions(pdev); |
@@ -476,12 +531,8 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
476 | 531 | ||
477 | netxen_nic_stop_all_ports(adapter); | 532 | netxen_nic_stop_all_ports(adapter); |
478 | /* leave the hw in the same state as reboot */ | 533 | /* leave the hw in the same state as reboot */ |
479 | netxen_pinit_from_rom(adapter, 0); | ||
480 | udelay(500); | ||
481 | netxen_load_firmware(adapter); | 534 | netxen_load_firmware(adapter); |
482 | 535 | netxen_free_adapter_offload(adapter); | |
483 | if ((adapter->flags & NETXEN_NIC_MSI_ENABLED)) | ||
484 | netxen_nic_disable_int(adapter); | ||
485 | 536 | ||
486 | udelay(500); /* Delay for a while to drain the DMA engines */ | 537 | udelay(500); /* Delay for a while to drain the DMA engines */ |
487 | for (i = 0; i < adapter->port_count; i++) { | 538 | for (i = 0; i < adapter->port_count; i++) { |
@@ -498,6 +549,7 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
498 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) | 549 | if (adapter->is_up == NETXEN_ADAPTER_UP_MAGIC) |
499 | netxen_free_hw_resources(adapter); | 550 | netxen_free_hw_resources(adapter); |
500 | 551 | ||
552 | iounmap(adapter->ahw.db_base); | ||
501 | iounmap(adapter->ahw.pci_base0); | 553 | iounmap(adapter->ahw.pci_base0); |
502 | iounmap(adapter->ahw.pci_base1); | 554 | iounmap(adapter->ahw.pci_base1); |
503 | iounmap(adapter->ahw.pci_base2); | 555 | iounmap(adapter->ahw.pci_base2); |
@@ -524,7 +576,6 @@ static void __devexit netxen_nic_remove(struct pci_dev *pdev) | |||
524 | } | 576 | } |
525 | 577 | ||
526 | vfree(adapter->cmd_buf_arr); | 578 | vfree(adapter->cmd_buf_arr); |
527 | kfree(adapter->ops); | ||
528 | kfree(adapter); | 579 | kfree(adapter); |
529 | } | 580 | } |
530 | 581 | ||
@@ -546,6 +597,8 @@ static int netxen_nic_open(struct net_device *netdev) | |||
546 | return -EIO; | 597 | return -EIO; |
547 | } | 598 | } |
548 | netxen_nic_flash_print(adapter); | 599 | netxen_nic_flash_print(adapter); |
600 | if (adapter->init_niu) | ||
601 | adapter->init_niu(adapter); | ||
549 | 602 | ||
550 | /* setup all the resources for the Phantom... */ | 603 | /* setup all the resources for the Phantom... */ |
551 | /* this include the descriptors for rcv, tx, and status */ | 604 | /* this include the descriptors for rcv, tx, and status */ |
@@ -556,32 +609,31 @@ static int netxen_nic_open(struct net_device *netdev) | |||
556 | err); | 609 | err); |
557 | return err; | 610 | return err; |
558 | } | 611 | } |
559 | if (adapter->ops->init_port | 612 | if (adapter->init_port |
560 | && adapter->ops->init_port(adapter, port->portnum) != 0) { | 613 | && adapter->init_port(adapter, port->portnum) != 0) { |
561 | printk(KERN_ERR "%s: Failed to initialize port %d\n", | 614 | printk(KERN_ERR "%s: Failed to initialize port %d\n", |
562 | netxen_nic_driver_name, port->portnum); | 615 | netxen_nic_driver_name, port->portnum); |
563 | netxen_free_hw_resources(adapter); | 616 | netxen_free_hw_resources(adapter); |
564 | return -EIO; | 617 | return -EIO; |
565 | } | 618 | } |
566 | if (adapter->ops->init_niu) | ||
567 | adapter->ops->init_niu(adapter); | ||
568 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { | 619 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
569 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) | 620 | for (ring = 0; ring < NUM_RCV_DESC_RINGS; ring++) |
570 | netxen_post_rx_buffers(adapter, ctx, ring); | 621 | netxen_post_rx_buffers(adapter, ctx, ring); |
571 | } | 622 | } |
572 | adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; | 623 | adapter->irq = adapter->ahw.pdev->irq; |
573 | } | ||
574 | adapter->active_ports++; | ||
575 | if (adapter->active_ports == 1) { | ||
576 | err = request_irq(adapter->ahw.pdev->irq, &netxen_intr, | 624 | err = request_irq(adapter->ahw.pdev->irq, &netxen_intr, |
577 | SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, | 625 | SA_SHIRQ | SA_SAMPLE_RANDOM, netdev->name, |
578 | adapter); | 626 | adapter); |
579 | if (err) { | 627 | if (err) { |
580 | printk(KERN_ERR "request_irq failed with: %d\n", err); | 628 | printk(KERN_ERR "request_irq failed with: %d\n", err); |
581 | adapter->active_ports--; | 629 | netxen_free_hw_resources(adapter); |
582 | return err; | 630 | return err; |
583 | } | 631 | } |
584 | adapter->irq = adapter->ahw.pdev->irq; | 632 | |
633 | adapter->is_up = NETXEN_ADAPTER_UP_MAGIC; | ||
634 | } | ||
635 | adapter->active_ports++; | ||
636 | if (adapter->active_ports == 1) { | ||
585 | if (!adapter->driver_mismatch) | 637 | if (!adapter->driver_mismatch) |
586 | mod_timer(&adapter->watchdog_timer, jiffies); | 638 | mod_timer(&adapter->watchdog_timer, jiffies); |
587 | 639 | ||
@@ -590,11 +642,14 @@ static int netxen_nic_open(struct net_device *netdev) | |||
590 | 642 | ||
591 | /* Done here again so that even if phantom sw overwrote it, | 643 | /* Done here again so that even if phantom sw overwrote it, |
592 | * we set it */ | 644 | * we set it */ |
593 | if (adapter->ops->macaddr_set) | 645 | if (adapter->macaddr_set) |
594 | adapter->ops->macaddr_set(port, netdev->dev_addr); | 646 | adapter->macaddr_set(port, netdev->dev_addr); |
595 | netxen_nic_set_link_parameters(port); | 647 | netxen_nic_set_link_parameters(port); |
596 | 648 | ||
597 | netxen_nic_set_multi(netdev); | 649 | netxen_nic_set_multi(netdev); |
650 | if (adapter->set_mtu) | ||
651 | adapter->set_mtu(port, netdev->mtu); | ||
652 | |||
598 | if (!adapter->driver_mismatch) | 653 | if (!adapter->driver_mismatch) |
599 | netif_start_queue(netdev); | 654 | netif_start_queue(netdev); |
600 | 655 | ||
@@ -647,6 +702,7 @@ static int netxen_nic_close(struct net_device *netdev) | |||
647 | } | 702 | } |
648 | cmd_buff++; | 703 | cmd_buff++; |
649 | } | 704 | } |
705 | FLUSH_SCHEDULED_WORK(); | ||
650 | del_timer_sync(&adapter->watchdog_timer); | 706 | del_timer_sync(&adapter->watchdog_timer); |
651 | } | 707 | } |
652 | 708 | ||
@@ -667,7 +723,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
667 | struct cmd_desc_type0 *hwdesc; | 723 | struct cmd_desc_type0 *hwdesc; |
668 | int k; | 724 | int k; |
669 | struct netxen_cmd_buffer *pbuf = NULL; | 725 | struct netxen_cmd_buffer *pbuf = NULL; |
670 | unsigned int tries = 0; | ||
671 | static int dropped_packet = 0; | 726 | static int dropped_packet = 0; |
672 | int frag_count; | 727 | int frag_count; |
673 | u32 local_producer = 0; | 728 | u32 local_producer = 0; |
@@ -729,7 +784,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
729 | if (((skb->nh.iph)->ihl * sizeof(u32)) + | 784 | if (((skb->nh.iph)->ihl * sizeof(u32)) + |
730 | ((skb->h.th)->doff * sizeof(u32)) + | 785 | ((skb->h.th)->doff * sizeof(u32)) + |
731 | sizeof(struct ethhdr) > | 786 | sizeof(struct ethhdr) > |
732 | (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) { | 787 | (sizeof(struct cmd_desc_type0) - 2)) { |
733 | no_of_desc++; | 788 | no_of_desc++; |
734 | } | 789 | } |
735 | } | 790 | } |
@@ -740,27 +795,17 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
740 | if ((k + no_of_desc) >= | 795 | if ((k + no_of_desc) >= |
741 | ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : | 796 | ((last_cmd_consumer <= k) ? last_cmd_consumer + max_tx_desc_count : |
742 | last_cmd_consumer)) { | 797 | last_cmd_consumer)) { |
798 | port->stats.nocmddescriptor++; | ||
799 | DPRINTK(ERR, "No command descriptors available," | ||
800 | " producer = %d, consumer = %d count=%llu," | ||
801 | " dropping packet\n", producer, | ||
802 | adapter->last_cmd_consumer, | ||
803 | port->stats.nocmddescriptor); | ||
804 | |||
805 | netif_stop_queue(netdev); | ||
806 | port->flags |= NETXEN_NETDEV_STATUS; | ||
743 | spin_unlock_bh(&adapter->tx_lock); | 807 | spin_unlock_bh(&adapter->tx_lock); |
744 | if (tries == 0) { | 808 | return NETDEV_TX_BUSY; |
745 | local_bh_disable(); | ||
746 | netxen_process_cmd_ring((unsigned long)adapter); | ||
747 | local_bh_enable(); | ||
748 | ++tries; | ||
749 | goto retry_getting_window; | ||
750 | } else { | ||
751 | port->stats.nocmddescriptor++; | ||
752 | DPRINTK(ERR, "No command descriptors available," | ||
753 | " producer = %d, consumer = %d count=%llu," | ||
754 | " dropping packet\n", producer, | ||
755 | adapter->last_cmd_consumer, | ||
756 | port->stats.nocmddescriptor); | ||
757 | |||
758 | spin_lock_bh(&adapter->tx_lock); | ||
759 | netif_stop_queue(netdev); | ||
760 | port->flags |= NETXEN_NETDEV_STATUS; | ||
761 | spin_unlock_bh(&adapter->tx_lock); | ||
762 | return NETDEV_TX_BUSY; | ||
763 | } | ||
764 | } | 809 | } |
765 | k = get_index_range(k, max_tx_desc_count, no_of_desc); | 810 | k = get_index_range(k, max_tx_desc_count, no_of_desc); |
766 | adapter->cmd_producer = k; | 811 | adapter->cmd_producer = k; |
@@ -782,7 +827,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
782 | pbuf->mss = 0; | 827 | pbuf->mss = 0; |
783 | hwdesc->mss = 0; | 828 | hwdesc->mss = 0; |
784 | } | 829 | } |
785 | pbuf->no_of_descriptors = no_of_desc; | ||
786 | pbuf->total_length = skb->len; | 830 | pbuf->total_length = skb->len; |
787 | pbuf->skb = skb; | 831 | pbuf->skb = skb; |
788 | pbuf->cmd = TX_ETHER_PKT; | 832 | pbuf->cmd = TX_ETHER_PKT; |
@@ -792,11 +836,11 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
792 | buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len, | 836 | buffrag->dma = pci_map_single(port->pdev, skb->data, first_seg_len, |
793 | PCI_DMA_TODEVICE); | 837 | PCI_DMA_TODEVICE); |
794 | buffrag->length = first_seg_len; | 838 | buffrag->length = first_seg_len; |
795 | CMD_DESC_TOTAL_LENGTH_WRT(hwdesc, skb->len); | 839 | netxen_set_cmd_desc_totallength(hwdesc, skb->len); |
796 | hwdesc->num_of_buffers = frag_count; | 840 | netxen_set_cmd_desc_num_of_buff(hwdesc, frag_count); |
797 | hwdesc->opcode = TX_ETHER_PKT; | 841 | netxen_set_cmd_desc_opcode(hwdesc, TX_ETHER_PKT); |
798 | 842 | ||
799 | CMD_DESC_PORT_WRT(hwdesc, port->portnum); | 843 | netxen_set_cmd_desc_port(hwdesc, port->portnum); |
800 | hwdesc->buffer1_length = cpu_to_le16(first_seg_len); | 844 | hwdesc->buffer1_length = cpu_to_le16(first_seg_len); |
801 | hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); | 845 | hwdesc->addr_buffer1 = cpu_to_le64(buffrag->dma); |
802 | 846 | ||
@@ -855,12 +899,12 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
855 | /* For LSO, we need to copy the MAC/IP/TCP headers into | 899 | /* For LSO, we need to copy the MAC/IP/TCP headers into |
856 | * the descriptor ring | 900 | * the descriptor ring |
857 | */ | 901 | */ |
858 | if (hw->cmd_desc_head[saved_producer].opcode == TX_TCP_LSO) { | 902 | if (netxen_get_cmd_desc_opcode(&hw->cmd_desc_head[saved_producer]) |
903 | == TX_TCP_LSO) { | ||
859 | int hdr_len, first_hdr_len, more_hdr; | 904 | int hdr_len, first_hdr_len, more_hdr; |
860 | hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length; | 905 | hdr_len = hw->cmd_desc_head[saved_producer].total_hdr_length; |
861 | if (hdr_len > (sizeof(struct cmd_desc_type0) - NET_IP_ALIGN)) { | 906 | if (hdr_len > (sizeof(struct cmd_desc_type0) - 2)) { |
862 | first_hdr_len = | 907 | first_hdr_len = sizeof(struct cmd_desc_type0) - 2; |
863 | sizeof(struct cmd_desc_type0) - NET_IP_ALIGN; | ||
864 | more_hdr = 1; | 908 | more_hdr = 1; |
865 | } else { | 909 | } else { |
866 | first_hdr_len = hdr_len; | 910 | first_hdr_len = hdr_len; |
@@ -870,7 +914,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
870 | hwdesc = &hw->cmd_desc_head[producer]; | 914 | hwdesc = &hw->cmd_desc_head[producer]; |
871 | 915 | ||
872 | /* copy the first 64 bytes */ | 916 | /* copy the first 64 bytes */ |
873 | memcpy(((void *)hwdesc) + NET_IP_ALIGN, | 917 | memcpy(((void *)hwdesc) + 2, |
874 | (void *)(skb->data), first_hdr_len); | 918 | (void *)(skb->data), first_hdr_len); |
875 | producer = get_next_index(producer, max_tx_desc_count); | 919 | producer = get_next_index(producer, max_tx_desc_count); |
876 | 920 | ||
@@ -886,7 +930,7 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
886 | } | 930 | } |
887 | spin_lock_bh(&adapter->tx_lock); | 931 | spin_lock_bh(&adapter->tx_lock); |
888 | port->stats.txbytes += | 932 | port->stats.txbytes += |
889 | CMD_DESC_TOTAL_LENGTH(&hw->cmd_desc_head[saved_producer]); | 933 | netxen_get_cmd_desc_totallength(&hw->cmd_desc_head[saved_producer]); |
890 | /* Code to update the adapter considering how many producer threads | 934 | /* Code to update the adapter considering how many producer threads |
891 | are currently working */ | 935 | are currently working */ |
892 | if ((--adapter->num_threads) == 0) { | 936 | if ((--adapter->num_threads) == 0) { |
@@ -896,20 +940,6 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
896 | NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET)); | 940 | NETXEN_CRB_NORMALIZE(adapter, CRB_CMD_PRODUCER_OFFSET)); |
897 | wmb(); | 941 | wmb(); |
898 | adapter->total_threads = 0; | 942 | adapter->total_threads = 0; |
899 | } else { | ||
900 | u32 crb_producer = 0; | ||
901 | crb_producer = | ||
902 | readl(NETXEN_CRB_NORMALIZE | ||
903 | (adapter, CRB_CMD_PRODUCER_OFFSET)); | ||
904 | if (crb_producer == local_producer) { | ||
905 | crb_producer = get_index_range(crb_producer, | ||
906 | max_tx_desc_count, | ||
907 | no_of_desc); | ||
908 | writel(crb_producer, | ||
909 | NETXEN_CRB_NORMALIZE(adapter, | ||
910 | CRB_CMD_PRODUCER_OFFSET)); | ||
911 | wmb(); | ||
912 | } | ||
913 | } | 943 | } |
914 | 944 | ||
915 | port->stats.xmitfinished++; | 945 | port->stats.xmitfinished++; |
@@ -926,15 +956,20 @@ static int netxen_nic_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
926 | static void netxen_watchdog(unsigned long v) | 956 | static void netxen_watchdog(unsigned long v) |
927 | { | 957 | { |
928 | struct netxen_adapter *adapter = (struct netxen_adapter *)v; | 958 | struct netxen_adapter *adapter = (struct netxen_adapter *)v; |
929 | schedule_work(&adapter->watchdog_task); | 959 | if (adapter != g_adapter) { |
960 | printk("%s: ***BUG*** adapter[%p] != g_adapter[%p]\n", | ||
961 | __FUNCTION__, adapter, g_adapter); | ||
962 | return; | ||
963 | } | ||
964 | |||
965 | SCHEDULE_WORK(&adapter->watchdog_task); | ||
930 | } | 966 | } |
931 | 967 | ||
932 | static void netxen_tx_timeout(struct net_device *netdev) | 968 | static void netxen_tx_timeout(struct net_device *netdev) |
933 | { | 969 | { |
934 | struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); | 970 | struct netxen_port *port = (struct netxen_port *)netdev_priv(netdev); |
935 | struct netxen_adapter *adapter = port->adapter; | ||
936 | 971 | ||
937 | schedule_work(&adapter->tx_timeout_task); | 972 | SCHEDULE_WORK(&port->adapter->tx_timeout_task); |
938 | } | 973 | } |
939 | 974 | ||
940 | static void netxen_tx_timeout_task(struct work_struct *work) | 975 | static void netxen_tx_timeout_task(struct work_struct *work) |
@@ -967,6 +1002,11 @@ netxen_handle_int(struct netxen_adapter *adapter, struct net_device *netdev) | |||
967 | if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { | 1002 | if (!(adapter->flags & NETXEN_NIC_MSI_ENABLED)) { |
968 | int count = 0; | 1003 | int count = 0; |
969 | u32 mask; | 1004 | u32 mask; |
1005 | mask = readl(pci_base_offset(adapter, ISR_INT_VECTOR)); | ||
1006 | if ((mask & 0x80) == 0) { | ||
1007 | /* not our interrupt */ | ||
1008 | return ret; | ||
1009 | } | ||
970 | netxen_nic_disable_int(adapter); | 1010 | netxen_nic_disable_int(adapter); |
971 | /* Window = 0 or 1 */ | 1011 | /* Window = 0 or 1 */ |
972 | do { | 1012 | do { |
@@ -1026,7 +1066,10 @@ irqreturn_t netxen_intr(int irq, void *data) | |||
1026 | netdev = port->netdev; | 1066 | netdev = port->netdev; |
1027 | 1067 | ||
1028 | /* process our status queue (for all 4 ports) */ | 1068 | /* process our status queue (for all 4 ports) */ |
1029 | netxen_handle_int(adapter, netdev); | 1069 | if (netif_running(netdev)) { |
1070 | netxen_handle_int(adapter, netdev); | ||
1071 | break; | ||
1072 | } | ||
1030 | } | 1073 | } |
1031 | 1074 | ||
1032 | return IRQ_HANDLED; | 1075 | return IRQ_HANDLED; |
@@ -1040,11 +1083,12 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget) | |||
1040 | int done = 1; | 1083 | int done = 1; |
1041 | int ctx; | 1084 | int ctx; |
1042 | int this_work_done; | 1085 | int this_work_done; |
1086 | int work_done = 0; | ||
1043 | 1087 | ||
1044 | DPRINTK(INFO, "polling for %d descriptors\n", *budget); | 1088 | DPRINTK(INFO, "polling for %d descriptors\n", *budget); |
1045 | port->stats.polled++; | 1089 | port->stats.polled++; |
1046 | 1090 | ||
1047 | adapter->work_done = 0; | 1091 | work_done = 0; |
1048 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { | 1092 | for (ctx = 0; ctx < MAX_RCV_CTX; ++ctx) { |
1049 | /* | 1093 | /* |
1050 | * Fairness issue. This will give undue weight to the | 1094 | * Fairness issue. This will give undue weight to the |
@@ -1061,20 +1105,20 @@ static int netxen_nic_poll(struct net_device *netdev, int *budget) | |||
1061 | this_work_done = netxen_process_rcv_ring(adapter, ctx, | 1105 | this_work_done = netxen_process_rcv_ring(adapter, ctx, |
1062 | work_to_do / | 1106 | work_to_do / |
1063 | MAX_RCV_CTX); | 1107 | MAX_RCV_CTX); |
1064 | adapter->work_done += this_work_done; | 1108 | work_done += this_work_done; |
1065 | } | 1109 | } |
1066 | 1110 | ||
1067 | netdev->quota -= adapter->work_done; | 1111 | netdev->quota -= work_done; |
1068 | *budget -= adapter->work_done; | 1112 | *budget -= work_done; |
1069 | 1113 | ||
1070 | if (adapter->work_done >= work_to_do | 1114 | if (work_done >= work_to_do && netxen_nic_rx_has_work(adapter) != 0) |
1071 | && netxen_nic_rx_has_work(adapter) != 0) | ||
1072 | done = 0; | 1115 | done = 0; |
1073 | 1116 | ||
1074 | netxen_process_cmd_ring((unsigned long)adapter); | 1117 | if (netxen_process_cmd_ring((unsigned long)adapter) == 0) |
1118 | done = 0; | ||
1075 | 1119 | ||
1076 | DPRINTK(INFO, "new work_done: %d work_to_do: %d\n", | 1120 | DPRINTK(INFO, "new work_done: %d work_to_do: %d\n", |
1077 | adapter->work_done, work_to_do); | 1121 | work_done, work_to_do); |
1078 | if (done) { | 1122 | if (done) { |
1079 | netif_rx_complete(netdev); | 1123 | netif_rx_complete(netdev); |
1080 | netxen_nic_enable_int(adapter); | 1124 | netxen_nic_enable_int(adapter); |
@@ -1117,8 +1161,9 @@ netxen_nic_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd) | |||
1117 | if (ifr->ifr_data) { | 1161 | if (ifr->ifr_data) { |
1118 | sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP, | 1162 | sprintf(dev_name, "%s-%d", NETXEN_NIC_NAME_RSP, |
1119 | port->portnum); | 1163 | port->portnum); |
1120 | nr_bytes = copy_to_user((char *)ifr->ifr_data, dev_name, | 1164 | nr_bytes = |
1121 | NETXEN_NIC_NAME_LEN); | 1165 | copy_to_user((char __user *)ifr->ifr_data, dev_name, |
1166 | NETXEN_NIC_NAME_LEN); | ||
1122 | if (nr_bytes) | 1167 | if (nr_bytes) |
1123 | err = -EIO; | 1168 | err = -EIO; |
1124 | 1169 | ||
@@ -1145,6 +1190,9 @@ static struct pci_driver netxen_driver = { | |||
1145 | 1190 | ||
1146 | static int __init netxen_init_module(void) | 1191 | static int __init netxen_init_module(void) |
1147 | { | 1192 | { |
1193 | if ((netxen_workq = create_singlethread_workqueue("netxen")) == 0) | ||
1194 | return -ENOMEM; | ||
1195 | |||
1148 | return pci_module_init(&netxen_driver); | 1196 | return pci_module_init(&netxen_driver); |
1149 | } | 1197 | } |
1150 | 1198 | ||
@@ -1155,7 +1203,7 @@ static void __exit netxen_exit_module(void) | |||
1155 | /* | 1203 | /* |
1156 | * Wait for some time to allow the dma to drain, if any. | 1204 | * Wait for some time to allow the dma to drain, if any. |
1157 | */ | 1205 | */ |
1158 | mdelay(5); | 1206 | destroy_workqueue(netxen_workq); |
1159 | pci_unregister_driver(&netxen_driver); | 1207 | pci_unregister_driver(&netxen_driver); |
1160 | } | 1208 | } |
1161 | 1209 | ||
diff --git a/drivers/net/netxen/netxen_nic_niu.c b/drivers/net/netxen/netxen_nic_niu.c index 7950a04532e6..4987dc765d99 100644 --- a/drivers/net/netxen/netxen_nic_niu.c +++ b/drivers/net/netxen/netxen_nic_niu.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * Copyright (C) 2003 - 2006 NetXen, Inc. | 2 | * Copyright (C) 2003 - 2006 NetXen, Inc. |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
5 | * This program is free software; you can redistribute it and/or | 5 | * This program is free software; you can redistribute it and/or |
6 | * modify it under the terms of the GNU General Public License | 6 | * modify it under the terms of the GNU General Public License |
7 | * as published by the Free Software Foundation; either version 2 | 7 | * as published by the Free Software Foundation; either version 2 |
@@ -16,10 +16,10 @@ | |||
16 | * along with this program; if not, write to the Free Software | 16 | * along with this program; if not, write to the Free Software |
17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, | 17 | * Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
18 | * MA 02111-1307, USA. | 18 | * MA 02111-1307, USA. |
19 | * | 19 | * |
20 | * The full GNU General Public License is included in this distribution | 20 | * The full GNU General Public License is included in this distribution |
21 | * in the file called LICENSE. | 21 | * in the file called LICENSE. |
22 | * | 22 | * |
23 | * Contact Information: | 23 | * Contact Information: |
24 | * info@netxen.com | 24 | * info@netxen.com |
25 | * NetXen, | 25 | * NetXen, |
@@ -40,13 +40,15 @@ | |||
40 | 40 | ||
41 | static long phy_lock_timeout = 100000000; | 41 | static long phy_lock_timeout = 100000000; |
42 | 42 | ||
43 | static inline int phy_lock(void) | 43 | static inline int phy_lock(struct netxen_adapter *adapter) |
44 | { | 44 | { |
45 | int i; | 45 | int i; |
46 | int done = 0, timeout = 0; | 46 | int done = 0, timeout = 0; |
47 | 47 | ||
48 | while (!done) { | 48 | while (!done) { |
49 | done = readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_LOCK)); | 49 | done = |
50 | readl(pci_base_offset | ||
51 | (adapter, NETXEN_PCIE_REG(PCIE_SEM3_LOCK))); | ||
50 | if (done == 1) | 52 | if (done == 1) |
51 | break; | 53 | break; |
52 | if (timeout >= phy_lock_timeout) { | 54 | if (timeout >= phy_lock_timeout) { |
@@ -61,13 +63,15 @@ static inline int phy_lock(void) | |||
61 | } | 63 | } |
62 | } | 64 | } |
63 | 65 | ||
64 | writel(NETXEN_PHY_LOCK_ID, (void __iomem *)PHY_LOCK_DRIVER); | 66 | writel(PHY_LOCK_DRIVER, |
67 | NETXEN_CRB_NORMALIZE(adapter, NETXEN_PHY_LOCK_ID)); | ||
65 | return 0; | 68 | return 0; |
66 | } | 69 | } |
67 | 70 | ||
68 | static inline int phy_unlock(void) | 71 | static inline int phy_unlock(struct netxen_adapter *adapter) |
69 | { | 72 | { |
70 | readl((void __iomem *)NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK)); | 73 | readl(pci_base_offset(adapter, NETXEN_PCIE_REG(PCIE_SEM3_UNLOCK))); |
74 | |||
71 | return 0; | 75 | return 0; |
72 | } | 76 | } |
73 | 77 | ||
@@ -95,7 +99,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, | |||
95 | __le32 status; | 99 | __le32 status; |
96 | __le32 mac_cfg0; | 100 | __le32 mac_cfg0; |
97 | 101 | ||
98 | if (phy_lock() != 0) { | 102 | if (phy_lock(adapter) != 0) { |
99 | return -1; | 103 | return -1; |
100 | } | 104 | } |
101 | 105 | ||
@@ -162,7 +166,7 @@ int netxen_niu_gbe_phy_read(struct netxen_adapter *adapter, long phy, | |||
162 | NETXEN_NIU_GB_MAC_CONFIG_0(0), | 166 | NETXEN_NIU_GB_MAC_CONFIG_0(0), |
163 | &mac_cfg0, 4)) | 167 | &mac_cfg0, 4)) |
164 | return -EIO; | 168 | return -EIO; |
165 | phy_unlock(); | 169 | phy_unlock(adapter); |
166 | return result; | 170 | return result; |
167 | } | 171 | } |
168 | 172 | ||
@@ -399,8 +403,8 @@ int netxen_niu_gbe_init_port(struct netxen_adapter *adapter, int port) | |||
399 | { | 403 | { |
400 | int result = 0; | 404 | int result = 0; |
401 | __le32 status; | 405 | __le32 status; |
402 | if (adapter->ops->disable_phy_interrupts) | 406 | if (adapter->disable_phy_interrupts) |
403 | adapter->ops->disable_phy_interrupts(adapter, port); | 407 | adapter->disable_phy_interrupts(adapter, port); |
404 | mdelay(2); | 408 | mdelay(2); |
405 | 409 | ||
406 | if (0 == | 410 | if (0 == |
@@ -612,7 +616,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port, | |||
612 | __le32 temp = 0; | 616 | __le32 temp = 0; |
613 | struct netxen_adapter *adapter = port->adapter; | 617 | struct netxen_adapter *adapter = port->adapter; |
614 | int phy = port->portnum; | 618 | int phy = port->portnum; |
615 | unsigned char mac_addr[MAX_ADDR_LEN]; | 619 | unsigned char mac_addr[6]; |
616 | int i; | 620 | int i; |
617 | 621 | ||
618 | for (i = 0; i < 10; i++) { | 622 | for (i = 0; i < 10; i++) { |
@@ -631,7 +635,7 @@ int netxen_niu_macaddr_set(struct netxen_port *port, | |||
631 | 635 | ||
632 | netxen_niu_macaddr_get(adapter, phy, | 636 | netxen_niu_macaddr_get(adapter, phy, |
633 | (netxen_ethernet_macaddr_t *) mac_addr); | 637 | (netxen_ethernet_macaddr_t *) mac_addr); |
634 | if (memcmp(mac_addr, addr, MAX_ADDR_LEN == 0)) | 638 | if (memcmp(mac_addr, addr, 6) == 0) |
635 | break; | 639 | break; |
636 | } | 640 | } |
637 | 641 | ||
diff --git a/drivers/net/netxen/netxen_nic_phan_reg.h b/drivers/net/netxen/netxen_nic_phan_reg.h index 8181d436783f..7879f855af0b 100644 --- a/drivers/net/netxen/netxen_nic_phan_reg.h +++ b/drivers/net/netxen/netxen_nic_phan_reg.h | |||
@@ -33,15 +33,74 @@ | |||
33 | /* | 33 | /* |
34 | * CRB Registers or queue message done only at initialization time. | 34 | * CRB Registers or queue message done only at initialization time. |
35 | */ | 35 | */ |
36 | #define NIC_CRB_BASE NETXEN_CAM_RAM(0x200) | ||
37 | #define NETXEN_NIC_REG(X) (NIC_CRB_BASE+(X)) | ||
36 | 38 | ||
37 | /* | 39 | #define CRB_PHAN_CNTRL_LO_OFFSET NETXEN_NIC_REG(0x00) |
38 | * The following 2 are the base adresses for the CRB registers and their | 40 | #define CRB_PHAN_CNTRL_HI_OFFSET NETXEN_NIC_REG(0x04) |
39 | * offsets will be added to get addresses for the index addresses. | 41 | #define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08) |
40 | */ | 42 | #define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c) |
41 | #define NIC_CRB_BASE_PORT1 NETXEN_CAM_RAM(0x200) | 43 | #define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10) /* C0 EPG BUG */ |
42 | #define NIC_CRB_BASE_PORT2 NETXEN_CAM_RAM(0x250) | 44 | #define CRB_PAUSE_ADDR_HI NETXEN_NIC_REG(0x14) |
45 | #define CRB_HOST_CMD_ADDR_HI NETXEN_NIC_REG(0x18) /* host add:cmd ring */ | ||
46 | #define CRB_HOST_CMD_ADDR_LO NETXEN_NIC_REG(0x1c) | ||
47 | #define CRB_CMD_INTR_LOOP NETXEN_NIC_REG(0x20) /* 4 regs for perf */ | ||
48 | #define CRB_CMD_DMA_LOOP NETXEN_NIC_REG(0x24) | ||
49 | #define CRB_RCV_INTR_LOOP NETXEN_NIC_REG(0x28) | ||
50 | #define CRB_RCV_DMA_LOOP NETXEN_NIC_REG(0x2c) | ||
51 | #define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x30) /* phantom init status */ | ||
52 | #define CRB_MMAP_ADDR_3 NETXEN_NIC_REG(0x34) | ||
53 | #define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x38) | ||
54 | #define CRB_HOST_DUMMY_BUF_ADDR_HI NETXEN_NIC_REG(0x3c) | ||
55 | #define CRB_HOST_DUMMY_BUF_ADDR_LO NETXEN_NIC_REG(0x40) | ||
56 | #define CRB_MMAP_ADDR_0 NETXEN_NIC_REG(0x44) | ||
57 | #define CRB_MMAP_ADDR_1 NETXEN_NIC_REG(0x48) | ||
58 | #define CRB_MMAP_ADDR_2 NETXEN_NIC_REG(0x4c) | ||
59 | #define CRB_CMDPEG_STATE NETXEN_NIC_REG(0x50) | ||
60 | #define CRB_MMAP_SIZE_0 NETXEN_NIC_REG(0x54) | ||
61 | #define CRB_MMAP_SIZE_1 NETXEN_NIC_REG(0x58) | ||
62 | #define CRB_MMAP_SIZE_2 NETXEN_NIC_REG(0x5c) | ||
63 | #define CRB_MMAP_SIZE_3 NETXEN_NIC_REG(0x60) | ||
64 | #define CRB_GLOBAL_INT_COAL NETXEN_NIC_REG(0x64) /* interrupt coalescing */ | ||
65 | #define CRB_INT_COAL_MODE NETXEN_NIC_REG(0x68) | ||
66 | #define CRB_MAX_RCV_BUFS NETXEN_NIC_REG(0x6c) | ||
67 | #define CRB_TX_INT_THRESHOLD NETXEN_NIC_REG(0x70) | ||
68 | #define CRB_RX_PKT_TIMER NETXEN_NIC_REG(0x74) | ||
69 | #define CRB_TX_PKT_TIMER NETXEN_NIC_REG(0x78) | ||
70 | #define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x7c) | ||
71 | #define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x80) | ||
72 | #define CRB_RX_LRO_TIMER NETXEN_NIC_REG(0x84) | ||
73 | #define CRB_RX_LRO_MID_TIMER NETXEN_NIC_REG(0x88) | ||
74 | #define CRB_DMA_MAX_RCV_BUFS NETXEN_NIC_REG(0x8c) | ||
75 | #define CRB_MAX_DMA_ENTRIES NETXEN_NIC_REG(0x90) | ||
76 | #define CRB_XG_STATE NETXEN_NIC_REG(0x94) /* XG Link status */ | ||
77 | #define CRB_AGENT_GO NETXEN_NIC_REG(0x98) /* NIC pkt gen agent */ | ||
78 | #define CRB_AGENT_TX_SIZE NETXEN_NIC_REG(0x9c) | ||
79 | #define CRB_AGENT_TX_TYPE NETXEN_NIC_REG(0xa0) | ||
80 | #define CRB_AGENT_TX_ADDR NETXEN_NIC_REG(0xa4) | ||
81 | #define CRB_AGENT_TX_MSS NETXEN_NIC_REG(0xa8) | ||
82 | #define CRB_TX_STATE NETXEN_NIC_REG(0xac) /* Debug -performance */ | ||
83 | #define CRB_TX_COUNT NETXEN_NIC_REG(0xb0) | ||
84 | #define CRB_RX_STATE NETXEN_NIC_REG(0xb4) | ||
85 | #define CRB_RX_PERF_DEBUG_1 NETXEN_NIC_REG(0xb8) | ||
86 | #define CRB_RX_LRO_CONTROL NETXEN_NIC_REG(0xbc) /* LRO On/OFF */ | ||
87 | #define CRB_RX_LRO_START_NUM NETXEN_NIC_REG(0xc0) | ||
88 | #define CRB_MPORT_MODE NETXEN_NIC_REG(0xc4) /* Multiport Mode */ | ||
89 | #define CRB_CMD_RING_SIZE NETXEN_NIC_REG(0xc8) | ||
90 | #define CRB_INT_VECTOR NETXEN_NIC_REG(0xd4) | ||
91 | #define CRB_CTX_RESET NETXEN_NIC_REG(0xd8) | ||
92 | #define CRB_HOST_STS_PROD NETXEN_NIC_REG(0xdc) | ||
93 | #define CRB_HOST_STS_CONS NETXEN_NIC_REG(0xe0) | ||
94 | #define CRB_PEG_CMD_PROD NETXEN_NIC_REG(0xe4) | ||
95 | #define CRB_PEG_CMD_CONS NETXEN_NIC_REG(0xe8) | ||
96 | #define CRB_HOST_BUFFER_PROD NETXEN_NIC_REG(0xec) | ||
97 | #define CRB_HOST_BUFFER_CONS NETXEN_NIC_REG(0xf0) | ||
98 | #define CRB_JUMBO_BUFFER_PROD NETXEN_NIC_REG(0xf4) | ||
99 | #define CRB_JUMBO_BUFFER_CONS NETXEN_NIC_REG(0xf8) | ||
43 | 100 | ||
44 | #define NETXEN_NIC_REG(X) (NIC_CRB_BASE_PORT1+(X)) | 101 | #define CRB_CMD_PRODUCER_OFFSET_1 NETXEN_NIC_REG(0x1ac) |
102 | #define CRB_CMD_CONSUMER_OFFSET_1 NETXEN_NIC_REG(0x1b0) | ||
103 | #define CRB_TEMP_STATE NETXEN_NIC_REG(0x1b4) | ||
45 | 104 | ||
46 | /* | 105 | /* |
47 | * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address | 106 | * CrbPortPhanCntrHi/Lo is used to pass the address of HostPhantomIndex address |
@@ -51,74 +110,20 @@ | |||
51 | * on the Phantom. | 110 | * on the Phantom. |
52 | */ | 111 | */ |
53 | 112 | ||
54 | #define CRB_PHAN_CNTRL_LO_OFFSET NETXEN_NIC_REG(0x00) | 113 | #define nx_get_temp_val(x) ((x) >> 16) |
55 | #define CRB_PHAN_CNTRL_HI_OFFSET NETXEN_NIC_REG(0x04) | 114 | #define nx_get_temp_state(x) ((x) & 0xffff) |
56 | 115 | #define nx_encode_temp(val, state) (((val) << 16) | (state)) | |
57 | /* point to the indexes */ | ||
58 | #define CRB_CMD_PRODUCER_OFFSET NETXEN_NIC_REG(0x08) | ||
59 | #define CRB_CMD_CONSUMER_OFFSET NETXEN_NIC_REG(0x0c) | ||
60 | |||
61 | #define CRB_PAUSE_ADDR_LO NETXEN_NIC_REG(0x10) | ||
62 | #define CRB_PAUSE_ADDR_HI NETXEN_NIC_REG(0x14) | ||
63 | |||
64 | /* address of command descriptors in the host memory */ | ||
65 | #define CRB_HOST_CMD_ADDR_HI NETXEN_NIC_REG(0x30) | ||
66 | #define CRB_HOST_CMD_ADDR_LO NETXEN_NIC_REG(0x34) | ||
67 | |||
68 | /* The following 4 CRB registers are for doing performance coal */ | ||
69 | #define CRB_CMD_INTR_LOOP NETXEN_NIC_REG(0x38) | ||
70 | #define CRB_CMD_DMA_LOOP NETXEN_NIC_REG(0x3c) | ||
71 | #define CRB_RCV_INTR_LOOP NETXEN_NIC_REG(0x40) | ||
72 | #define CRB_RCV_DMA_LOOP NETXEN_NIC_REG(0x44) | ||
73 | |||
74 | /* Needed by the host to find out the state of Phantom's initialization */ | ||
75 | #define CRB_ENABLE_TX_INTR NETXEN_NIC_REG(0x4c) | ||
76 | #define CRB_CMDPEG_STATE NETXEN_NIC_REG(0x50) | ||
77 | #define CRB_CMDPEG_CMDRING NETXEN_NIC_REG(0x54) | ||
78 | |||
79 | /* Interrupt coalescing parameters */ | ||
80 | #define CRB_GLOBAL_INT_COAL NETXEN_NIC_REG(0x80) | ||
81 | #define CRB_INT_COAL_MODE NETXEN_NIC_REG(0x84) | ||
82 | #define CRB_MAX_RCV_BUFS NETXEN_NIC_REG(0x88) | ||
83 | #define CRB_TX_INT_THRESHOLD NETXEN_NIC_REG(0x8c) | ||
84 | #define CRB_RX_PKT_TIMER NETXEN_NIC_REG(0x90) | ||
85 | #define CRB_TX_PKT_TIMER NETXEN_NIC_REG(0x94) | ||
86 | #define CRB_RX_PKT_CNT NETXEN_NIC_REG(0x98) | ||
87 | #define CRB_RX_TMR_CNT NETXEN_NIC_REG(0x9c) | ||
88 | #define CRB_INT_THRESH NETXEN_NIC_REG(0xa4) | ||
89 | |||
90 | /* Register for communicating XG link status */ | ||
91 | #define CRB_XG_STATE NETXEN_NIC_REG(0xa0) | ||
92 | |||
93 | /* Register for communicating card temperature */ | ||
94 | /* Upper 16 bits are temperature value. Lower 16 bits are the state */ | ||
95 | #define CRB_TEMP_STATE NETXEN_NIC_REG(0xa8) | ||
96 | #define nx_get_temp_val(x) ((x) >> 16) | ||
97 | #define nx_get_temp_state(x) ((x) & 0xffff) | ||
98 | #define nx_encode_temp(val, state) (((val) << 16) | (state)) | ||
99 | |||
100 | /* Debug registers for controlling NIC pkt gen agent */ | ||
101 | #define CRB_AGENT_GO NETXEN_NIC_REG(0xb0) | ||
102 | #define CRB_AGENT_TX_SIZE NETXEN_NIC_REG(0xb4) | ||
103 | #define CRB_AGENT_TX_TYPE NETXEN_NIC_REG(0xb8) | ||
104 | #define CRB_AGENT_TX_ADDR NETXEN_NIC_REG(0xbc) | ||
105 | #define CRB_AGENT_TX_MSS NETXEN_NIC_REG(0xc0) | ||
106 | |||
107 | /* Debug registers for observing NIC performance */ | ||
108 | #define CRB_TX_STATE NETXEN_NIC_REG(0xd0) | ||
109 | #define CRB_TX_COUNT NETXEN_NIC_REG(0xd4) | ||
110 | #define CRB_RX_STATE NETXEN_NIC_REG(0xd8) | ||
111 | 116 | ||
112 | /* CRB registers per Rcv Descriptor ring */ | 117 | /* CRB registers per Rcv Descriptor ring */ |
113 | struct netxen_rcv_desc_crb { | 118 | struct netxen_rcv_desc_crb { |
114 | u32 crb_rcv_producer_offset __attribute__ ((aligned(512))); | 119 | u32 crb_rcv_producer_offset __attribute__ ((aligned(512))); |
115 | u32 crb_rcv_consumer_offset; | 120 | u32 crb_rcv_consumer_offset; |
116 | u32 crb_globalrcv_ring; | 121 | u32 crb_globalrcv_ring; |
122 | u32 crb_rcv_ring_size; | ||
117 | }; | 123 | }; |
118 | 124 | ||
119 | /* | 125 | /* |
120 | * CRB registers used by the receive peg logic. One instance of these | 126 | * CRB registers used by the receive peg logic. |
121 | * needs to be instantiated per instance of the receive peg. | ||
122 | */ | 127 | */ |
123 | 128 | ||
124 | struct netxen_recv_crb { | 129 | struct netxen_recv_crb { |
@@ -127,6 +132,7 @@ struct netxen_recv_crb { | |||
127 | u32 crb_rcv_status_producer; | 132 | u32 crb_rcv_status_producer; |
128 | u32 crb_rcv_status_consumer; | 133 | u32 crb_rcv_status_consumer; |
129 | u32 crb_rcvpeg_state; | 134 | u32 crb_rcvpeg_state; |
135 | u32 crb_status_ring_size; | ||
130 | }; | 136 | }; |
131 | 137 | ||
132 | #if defined(DEFINE_GLOBAL_RECV_CRB) | 138 | #if defined(DEFINE_GLOBAL_RECV_CRB) |
@@ -139,30 +145,48 @@ struct netxen_recv_crb recv_crb_registers[] = { | |||
139 | { | 145 | { |
140 | { | 146 | { |
141 | /* crb_rcv_producer_offset: */ | 147 | /* crb_rcv_producer_offset: */ |
142 | NETXEN_NIC_REG(0x18), | 148 | NETXEN_NIC_REG(0x100), |
143 | /* crb_rcv_consumer_offset: */ | 149 | /* crb_rcv_consumer_offset: */ |
144 | NETXEN_NIC_REG(0x1c), | 150 | NETXEN_NIC_REG(0x104), |
145 | /* crb_gloablrcv_ring: */ | 151 | /* crb_gloablrcv_ring: */ |
146 | NETXEN_NIC_REG(0x20), | 152 | NETXEN_NIC_REG(0x108), |
153 | /* crb_rcv_ring_size */ | ||
154 | NETXEN_NIC_REG(0x10c), | ||
155 | |||
147 | }, | 156 | }, |
148 | /* Jumbo frames */ | 157 | /* Jumbo frames */ |
149 | { | 158 | { |
150 | /* crb_rcv_producer_offset: */ | 159 | /* crb_rcv_producer_offset: */ |
151 | NETXEN_NIC_REG(0x100), | 160 | NETXEN_NIC_REG(0x110), |
152 | /* crb_rcv_consumer_offset: */ | 161 | /* crb_rcv_consumer_offset: */ |
153 | NETXEN_NIC_REG(0x104), | 162 | NETXEN_NIC_REG(0x114), |
154 | /* crb_gloablrcv_ring: */ | 163 | /* crb_gloablrcv_ring: */ |
155 | NETXEN_NIC_REG(0x108), | 164 | NETXEN_NIC_REG(0x118), |
165 | /* crb_rcv_ring_size */ | ||
166 | NETXEN_NIC_REG(0x11c), | ||
167 | }, | ||
168 | /* LRO */ | ||
169 | { | ||
170 | /* crb_rcv_producer_offset: */ | ||
171 | NETXEN_NIC_REG(0x120), | ||
172 | /* crb_rcv_consumer_offset: */ | ||
173 | NETXEN_NIC_REG(0x124), | ||
174 | /* crb_gloablrcv_ring: */ | ||
175 | NETXEN_NIC_REG(0x128), | ||
176 | /* crb_rcv_ring_size */ | ||
177 | NETXEN_NIC_REG(0x12c), | ||
156 | } | 178 | } |
157 | }, | 179 | }, |
158 | /* crb_rcvstatus_ring: */ | 180 | /* crb_rcvstatus_ring: */ |
159 | NETXEN_NIC_REG(0x24), | 181 | NETXEN_NIC_REG(0x130), |
160 | /* crb_rcv_status_producer: */ | 182 | /* crb_rcv_status_producer: */ |
161 | NETXEN_NIC_REG(0x28), | 183 | NETXEN_NIC_REG(0x134), |
162 | /* crb_rcv_status_consumer: */ | 184 | /* crb_rcv_status_consumer: */ |
163 | NETXEN_NIC_REG(0x2c), | 185 | NETXEN_NIC_REG(0x138), |
164 | /* crb_rcvpeg_state: */ | 186 | /* crb_rcvpeg_state: */ |
165 | NETXEN_NIC_REG(0x48), | 187 | NETXEN_NIC_REG(0x13c), |
188 | /* crb_status_ring_size */ | ||
189 | NETXEN_NIC_REG(0x140), | ||
166 | 190 | ||
167 | }, | 191 | }, |
168 | /* | 192 | /* |
@@ -173,34 +197,66 @@ struct netxen_recv_crb recv_crb_registers[] = { | |||
173 | { | 197 | { |
174 | { | 198 | { |
175 | /* crb_rcv_producer_offset: */ | 199 | /* crb_rcv_producer_offset: */ |
176 | NETXEN_NIC_REG(0x80), | 200 | NETXEN_NIC_REG(0x144), |
177 | /* crb_rcv_consumer_offset: */ | 201 | /* crb_rcv_consumer_offset: */ |
178 | NETXEN_NIC_REG(0x84), | 202 | NETXEN_NIC_REG(0x148), |
179 | /* crb_globalrcv_ring: */ | 203 | /* crb_globalrcv_ring: */ |
180 | NETXEN_NIC_REG(0x88), | 204 | NETXEN_NIC_REG(0x14c), |
205 | /* crb_rcv_ring_size */ | ||
206 | NETXEN_NIC_REG(0x150), | ||
207 | |||
181 | }, | 208 | }, |
182 | /* Jumbo frames */ | 209 | /* Jumbo frames */ |
183 | { | 210 | { |
184 | /* crb_rcv_producer_offset: */ | 211 | /* crb_rcv_producer_offset: */ |
185 | NETXEN_NIC_REG(0x10C), | 212 | NETXEN_NIC_REG(0x154), |
186 | /* crb_rcv_consumer_offset: */ | 213 | /* crb_rcv_consumer_offset: */ |
187 | NETXEN_NIC_REG(0x110), | 214 | NETXEN_NIC_REG(0x158), |
188 | /* crb_globalrcv_ring: */ | 215 | /* crb_globalrcv_ring: */ |
189 | NETXEN_NIC_REG(0x114), | 216 | NETXEN_NIC_REG(0x15c), |
217 | /* crb_rcv_ring_size */ | ||
218 | NETXEN_NIC_REG(0x160), | ||
219 | }, | ||
220 | /* LRO */ | ||
221 | { | ||
222 | /* crb_rcv_producer_offset: */ | ||
223 | NETXEN_NIC_REG(0x164), | ||
224 | /* crb_rcv_consumer_offset: */ | ||
225 | NETXEN_NIC_REG(0x168), | ||
226 | /* crb_globalrcv_ring: */ | ||
227 | NETXEN_NIC_REG(0x16c), | ||
228 | /* crb_rcv_ring_size */ | ||
229 | NETXEN_NIC_REG(0x170), | ||
190 | } | 230 | } |
231 | |||
191 | }, | 232 | }, |
192 | /* crb_rcvstatus_ring: */ | 233 | /* crb_rcvstatus_ring: */ |
193 | NETXEN_NIC_REG(0x8c), | 234 | NETXEN_NIC_REG(0x174), |
194 | /* crb_rcv_status_producer: */ | 235 | /* crb_rcv_status_producer: */ |
195 | NETXEN_NIC_REG(0x90), | 236 | NETXEN_NIC_REG(0x178), |
196 | /* crb_rcv_status_consumer: */ | 237 | /* crb_rcv_status_consumer: */ |
197 | NETXEN_NIC_REG(0x94), | 238 | NETXEN_NIC_REG(0x17c), |
198 | /* crb_rcvpeg_state: */ | 239 | /* crb_rcvpeg_state: */ |
199 | NETXEN_NIC_REG(0x98), | 240 | NETXEN_NIC_REG(0x180), |
241 | /* crb_status_ring_size */ | ||
242 | NETXEN_NIC_REG(0x184), | ||
243 | |||
200 | }, | 244 | }, |
201 | }; | 245 | }; |
246 | |||
247 | u64 ctx_addr_sig_regs[][3] = { | ||
248 | {NETXEN_NIC_REG(0x188), NETXEN_NIC_REG(0x18c), NETXEN_NIC_REG(0x1c0)}, | ||
249 | {NETXEN_NIC_REG(0x190), NETXEN_NIC_REG(0x194), NETXEN_NIC_REG(0x1c4)}, | ||
250 | {NETXEN_NIC_REG(0x198), NETXEN_NIC_REG(0x19c), NETXEN_NIC_REG(0x1c8)}, | ||
251 | {NETXEN_NIC_REG(0x1a0), NETXEN_NIC_REG(0x1a4), NETXEN_NIC_REG(0x1cc)} | ||
252 | }; | ||
253 | |||
202 | #else | 254 | #else |
203 | extern struct netxen_recv_crb recv_crb_registers[]; | 255 | extern struct netxen_recv_crb recv_crb_registers[]; |
256 | extern u64 ctx_addr_sig_regs[][3]; | ||
257 | #define CRB_CTX_ADDR_REG_LO (ctx_addr_sig_regs[0][0]) | ||
258 | #define CRB_CTX_ADDR_REG_HI (ctx_addr_sig_regs[0][2]) | ||
259 | #define CRB_CTX_SIGNATURE_REG (ctx_addr_sig_regs[0][1]) | ||
204 | #endif /* DEFINE_GLOBAL_RECEIVE_CRB */ | 260 | #endif /* DEFINE_GLOBAL_RECEIVE_CRB */ |
205 | 261 | ||
206 | /* | 262 | /* |
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c index 26e42f6e9fb1..196993a29b09 100644 --- a/drivers/net/ni52.c +++ b/drivers/net/ni52.c | |||
@@ -1335,7 +1335,7 @@ int __init init_module(void) | |||
1335 | return 0; | 1335 | return 0; |
1336 | } | 1336 | } |
1337 | 1337 | ||
1338 | void cleanup_module(void) | 1338 | void __exit cleanup_module(void) |
1339 | { | 1339 | { |
1340 | unregister_netdev(dev_ni52); | 1340 | unregister_netdev(dev_ni52); |
1341 | release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE); | 1341 | release_region(dev_ni52->base_addr, NI52_TOTAL_SIZE); |
diff --git a/drivers/net/ni65.c b/drivers/net/ni65.c index 340ad0d5388a..1578f4d98498 100644 --- a/drivers/net/ni65.c +++ b/drivers/net/ni65.c | |||
@@ -1259,7 +1259,7 @@ int __init init_module(void) | |||
1259 | return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0; | 1259 | return IS_ERR(dev_ni65) ? PTR_ERR(dev_ni65) : 0; |
1260 | } | 1260 | } |
1261 | 1261 | ||
1262 | void cleanup_module(void) | 1262 | void __exit cleanup_module(void) |
1263 | { | 1263 | { |
1264 | unregister_netdev(dev_ni65); | 1264 | unregister_netdev(dev_ni65); |
1265 | cleanup_card(dev_ni65); | 1265 | cleanup_card(dev_ni65); |
diff --git a/drivers/net/ns83820.c b/drivers/net/ns83820.c index 312e0e331712..568daeb3e9d8 100644 --- a/drivers/net/ns83820.c +++ b/drivers/net/ns83820.c | |||
@@ -414,10 +414,10 @@ struct rx_info { | |||
414 | 414 | ||
415 | struct sk_buff *skbs[NR_RX_DESC]; | 415 | struct sk_buff *skbs[NR_RX_DESC]; |
416 | 416 | ||
417 | u32 *next_rx_desc; | 417 | __le32 *next_rx_desc; |
418 | u16 next_rx, next_empty; | 418 | u16 next_rx, next_empty; |
419 | 419 | ||
420 | u32 *descs; | 420 | __le32 *descs; |
421 | dma_addr_t phy_descs; | 421 | dma_addr_t phy_descs; |
422 | }; | 422 | }; |
423 | 423 | ||
@@ -460,7 +460,7 @@ struct ns83820 { | |||
460 | struct sk_buff *tx_skbs[NR_TX_DESC]; | 460 | struct sk_buff *tx_skbs[NR_TX_DESC]; |
461 | 461 | ||
462 | char pad[16] __attribute__((aligned(16))); | 462 | char pad[16] __attribute__((aligned(16))); |
463 | u32 *tx_descs; | 463 | __le32 *tx_descs; |
464 | dma_addr_t tx_phy_descs; | 464 | dma_addr_t tx_phy_descs; |
465 | 465 | ||
466 | struct timer_list tx_watchdog; | 466 | struct timer_list tx_watchdog; |
@@ -534,7 +534,7 @@ static void ns83820_vlan_rx_kill_vid(struct net_device *ndev, unsigned short vid | |||
534 | * conditions, still route realtime traffic with as low jitter as | 534 | * conditions, still route realtime traffic with as low jitter as |
535 | * possible. | 535 | * possible. |
536 | */ | 536 | */ |
537 | static inline void build_rx_desc(struct ns83820 *dev, u32 *desc, dma_addr_t link, dma_addr_t buf, u32 cmdsts, u32 extsts) | 537 | static inline void build_rx_desc(struct ns83820 *dev, __le32 *desc, dma_addr_t link, dma_addr_t buf, u32 cmdsts, u32 extsts) |
538 | { | 538 | { |
539 | desc_addr_set(desc + DESC_LINK, link); | 539 | desc_addr_set(desc + DESC_LINK, link); |
540 | desc_addr_set(desc + DESC_BUFPTR, buf); | 540 | desc_addr_set(desc + DESC_BUFPTR, buf); |
@@ -548,7 +548,7 @@ static inline int ns83820_add_rx_skb(struct ns83820 *dev, struct sk_buff *skb) | |||
548 | { | 548 | { |
549 | unsigned next_empty; | 549 | unsigned next_empty; |
550 | u32 cmdsts; | 550 | u32 cmdsts; |
551 | u32 *sg; | 551 | __le32 *sg; |
552 | dma_addr_t buf; | 552 | dma_addr_t buf; |
553 | 553 | ||
554 | next_empty = dev->rx_info.next_empty; | 554 | next_empty = dev->rx_info.next_empty; |
@@ -875,7 +875,8 @@ static void fastcall rx_irq(struct net_device *ndev) | |||
875 | struct rx_info *info = &dev->rx_info; | 875 | struct rx_info *info = &dev->rx_info; |
876 | unsigned next_rx; | 876 | unsigned next_rx; |
877 | int rx_rc, len; | 877 | int rx_rc, len; |
878 | u32 cmdsts, *desc; | 878 | u32 cmdsts; |
879 | __le32 *desc; | ||
879 | unsigned long flags; | 880 | unsigned long flags; |
880 | int nr = 0; | 881 | int nr = 0; |
881 | 882 | ||
@@ -1011,7 +1012,8 @@ static inline void kick_tx(struct ns83820 *dev) | |||
1011 | static void do_tx_done(struct net_device *ndev) | 1012 | static void do_tx_done(struct net_device *ndev) |
1012 | { | 1013 | { |
1013 | struct ns83820 *dev = PRIV(ndev); | 1014 | struct ns83820 *dev = PRIV(ndev); |
1014 | u32 cmdsts, tx_done_idx, *desc; | 1015 | u32 cmdsts, tx_done_idx; |
1016 | __le32 *desc; | ||
1015 | 1017 | ||
1016 | dprintk("do_tx_done(%p)\n", ndev); | 1018 | dprintk("do_tx_done(%p)\n", ndev); |
1017 | tx_done_idx = dev->tx_done_idx; | 1019 | tx_done_idx = dev->tx_done_idx; |
@@ -1078,7 +1080,7 @@ static void ns83820_cleanup_tx(struct ns83820 *dev) | |||
1078 | struct sk_buff *skb = dev->tx_skbs[i]; | 1080 | struct sk_buff *skb = dev->tx_skbs[i]; |
1079 | dev->tx_skbs[i] = NULL; | 1081 | dev->tx_skbs[i] = NULL; |
1080 | if (skb) { | 1082 | if (skb) { |
1081 | u32 *desc = dev->tx_descs + (i * DESC_SIZE); | 1083 | __le32 *desc = dev->tx_descs + (i * DESC_SIZE); |
1082 | pci_unmap_single(dev->pci_dev, | 1084 | pci_unmap_single(dev->pci_dev, |
1083 | desc_addr_get(desc + DESC_BUFPTR), | 1085 | desc_addr_get(desc + DESC_BUFPTR), |
1084 | le32_to_cpu(desc[DESC_CMDSTS]) & CMDSTS_LEN_MASK, | 1086 | le32_to_cpu(desc[DESC_CMDSTS]) & CMDSTS_LEN_MASK, |
@@ -1108,7 +1110,7 @@ static int ns83820_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
1108 | skb_frag_t *frag; | 1110 | skb_frag_t *frag; |
1109 | int stopped = 0; | 1111 | int stopped = 0; |
1110 | int do_intr = 0; | 1112 | int do_intr = 0; |
1111 | volatile u32 *first_desc; | 1113 | volatile __le32 *first_desc; |
1112 | 1114 | ||
1113 | dprintk("ns83820_hard_start_xmit\n"); | 1115 | dprintk("ns83820_hard_start_xmit\n"); |
1114 | 1116 | ||
@@ -1181,7 +1183,7 @@ again: | |||
1181 | first_desc = dev->tx_descs + (free_idx * DESC_SIZE); | 1183 | first_desc = dev->tx_descs + (free_idx * DESC_SIZE); |
1182 | 1184 | ||
1183 | for (;;) { | 1185 | for (;;) { |
1184 | volatile u32 *desc = dev->tx_descs + (free_idx * DESC_SIZE); | 1186 | volatile __le32 *desc = dev->tx_descs + (free_idx * DESC_SIZE); |
1185 | 1187 | ||
1186 | dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len, | 1188 | dprintk("frag[%3u]: %4u @ 0x%08Lx\n", free_idx, len, |
1187 | (unsigned long long)buf); | 1189 | (unsigned long long)buf); |
@@ -1456,7 +1458,8 @@ static int ns83820_stop(struct net_device *ndev) | |||
1456 | static void ns83820_tx_timeout(struct net_device *ndev) | 1458 | static void ns83820_tx_timeout(struct net_device *ndev) |
1457 | { | 1459 | { |
1458 | struct ns83820 *dev = PRIV(ndev); | 1460 | struct ns83820 *dev = PRIV(ndev); |
1459 | u32 tx_done_idx, *desc; | 1461 | u32 tx_done_idx; |
1462 | __le32 *desc; | ||
1460 | unsigned long flags; | 1463 | unsigned long flags; |
1461 | 1464 | ||
1462 | spin_lock_irqsave(&dev->tx_lock, flags); | 1465 | spin_lock_irqsave(&dev->tx_lock, flags); |
diff --git a/drivers/net/r8169.c b/drivers/net/r8169.c index 85a392fab5cc..f83b41d4cb0e 100644 --- a/drivers/net/r8169.c +++ b/drivers/net/r8169.c | |||
@@ -225,6 +225,7 @@ MODULE_DEVICE_TABLE(pci, rtl8169_pci_tbl); | |||
225 | 225 | ||
226 | static int rx_copybreak = 200; | 226 | static int rx_copybreak = 200; |
227 | static int use_dac; | 227 | static int use_dac; |
228 | static int ignore_parity_err; | ||
228 | static struct { | 229 | static struct { |
229 | u32 msg_enable; | 230 | u32 msg_enable; |
230 | } debug = { -1 }; | 231 | } debug = { -1 }; |
@@ -470,6 +471,8 @@ module_param(use_dac, int, 0); | |||
470 | MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); | 471 | MODULE_PARM_DESC(use_dac, "Enable PCI DAC. Unsafe on 32 bit PCI slot."); |
471 | module_param_named(debug, debug.msg_enable, int, 0); | 472 | module_param_named(debug, debug.msg_enable, int, 0); |
472 | MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); | 473 | MODULE_PARM_DESC(debug, "Debug verbosity level (0=none, ..., 16=all)"); |
474 | module_param_named(ignore_parity_err, ignore_parity_err, bool, 0); | ||
475 | MODULE_PARM_DESC(ignore_parity_err, "Ignore PCI parity error as target. Default: false"); | ||
473 | MODULE_LICENSE("GPL"); | 476 | MODULE_LICENSE("GPL"); |
474 | MODULE_VERSION(RTL8169_VERSION); | 477 | MODULE_VERSION(RTL8169_VERSION); |
475 | 478 | ||
@@ -1284,11 +1287,6 @@ static void rtl8169_hw_phy_config(struct net_device *dev) | |||
1284 | /* Shazam ! */ | 1287 | /* Shazam ! */ |
1285 | 1288 | ||
1286 | if (tp->mac_version == RTL_GIGA_MAC_VER_04) { | 1289 | if (tp->mac_version == RTL_GIGA_MAC_VER_04) { |
1287 | mdio_write(ioaddr, 31, 0x0001); | ||
1288 | mdio_write(ioaddr, 9, 0x273a); | ||
1289 | mdio_write(ioaddr, 14, 0x7bfb); | ||
1290 | mdio_write(ioaddr, 27, 0x841e); | ||
1291 | |||
1292 | mdio_write(ioaddr, 31, 0x0002); | 1290 | mdio_write(ioaddr, 31, 0x0002); |
1293 | mdio_write(ioaddr, 1, 0x90d0); | 1291 | mdio_write(ioaddr, 1, 0x90d0); |
1294 | mdio_write(ioaddr, 31, 0x0000); | 1292 | mdio_write(ioaddr, 31, 0x0000); |
@@ -1817,12 +1815,25 @@ static void rtl8169_hw_reset(void __iomem *ioaddr) | |||
1817 | RTL_R8(ChipCmd); | 1815 | RTL_R8(ChipCmd); |
1818 | } | 1816 | } |
1819 | 1817 | ||
1820 | static void | 1818 | static void rtl8169_set_rx_tx_config_registers(struct rtl8169_private *tp) |
1821 | rtl8169_hw_start(struct net_device *dev) | 1819 | { |
1820 | void __iomem *ioaddr = tp->mmio_addr; | ||
1821 | u32 cfg = rtl8169_rx_config; | ||
1822 | |||
1823 | cfg |= (RTL_R32(RxConfig) & rtl_chip_info[tp->chipset].RxConfigMask); | ||
1824 | RTL_W32(RxConfig, cfg); | ||
1825 | |||
1826 | /* Set DMA burst size and Interframe Gap Time */ | ||
1827 | RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) | | ||
1828 | (InterFrameGap << TxInterFrameGapShift)); | ||
1829 | } | ||
1830 | |||
1831 | static void rtl8169_hw_start(struct net_device *dev) | ||
1822 | { | 1832 | { |
1823 | struct rtl8169_private *tp = netdev_priv(dev); | 1833 | struct rtl8169_private *tp = netdev_priv(dev); |
1824 | void __iomem *ioaddr = tp->mmio_addr; | 1834 | void __iomem *ioaddr = tp->mmio_addr; |
1825 | struct pci_dev *pdev = tp->pci_dev; | 1835 | struct pci_dev *pdev = tp->pci_dev; |
1836 | u16 cmd; | ||
1826 | u32 i; | 1837 | u32 i; |
1827 | 1838 | ||
1828 | /* Soft reset the chip. */ | 1839 | /* Soft reset the chip. */ |
@@ -1835,6 +1846,11 @@ rtl8169_hw_start(struct net_device *dev) | |||
1835 | msleep_interruptible(1); | 1846 | msleep_interruptible(1); |
1836 | } | 1847 | } |
1837 | 1848 | ||
1849 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) { | ||
1850 | RTL_W16(CPlusCmd, RTL_R16(CPlusCmd) | PCIMulRW); | ||
1851 | pci_write_config_byte(pdev, PCI_CACHE_LINE_SIZE, 0x08); | ||
1852 | } | ||
1853 | |||
1838 | if (tp->mac_version == RTL_GIGA_MAC_VER_13) { | 1854 | if (tp->mac_version == RTL_GIGA_MAC_VER_13) { |
1839 | pci_write_config_word(pdev, 0x68, 0x00); | 1855 | pci_write_config_word(pdev, 0x68, 0x00); |
1840 | pci_write_config_word(pdev, 0x69, 0x08); | 1856 | pci_write_config_word(pdev, 0x69, 0x08); |
@@ -1842,8 +1858,6 @@ rtl8169_hw_start(struct net_device *dev) | |||
1842 | 1858 | ||
1843 | /* Undocumented stuff. */ | 1859 | /* Undocumented stuff. */ |
1844 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) { | 1860 | if (tp->mac_version == RTL_GIGA_MAC_VER_05) { |
1845 | u16 cmd; | ||
1846 | |||
1847 | /* Realtek's r1000_n.c driver uses '&& 0x01' here. Well... */ | 1861 | /* Realtek's r1000_n.c driver uses '&& 0x01' here. Well... */ |
1848 | if ((RTL_R8(Config2) & 0x07) & 0x01) | 1862 | if ((RTL_R8(Config2) & 0x07) & 0x01) |
1849 | RTL_W32(0x7c, 0x0007ffff); | 1863 | RTL_W32(0x7c, 0x0007ffff); |
@@ -1855,23 +1869,29 @@ rtl8169_hw_start(struct net_device *dev) | |||
1855 | pci_write_config_word(pdev, PCI_COMMAND, cmd); | 1869 | pci_write_config_word(pdev, PCI_COMMAND, cmd); |
1856 | } | 1870 | } |
1857 | 1871 | ||
1858 | |||
1859 | RTL_W8(Cfg9346, Cfg9346_Unlock); | 1872 | RTL_W8(Cfg9346, Cfg9346_Unlock); |
1873 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || | ||
1874 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || | ||
1875 | (tp->mac_version == RTL_GIGA_MAC_VER_03) || | ||
1876 | (tp->mac_version == RTL_GIGA_MAC_VER_04)) | ||
1877 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | ||
1878 | |||
1860 | RTL_W8(EarlyTxThres, EarlyTxThld); | 1879 | RTL_W8(EarlyTxThres, EarlyTxThld); |
1861 | 1880 | ||
1862 | /* Low hurts. Let's disable the filtering. */ | 1881 | /* Low hurts. Let's disable the filtering. */ |
1863 | RTL_W16(RxMaxSize, 16383); | 1882 | RTL_W16(RxMaxSize, 16383); |
1864 | 1883 | ||
1865 | /* Set Rx Config register */ | 1884 | if ((tp->mac_version == RTL_GIGA_MAC_VER_01) || |
1866 | i = rtl8169_rx_config | | 1885 | (tp->mac_version == RTL_GIGA_MAC_VER_02) || |
1867 | (RTL_R32(RxConfig) & rtl_chip_info[tp->chipset].RxConfigMask); | 1886 | (tp->mac_version == RTL_GIGA_MAC_VER_03) || |
1868 | RTL_W32(RxConfig, i); | 1887 | (tp->mac_version == RTL_GIGA_MAC_VER_04)) |
1888 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | ||
1889 | rtl8169_set_rx_tx_config_registers(tp); | ||
1869 | 1890 | ||
1870 | /* Set DMA burst size and Interframe Gap Time */ | 1891 | cmd = RTL_R16(CPlusCmd); |
1871 | RTL_W32(TxConfig, (TX_DMA_BURST << TxDMAShift) | | 1892 | RTL_W16(CPlusCmd, cmd); |
1872 | (InterFrameGap << TxInterFrameGapShift)); | ||
1873 | 1893 | ||
1874 | tp->cp_cmd |= RTL_R16(CPlusCmd) | PCIMulRW; | 1894 | tp->cp_cmd |= cmd | PCIMulRW; |
1875 | 1895 | ||
1876 | if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || | 1896 | if ((tp->mac_version == RTL_GIGA_MAC_VER_02) || |
1877 | (tp->mac_version == RTL_GIGA_MAC_VER_03)) { | 1897 | (tp->mac_version == RTL_GIGA_MAC_VER_03)) { |
@@ -1897,7 +1917,15 @@ rtl8169_hw_start(struct net_device *dev) | |||
1897 | RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr & DMA_32BIT_MASK)); | 1917 | RTL_W32(TxDescStartAddrLow, ((u64) tp->TxPhyAddr & DMA_32BIT_MASK)); |
1898 | RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr >> 32)); | 1918 | RTL_W32(RxDescAddrHigh, ((u64) tp->RxPhyAddr >> 32)); |
1899 | RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr & DMA_32BIT_MASK)); | 1919 | RTL_W32(RxDescAddrLow, ((u64) tp->RxPhyAddr & DMA_32BIT_MASK)); |
1900 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | 1920 | |
1921 | if ((tp->mac_version != RTL_GIGA_MAC_VER_01) && | ||
1922 | (tp->mac_version != RTL_GIGA_MAC_VER_02) && | ||
1923 | (tp->mac_version != RTL_GIGA_MAC_VER_03) && | ||
1924 | (tp->mac_version != RTL_GIGA_MAC_VER_04)) { | ||
1925 | RTL_W8(ChipCmd, CmdTxEnb | CmdRxEnb); | ||
1926 | rtl8169_set_rx_tx_config_registers(tp); | ||
1927 | } | ||
1928 | |||
1901 | RTL_W8(Cfg9346, Cfg9346_Lock); | 1929 | RTL_W8(Cfg9346, Cfg9346_Lock); |
1902 | 1930 | ||
1903 | /* Initially a 10 us delay. Turned it into a PCI commit. - FR */ | 1931 | /* Initially a 10 us delay. Turned it into a PCI commit. - FR */ |
@@ -1992,7 +2020,7 @@ static int rtl8169_alloc_rx_skb(struct pci_dev *pdev, struct sk_buff **sk_buff, | |||
1992 | if (!skb) | 2020 | if (!skb) |
1993 | goto err_out; | 2021 | goto err_out; |
1994 | 2022 | ||
1995 | skb_reserve(skb, align); | 2023 | skb_reserve(skb, (align - 1) & (u32)skb->data); |
1996 | *sk_buff = skb; | 2024 | *sk_buff = skb; |
1997 | 2025 | ||
1998 | mapping = pci_map_single(pdev, skb->data, rx_buf_sz, | 2026 | mapping = pci_map_single(pdev, skb->data, rx_buf_sz, |
@@ -2355,12 +2383,17 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) | |||
2355 | /* | 2383 | /* |
2356 | * The recovery sequence below admits a very elaborated explanation: | 2384 | * The recovery sequence below admits a very elaborated explanation: |
2357 | * - it seems to work; | 2385 | * - it seems to work; |
2358 | * - I did not see what else could be done. | 2386 | * - I did not see what else could be done; |
2387 | * - it makes iop3xx happy. | ||
2359 | * | 2388 | * |
2360 | * Feel free to adjust to your needs. | 2389 | * Feel free to adjust to your needs. |
2361 | */ | 2390 | */ |
2362 | pci_write_config_word(pdev, PCI_COMMAND, | 2391 | if (ignore_parity_err) |
2363 | pci_cmd | PCI_COMMAND_SERR | PCI_COMMAND_PARITY); | 2392 | pci_cmd &= ~PCI_COMMAND_PARITY; |
2393 | else | ||
2394 | pci_cmd |= PCI_COMMAND_SERR | PCI_COMMAND_PARITY; | ||
2395 | |||
2396 | pci_write_config_word(pdev, PCI_COMMAND, pci_cmd); | ||
2364 | 2397 | ||
2365 | pci_write_config_word(pdev, PCI_STATUS, | 2398 | pci_write_config_word(pdev, PCI_STATUS, |
2366 | pci_status & (PCI_STATUS_DETECTED_PARITY | | 2399 | pci_status & (PCI_STATUS_DETECTED_PARITY | |
@@ -2374,10 +2407,11 @@ static void rtl8169_pcierr_interrupt(struct net_device *dev) | |||
2374 | tp->cp_cmd &= ~PCIDAC; | 2407 | tp->cp_cmd &= ~PCIDAC; |
2375 | RTL_W16(CPlusCmd, tp->cp_cmd); | 2408 | RTL_W16(CPlusCmd, tp->cp_cmd); |
2376 | dev->features &= ~NETIF_F_HIGHDMA; | 2409 | dev->features &= ~NETIF_F_HIGHDMA; |
2377 | rtl8169_schedule_work(dev, rtl8169_reinit_task); | ||
2378 | } | 2410 | } |
2379 | 2411 | ||
2380 | rtl8169_hw_reset(ioaddr); | 2412 | rtl8169_hw_reset(ioaddr); |
2413 | |||
2414 | rtl8169_schedule_work(dev, rtl8169_reinit_task); | ||
2381 | } | 2415 | } |
2382 | 2416 | ||
2383 | static void | 2417 | static void |
@@ -2457,7 +2491,7 @@ static inline int rtl8169_try_rx_copy(struct sk_buff **sk_buff, int pkt_size, | |||
2457 | 2491 | ||
2458 | skb = dev_alloc_skb(pkt_size + align); | 2492 | skb = dev_alloc_skb(pkt_size + align); |
2459 | if (skb) { | 2493 | if (skb) { |
2460 | skb_reserve(skb, align); | 2494 | skb_reserve(skb, (align - 1) & (u32)skb->data); |
2461 | eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0); | 2495 | eth_copy_and_sum(skb, sk_buff[0]->data, pkt_size, 0); |
2462 | *sk_buff = skb; | 2496 | *sk_buff = skb; |
2463 | rtl8169_mark_to_asic(desc, rx_buf_sz); | 2497 | rtl8169_mark_to_asic(desc, rx_buf_sz); |
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c index d9d0a3a3c558..0d6c95c7aedf 100644 --- a/drivers/net/seeq8005.c +++ b/drivers/net/seeq8005.c | |||
@@ -750,7 +750,7 @@ int __init init_module(void) | |||
750 | return 0; | 750 | return 0; |
751 | } | 751 | } |
752 | 752 | ||
753 | void cleanup_module(void) | 753 | void __exit cleanup_module(void) |
754 | { | 754 | { |
755 | unregister_netdev(dev_seeq); | 755 | unregister_netdev(dev_seeq); |
756 | release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT); | 756 | release_region(dev_seeq->base_addr, SEEQ8005_IO_EXTENT); |
diff --git a/drivers/net/sk98lin/skgesirq.c b/drivers/net/sk98lin/skgesirq.c index ab66d80a4455..3e7aa49afd00 100644 --- a/drivers/net/sk98lin/skgesirq.c +++ b/drivers/net/sk98lin/skgesirq.c | |||
@@ -1319,7 +1319,7 @@ SK_BOOL AutoNeg) /* Is Auto-negotiation used ? */ | |||
1319 | SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc); | 1319 | SkXmPhyRead(pAC, IoC, Port, PHY_BCOM_INT_STAT, &Isrc); |
1320 | 1320 | ||
1321 | #ifdef xDEBUG | 1321 | #ifdef xDEBUG |
1322 | if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT) == | 1322 | if ((Isrc & ~(PHY_B_IS_HCT | PHY_B_IS_LCT)) == |
1323 | (PHY_B_IS_SCR_S_ER | PHY_B_IS_RRS_CHANGE | PHY_B_IS_LRS_CHANGE)) { | 1323 | (PHY_B_IS_SCR_S_ER | PHY_B_IS_RRS_CHANGE | PHY_B_IS_LRS_CHANGE)) { |
1324 | 1324 | ||
1325 | SK_U32 Stat1, Stat2, Stat3; | 1325 | SK_U32 Stat1, Stat2, Stat3; |
diff --git a/drivers/net/skge.h b/drivers/net/skge.h index 23e5275d920c..f6223c533c01 100644 --- a/drivers/net/skge.h +++ b/drivers/net/skge.h | |||
@@ -389,10 +389,10 @@ enum { | |||
389 | /* Packet Arbiter Registers */ | 389 | /* Packet Arbiter Registers */ |
390 | /* B3_PA_CTRL 16 bit Packet Arbiter Ctrl Register */ | 390 | /* B3_PA_CTRL 16 bit Packet Arbiter Ctrl Register */ |
391 | enum { | 391 | enum { |
392 | PA_CLR_TO_TX2 = 1<<13, /* Clear IRQ Packet Timeout TX2 */ | 392 | PA_CLR_TO_TX2 = 1<<13,/* Clear IRQ Packet Timeout TX2 */ |
393 | PA_CLR_TO_TX1 = 1<<12, /* Clear IRQ Packet Timeout TX1 */ | 393 | PA_CLR_TO_TX1 = 1<<12,/* Clear IRQ Packet Timeout TX1 */ |
394 | PA_CLR_TO_RX2 = 1<<11, /* Clear IRQ Packet Timeout RX2 */ | 394 | PA_CLR_TO_RX2 = 1<<11,/* Clear IRQ Packet Timeout RX2 */ |
395 | PA_CLR_TO_RX1 = 1<<10, /* Clear IRQ Packet Timeout RX1 */ | 395 | PA_CLR_TO_RX1 = 1<<10,/* Clear IRQ Packet Timeout RX1 */ |
396 | PA_ENA_TO_TX2 = 1<<9, /* Enable Timeout Timer TX2 */ | 396 | PA_ENA_TO_TX2 = 1<<9, /* Enable Timeout Timer TX2 */ |
397 | PA_DIS_TO_TX2 = 1<<8, /* Disable Timeout Timer TX2 */ | 397 | PA_DIS_TO_TX2 = 1<<8, /* Disable Timeout Timer TX2 */ |
398 | PA_ENA_TO_TX1 = 1<<7, /* Enable Timeout Timer TX1 */ | 398 | PA_ENA_TO_TX1 = 1<<7, /* Enable Timeout Timer TX1 */ |
@@ -481,14 +481,14 @@ enum { | |||
481 | /* RAM Buffer Register Offsets */ | 481 | /* RAM Buffer Register Offsets */ |
482 | enum { | 482 | enum { |
483 | 483 | ||
484 | RB_START = 0x00,/* 32 bit RAM Buffer Start Address */ | 484 | RB_START= 0x00,/* 32 bit RAM Buffer Start Address */ |
485 | RB_END = 0x04,/* 32 bit RAM Buffer End Address */ | 485 | RB_END = 0x04,/* 32 bit RAM Buffer End Address */ |
486 | RB_WP = 0x08,/* 32 bit RAM Buffer Write Pointer */ | 486 | RB_WP = 0x08,/* 32 bit RAM Buffer Write Pointer */ |
487 | RB_RP = 0x0c,/* 32 bit RAM Buffer Read Pointer */ | 487 | RB_RP = 0x0c,/* 32 bit RAM Buffer Read Pointer */ |
488 | RB_RX_UTPP = 0x10,/* 32 bit Rx Upper Threshold, Pause Packet */ | 488 | RB_RX_UTPP= 0x10,/* 32 bit Rx Upper Threshold, Pause Packet */ |
489 | RB_RX_LTPP = 0x14,/* 32 bit Rx Lower Threshold, Pause Packet */ | 489 | RB_RX_LTPP= 0x14,/* 32 bit Rx Lower Threshold, Pause Packet */ |
490 | RB_RX_UTHP = 0x18,/* 32 bit Rx Upper Threshold, High Prio */ | 490 | RB_RX_UTHP= 0x18,/* 32 bit Rx Upper Threshold, High Prio */ |
491 | RB_RX_LTHP = 0x1c,/* 32 bit Rx Lower Threshold, High Prio */ | 491 | RB_RX_LTHP= 0x1c,/* 32 bit Rx Lower Threshold, High Prio */ |
492 | /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */ | 492 | /* 0x10 - 0x1f: reserved at Tx RAM Buffer Registers */ |
493 | RB_PC = 0x20,/* 32 bit RAM Buffer Packet Counter */ | 493 | RB_PC = 0x20,/* 32 bit RAM Buffer Packet Counter */ |
494 | RB_LEV = 0x24,/* 32 bit RAM Buffer Level Register */ | 494 | RB_LEV = 0x24,/* 32 bit RAM Buffer Level Register */ |
@@ -532,7 +532,7 @@ enum { | |||
532 | PHY_ADDR_MARV = 0, | 532 | PHY_ADDR_MARV = 0, |
533 | }; | 533 | }; |
534 | 534 | ||
535 | #define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs)) | 535 | #define RB_ADDR(offs, queue) ((u16)B16_RAM_REGS + (u16)(queue) + (offs)) |
536 | 536 | ||
537 | /* Receive MAC FIFO, Receive LED, and Link_Sync regs (GENESIS only) */ | 537 | /* Receive MAC FIFO, Receive LED, and Link_Sync regs (GENESIS only) */ |
538 | enum { | 538 | enum { |
@@ -578,15 +578,15 @@ enum { | |||
578 | MFF_DIS_TIST = 1<<2, /* Disable Time Stamp Gener */ | 578 | MFF_DIS_TIST = 1<<2, /* Disable Time Stamp Gener */ |
579 | MFF_CLR_INTIST = 1<<1, /* Clear IRQ No Time Stamp */ | 579 | MFF_CLR_INTIST = 1<<1, /* Clear IRQ No Time Stamp */ |
580 | MFF_CLR_INSTAT = 1<<0, /* Clear IRQ No Status */ | 580 | MFF_CLR_INSTAT = 1<<0, /* Clear IRQ No Status */ |
581 | #define MFF_RX_CTRL_DEF MFF_ENA_TIM_PAT | 581 | MFF_RX_CTRL_DEF = MFF_ENA_TIM_PAT, |
582 | }; | 582 | }; |
583 | 583 | ||
584 | /* TX_MFF_CTRL1 16 bit Transmit MAC FIFO Control Reg 1 */ | 584 | /* TX_MFF_CTRL1 16 bit Transmit MAC FIFO Control Reg 1 */ |
585 | enum { | 585 | enum { |
586 | MFF_CLR_PERR = 1<<15, /* Clear Parity Error IRQ */ | 586 | MFF_CLR_PERR = 1<<15, /* Clear Parity Error IRQ */ |
587 | /* Bit 14: reserved */ | 587 | |
588 | MFF_ENA_PKT_REC = 1<<13, /* Enable Packet Recovery */ | 588 | MFF_ENA_PKT_REC = 1<<13, /* Enable Packet Recovery */ |
589 | MFF_DIS_PKT_REC = 1<<12, /* Disable Packet Recovery */ | 589 | MFF_DIS_PKT_REC = 1<<12, /* Disable Packet Recovery */ |
590 | 590 | ||
591 | MFF_ENA_W4E = 1<<7, /* Enable Wait for Empty */ | 591 | MFF_ENA_W4E = 1<<7, /* Enable Wait for Empty */ |
592 | MFF_DIS_W4E = 1<<6, /* Disable Wait for Empty */ | 592 | MFF_DIS_W4E = 1<<6, /* Disable Wait for Empty */ |
@@ -595,9 +595,10 @@ enum { | |||
595 | MFF_DIS_LOOPB = 1<<2, /* Disable Loopback */ | 595 | MFF_DIS_LOOPB = 1<<2, /* Disable Loopback */ |
596 | MFF_CLR_MAC_RST = 1<<1, /* Clear XMAC Reset */ | 596 | MFF_CLR_MAC_RST = 1<<1, /* Clear XMAC Reset */ |
597 | MFF_SET_MAC_RST = 1<<0, /* Set XMAC Reset */ | 597 | MFF_SET_MAC_RST = 1<<0, /* Set XMAC Reset */ |
598 | |||
599 | MFF_TX_CTRL_DEF = MFF_ENA_PKT_REC | (u16) MFF_ENA_TIM_PAT | MFF_ENA_FLUSH, | ||
598 | }; | 600 | }; |
599 | 601 | ||
600 | #define MFF_TX_CTRL_DEF (MFF_ENA_PKT_REC | MFF_ENA_TIM_PAT | MFF_ENA_FLUSH) | ||
601 | 602 | ||
602 | /* RX_MFF_TST2 8 bit Receive MAC FIFO Test Register 2 */ | 603 | /* RX_MFF_TST2 8 bit Receive MAC FIFO Test Register 2 */ |
603 | /* TX_MFF_TST2 8 bit Transmit MAC FIFO Test Register 2 */ | 604 | /* TX_MFF_TST2 8 bit Transmit MAC FIFO Test Register 2 */ |
@@ -1304,8 +1305,8 @@ enum { | |||
1304 | 1305 | ||
1305 | /* special defines for FIBER (88E1011S only) */ | 1306 | /* special defines for FIBER (88E1011S only) */ |
1306 | enum { | 1307 | enum { |
1307 | PHY_M_AN_ASP_X = 1<<8, /* Asymmetric Pause */ | 1308 | PHY_M_AN_ASP_X = 1<<8, /* Asymmetric Pause */ |
1308 | PHY_M_AN_PC_X = 1<<7, /* MAC Pause implemented */ | 1309 | PHY_M_AN_PC_X = 1<<7, /* MAC Pause implemented */ |
1309 | PHY_M_AN_1000X_AHD = 1<<6, /* Advertise 10000Base-X Half Duplex */ | 1310 | PHY_M_AN_1000X_AHD = 1<<6, /* Advertise 10000Base-X Half Duplex */ |
1310 | PHY_M_AN_1000X_AFD = 1<<5, /* Advertise 10000Base-X Full Duplex */ | 1311 | PHY_M_AN_1000X_AFD = 1<<5, /* Advertise 10000Base-X Full Duplex */ |
1311 | }; | 1312 | }; |
@@ -1320,7 +1321,7 @@ enum { | |||
1320 | 1321 | ||
1321 | /***** PHY_MARV_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/ | 1322 | /***** PHY_MARV_1000T_CTRL 16 bit r/w 1000Base-T Control Reg *****/ |
1322 | enum { | 1323 | enum { |
1323 | PHY_M_1000C_TEST = 7<<13,/* Bit 15..13: Test Modes */ | 1324 | PHY_M_1000C_TEST= 7<<13,/* Bit 15..13: Test Modes */ |
1324 | PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */ | 1325 | PHY_M_1000C_MSE = 1<<12, /* Manual Master/Slave Enable */ |
1325 | PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */ | 1326 | PHY_M_1000C_MSC = 1<<11, /* M/S Configuration (1=Master) */ |
1326 | PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */ | 1327 | PHY_M_1000C_MPD = 1<<10, /* Multi-Port Device */ |
@@ -1349,7 +1350,7 @@ enum { | |||
1349 | PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ | 1350 | PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ |
1350 | }; | 1351 | }; |
1351 | 1352 | ||
1352 | #define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK) | 1353 | #define PHY_M_PC_MDI_XMODE(x) ((((u16)(x)<<5) & PHY_M_PC_MDIX_MSK) |
1353 | 1354 | ||
1354 | enum { | 1355 | enum { |
1355 | PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ | 1356 | PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ |
@@ -1432,24 +1433,24 @@ enum { | |||
1432 | PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */ | 1433 | PHY_M_EC_DIS_LINK_P = 1<<12, /* Disable Link Pulses (88E1111 only) */ |
1433 | PHY_M_EC_M_DSC_MSK = 3<<10, /* Bit 11..10: Master Downshift Counter */ | 1434 | PHY_M_EC_M_DSC_MSK = 3<<10, /* Bit 11..10: Master Downshift Counter */ |
1434 | /* (88E1011 only) */ | 1435 | /* (88E1011 only) */ |
1435 | PHY_M_EC_S_DSC_MSK = 3<<8,/* Bit 9.. 8: Slave Downshift Counter */ | 1436 | PHY_M_EC_S_DSC_MSK = 3<<8, /* Bit 9.. 8: Slave Downshift Counter */ |
1436 | /* (88E1011 only) */ | 1437 | /* (88E1011 only) */ |
1437 | PHY_M_EC_M_DSC_MSK2 = 7<<9,/* Bit 11.. 9: Master Downshift Counter */ | 1438 | PHY_M_EC_M_DSC_MSK2 = 7<<9, /* Bit 11.. 9: Master Downshift Counter */ |
1438 | /* (88E1111 only) */ | 1439 | /* (88E1111 only) */ |
1439 | PHY_M_EC_DOWN_S_ENA = 1<<8, /* Downshift Enable (88E1111 only) */ | 1440 | PHY_M_EC_DOWN_S_ENA = 1<<8, /* Downshift Enable (88E1111 only) */ |
1440 | /* !!! Errata in spec. (1 = disable) */ | 1441 | /* !!! Errata in spec. (1 = disable) */ |
1441 | PHY_M_EC_RX_TIM_CT = 1<<7, /* RGMII Rx Timing Control*/ | 1442 | PHY_M_EC_RX_TIM_CT = 1<<7, /* RGMII Rx Timing Control*/ |
1442 | PHY_M_EC_MAC_S_MSK = 7<<4,/* Bit 6.. 4: Def. MAC interface speed */ | 1443 | PHY_M_EC_MAC_S_MSK = 7<<4, /* Bit 6.. 4: Def. MAC interface speed */ |
1443 | PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */ | 1444 | PHY_M_EC_FIB_AN_ENA = 1<<3, /* Fiber Auto-Neg. Enable (88E1011S only) */ |
1444 | PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */ | 1445 | PHY_M_EC_DTE_D_ENA = 1<<2, /* DTE Detect Enable (88E1111 only) */ |
1445 | PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ | 1446 | PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ |
1446 | PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; | 1447 | PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; |
1447 | 1448 | ||
1448 | #define PHY_M_EC_M_DSC(x) ((x)<<10) /* 00=1x; 01=2x; 10=3x; 11=4x */ | 1449 | #define PHY_M_EC_M_DSC(x) ((u16)(x)<<10) /* 00=1x; 01=2x; 10=3x; 11=4x */ |
1449 | #define PHY_M_EC_S_DSC(x) ((x)<<8) /* 00=dis; 01=1x; 10=2x; 11=3x */ | 1450 | #define PHY_M_EC_S_DSC(x) ((u16)(x)<<8) /* 00=dis; 01=1x; 10=2x; 11=3x */ |
1450 | #define PHY_M_EC_MAC_S(x) ((x)<<4) /* 01X=0; 110=2.5; 111=25 (MHz) */ | 1451 | #define PHY_M_EC_MAC_S(x) ((u16)(x)<<4) /* 01X=0; 110=2.5; 111=25 (MHz) */ |
1451 | 1452 | ||
1452 | #define PHY_M_EC_M_DSC_2(x) ((x)<<9) /* 000=1x; 001=2x; 010=3x; 011=4x */ | 1453 | #define PHY_M_EC_M_DSC_2(x) ((u16)(x)<<9) /* 000=1x; 001=2x; 010=3x; 011=4x */ |
1453 | /* 100=5x; 101=6x; 110=7x; 111=8x */ | 1454 | /* 100=5x; 101=6x; 110=7x; 111=8x */ |
1454 | enum { | 1455 | enum { |
1455 | MAC_TX_CLK_0_MHZ = 2, | 1456 | MAC_TX_CLK_0_MHZ = 2, |
@@ -1468,10 +1469,12 @@ enum { | |||
1468 | PHY_M_LEDC_LK_C_MSK = 7<<3,/* Bit 5.. 3: Link Control Mask */ | 1469 | PHY_M_LEDC_LK_C_MSK = 7<<3,/* Bit 5.. 3: Link Control Mask */ |
1469 | /* (88E1111 only) */ | 1470 | /* (88E1111 only) */ |
1470 | }; | 1471 | }; |
1472 | #define PHY_M_LED_PULS_DUR(x) (((u16)(x)<<12) & PHY_M_LEDC_PULS_MSK) | ||
1473 | #define PHY_M_LED_BLINK_RT(x) (((u16)(x)<<8) & PHY_M_LEDC_BL_R_MSK) | ||
1471 | 1474 | ||
1472 | enum { | 1475 | enum { |
1473 | PHY_M_LEDC_LINK_MSK = 3<<3,/* Bit 4.. 3: Link Control Mask */ | 1476 | PHY_M_LEDC_LINK_MSK = 3<<3, /* Bit 4.. 3: Link Control Mask */ |
1474 | /* (88E1011 only) */ | 1477 | /* (88E1011 only) */ |
1475 | PHY_M_LEDC_DP_CTRL = 1<<2, /* Duplex Control */ | 1478 | PHY_M_LEDC_DP_CTRL = 1<<2, /* Duplex Control */ |
1476 | PHY_M_LEDC_DP_C_MSB = 1<<2, /* Duplex Control (MSB, 88E1111 only) */ | 1479 | PHY_M_LEDC_DP_C_MSB = 1<<2, /* Duplex Control (MSB, 88E1111 only) */ |
1477 | PHY_M_LEDC_RX_CTRL = 1<<1, /* Rx Activity / Link */ | 1480 | PHY_M_LEDC_RX_CTRL = 1<<1, /* Rx Activity / Link */ |
@@ -1479,27 +1482,24 @@ enum { | |||
1479 | PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ | 1482 | PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ |
1480 | }; | 1483 | }; |
1481 | 1484 | ||
1482 | #define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK) | ||
1483 | |||
1484 | enum { | 1485 | enum { |
1485 | PULS_NO_STR = 0,/* no pulse stretching */ | 1486 | PULS_NO_STR = 0, /* no pulse stretching */ |
1486 | PULS_21MS = 1,/* 21 ms to 42 ms */ | 1487 | PULS_21MS = 1, /* 21 ms to 42 ms */ |
1487 | PULS_42MS = 2,/* 42 ms to 84 ms */ | 1488 | PULS_42MS = 2, /* 42 ms to 84 ms */ |
1488 | PULS_84MS = 3,/* 84 ms to 170 ms */ | 1489 | PULS_84MS = 3, /* 84 ms to 170 ms */ |
1489 | PULS_170MS = 4,/* 170 ms to 340 ms */ | 1490 | PULS_170MS = 4, /* 170 ms to 340 ms */ |
1490 | PULS_340MS = 5,/* 340 ms to 670 ms */ | 1491 | PULS_340MS = 5, /* 340 ms to 670 ms */ |
1491 | PULS_670MS = 6,/* 670 ms to 1.3 s */ | 1492 | PULS_670MS = 6, /* 670 ms to 1.3 s */ |
1492 | PULS_1300MS = 7,/* 1.3 s to 2.7 s */ | 1493 | PULS_1300MS = 7, /* 1.3 s to 2.7 s */ |
1493 | }; | 1494 | }; |
1494 | 1495 | ||
1495 | #define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK) | ||
1496 | 1496 | ||
1497 | enum { | 1497 | enum { |
1498 | BLINK_42MS = 0,/* 42 ms */ | 1498 | BLINK_42MS = 0, /* 42 ms */ |
1499 | BLINK_84MS = 1,/* 84 ms */ | 1499 | BLINK_84MS = 1, /* 84 ms */ |
1500 | BLINK_170MS = 2,/* 170 ms */ | 1500 | BLINK_170MS = 2, /* 170 ms */ |
1501 | BLINK_340MS = 3,/* 340 ms */ | 1501 | BLINK_340MS = 3, /* 340 ms */ |
1502 | BLINK_670MS = 4,/* 670 ms */ | 1502 | BLINK_670MS = 4, /* 670 ms */ |
1503 | }; | 1503 | }; |
1504 | 1504 | ||
1505 | /***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/ | 1505 | /***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/ |
@@ -1525,7 +1525,7 @@ enum { | |||
1525 | PHY_M_EC2_FO_IMPED = 1<<5, /* Fiber Output Impedance */ | 1525 | PHY_M_EC2_FO_IMPED = 1<<5, /* Fiber Output Impedance */ |
1526 | PHY_M_EC2_FO_M_CLK = 1<<4, /* Fiber Mode Clock Enable */ | 1526 | PHY_M_EC2_FO_M_CLK = 1<<4, /* Fiber Mode Clock Enable */ |
1527 | PHY_M_EC2_FO_BOOST = 1<<3, /* Fiber Output Boost */ | 1527 | PHY_M_EC2_FO_BOOST = 1<<3, /* Fiber Output Boost */ |
1528 | PHY_M_EC2_FO_AM_MSK = 7,/* Bit 2.. 0: Fiber Output Amplitude */ | 1528 | PHY_M_EC2_FO_AM_MSK = 7, /* Bit 2.. 0: Fiber Output Amplitude */ |
1529 | }; | 1529 | }; |
1530 | 1530 | ||
1531 | /***** PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/ | 1531 | /***** PHY_MARV_EXT_P_STAT 16 bit r/w Ext. PHY Specific Status *****/ |
@@ -1550,7 +1550,7 @@ enum { | |||
1550 | PHY_M_CABD_DIS_WAIT = 1<<15, /* Disable Waiting Period (Page 1) */ | 1550 | PHY_M_CABD_DIS_WAIT = 1<<15, /* Disable Waiting Period (Page 1) */ |
1551 | /* (88E1111 only) */ | 1551 | /* (88E1111 only) */ |
1552 | PHY_M_CABD_STAT_MSK = 3<<13, /* Bit 14..13: Status Mask */ | 1552 | PHY_M_CABD_STAT_MSK = 3<<13, /* Bit 14..13: Status Mask */ |
1553 | PHY_M_CABD_AMPL_MSK = 0x1f<<8,/* Bit 12.. 8: Amplitude Mask */ | 1553 | PHY_M_CABD_AMPL_MSK = 0x1f<<8, /* Bit 12.. 8: Amplitude Mask */ |
1554 | /* (88E1111 only) */ | 1554 | /* (88E1111 only) */ |
1555 | PHY_M_CABD_DIST_MSK = 0xff, /* Bit 7.. 0: Distance Mask */ | 1555 | PHY_M_CABD_DIST_MSK = 0xff, /* Bit 7.. 0: Distance Mask */ |
1556 | }; | 1556 | }; |
@@ -1605,9 +1605,9 @@ enum { | |||
1605 | 1605 | ||
1606 | /***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ | 1606 | /***** PHY_MARV_PHY_CTRL (page 3) 16 bit r/w LED Control Reg. *****/ |
1607 | enum { | 1607 | enum { |
1608 | PHY_M_LEDC_LOS_MSK = 0xf<<12,/* Bit 15..12: LOS LED Ctrl. Mask */ | 1608 | PHY_M_LEDC_LOS_MSK = 0xf<<12, /* Bit 15..12: LOS LED Ctrl. Mask */ |
1609 | PHY_M_LEDC_INIT_MSK = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */ | 1609 | PHY_M_LEDC_INIT_MSK = 0xf<<8, /* Bit 11.. 8: INIT LED Ctrl. Mask */ |
1610 | PHY_M_LEDC_STA1_MSK = 0xf<<4,/* Bit 7.. 4: STAT1 LED Ctrl. Mask */ | 1610 | PHY_M_LEDC_STA1_MSK = 0xf<<4, /* Bit 7.. 4: STAT1 LED Ctrl. Mask */ |
1611 | PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */ | 1611 | PHY_M_LEDC_STA0_MSK = 0xf, /* Bit 3.. 0: STAT0 LED Ctrl. Mask */ |
1612 | }; | 1612 | }; |
1613 | 1613 | ||
@@ -1804,8 +1804,8 @@ enum { | |||
1804 | 1804 | ||
1805 | /* GM_SMI_CTRL 16 bit r/w SMI Control Register */ | 1805 | /* GM_SMI_CTRL 16 bit r/w SMI Control Register */ |
1806 | enum { | 1806 | enum { |
1807 | GM_SMI_CT_PHY_A_MSK = 0x1f<<11,/* Bit 15..11: PHY Device Address */ | 1807 | GM_SMI_CT_PHY_A_MSK = 0x1f<<11, /* Bit 15..11: PHY Device Address */ |
1808 | GM_SMI_CT_REG_A_MSK = 0x1f<<6,/* Bit 10.. 6: PHY Register Address */ | 1808 | GM_SMI_CT_REG_A_MSK = 0x1f<<6, /* Bit 10.. 6: PHY Register Address */ |
1809 | GM_SMI_CT_OP_RD = 1<<5, /* Bit 5: OpCode Read (0=Write)*/ | 1809 | GM_SMI_CT_OP_RD = 1<<5, /* Bit 5: OpCode Read (0=Write)*/ |
1810 | GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */ | 1810 | GM_SMI_CT_RD_VAL = 1<<4, /* Bit 4: Read Valid (Read completed) */ |
1811 | GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ | 1811 | GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ |
@@ -1875,9 +1875,9 @@ enum { | |||
1875 | 1875 | ||
1876 | /* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */ | 1876 | /* TX_GMF_CTRL_T 32 bit Tx GMAC FIFO Control/Test */ |
1877 | enum { | 1877 | enum { |
1878 | GMF_WSP_TST_ON = 1<<18,/* Write Shadow Pointer Test On */ | 1878 | GMF_WSP_TST_ON = 1<<18, /* Write Shadow Pointer Test On */ |
1879 | GMF_WSP_TST_OFF = 1<<17,/* Write Shadow Pointer Test Off */ | 1879 | GMF_WSP_TST_OFF = 1<<17, /* Write Shadow Pointer Test Off */ |
1880 | GMF_WSP_STEP = 1<<16,/* Write Shadow Pointer Step/Increment */ | 1880 | GMF_WSP_STEP = 1<<16, /* Write Shadow Pointer Step/Increment */ |
1881 | 1881 | ||
1882 | GMF_CLI_TX_FU = 1<<6, /* Clear IRQ Tx FIFO Underrun */ | 1882 | GMF_CLI_TX_FU = 1<<6, /* Clear IRQ Tx FIFO Underrun */ |
1883 | GMF_CLI_TX_FC = 1<<5, /* Clear IRQ Tx Frame Complete */ | 1883 | GMF_CLI_TX_FC = 1<<5, /* Clear IRQ Tx Frame Complete */ |
@@ -2111,18 +2111,18 @@ enum { | |||
2111 | 2111 | ||
2112 | /* XM_MMU_CMD 16 bit r/w MMU Command Register */ | 2112 | /* XM_MMU_CMD 16 bit r/w MMU Command Register */ |
2113 | enum { | 2113 | enum { |
2114 | XM_MMU_PHY_RDY = 1<<12,/* Bit 12: PHY Read Ready */ | 2114 | XM_MMU_PHY_RDY = 1<<12, /* Bit 12: PHY Read Ready */ |
2115 | XM_MMU_PHY_BUSY = 1<<11,/* Bit 11: PHY Busy */ | 2115 | XM_MMU_PHY_BUSY = 1<<11, /* Bit 11: PHY Busy */ |
2116 | XM_MMU_IGN_PF = 1<<10,/* Bit 10: Ignore Pause Frame */ | 2116 | XM_MMU_IGN_PF = 1<<10, /* Bit 10: Ignore Pause Frame */ |
2117 | XM_MMU_MAC_LB = 1<<9, /* Bit 9: Enable MAC Loopback */ | 2117 | XM_MMU_MAC_LB = 1<<9, /* Bit 9: Enable MAC Loopback */ |
2118 | XM_MMU_FRC_COL = 1<<7, /* Bit 7: Force Collision */ | 2118 | XM_MMU_FRC_COL = 1<<7, /* Bit 7: Force Collision */ |
2119 | XM_MMU_SIM_COL = 1<<6, /* Bit 6: Simulate Collision */ | 2119 | XM_MMU_SIM_COL = 1<<6, /* Bit 6: Simulate Collision */ |
2120 | XM_MMU_NO_PRE = 1<<5, /* Bit 5: No MDIO Preamble */ | 2120 | XM_MMU_NO_PRE = 1<<5, /* Bit 5: No MDIO Preamble */ |
2121 | XM_MMU_GMII_FD = 1<<4, /* Bit 4: GMII uses Full Duplex */ | 2121 | XM_MMU_GMII_FD = 1<<4, /* Bit 4: GMII uses Full Duplex */ |
2122 | XM_MMU_RAT_CTRL = 1<<3, /* Bit 3: Enable Rate Control */ | 2122 | XM_MMU_RAT_CTRL = 1<<3, /* Bit 3: Enable Rate Control */ |
2123 | XM_MMU_GMII_LOOP= 1<<2, /* Bit 2: PHY is in Loopback Mode */ | 2123 | XM_MMU_GMII_LOOP= 1<<2, /* Bit 2: PHY is in Loopback Mode */ |
2124 | XM_MMU_ENA_RX = 1<<1, /* Bit 1: Enable Receiver */ | 2124 | XM_MMU_ENA_RX = 1<<1, /* Bit 1: Enable Receiver */ |
2125 | XM_MMU_ENA_TX = 1<<0, /* Bit 0: Enable Transmitter */ | 2125 | XM_MMU_ENA_TX = 1<<0, /* Bit 0: Enable Transmitter */ |
2126 | }; | 2126 | }; |
2127 | 2127 | ||
2128 | 2128 | ||
@@ -2506,7 +2506,7 @@ static inline void skge_write8(const struct skge_hw *hw, int reg, u8 val) | |||
2506 | } | 2506 | } |
2507 | 2507 | ||
2508 | /* MAC Related Registers inside the device. */ | 2508 | /* MAC Related Registers inside the device. */ |
2509 | #define SK_REG(port,reg) (((port)<<7)+(reg)) | 2509 | #define SK_REG(port,reg) (((port)<<7)+(u16)(reg)) |
2510 | #define SK_XMAC_REG(port, reg) \ | 2510 | #define SK_XMAC_REG(port, reg) \ |
2511 | ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1) | 2511 | ((BASE_XMAC_1 + (port) * (BASE_XMAC_2 - BASE_XMAC_1)) | (reg) << 1) |
2512 | 2512 | ||
diff --git a/drivers/net/sky2.c b/drivers/net/sky2.c index 842abd9396c6..fb1d2c30c1bb 100644 --- a/drivers/net/sky2.c +++ b/drivers/net/sky2.c | |||
@@ -100,33 +100,32 @@ module_param(idle_timeout, int, 0); | |||
100 | MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)"); | 100 | MODULE_PARM_DESC(idle_timeout, "Watchdog timer for lost interrupts (ms)"); |
101 | 101 | ||
102 | static const struct pci_device_id sky2_id_table[] = { | 102 | static const struct pci_device_id sky2_id_table[] = { |
103 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, | 103 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */ |
104 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, | 104 | { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */ |
105 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */ | 105 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4b00) }, /* DGE-560T */ |
106 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, /* DGE-550SX */ | 106 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4001) }, /* DGE-550SX */ |
107 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B02) }, /* DGE-560SX */ | 107 | { PCI_DEVICE(PCI_VENDOR_ID_DLINK, 0x4B02) }, /* DGE-560SX */ |
108 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, | 108 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4340) }, /* 88E8021 */ |
109 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, | 109 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4341) }, /* 88E8022 */ |
110 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, | 110 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4342) }, /* 88E8061 */ |
111 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) }, | 111 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4343) }, /* 88E8062 */ |
112 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) }, | 112 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4344) }, /* 88E8021 */ |
113 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) }, | 113 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4345) }, /* 88E8022 */ |
114 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) }, | 114 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4346) }, /* 88E8061 */ |
115 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, | 115 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4347) }, /* 88E8062 */ |
116 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, | 116 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4350) }, /* 88E8035 */ |
117 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, | 117 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4351) }, /* 88E8036 */ |
118 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) }, | 118 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4352) }, /* 88E8038 */ |
119 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, | 119 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4353) }, /* 88E8039 */ |
120 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, | 120 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4356) }, /* 88EC033 */ |
121 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, | 121 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4360) }, /* 88E8052 */ |
122 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, | 122 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4361) }, /* 88E8050 */ |
123 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, | 123 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4362) }, /* 88E8053 */ |
124 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, | 124 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4363) }, /* 88E8055 */ |
125 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4365) }, | 125 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4364) }, /* 88E8056 */ |
126 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, | 126 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4366) }, /* 88EC036 */ |
127 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, | 127 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4367) }, /* 88EC032 */ |
128 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, | 128 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4368) }, /* 88EC034 */ |
129 | { PCI_DEVICE(PCI_VENDOR_ID_MARVELL, 0x4369) }, | ||
130 | { 0 } | 129 | { 0 } |
131 | }; | 130 | }; |
132 | 131 | ||
@@ -522,7 +521,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
522 | /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ | 521 | /* set Tx LED (LED_TX) to blink mode on Rx OR Tx activity */ |
523 | ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL; | 522 | ledctrl |= PHY_M_LED_BLINK_RT(BLINK_84MS) | PHY_M_LEDC_TX_CTRL; |
524 | /* turn off the Rx LED (LED_RX) */ | 523 | /* turn off the Rx LED (LED_RX) */ |
525 | ledover |= PHY_M_LED_MO_RX(MO_LED_OFF); | 524 | ledover &= ~PHY_M_LED_MO_RX; |
526 | } | 525 | } |
527 | 526 | ||
528 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) { | 527 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && hw->chip_rev == CHIP_REV_YU_EC_A1) { |
@@ -545,7 +544,7 @@ static void sky2_phy_init(struct sky2_hw *hw, unsigned port) | |||
545 | 544 | ||
546 | if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) { | 545 | if (sky2->autoneg == AUTONEG_DISABLE || sky2->speed == SPEED_100) { |
547 | /* turn on 100 Mbps LED (LED_LINK100) */ | 546 | /* turn on 100 Mbps LED (LED_LINK100) */ |
548 | ledover |= PHY_M_LED_MO_100(MO_LED_ON); | 547 | ledover |= PHY_M_LED_MO_100; |
549 | } | 548 | } |
550 | 549 | ||
551 | if (ledover) | 550 | if (ledover) |
@@ -697,10 +696,15 @@ static void sky2_mac_init(struct sky2_hw *hw, unsigned port) | |||
697 | 696 | ||
698 | } | 697 | } |
699 | 698 | ||
700 | /* Assign Ram Buffer allocation in units of 64bit (8 bytes) */ | 699 | /* Assign Ram Buffer allocation to queue */ |
701 | static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end) | 700 | static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 space) |
702 | { | 701 | { |
703 | pr_debug(PFX "q %d %#x %#x\n", q, start, end); | 702 | u32 end; |
703 | |||
704 | /* convert from K bytes to qwords used for hw register */ | ||
705 | start *= 1024/8; | ||
706 | space *= 1024/8; | ||
707 | end = start + space - 1; | ||
704 | 708 | ||
705 | sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); | 709 | sky2_write8(hw, RB_ADDR(q, RB_CTRL), RB_RST_CLR); |
706 | sky2_write32(hw, RB_ADDR(q, RB_START), start); | 710 | sky2_write32(hw, RB_ADDR(q, RB_START), start); |
@@ -709,7 +713,6 @@ static void sky2_ramset(struct sky2_hw *hw, u16 q, u32 start, u32 end) | |||
709 | sky2_write32(hw, RB_ADDR(q, RB_RP), start); | 713 | sky2_write32(hw, RB_ADDR(q, RB_RP), start); |
710 | 714 | ||
711 | if (q == Q_R1 || q == Q_R2) { | 715 | if (q == Q_R1 || q == Q_R2) { |
712 | u32 space = end - start + 1; | ||
713 | u32 tp = space - space/4; | 716 | u32 tp = space - space/4; |
714 | 717 | ||
715 | /* On receive queue's set the thresholds | 718 | /* On receive queue's set the thresholds |
@@ -1059,11 +1062,16 @@ static int sky2_rx_start(struct sky2_port *sky2) | |||
1059 | sky2->rx_put = sky2->rx_next = 0; | 1062 | sky2->rx_put = sky2->rx_next = 0; |
1060 | sky2_qset(hw, rxq); | 1063 | sky2_qset(hw, rxq); |
1061 | 1064 | ||
1065 | /* On PCI express lowering the watermark gives better performance */ | ||
1066 | if (pci_find_capability(hw->pdev, PCI_CAP_ID_EXP)) | ||
1067 | sky2_write32(hw, Q_ADDR(rxq, Q_WM), BMU_WM_PEX); | ||
1068 | |||
1069 | /* These chips have no ram buffer? | ||
1070 | * MAC Rx RAM Read is controlled by hardware */ | ||
1062 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && | 1071 | if (hw->chip_id == CHIP_ID_YUKON_EC_U && |
1063 | (hw->chip_rev == CHIP_REV_YU_EC_U_A1 || hw->chip_rev == CHIP_REV_YU_EC_U_B0)) { | 1072 | (hw->chip_rev == CHIP_REV_YU_EC_U_A1 |
1064 | /* MAC Rx RAM Read is controlled by hardware */ | 1073 | || hw->chip_rev == CHIP_REV_YU_EC_U_B0)) |
1065 | sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS); | 1074 | sky2_write32(hw, Q_ADDR(rxq, Q_F), F_M_RX_RAM_DIS); |
1066 | } | ||
1067 | 1075 | ||
1068 | sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); | 1076 | sky2_prefetch_init(hw, rxq, sky2->rx_le_map, RX_LE_SIZE - 1); |
1069 | 1077 | ||
@@ -1139,7 +1147,7 @@ static int sky2_up(struct net_device *dev) | |||
1139 | struct sky2_port *sky2 = netdev_priv(dev); | 1147 | struct sky2_port *sky2 = netdev_priv(dev); |
1140 | struct sky2_hw *hw = sky2->hw; | 1148 | struct sky2_hw *hw = sky2->hw; |
1141 | unsigned port = sky2->port; | 1149 | unsigned port = sky2->port; |
1142 | u32 ramsize, rxspace, imask; | 1150 | u32 ramsize, imask; |
1143 | int cap, err = -ENOMEM; | 1151 | int cap, err = -ENOMEM; |
1144 | struct net_device *otherdev = hw->dev[sky2->port^1]; | 1152 | struct net_device *otherdev = hw->dev[sky2->port^1]; |
1145 | 1153 | ||
@@ -1192,20 +1200,25 @@ static int sky2_up(struct net_device *dev) | |||
1192 | 1200 | ||
1193 | sky2_mac_init(hw, port); | 1201 | sky2_mac_init(hw, port); |
1194 | 1202 | ||
1195 | /* Determine available ram buffer space in qwords. */ | 1203 | /* Register is number of 4K blocks on internal RAM buffer. */ |
1196 | ramsize = sky2_read8(hw, B2_E_0) * 4096/8; | 1204 | ramsize = sky2_read8(hw, B2_E_0) * 4; |
1205 | printk(KERN_INFO PFX "%s: ram buffer %dK\n", dev->name, ramsize); | ||
1197 | 1206 | ||
1198 | if (ramsize > 6*1024/8) | 1207 | if (ramsize > 0) { |
1199 | rxspace = ramsize - (ramsize + 2) / 3; | 1208 | u32 rxspace; |
1200 | else | ||
1201 | rxspace = ramsize / 2; | ||
1202 | 1209 | ||
1203 | sky2_ramset(hw, rxqaddr[port], 0, rxspace-1); | 1210 | if (ramsize < 16) |
1204 | sky2_ramset(hw, txqaddr[port], rxspace, ramsize-1); | 1211 | rxspace = ramsize / 2; |
1212 | else | ||
1213 | rxspace = 8 + (2*(ramsize - 16))/3; | ||
1214 | |||
1215 | sky2_ramset(hw, rxqaddr[port], 0, rxspace); | ||
1216 | sky2_ramset(hw, txqaddr[port], rxspace, ramsize - rxspace); | ||
1205 | 1217 | ||
1206 | /* Make sure SyncQ is disabled */ | 1218 | /* Make sure SyncQ is disabled */ |
1207 | sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), | 1219 | sky2_write8(hw, RB_ADDR(port == 0 ? Q_XS1 : Q_XS2, RB_CTRL), |
1208 | RB_RST_SET); | 1220 | RB_RST_SET); |
1221 | } | ||
1209 | 1222 | ||
1210 | sky2_qset(hw, txqaddr[port]); | 1223 | sky2_qset(hw, txqaddr[port]); |
1211 | 1224 | ||
@@ -2917,18 +2930,8 @@ static void sky2_led(struct sky2_hw *hw, unsigned port, int on) | |||
2917 | 2930 | ||
2918 | default: | 2931 | default: |
2919 | gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); | 2932 | gm_phy_write(hw, port, PHY_MARV_LED_CTRL, 0); |
2920 | gm_phy_write(hw, port, PHY_MARV_LED_OVER, | 2933 | gm_phy_write(hw, port, PHY_MARV_LED_OVER, |
2921 | on ? PHY_M_LED_MO_DUP(MO_LED_ON) | | 2934 | on ? PHY_M_LED_ALL : 0); |
2922 | PHY_M_LED_MO_10(MO_LED_ON) | | ||
2923 | PHY_M_LED_MO_100(MO_LED_ON) | | ||
2924 | PHY_M_LED_MO_1000(MO_LED_ON) | | ||
2925 | PHY_M_LED_MO_RX(MO_LED_ON) | ||
2926 | : PHY_M_LED_MO_DUP(MO_LED_OFF) | | ||
2927 | PHY_M_LED_MO_10(MO_LED_OFF) | | ||
2928 | PHY_M_LED_MO_100(MO_LED_OFF) | | ||
2929 | PHY_M_LED_MO_1000(MO_LED_OFF) | | ||
2930 | PHY_M_LED_MO_RX(MO_LED_OFF)); | ||
2931 | |||
2932 | } | 2935 | } |
2933 | } | 2936 | } |
2934 | 2937 | ||
diff --git a/drivers/net/sky2.h b/drivers/net/sky2.h index 7760545edbf2..6ed1d47dbbd3 100644 --- a/drivers/net/sky2.h +++ b/drivers/net/sky2.h | |||
@@ -608,7 +608,7 @@ enum { | |||
608 | PHY_ADDR_MARV = 0, | 608 | PHY_ADDR_MARV = 0, |
609 | }; | 609 | }; |
610 | 610 | ||
611 | #define RB_ADDR(offs, queue) (B16_RAM_REGS + (queue) + (offs)) | 611 | #define RB_ADDR(offs, queue) ((u16) B16_RAM_REGS + (queue) + (offs)) |
612 | 612 | ||
613 | 613 | ||
614 | enum { | 614 | enum { |
@@ -680,6 +680,7 @@ enum { | |||
680 | BMU_FIFO_ENA | BMU_OP_ON, | 680 | BMU_FIFO_ENA | BMU_OP_ON, |
681 | 681 | ||
682 | BMU_WM_DEFAULT = 0x600, | 682 | BMU_WM_DEFAULT = 0x600, |
683 | BMU_WM_PEX = 0x80, | ||
683 | }; | 684 | }; |
684 | 685 | ||
685 | /* Tx BMU Control / Status Registers (Yukon-2) */ | 686 | /* Tx BMU Control / Status Registers (Yukon-2) */ |
@@ -1060,7 +1061,7 @@ enum { | |||
1060 | PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ | 1061 | PHY_M_PC_EN_DET_PLUS = 3<<8, /* Energy Detect Plus (Mode 2) */ |
1061 | }; | 1062 | }; |
1062 | 1063 | ||
1063 | #define PHY_M_PC_MDI_XMODE(x) (((x)<<5) & PHY_M_PC_MDIX_MSK) | 1064 | #define PHY_M_PC_MDI_XMODE(x) (((u16)(x)<<5) & PHY_M_PC_MDIX_MSK) |
1064 | 1065 | ||
1065 | enum { | 1066 | enum { |
1066 | PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ | 1067 | PHY_M_PC_MAN_MDI = 0, /* 00 = Manual MDI configuration */ |
@@ -1156,13 +1157,13 @@ enum { | |||
1156 | PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ | 1157 | PHY_M_EC_TX_TIM_CT = 1<<1, /* RGMII Tx Timing Control */ |
1157 | PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; | 1158 | PHY_M_EC_TRANS_DIS = 1<<0, /* Transmitter Disable (88E1111 only) */}; |
1158 | 1159 | ||
1159 | #define PHY_M_EC_M_DSC(x) ((x)<<10 & PHY_M_EC_M_DSC_MSK) | 1160 | #define PHY_M_EC_M_DSC(x) ((u16)(x)<<10 & PHY_M_EC_M_DSC_MSK) |
1160 | /* 00=1x; 01=2x; 10=3x; 11=4x */ | 1161 | /* 00=1x; 01=2x; 10=3x; 11=4x */ |
1161 | #define PHY_M_EC_S_DSC(x) ((x)<<8 & PHY_M_EC_S_DSC_MSK) | 1162 | #define PHY_M_EC_S_DSC(x) ((u16)(x)<<8 & PHY_M_EC_S_DSC_MSK) |
1162 | /* 00=dis; 01=1x; 10=2x; 11=3x */ | 1163 | /* 00=dis; 01=1x; 10=2x; 11=3x */ |
1163 | #define PHY_M_EC_DSC_2(x) ((x)<<9 & PHY_M_EC_M_DSC_MSK2) | 1164 | #define PHY_M_EC_DSC_2(x) ((u16)(x)<<9 & PHY_M_EC_M_DSC_MSK2) |
1164 | /* 000=1x; 001=2x; 010=3x; 011=4x */ | 1165 | /* 000=1x; 001=2x; 010=3x; 011=4x */ |
1165 | #define PHY_M_EC_MAC_S(x) ((x)<<4 & PHY_M_EC_MAC_S_MSK) | 1166 | #define PHY_M_EC_MAC_S(x) ((u16)(x)<<4 & PHY_M_EC_MAC_S_MSK) |
1166 | /* 01X=0; 110=2.5; 111=25 (MHz) */ | 1167 | /* 01X=0; 110=2.5; 111=25 (MHz) */ |
1167 | 1168 | ||
1168 | /* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */ | 1169 | /* for Yukon-2 Gigabit Ethernet PHY (88E1112 only) */ |
@@ -1173,7 +1174,7 @@ enum { | |||
1173 | }; | 1174 | }; |
1174 | /* !!! Errata in spec. (1 = disable) */ | 1175 | /* !!! Errata in spec. (1 = disable) */ |
1175 | 1176 | ||
1176 | #define PHY_M_PC_DSC(x) (((x)<<12) & PHY_M_PC_DSC_MSK) | 1177 | #define PHY_M_PC_DSC(x) (((u16)(x)<<12) & PHY_M_PC_DSC_MSK) |
1177 | /* 100=5x; 101=6x; 110=7x; 111=8x */ | 1178 | /* 100=5x; 101=6x; 110=7x; 111=8x */ |
1178 | enum { | 1179 | enum { |
1179 | MAC_TX_CLK_0_MHZ = 2, | 1180 | MAC_TX_CLK_0_MHZ = 2, |
@@ -1203,7 +1204,7 @@ enum { | |||
1203 | PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ | 1204 | PHY_M_LEDC_TX_C_MSB = 1<<0, /* Tx Control (MSB, 88E1111 only) */ |
1204 | }; | 1205 | }; |
1205 | 1206 | ||
1206 | #define PHY_M_LED_PULS_DUR(x) (((x)<<12) & PHY_M_LEDC_PULS_MSK) | 1207 | #define PHY_M_LED_PULS_DUR(x) (((u16)(x)<<12) & PHY_M_LEDC_PULS_MSK) |
1207 | 1208 | ||
1208 | /***** PHY_MARV_PHY_STAT (page 3)16 bit r/w Polarity Control Reg. *****/ | 1209 | /***** PHY_MARV_PHY_STAT (page 3)16 bit r/w Polarity Control Reg. *****/ |
1209 | enum { | 1210 | enum { |
@@ -1233,7 +1234,7 @@ enum { | |||
1233 | PULS_1300MS = 7,/* 1.3 s to 2.7 s */ | 1234 | PULS_1300MS = 7,/* 1.3 s to 2.7 s */ |
1234 | }; | 1235 | }; |
1235 | 1236 | ||
1236 | #define PHY_M_LED_BLINK_RT(x) (((x)<<8) & PHY_M_LEDC_BL_R_MSK) | 1237 | #define PHY_M_LED_BLINK_RT(x) (((u16)(x)<<8) & PHY_M_LEDC_BL_R_MSK) |
1237 | 1238 | ||
1238 | enum { | 1239 | enum { |
1239 | BLINK_42MS = 0,/* 42 ms */ | 1240 | BLINK_42MS = 0,/* 42 ms */ |
@@ -1243,21 +1244,18 @@ enum { | |||
1243 | BLINK_670MS = 4,/* 670 ms */ | 1244 | BLINK_670MS = 4,/* 670 ms */ |
1244 | }; | 1245 | }; |
1245 | 1246 | ||
1246 | /***** PHY_MARV_LED_OVER 16 bit r/w Manual LED Override Reg *****/ | 1247 | /**** PHY_MARV_LED_OVER 16 bit r/w LED control */ |
1247 | #define PHY_M_LED_MO_SGMII(x) ((x)<<14) /* Bit 15..14: SGMII AN Timer */ | ||
1248 | /* Bit 13..12: reserved */ | ||
1249 | #define PHY_M_LED_MO_DUP(x) ((x)<<10) /* Bit 11..10: Duplex */ | ||
1250 | #define PHY_M_LED_MO_10(x) ((x)<<8) /* Bit 9.. 8: Link 10 */ | ||
1251 | #define PHY_M_LED_MO_100(x) ((x)<<6) /* Bit 7.. 6: Link 100 */ | ||
1252 | #define PHY_M_LED_MO_1000(x) ((x)<<4) /* Bit 5.. 4: Link 1000 */ | ||
1253 | #define PHY_M_LED_MO_RX(x) ((x)<<2) /* Bit 3.. 2: Rx */ | ||
1254 | #define PHY_M_LED_MO_TX(x) ((x)<<0) /* Bit 1.. 0: Tx */ | ||
1255 | |||
1256 | enum { | 1248 | enum { |
1257 | MO_LED_NORM = 0, | 1249 | PHY_M_LED_MO_DUP = 3<<10,/* Bit 11..10: Duplex */ |
1258 | MO_LED_BLINK = 1, | 1250 | PHY_M_LED_MO_10 = 3<<8, /* Bit 9.. 8: Link 10 */ |
1259 | MO_LED_OFF = 2, | 1251 | PHY_M_LED_MO_100 = 3<<6, /* Bit 7.. 6: Link 100 */ |
1260 | MO_LED_ON = 3, | 1252 | PHY_M_LED_MO_1000 = 3<<4, /* Bit 5.. 4: Link 1000 */ |
1253 | PHY_M_LED_MO_RX = 3<<2, /* Bit 3.. 2: Rx */ | ||
1254 | PHY_M_LED_MO_TX = 3<<0, /* Bit 1.. 0: Tx */ | ||
1255 | |||
1256 | PHY_M_LED_ALL = PHY_M_LED_MO_DUP | PHY_M_LED_MO_10 | ||
1257 | | PHY_M_LED_MO_100 | PHY_M_LED_MO_1000 | ||
1258 | | PHY_M_LED_MO_RX, | ||
1261 | }; | 1259 | }; |
1262 | 1260 | ||
1263 | /***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/ | 1261 | /***** PHY_MARV_EXT_CTRL_2 16 bit r/w Ext. PHY Specific Ctrl 2 *****/ |
@@ -1294,9 +1292,9 @@ enum { | |||
1294 | PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */ | 1292 | PHY_M_FELP_LED0_MSK = 0xf, /* Bit 3.. 0: LED0 Mask (SPEED) */ |
1295 | }; | 1293 | }; |
1296 | 1294 | ||
1297 | #define PHY_M_FELP_LED2_CTRL(x) (((x)<<8) & PHY_M_FELP_LED2_MSK) | 1295 | #define PHY_M_FELP_LED2_CTRL(x) (((u16)(x)<<8) & PHY_M_FELP_LED2_MSK) |
1298 | #define PHY_M_FELP_LED1_CTRL(x) (((x)<<4) & PHY_M_FELP_LED1_MSK) | 1296 | #define PHY_M_FELP_LED1_CTRL(x) (((u16)(x)<<4) & PHY_M_FELP_LED1_MSK) |
1299 | #define PHY_M_FELP_LED0_CTRL(x) (((x)<<0) & PHY_M_FELP_LED0_MSK) | 1297 | #define PHY_M_FELP_LED0_CTRL(x) (((u16)(x)<<0) & PHY_M_FELP_LED0_MSK) |
1300 | 1298 | ||
1301 | enum { | 1299 | enum { |
1302 | LED_PAR_CTRL_COLX = 0x00, | 1300 | LED_PAR_CTRL_COLX = 0x00, |
@@ -1552,8 +1550,8 @@ enum { | |||
1552 | GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ | 1550 | GM_SMI_CT_BUSY = 1<<3, /* Bit 3: Busy (Operation in progress) */ |
1553 | }; | 1551 | }; |
1554 | 1552 | ||
1555 | #define GM_SMI_CT_PHY_AD(x) (((x)<<11) & GM_SMI_CT_PHY_A_MSK) | 1553 | #define GM_SMI_CT_PHY_AD(x) (((u16)(x)<<11) & GM_SMI_CT_PHY_A_MSK) |
1556 | #define GM_SMI_CT_REG_AD(x) (((x)<<6) & GM_SMI_CT_REG_A_MSK) | 1554 | #define GM_SMI_CT_REG_AD(x) (((u16)(x)<<6) & GM_SMI_CT_REG_A_MSK) |
1557 | 1555 | ||
1558 | /* GM_PHY_ADDR 16 bit r/w GPHY Address Register */ | 1556 | /* GM_PHY_ADDR 16 bit r/w GPHY Address Register */ |
1559 | enum { | 1557 | enum { |
diff --git a/drivers/net/smc-ultra.c b/drivers/net/smc-ultra.c index 889ef0d7c374..d70bc9795346 100644 --- a/drivers/net/smc-ultra.c +++ b/drivers/net/smc-ultra.c | |||
@@ -593,7 +593,7 @@ static void cleanup_card(struct net_device *dev) | |||
593 | iounmap(ei_status.mem); | 593 | iounmap(ei_status.mem); |
594 | } | 594 | } |
595 | 595 | ||
596 | void | 596 | void __exit |
597 | cleanup_module(void) | 597 | cleanup_module(void) |
598 | { | 598 | { |
599 | int this_dev; | 599 | int this_dev; |
diff --git a/drivers/net/smc-ultra32.c b/drivers/net/smc-ultra32.c index e10755ec5def..2c5319c62fa5 100644 --- a/drivers/net/smc-ultra32.c +++ b/drivers/net/smc-ultra32.c | |||
@@ -437,7 +437,7 @@ int __init init_module(void) | |||
437 | return -ENXIO; | 437 | return -ENXIO; |
438 | } | 438 | } |
439 | 439 | ||
440 | void cleanup_module(void) | 440 | void __exit cleanup_module(void) |
441 | { | 441 | { |
442 | int this_dev; | 442 | int this_dev; |
443 | 443 | ||
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c index c0d13d650913..bd6e84506c29 100644 --- a/drivers/net/smc9194.c +++ b/drivers/net/smc9194.c | |||
@@ -1616,7 +1616,7 @@ int __init init_module(void) | |||
1616 | return 0; | 1616 | return 0; |
1617 | } | 1617 | } |
1618 | 1618 | ||
1619 | void cleanup_module(void) | 1619 | void __exit cleanup_module(void) |
1620 | { | 1620 | { |
1621 | unregister_netdev(devSMC9194); | 1621 | unregister_netdev(devSMC9194); |
1622 | free_irq(devSMC9194->irq, devSMC9194); | 1622 | free_irq(devSMC9194->irq, devSMC9194); |
diff --git a/drivers/net/smc91x.h b/drivers/net/smc91x.h index a8640169fc77..9367c574477a 100644 --- a/drivers/net/smc91x.h +++ b/drivers/net/smc91x.h | |||
@@ -238,7 +238,7 @@ SMC_outw(u16 val, void __iomem *ioaddr, int reg) | |||
238 | #define SMC_CAN_USE_16BIT 1 | 238 | #define SMC_CAN_USE_16BIT 1 |
239 | #define SMC_CAN_USE_32BIT 0 | 239 | #define SMC_CAN_USE_32BIT 0 |
240 | 240 | ||
241 | #define SMC_inb(a, r) inb((u32)a) + (r)) | 241 | #define SMC_inb(a, r) inb(((u32)a) + (r)) |
242 | #define SMC_inw(a, r) inw(((u32)a) + (r)) | 242 | #define SMC_inw(a, r) inw(((u32)a) + (r)) |
243 | #define SMC_outb(v, a, r) outb(v, ((u32)a) + (r)) | 243 | #define SMC_outb(v, a, r) outb(v, ((u32)a) + (r)) |
244 | #define SMC_outw(v, a, r) outw(v, ((u32)a) + (r)) | 244 | #define SMC_outw(v, a, r) outw(v, ((u32)a) + (r)) |
@@ -434,6 +434,24 @@ static inline void LPD7_SMC_outsw (unsigned char* a, int r, | |||
434 | 434 | ||
435 | #define SMC_IRQ_FLAGS (0) | 435 | #define SMC_IRQ_FLAGS (0) |
436 | 436 | ||
437 | #elif defined(CONFIG_ARCH_VERSATILE) | ||
438 | |||
439 | #define SMC_CAN_USE_8BIT 1 | ||
440 | #define SMC_CAN_USE_16BIT 1 | ||
441 | #define SMC_CAN_USE_32BIT 1 | ||
442 | #define SMC_NOWAIT 1 | ||
443 | |||
444 | #define SMC_inb(a, r) readb((a) + (r)) | ||
445 | #define SMC_inw(a, r) readw((a) + (r)) | ||
446 | #define SMC_inl(a, r) readl((a) + (r)) | ||
447 | #define SMC_outb(v, a, r) writeb(v, (a) + (r)) | ||
448 | #define SMC_outw(v, a, r) writew(v, (a) + (r)) | ||
449 | #define SMC_outl(v, a, r) writel(v, (a) + (r)) | ||
450 | #define SMC_insl(a, r, p, l) readsl((a) + (r), p, l) | ||
451 | #define SMC_outsl(a, r, p, l) writesl((a) + (r), p, l) | ||
452 | |||
453 | #define SMC_IRQ_FLAGS (0) | ||
454 | |||
437 | #else | 455 | #else |
438 | 456 | ||
439 | #define SMC_CAN_USE_8BIT 1 | 457 | #define SMC_CAN_USE_8BIT 1 |
@@ -1216,7 +1234,7 @@ static const char * chip_ids[ 16 ] = { | |||
1216 | if (SMC_CAN_USE_32BIT) { \ | 1234 | if (SMC_CAN_USE_32BIT) { \ |
1217 | void *__ptr = (p); \ | 1235 | void *__ptr = (p); \ |
1218 | int __len = (l); \ | 1236 | int __len = (l); \ |
1219 | void *__ioaddr = ioaddr; \ | 1237 | void __iomem *__ioaddr = ioaddr; \ |
1220 | if (__len >= 2 && (unsigned long)__ptr & 2) { \ | 1238 | if (__len >= 2 && (unsigned long)__ptr & 2) { \ |
1221 | __len -= 2; \ | 1239 | __len -= 2; \ |
1222 | SMC_outw(*(u16 *)__ptr, ioaddr, DATA_REG); \ | 1240 | SMC_outw(*(u16 *)__ptr, ioaddr, DATA_REG); \ |
@@ -1240,7 +1258,7 @@ static const char * chip_ids[ 16 ] = { | |||
1240 | if (SMC_CAN_USE_32BIT) { \ | 1258 | if (SMC_CAN_USE_32BIT) { \ |
1241 | void *__ptr = (p); \ | 1259 | void *__ptr = (p); \ |
1242 | int __len = (l); \ | 1260 | int __len = (l); \ |
1243 | void *__ioaddr = ioaddr; \ | 1261 | void __iomem *__ioaddr = ioaddr; \ |
1244 | if ((unsigned long)__ptr & 2) { \ | 1262 | if ((unsigned long)__ptr & 2) { \ |
1245 | /* \ | 1263 | /* \ |
1246 | * We want 32bit alignment here. \ | 1264 | * We want 32bit alignment here. \ |
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c index 47a1c09d19ac..c62e85d89f41 100644 --- a/drivers/net/sun3lance.c +++ b/drivers/net/sun3lance.c | |||
@@ -945,7 +945,7 @@ static void set_multicast_list( struct net_device *dev ) | |||
945 | 945 | ||
946 | static struct net_device *sun3lance_dev; | 946 | static struct net_device *sun3lance_dev; |
947 | 947 | ||
948 | int init_module(void) | 948 | int __init init_module(void) |
949 | { | 949 | { |
950 | sun3lance_dev = sun3lance_probe(-1); | 950 | sun3lance_dev = sun3lance_probe(-1); |
951 | if (IS_ERR(sun3lance_dev)) | 951 | if (IS_ERR(sun3lance_dev)) |
@@ -953,7 +953,7 @@ int init_module(void) | |||
953 | return 0; | 953 | return 0; |
954 | } | 954 | } |
955 | 955 | ||
956 | void cleanup_module(void) | 956 | void __exit cleanup_module(void) |
957 | { | 957 | { |
958 | unregister_netdev(sun3lance_dev); | 958 | unregister_netdev(sun3lance_dev); |
959 | #ifdef CONFIG_SUN3 | 959 | #ifdef CONFIG_SUN3 |
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c index 46dabdb12071..cec282a6f62d 100644 --- a/drivers/net/tokenring/smctr.c +++ b/drivers/net/tokenring/smctr.c | |||
@@ -5706,7 +5706,7 @@ int __init init_module(void) | |||
5706 | return found ? 0 : -ENODEV; | 5706 | return found ? 0 : -ENODEV; |
5707 | } | 5707 | } |
5708 | 5708 | ||
5709 | void cleanup_module(void) | 5709 | void __exit cleanup_module(void) |
5710 | { | 5710 | { |
5711 | int i; | 5711 | int i; |
5712 | 5712 | ||
diff --git a/drivers/net/wd.c b/drivers/net/wd.c index 41f1d6778849..7f38012b9c92 100644 --- a/drivers/net/wd.c +++ b/drivers/net/wd.c | |||
@@ -538,7 +538,7 @@ static void cleanup_card(struct net_device *dev) | |||
538 | iounmap(ei_status.mem); | 538 | iounmap(ei_status.mem); |
539 | } | 539 | } |
540 | 540 | ||
541 | void | 541 | void __exit |
542 | cleanup_module(void) | 542 | cleanup_module(void) |
543 | { | 543 | { |
544 | int this_dev; | 544 | int this_dev; |
diff --git a/drivers/net/wireless/hostap/hostap_ap.c b/drivers/net/wireless/hostap/hostap_ap.c index 08bc57a4b895..974a8e5bec8b 100644 --- a/drivers/net/wireless/hostap/hostap_ap.c +++ b/drivers/net/wireless/hostap/hostap_ap.c | |||
@@ -1100,15 +1100,13 @@ static struct sta_info * ap_add_sta(struct ap_data *ap, u8 *addr) | |||
1100 | { | 1100 | { |
1101 | struct sta_info *sta; | 1101 | struct sta_info *sta; |
1102 | 1102 | ||
1103 | sta = (struct sta_info *) | 1103 | sta = kzalloc(sizeof(struct sta_info), GFP_ATOMIC); |
1104 | kmalloc(sizeof(struct sta_info), GFP_ATOMIC); | ||
1105 | if (sta == NULL) { | 1104 | if (sta == NULL) { |
1106 | PDEBUG(DEBUG_AP, "AP: kmalloc failed\n"); | 1105 | PDEBUG(DEBUG_AP, "AP: kmalloc failed\n"); |
1107 | return NULL; | 1106 | return NULL; |
1108 | } | 1107 | } |
1109 | 1108 | ||
1110 | /* initialize STA info data */ | 1109 | /* initialize STA info data */ |
1111 | memset(sta, 0, sizeof(struct sta_info)); | ||
1112 | sta->local = ap->local; | 1110 | sta->local = ap->local; |
1113 | skb_queue_head_init(&sta->tx_buf); | 1111 | skb_queue_head_init(&sta->tx_buf); |
1114 | memcpy(sta->addr, addr, ETH_ALEN); | 1112 | memcpy(sta->addr, addr, ETH_ALEN); |
diff --git a/drivers/net/wireless/hostap/hostap_cs.c b/drivers/net/wireless/hostap/hostap_cs.c index ee542ec6d6a8..8d8f4b9b8b07 100644 --- a/drivers/net/wireless/hostap/hostap_cs.c +++ b/drivers/net/wireless/hostap/hostap_cs.c | |||
@@ -563,12 +563,11 @@ static int prism2_config(struct pcmcia_device *link) | |||
563 | PDEBUG(DEBUG_FLOW, "prism2_config()\n"); | 563 | PDEBUG(DEBUG_FLOW, "prism2_config()\n"); |
564 | 564 | ||
565 | parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); | 565 | parse = kmalloc(sizeof(cisparse_t), GFP_KERNEL); |
566 | hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); | 566 | hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); |
567 | if (parse == NULL || hw_priv == NULL) { | 567 | if (parse == NULL || hw_priv == NULL) { |
568 | ret = -ENOMEM; | 568 | ret = -ENOMEM; |
569 | goto failed; | 569 | goto failed; |
570 | } | 570 | } |
571 | memset(hw_priv, 0, sizeof(*hw_priv)); | ||
572 | 571 | ||
573 | tuple.Attributes = 0; | 572 | tuple.Attributes = 0; |
574 | tuple.TupleData = buf; | 573 | tuple.TupleData = buf; |
diff --git a/drivers/net/wireless/hostap/hostap_download.c b/drivers/net/wireless/hostap/hostap_download.c index ab26b52b3e76..24fc387bba67 100644 --- a/drivers/net/wireless/hostap/hostap_download.c +++ b/drivers/net/wireless/hostap/hostap_download.c | |||
@@ -685,14 +685,12 @@ static int prism2_download(local_info_t *local, | |||
685 | goto out; | 685 | goto out; |
686 | } | 686 | } |
687 | 687 | ||
688 | dl = kmalloc(sizeof(*dl) + param->num_areas * | 688 | dl = kzalloc(sizeof(*dl) + param->num_areas * |
689 | sizeof(struct prism2_download_data_area), GFP_KERNEL); | 689 | sizeof(struct prism2_download_data_area), GFP_KERNEL); |
690 | if (dl == NULL) { | 690 | if (dl == NULL) { |
691 | ret = -ENOMEM; | 691 | ret = -ENOMEM; |
692 | goto out; | 692 | goto out; |
693 | } | 693 | } |
694 | memset(dl, 0, sizeof(*dl) + param->num_areas * | ||
695 | sizeof(struct prism2_download_data_area)); | ||
696 | dl->dl_cmd = param->dl_cmd; | 694 | dl->dl_cmd = param->dl_cmd; |
697 | dl->start_addr = param->start_addr; | 695 | dl->start_addr = param->start_addr; |
698 | dl->num_areas = param->num_areas; | 696 | dl->num_areas = param->num_areas; |
diff --git a/drivers/net/wireless/hostap/hostap_hw.c b/drivers/net/wireless/hostap/hostap_hw.c index c19e68636a1c..a394a23b9a20 100644 --- a/drivers/net/wireless/hostap/hostap_hw.c +++ b/drivers/net/wireless/hostap/hostap_hw.c | |||
@@ -347,14 +347,12 @@ static int hfa384x_cmd(struct net_device *dev, u16 cmd, u16 param0, | |||
347 | if (signal_pending(current)) | 347 | if (signal_pending(current)) |
348 | return -EINTR; | 348 | return -EINTR; |
349 | 349 | ||
350 | entry = (struct hostap_cmd_queue *) | 350 | entry = kzalloc(sizeof(*entry), GFP_ATOMIC); |
351 | kmalloc(sizeof(*entry), GFP_ATOMIC); | ||
352 | if (entry == NULL) { | 351 | if (entry == NULL) { |
353 | printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n", | 352 | printk(KERN_DEBUG "%s: hfa384x_cmd - kmalloc failed\n", |
354 | dev->name); | 353 | dev->name); |
355 | return -ENOMEM; | 354 | return -ENOMEM; |
356 | } | 355 | } |
357 | memset(entry, 0, sizeof(*entry)); | ||
358 | atomic_set(&entry->usecnt, 1); | 356 | atomic_set(&entry->usecnt, 1); |
359 | entry->type = CMD_SLEEP; | 357 | entry->type = CMD_SLEEP; |
360 | entry->cmd = cmd; | 358 | entry->cmd = cmd; |
@@ -517,14 +515,12 @@ static int hfa384x_cmd_callback(struct net_device *dev, u16 cmd, u16 param0, | |||
517 | return -1; | 515 | return -1; |
518 | } | 516 | } |
519 | 517 | ||
520 | entry = (struct hostap_cmd_queue *) | 518 | entry = kzalloc(sizeof(*entry), GFP_ATOMIC); |
521 | kmalloc(sizeof(*entry), GFP_ATOMIC); | ||
522 | if (entry == NULL) { | 519 | if (entry == NULL) { |
523 | printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc " | 520 | printk(KERN_DEBUG "%s: hfa384x_cmd_callback - kmalloc " |
524 | "failed\n", dev->name); | 521 | "failed\n", dev->name); |
525 | return -ENOMEM; | 522 | return -ENOMEM; |
526 | } | 523 | } |
527 | memset(entry, 0, sizeof(*entry)); | ||
528 | atomic_set(&entry->usecnt, 1); | 524 | atomic_set(&entry->usecnt, 1); |
529 | entry->type = CMD_CALLBACK; | 525 | entry->type = CMD_CALLBACK; |
530 | entry->cmd = cmd; | 526 | entry->cmd = cmd; |
@@ -3016,14 +3012,12 @@ static int prism2_set_tim(struct net_device *dev, int aid, int set) | |||
3016 | iface = netdev_priv(dev); | 3012 | iface = netdev_priv(dev); |
3017 | local = iface->local; | 3013 | local = iface->local; |
3018 | 3014 | ||
3019 | new_entry = (struct set_tim_data *) | 3015 | new_entry = kzalloc(sizeof(*new_entry), GFP_ATOMIC); |
3020 | kmalloc(sizeof(*new_entry), GFP_ATOMIC); | ||
3021 | if (new_entry == NULL) { | 3016 | if (new_entry == NULL) { |
3022 | printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n", | 3017 | printk(KERN_DEBUG "%s: prism2_set_tim: kmalloc failed\n", |
3023 | local->dev->name); | 3018 | local->dev->name); |
3024 | return -ENOMEM; | 3019 | return -ENOMEM; |
3025 | } | 3020 | } |
3026 | memset(new_entry, 0, sizeof(*new_entry)); | ||
3027 | new_entry->aid = aid; | 3021 | new_entry->aid = aid; |
3028 | new_entry->set = set; | 3022 | new_entry->set = set; |
3029 | 3023 | ||
diff --git a/drivers/net/wireless/hostap/hostap_info.c b/drivers/net/wireless/hostap/hostap_info.c index 5fd2b1ad7f5e..b6a02a02da74 100644 --- a/drivers/net/wireless/hostap/hostap_info.c +++ b/drivers/net/wireless/hostap/hostap_info.c | |||
@@ -327,11 +327,10 @@ static void prism2_info_hostscanresults(local_info_t *local, | |||
327 | ptr = (u8 *) pos; | 327 | ptr = (u8 *) pos; |
328 | 328 | ||
329 | new_count = left / result_size; | 329 | new_count = left / result_size; |
330 | results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result), | 330 | results = kcalloc(new_count, sizeof(struct hfa384x_hostscan_result), |
331 | GFP_ATOMIC); | 331 | GFP_ATOMIC); |
332 | if (results == NULL) | 332 | if (results == NULL) |
333 | return; | 333 | return; |
334 | memset(results, 0, new_count * sizeof(struct hfa384x_hostscan_result)); | ||
335 | 334 | ||
336 | for (i = 0; i < new_count; i++) { | 335 | for (i = 0; i < new_count; i++) { |
337 | memcpy(&results[i], ptr, copy_len); | 336 | memcpy(&results[i], ptr, copy_len); |
diff --git a/drivers/net/wireless/hostap/hostap_ioctl.c b/drivers/net/wireless/hostap/hostap_ioctl.c index d061fb3443ff..3b7b8063ff1c 100644 --- a/drivers/net/wireless/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/hostap/hostap_ioctl.c | |||
@@ -181,12 +181,10 @@ static int prism2_ioctl_siwencode(struct net_device *dev, | |||
181 | struct ieee80211_crypt_data *new_crypt; | 181 | struct ieee80211_crypt_data *new_crypt; |
182 | 182 | ||
183 | /* take WEP into use */ | 183 | /* take WEP into use */ |
184 | new_crypt = (struct ieee80211_crypt_data *) | 184 | new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data), |
185 | kmalloc(sizeof(struct ieee80211_crypt_data), | ||
186 | GFP_KERNEL); | 185 | GFP_KERNEL); |
187 | if (new_crypt == NULL) | 186 | if (new_crypt == NULL) |
188 | return -ENOMEM; | 187 | return -ENOMEM; |
189 | memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); | ||
190 | new_crypt->ops = ieee80211_get_crypto_ops("WEP"); | 188 | new_crypt->ops = ieee80211_get_crypto_ops("WEP"); |
191 | if (!new_crypt->ops) { | 189 | if (!new_crypt->ops) { |
192 | request_module("ieee80211_crypt_wep"); | 190 | request_module("ieee80211_crypt_wep"); |
@@ -3320,14 +3318,12 @@ static int prism2_ioctl_siwencodeext(struct net_device *dev, | |||
3320 | 3318 | ||
3321 | prism2_crypt_delayed_deinit(local, crypt); | 3319 | prism2_crypt_delayed_deinit(local, crypt); |
3322 | 3320 | ||
3323 | new_crypt = (struct ieee80211_crypt_data *) | 3321 | new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data), |
3324 | kmalloc(sizeof(struct ieee80211_crypt_data), | ||
3325 | GFP_KERNEL); | 3322 | GFP_KERNEL); |
3326 | if (new_crypt == NULL) { | 3323 | if (new_crypt == NULL) { |
3327 | ret = -ENOMEM; | 3324 | ret = -ENOMEM; |
3328 | goto done; | 3325 | goto done; |
3329 | } | 3326 | } |
3330 | memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); | ||
3331 | new_crypt->ops = ops; | 3327 | new_crypt->ops = ops; |
3332 | new_crypt->priv = new_crypt->ops->init(i); | 3328 | new_crypt->priv = new_crypt->ops->init(i); |
3333 | if (new_crypt->priv == NULL) { | 3329 | if (new_crypt->priv == NULL) { |
@@ -3538,14 +3534,12 @@ static int prism2_ioctl_set_encryption(local_info_t *local, | |||
3538 | 3534 | ||
3539 | prism2_crypt_delayed_deinit(local, crypt); | 3535 | prism2_crypt_delayed_deinit(local, crypt); |
3540 | 3536 | ||
3541 | new_crypt = (struct ieee80211_crypt_data *) | 3537 | new_crypt = kzalloc(sizeof(struct ieee80211_crypt_data), |
3542 | kmalloc(sizeof(struct ieee80211_crypt_data), | ||
3543 | GFP_KERNEL); | 3538 | GFP_KERNEL); |
3544 | if (new_crypt == NULL) { | 3539 | if (new_crypt == NULL) { |
3545 | ret = -ENOMEM; | 3540 | ret = -ENOMEM; |
3546 | goto done; | 3541 | goto done; |
3547 | } | 3542 | } |
3548 | memset(new_crypt, 0, sizeof(struct ieee80211_crypt_data)); | ||
3549 | new_crypt->ops = ops; | 3543 | new_crypt->ops = ops; |
3550 | new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); | 3544 | new_crypt->priv = new_crypt->ops->init(param->u.crypt.idx); |
3551 | if (new_crypt->priv == NULL) { | 3545 | if (new_crypt->priv == NULL) { |
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c index d1de9766c831..c4f6020baa9e 100644 --- a/drivers/net/wireless/hostap/hostap_pci.c +++ b/drivers/net/wireless/hostap/hostap_pci.c | |||
@@ -300,10 +300,9 @@ static int prism2_pci_probe(struct pci_dev *pdev, | |||
300 | struct hostap_interface *iface; | 300 | struct hostap_interface *iface; |
301 | struct hostap_pci_priv *hw_priv; | 301 | struct hostap_pci_priv *hw_priv; |
302 | 302 | ||
303 | hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); | 303 | hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); |
304 | if (hw_priv == NULL) | 304 | if (hw_priv == NULL) |
305 | return -ENOMEM; | 305 | return -ENOMEM; |
306 | memset(hw_priv, 0, sizeof(*hw_priv)); | ||
307 | 306 | ||
308 | if (pci_enable_device(pdev)) | 307 | if (pci_enable_device(pdev)) |
309 | goto err_out_free; | 308 | goto err_out_free; |
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c index bc81b13a5a2a..e235e0647897 100644 --- a/drivers/net/wireless/hostap/hostap_plx.c +++ b/drivers/net/wireless/hostap/hostap_plx.c | |||
@@ -447,10 +447,9 @@ static int prism2_plx_probe(struct pci_dev *pdev, | |||
447 | int tmd7160; | 447 | int tmd7160; |
448 | struct hostap_plx_priv *hw_priv; | 448 | struct hostap_plx_priv *hw_priv; |
449 | 449 | ||
450 | hw_priv = kmalloc(sizeof(*hw_priv), GFP_KERNEL); | 450 | hw_priv = kzalloc(sizeof(*hw_priv), GFP_KERNEL); |
451 | if (hw_priv == NULL) | 451 | if (hw_priv == NULL) |
452 | return -ENOMEM; | 452 | return -ENOMEM; |
453 | memset(hw_priv, 0, sizeof(*hw_priv)); | ||
454 | 453 | ||
455 | if (pci_enable_device(pdev)) | 454 | if (pci_enable_device(pdev)) |
456 | goto err_out_free; | 455 | goto err_out_free; |
diff --git a/drivers/net/wireless/ipw2100.c b/drivers/net/wireless/ipw2100.c index 1bcd352a813b..dd9ba4aad7bb 100644 --- a/drivers/net/wireless/ipw2100.c +++ b/drivers/net/wireless/ipw2100.c | |||
@@ -6220,7 +6220,7 @@ static int ipw2100_pci_init_one(struct pci_dev *pci_dev, | |||
6220 | /* Allocate and initialize the Tx/Rx queues and lists */ | 6220 | /* Allocate and initialize the Tx/Rx queues and lists */ |
6221 | if (ipw2100_queues_allocate(priv)) { | 6221 | if (ipw2100_queues_allocate(priv)) { |
6222 | printk(KERN_WARNING DRV_NAME | 6222 | printk(KERN_WARNING DRV_NAME |
6223 | "Error calilng ipw2100_queues_allocate.\n"); | 6223 | "Error calling ipw2100_queues_allocate.\n"); |
6224 | err = -ENOMEM; | 6224 | err = -ENOMEM; |
6225 | goto fail; | 6225 | goto fail; |
6226 | } | 6226 | } |
diff --git a/drivers/net/wireless/ipw2200.c b/drivers/net/wireless/ipw2200.c index e82e56bb85e1..22cb3fb7502e 100644 --- a/drivers/net/wireless/ipw2200.c +++ b/drivers/net/wireless/ipw2200.c | |||
@@ -70,7 +70,7 @@ | |||
70 | #define VQ | 70 | #define VQ |
71 | #endif | 71 | #endif |
72 | 72 | ||
73 | #define IPW2200_VERSION "1.1.4" VK VD VM VP VR VQ | 73 | #define IPW2200_VERSION "1.2.0" VK VD VM VP VR VQ |
74 | #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver" | 74 | #define DRV_DESCRIPTION "Intel(R) PRO/Wireless 2200/2915 Network Driver" |
75 | #define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" | 75 | #define DRV_COPYRIGHT "Copyright(c) 2003-2006 Intel Corporation" |
76 | #define DRV_VERSION IPW2200_VERSION | 76 | #define DRV_VERSION IPW2200_VERSION |
@@ -7677,7 +7677,8 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv, | |||
7677 | 7677 | ||
7678 | /* Big bitfield of all the fields we provide in radiotap */ | 7678 | /* Big bitfield of all the fields we provide in radiotap */ |
7679 | ipw_rt->rt_hdr.it_present = | 7679 | ipw_rt->rt_hdr.it_present = |
7680 | ((1 << IEEE80211_RADIOTAP_FLAGS) | | 7680 | ((1 << IEEE80211_RADIOTAP_TSFT) | |
7681 | (1 << IEEE80211_RADIOTAP_FLAGS) | | ||
7681 | (1 << IEEE80211_RADIOTAP_RATE) | | 7682 | (1 << IEEE80211_RADIOTAP_RATE) | |
7682 | (1 << IEEE80211_RADIOTAP_CHANNEL) | | 7683 | (1 << IEEE80211_RADIOTAP_CHANNEL) | |
7683 | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | | 7684 | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | |
@@ -7686,10 +7687,14 @@ static void ipw_handle_data_packet_monitor(struct ipw_priv *priv, | |||
7686 | 7687 | ||
7687 | /* Zero the flags, we'll add to them as we go */ | 7688 | /* Zero the flags, we'll add to them as we go */ |
7688 | ipw_rt->rt_flags = 0; | 7689 | ipw_rt->rt_flags = 0; |
7689 | ipw_rt->rt_tsf = 0ULL; | 7690 | ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 | |
7691 | frame->parent_tsf[2] << 16 | | ||
7692 | frame->parent_tsf[1] << 8 | | ||
7693 | frame->parent_tsf[0]); | ||
7690 | 7694 | ||
7691 | /* Convert signal to DBM */ | 7695 | /* Convert signal to DBM */ |
7692 | ipw_rt->rt_dbmsignal = antsignal; | 7696 | ipw_rt->rt_dbmsignal = antsignal; |
7697 | ipw_rt->rt_dbmnoise = frame->noise; | ||
7693 | 7698 | ||
7694 | /* Convert the channel data and set the flags */ | 7699 | /* Convert the channel data and set the flags */ |
7695 | ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(received_channel)); | 7700 | ipw_rt->rt_channel = cpu_to_le16(ieee80211chan2mhz(received_channel)); |
@@ -7889,7 +7894,8 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv, | |||
7889 | 7894 | ||
7890 | /* Big bitfield of all the fields we provide in radiotap */ | 7895 | /* Big bitfield of all the fields we provide in radiotap */ |
7891 | ipw_rt->rt_hdr.it_present = | 7896 | ipw_rt->rt_hdr.it_present = |
7892 | ((1 << IEEE80211_RADIOTAP_FLAGS) | | 7897 | ((1 << IEEE80211_RADIOTAP_TSFT) | |
7898 | (1 << IEEE80211_RADIOTAP_FLAGS) | | ||
7893 | (1 << IEEE80211_RADIOTAP_RATE) | | 7899 | (1 << IEEE80211_RADIOTAP_RATE) | |
7894 | (1 << IEEE80211_RADIOTAP_CHANNEL) | | 7900 | (1 << IEEE80211_RADIOTAP_CHANNEL) | |
7895 | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | | 7901 | (1 << IEEE80211_RADIOTAP_DBM_ANTSIGNAL) | |
@@ -7898,7 +7904,10 @@ static void ipw_handle_promiscuous_rx(struct ipw_priv *priv, | |||
7898 | 7904 | ||
7899 | /* Zero the flags, we'll add to them as we go */ | 7905 | /* Zero the flags, we'll add to them as we go */ |
7900 | ipw_rt->rt_flags = 0; | 7906 | ipw_rt->rt_flags = 0; |
7901 | ipw_rt->rt_tsf = 0ULL; | 7907 | ipw_rt->rt_tsf = (u64)(frame->parent_tsf[3] << 24 | |
7908 | frame->parent_tsf[2] << 16 | | ||
7909 | frame->parent_tsf[1] << 8 | | ||
7910 | frame->parent_tsf[0]); | ||
7902 | 7911 | ||
7903 | /* Convert to DBM */ | 7912 | /* Convert to DBM */ |
7904 | ipw_rt->rt_dbmsignal = signal; | 7913 | ipw_rt->rt_dbmsignal = signal; |
@@ -8297,7 +8306,7 @@ static void ipw_rx(struct ipw_priv *priv) | |||
8297 | ("Notification: subtype=%02X flags=%02X size=%d\n", | 8306 | ("Notification: subtype=%02X flags=%02X size=%d\n", |
8298 | pkt->u.notification.subtype, | 8307 | pkt->u.notification.subtype, |
8299 | pkt->u.notification.flags, | 8308 | pkt->u.notification.flags, |
8300 | pkt->u.notification.size); | 8309 | le16_to_cpu(pkt->u.notification.size)); |
8301 | ipw_rx_notification(priv, &pkt->u.notification); | 8310 | ipw_rx_notification(priv, &pkt->u.notification); |
8302 | break; | 8311 | break; |
8303 | } | 8312 | } |
@@ -11145,14 +11154,13 @@ static int ipw_up(struct ipw_priv *priv) | |||
11145 | return -EIO; | 11154 | return -EIO; |
11146 | 11155 | ||
11147 | if (cmdlog && !priv->cmdlog) { | 11156 | if (cmdlog && !priv->cmdlog) { |
11148 | priv->cmdlog = kmalloc(sizeof(*priv->cmdlog) * cmdlog, | 11157 | priv->cmdlog = kcalloc(cmdlog, sizeof(*priv->cmdlog), |
11149 | GFP_KERNEL); | 11158 | GFP_KERNEL); |
11150 | if (priv->cmdlog == NULL) { | 11159 | if (priv->cmdlog == NULL) { |
11151 | IPW_ERROR("Error allocating %d command log entries.\n", | 11160 | IPW_ERROR("Error allocating %d command log entries.\n", |
11152 | cmdlog); | 11161 | cmdlog); |
11153 | return -ENOMEM; | 11162 | return -ENOMEM; |
11154 | } else { | 11163 | } else { |
11155 | memset(priv->cmdlog, 0, sizeof(*priv->cmdlog) * cmdlog); | ||
11156 | priv->cmdlog_len = cmdlog; | 11164 | priv->cmdlog_len = cmdlog; |
11157 | } | 11165 | } |
11158 | } | 11166 | } |
diff --git a/drivers/net/wireless/prism54/isl_ioctl.c b/drivers/net/wireless/prism54/isl_ioctl.c index a87eb51886c8..96606ed10076 100644 --- a/drivers/net/wireless/prism54/isl_ioctl.c +++ b/drivers/net/wireless/prism54/isl_ioctl.c | |||
@@ -2141,11 +2141,9 @@ prism54_wpa_bss_ie_add(islpci_private *priv, u8 *bssid, | |||
2141 | struct islpci_bss_wpa_ie, list); | 2141 | struct islpci_bss_wpa_ie, list); |
2142 | list_del(&bss->list); | 2142 | list_del(&bss->list); |
2143 | } else { | 2143 | } else { |
2144 | bss = kmalloc(sizeof (*bss), GFP_ATOMIC); | 2144 | bss = kzalloc(sizeof (*bss), GFP_ATOMIC); |
2145 | if (bss != NULL) { | 2145 | if (bss != NULL) |
2146 | priv->num_bss_wpa++; | 2146 | priv->num_bss_wpa++; |
2147 | memset(bss, 0, sizeof (*bss)); | ||
2148 | } | ||
2149 | } | 2147 | } |
2150 | if (bss != NULL) { | 2148 | if (bss != NULL) { |
2151 | memcpy(bss->bssid, bssid, ETH_ALEN); | 2149 | memcpy(bss->bssid, bssid, ETH_ALEN); |
@@ -2686,11 +2684,10 @@ prism2_ioctl_set_generic_element(struct net_device *ndev, | |||
2686 | return -EINVAL; | 2684 | return -EINVAL; |
2687 | 2685 | ||
2688 | alen = sizeof(*attach) + len; | 2686 | alen = sizeof(*attach) + len; |
2689 | attach = kmalloc(alen, GFP_KERNEL); | 2687 | attach = kzalloc(alen, GFP_KERNEL); |
2690 | if (attach == NULL) | 2688 | if (attach == NULL) |
2691 | return -ENOMEM; | 2689 | return -ENOMEM; |
2692 | 2690 | ||
2693 | memset(attach, 0, alen); | ||
2694 | #define WLAN_FC_TYPE_MGMT 0 | 2691 | #define WLAN_FC_TYPE_MGMT 0 |
2695 | #define WLAN_FC_STYPE_ASSOC_REQ 0 | 2692 | #define WLAN_FC_STYPE_ASSOC_REQ 0 |
2696 | #define WLAN_FC_STYPE_REASSOC_REQ 2 | 2693 | #define WLAN_FC_STYPE_REASSOC_REQ 2 |
diff --git a/drivers/net/wireless/prism54/oid_mgt.c b/drivers/net/wireless/prism54/oid_mgt.c index fbc52b6a3024..e6cf9df2c206 100644 --- a/drivers/net/wireless/prism54/oid_mgt.c +++ b/drivers/net/wireless/prism54/oid_mgt.c | |||
@@ -235,12 +235,10 @@ mgt_init(islpci_private *priv) | |||
235 | { | 235 | { |
236 | int i; | 236 | int i; |
237 | 237 | ||
238 | priv->mib = kmalloc(OID_NUM_LAST * sizeof (void *), GFP_KERNEL); | 238 | priv->mib = kcalloc(OID_NUM_LAST, sizeof (void *), GFP_KERNEL); |
239 | if (!priv->mib) | 239 | if (!priv->mib) |
240 | return -ENOMEM; | 240 | return -ENOMEM; |
241 | 241 | ||
242 | memset(priv->mib, 0, OID_NUM_LAST * sizeof (void *)); | ||
243 | |||
244 | /* Alloc the cache */ | 242 | /* Alloc the cache */ |
245 | for (i = 0; i < OID_NUM_LAST; i++) { | 243 | for (i = 0; i < OID_NUM_LAST; i++) { |
246 | if (isl_oid[i].flags & OID_FLAG_CACHED) { | 244 | if (isl_oid[i].flags & OID_FLAG_CACHED) { |
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.c b/drivers/net/wireless/zd1211rw/zd_chip.c index 8be99ebbe1cd..77e11ddad836 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.c +++ b/drivers/net/wireless/zd1211rw/zd_chip.c | |||
@@ -1673,3 +1673,16 @@ int zd_rfwritev_cr_locked(struct zd_chip *chip, | |||
1673 | 1673 | ||
1674 | return 0; | 1674 | return 0; |
1675 | } | 1675 | } |
1676 | |||
1677 | int zd_chip_set_multicast_hash(struct zd_chip *chip, | ||
1678 | struct zd_mc_hash *hash) | ||
1679 | { | ||
1680 | struct zd_ioreq32 ioreqs[] = { | ||
1681 | { CR_GROUP_HASH_P1, hash->low }, | ||
1682 | { CR_GROUP_HASH_P2, hash->high }, | ||
1683 | }; | ||
1684 | |||
1685 | dev_dbg_f(zd_chip_dev(chip), "hash l 0x%08x h 0x%08x\n", | ||
1686 | ioreqs[0].value, ioreqs[1].value); | ||
1687 | return zd_iowrite32a(chip, ioreqs, ARRAY_SIZE(ioreqs)); | ||
1688 | } | ||
diff --git a/drivers/net/wireless/zd1211rw/zd_chip.h b/drivers/net/wireless/zd1211rw/zd_chip.h index ca892b9a6448..a4e3cee9b59d 100644 --- a/drivers/net/wireless/zd1211rw/zd_chip.h +++ b/drivers/net/wireless/zd1211rw/zd_chip.h | |||
@@ -390,10 +390,19 @@ | |||
390 | #define CR_BSSID_P1 CTL_REG(0x0618) | 390 | #define CR_BSSID_P1 CTL_REG(0x0618) |
391 | #define CR_BSSID_P2 CTL_REG(0x061C) | 391 | #define CR_BSSID_P2 CTL_REG(0x061C) |
392 | #define CR_BCN_PLCP_CFG CTL_REG(0x0620) | 392 | #define CR_BCN_PLCP_CFG CTL_REG(0x0620) |
393 | |||
394 | /* Group hash table for filtering incoming packets. | ||
395 | * | ||
396 | * The group hash table is 64 bit large and split over two parts. The first | ||
397 | * part is the lower part. The upper 6 bits of the last byte of the target | ||
398 | * address are used as index. Packets are received if the hash table bit is | ||
399 | * set. This is used for multicast handling, but for broadcasts (address | ||
400 | * ff:ff:ff:ff:ff:ff) the highest bit in the second table must also be set. | ||
401 | */ | ||
393 | #define CR_GROUP_HASH_P1 CTL_REG(0x0624) | 402 | #define CR_GROUP_HASH_P1 CTL_REG(0x0624) |
394 | #define CR_GROUP_HASH_P2 CTL_REG(0x0628) | 403 | #define CR_GROUP_HASH_P2 CTL_REG(0x0628) |
395 | #define CR_RX_TIMEOUT CTL_REG(0x062C) | ||
396 | 404 | ||
405 | #define CR_RX_TIMEOUT CTL_REG(0x062C) | ||
397 | /* Basic rates supported by the BSS. When producing ACK or CTS messages, the | 406 | /* Basic rates supported by the BSS. When producing ACK or CTS messages, the |
398 | * device will use a rate in this table that is less than or equal to the rate | 407 | * device will use a rate in this table that is less than or equal to the rate |
399 | * of the incoming frame which prompted the response */ | 408 | * of the incoming frame which prompted the response */ |
@@ -864,4 +873,36 @@ u8 zd_rx_strength_percent(u8 rssi); | |||
864 | 873 | ||
865 | u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status); | 874 | u16 zd_rx_rate(const void *rx_frame, const struct rx_status *status); |
866 | 875 | ||
876 | struct zd_mc_hash { | ||
877 | u32 low; | ||
878 | u32 high; | ||
879 | }; | ||
880 | |||
881 | static inline void zd_mc_clear(struct zd_mc_hash *hash) | ||
882 | { | ||
883 | hash->low = 0; | ||
884 | /* The interfaces must always received broadcasts. | ||
885 | * The hash of the broadcast address ff:ff:ff:ff:ff:ff is 63. | ||
886 | */ | ||
887 | hash->high = 0x80000000; | ||
888 | } | ||
889 | |||
890 | static inline void zd_mc_add_all(struct zd_mc_hash *hash) | ||
891 | { | ||
892 | hash->low = hash->high = 0xffffffff; | ||
893 | } | ||
894 | |||
895 | static inline void zd_mc_add_addr(struct zd_mc_hash *hash, u8 *addr) | ||
896 | { | ||
897 | unsigned int i = addr[5] >> 2; | ||
898 | if (i < 32) { | ||
899 | hash->low |= 1 << i; | ||
900 | } else { | ||
901 | hash->high |= 1 << (i-32); | ||
902 | } | ||
903 | } | ||
904 | |||
905 | int zd_chip_set_multicast_hash(struct zd_chip *chip, | ||
906 | struct zd_mc_hash *hash); | ||
907 | |||
867 | #endif /* _ZD_CHIP_H */ | 908 | #endif /* _ZD_CHIP_H */ |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index f1573a9c2336..00ca704ece35 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -39,6 +39,8 @@ static void housekeeping_init(struct zd_mac *mac); | |||
39 | static void housekeeping_enable(struct zd_mac *mac); | 39 | static void housekeeping_enable(struct zd_mac *mac); |
40 | static void housekeeping_disable(struct zd_mac *mac); | 40 | static void housekeeping_disable(struct zd_mac *mac); |
41 | 41 | ||
42 | static void set_multicast_hash_handler(struct work_struct *work); | ||
43 | |||
42 | int zd_mac_init(struct zd_mac *mac, | 44 | int zd_mac_init(struct zd_mac *mac, |
43 | struct net_device *netdev, | 45 | struct net_device *netdev, |
44 | struct usb_interface *intf) | 46 | struct usb_interface *intf) |
@@ -55,6 +57,7 @@ int zd_mac_init(struct zd_mac *mac, | |||
55 | softmac_init(ieee80211_priv(netdev)); | 57 | softmac_init(ieee80211_priv(netdev)); |
56 | zd_chip_init(&mac->chip, netdev, intf); | 58 | zd_chip_init(&mac->chip, netdev, intf); |
57 | housekeeping_init(mac); | 59 | housekeeping_init(mac); |
60 | INIT_WORK(&mac->set_multicast_hash_work, set_multicast_hash_handler); | ||
58 | return 0; | 61 | return 0; |
59 | } | 62 | } |
60 | 63 | ||
@@ -136,6 +139,7 @@ out: | |||
136 | 139 | ||
137 | void zd_mac_clear(struct zd_mac *mac) | 140 | void zd_mac_clear(struct zd_mac *mac) |
138 | { | 141 | { |
142 | flush_workqueue(zd_workqueue); | ||
139 | zd_chip_clear(&mac->chip); | 143 | zd_chip_clear(&mac->chip); |
140 | ZD_ASSERT(!spin_is_locked(&mac->lock)); | 144 | ZD_ASSERT(!spin_is_locked(&mac->lock)); |
141 | ZD_MEMCLEAR(mac, sizeof(struct zd_mac)); | 145 | ZD_MEMCLEAR(mac, sizeof(struct zd_mac)); |
@@ -256,6 +260,43 @@ int zd_mac_set_mac_address(struct net_device *netdev, void *p) | |||
256 | return 0; | 260 | return 0; |
257 | } | 261 | } |
258 | 262 | ||
263 | static void set_multicast_hash_handler(struct work_struct *work) | ||
264 | { | ||
265 | struct zd_mac *mac = container_of(work, struct zd_mac, | ||
266 | set_multicast_hash_work); | ||
267 | struct zd_mc_hash hash; | ||
268 | |||
269 | spin_lock_irq(&mac->lock); | ||
270 | hash = mac->multicast_hash; | ||
271 | spin_unlock_irq(&mac->lock); | ||
272 | |||
273 | zd_chip_set_multicast_hash(&mac->chip, &hash); | ||
274 | } | ||
275 | |||
276 | void zd_mac_set_multicast_list(struct net_device *dev) | ||
277 | { | ||
278 | struct zd_mc_hash hash; | ||
279 | struct zd_mac *mac = zd_netdev_mac(dev); | ||
280 | struct dev_mc_list *mc; | ||
281 | unsigned long flags; | ||
282 | |||
283 | if (dev->flags & (IFF_PROMISC|IFF_ALLMULTI)) { | ||
284 | zd_mc_add_all(&hash); | ||
285 | } else { | ||
286 | zd_mc_clear(&hash); | ||
287 | for (mc = dev->mc_list; mc; mc = mc->next) { | ||
288 | dev_dbg_f(zd_mac_dev(mac), "mc addr " MAC_FMT "\n", | ||
289 | MAC_ARG(mc->dmi_addr)); | ||
290 | zd_mc_add_addr(&hash, mc->dmi_addr); | ||
291 | } | ||
292 | } | ||
293 | |||
294 | spin_lock_irqsave(&mac->lock, flags); | ||
295 | mac->multicast_hash = hash; | ||
296 | spin_unlock_irqrestore(&mac->lock, flags); | ||
297 | queue_work(zd_workqueue, &mac->set_multicast_hash_work); | ||
298 | } | ||
299 | |||
259 | int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain) | 300 | int zd_mac_set_regdomain(struct zd_mac *mac, u8 regdomain) |
260 | { | 301 | { |
261 | int r; | 302 | int r; |
@@ -618,6 +659,9 @@ int zd_mac_get_range(struct zd_mac *mac, struct iw_range *range) | |||
618 | range->we_version_compiled = WIRELESS_EXT; | 659 | range->we_version_compiled = WIRELESS_EXT; |
619 | range->we_version_source = 20; | 660 | range->we_version_source = 20; |
620 | 661 | ||
662 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_WPA2 | | ||
663 | IW_ENC_CAPA_CIPHER_TKIP | IW_ENC_CAPA_CIPHER_CCMP; | ||
664 | |||
621 | ZD_ASSERT(!irqs_disabled()); | 665 | ZD_ASSERT(!irqs_disabled()); |
622 | spin_lock_irq(&mac->lock); | 666 | spin_lock_irq(&mac->lock); |
623 | regdomain = mac->regdomain; | 667 | regdomain = mac->regdomain; |
@@ -930,7 +974,8 @@ static int is_data_packet_for_us(struct ieee80211_device *ieee, | |||
930 | } | 974 | } |
931 | 975 | ||
932 | return memcmp(hdr->addr1, netdev->dev_addr, ETH_ALEN) == 0 || | 976 | return memcmp(hdr->addr1, netdev->dev_addr, ETH_ALEN) == 0 || |
933 | is_multicast_ether_addr(hdr->addr1) || | 977 | (is_multicast_ether_addr(hdr->addr1) && |
978 | memcmp(hdr->addr3, netdev->dev_addr, ETH_ALEN) != 0) || | ||
934 | (netdev->flags & IFF_PROMISC); | 979 | (netdev->flags & IFF_PROMISC); |
935 | } | 980 | } |
936 | 981 | ||
@@ -1062,10 +1107,8 @@ int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length) | |||
1062 | memcpy(skb_put(skb, length), buffer, length); | 1107 | memcpy(skb_put(skb, length), buffer, length); |
1063 | 1108 | ||
1064 | r = ieee80211_rx(ieee, skb, &stats); | 1109 | r = ieee80211_rx(ieee, skb, &stats); |
1065 | if (!r) { | 1110 | if (!r) |
1066 | ZD_ASSERT(in_irq()); | 1111 | dev_kfree_skb_any(skb); |
1067 | dev_kfree_skb_irq(skb); | ||
1068 | } | ||
1069 | return 0; | 1112 | return 0; |
1070 | } | 1113 | } |
1071 | 1114 | ||
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.h b/drivers/net/wireless/zd1211rw/zd_mac.h index d4e8b870409d..f0cf05dc7d3e 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.h +++ b/drivers/net/wireless/zd1211rw/zd_mac.h | |||
@@ -133,6 +133,8 @@ struct zd_mac { | |||
133 | struct iw_statistics iw_stats; | 133 | struct iw_statistics iw_stats; |
134 | 134 | ||
135 | struct housekeeping housekeeping; | 135 | struct housekeeping housekeeping; |
136 | struct work_struct set_multicast_hash_work; | ||
137 | struct zd_mc_hash multicast_hash; | ||
136 | struct delayed_work set_rts_cts_work; | 138 | struct delayed_work set_rts_cts_work; |
137 | struct delayed_work set_basic_rates_work; | 139 | struct delayed_work set_basic_rates_work; |
138 | 140 | ||
@@ -189,6 +191,7 @@ int zd_mac_init_hw(struct zd_mac *mac, u8 device_type); | |||
189 | int zd_mac_open(struct net_device *netdev); | 191 | int zd_mac_open(struct net_device *netdev); |
190 | int zd_mac_stop(struct net_device *netdev); | 192 | int zd_mac_stop(struct net_device *netdev); |
191 | int zd_mac_set_mac_address(struct net_device *dev, void *p); | 193 | int zd_mac_set_mac_address(struct net_device *dev, void *p); |
194 | void zd_mac_set_multicast_list(struct net_device *netdev); | ||
192 | 195 | ||
193 | int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length); | 196 | int zd_mac_rx(struct zd_mac *mac, const u8 *buffer, unsigned int length); |
194 | 197 | ||
diff --git a/drivers/net/wireless/zd1211rw/zd_netdev.c b/drivers/net/wireless/zd1211rw/zd_netdev.c index 60f1b0f6d45b..8bda48de31ef 100644 --- a/drivers/net/wireless/zd1211rw/zd_netdev.c +++ b/drivers/net/wireless/zd1211rw/zd_netdev.c | |||
@@ -242,7 +242,7 @@ struct net_device *zd_netdev_alloc(struct usb_interface *intf) | |||
242 | netdev->open = zd_mac_open; | 242 | netdev->open = zd_mac_open; |
243 | netdev->stop = zd_mac_stop; | 243 | netdev->stop = zd_mac_stop; |
244 | /* netdev->get_stats = */ | 244 | /* netdev->get_stats = */ |
245 | /* netdev->set_multicast_list = */ | 245 | netdev->set_multicast_list = zd_mac_set_multicast_list; |
246 | netdev->set_mac_address = zd_mac_set_mac_address; | 246 | netdev->set_mac_address = zd_mac_set_mac_address; |
247 | netdev->wireless_handlers = &iw_handler_def; | 247 | netdev->wireless_handlers = &iw_handler_def; |
248 | /* netdev->ethtool_ops = */ | 248 | /* netdev->ethtool_ops = */ |
diff --git a/net/ieee80211/softmac/ieee80211softmac_assoc.c b/net/ieee80211/softmac/ieee80211softmac_assoc.c index 08386c102954..eec1a1dd91da 100644 --- a/net/ieee80211/softmac/ieee80211softmac_assoc.c +++ b/net/ieee80211/softmac/ieee80211softmac_assoc.c | |||
@@ -431,6 +431,17 @@ ieee80211softmac_handle_assoc_response(struct net_device * dev, | |||
431 | return 0; | 431 | return 0; |
432 | } | 432 | } |
433 | 433 | ||
434 | void | ||
435 | ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac) | ||
436 | { | ||
437 | unsigned long flags; | ||
438 | |||
439 | spin_lock_irqsave(&mac->lock, flags); | ||
440 | mac->associnfo.associating = 1; | ||
441 | schedule_work(&mac->associnfo.work); | ||
442 | spin_unlock_irqrestore(&mac->lock, flags); | ||
443 | } | ||
444 | |||
434 | int | 445 | int |
435 | ieee80211softmac_handle_disassoc(struct net_device * dev, | 446 | ieee80211softmac_handle_disassoc(struct net_device * dev, |
436 | struct ieee80211_disassoc *disassoc) | 447 | struct ieee80211_disassoc *disassoc) |
@@ -449,8 +460,7 @@ ieee80211softmac_handle_disassoc(struct net_device * dev, | |||
449 | dprintk(KERN_INFO PFX "got disassoc frame\n"); | 460 | dprintk(KERN_INFO PFX "got disassoc frame\n"); |
450 | ieee80211softmac_disassoc(mac); | 461 | ieee80211softmac_disassoc(mac); |
451 | 462 | ||
452 | /* try to reassociate */ | 463 | ieee80211softmac_try_reassoc(mac); |
453 | schedule_delayed_work(&mac->associnfo.work, 0); | ||
454 | 464 | ||
455 | return 0; | 465 | return 0; |
456 | } | 466 | } |
diff --git a/net/ieee80211/softmac/ieee80211softmac_auth.c b/net/ieee80211/softmac/ieee80211softmac_auth.c index 6012705aa4f8..8ed3e59b8024 100644 --- a/net/ieee80211/softmac/ieee80211softmac_auth.c +++ b/net/ieee80211/softmac/ieee80211softmac_auth.c | |||
@@ -337,6 +337,8 @@ ieee80211softmac_deauth_from_net(struct ieee80211softmac_device *mac, | |||
337 | /* can't transmit data right now... */ | 337 | /* can't transmit data right now... */ |
338 | netif_carrier_off(mac->dev); | 338 | netif_carrier_off(mac->dev); |
339 | spin_unlock_irqrestore(&mac->lock, flags); | 339 | spin_unlock_irqrestore(&mac->lock, flags); |
340 | |||
341 | ieee80211softmac_try_reassoc(mac); | ||
340 | } | 342 | } |
341 | 343 | ||
342 | /* | 344 | /* |
diff --git a/net/ieee80211/softmac/ieee80211softmac_priv.h b/net/ieee80211/softmac/ieee80211softmac_priv.h index c0dbe070e548..4c2bba34d328 100644 --- a/net/ieee80211/softmac/ieee80211softmac_priv.h +++ b/net/ieee80211/softmac/ieee80211softmac_priv.h | |||
@@ -239,4 +239,6 @@ void ieee80211softmac_call_events_locked(struct ieee80211softmac_device *mac, in | |||
239 | int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac, | 239 | int ieee80211softmac_notify_internal(struct ieee80211softmac_device *mac, |
240 | int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask); | 240 | int event, void *event_context, notify_function_ptr fun, void *context, gfp_t gfp_mask); |
241 | 241 | ||
242 | void ieee80211softmac_try_reassoc(struct ieee80211softmac_device *mac); | ||
243 | |||
242 | #endif /* IEEE80211SOFTMAC_PRIV_H_ */ | 244 | #endif /* IEEE80211SOFTMAC_PRIV_H_ */ |
diff --git a/net/ieee80211/softmac/ieee80211softmac_wx.c b/net/ieee80211/softmac/ieee80211softmac_wx.c index 2ffaebd21c53..480d72c7a42c 100644 --- a/net/ieee80211/softmac/ieee80211softmac_wx.c +++ b/net/ieee80211/softmac/ieee80211softmac_wx.c | |||
@@ -495,7 +495,8 @@ ieee80211softmac_wx_set_mlme(struct net_device *dev, | |||
495 | printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n"); | 495 | printk(KERN_DEBUG PFX "wx_set_mlme: we should know the net here...\n"); |
496 | goto out; | 496 | goto out; |
497 | } | 497 | } |
498 | return ieee80211softmac_deauth_req(mac, net, reason); | 498 | err = ieee80211softmac_deauth_req(mac, net, reason); |
499 | goto out; | ||
499 | case IW_MLME_DISASSOC: | 500 | case IW_MLME_DISASSOC: |
500 | ieee80211softmac_send_disassoc_req(mac, reason); | 501 | ieee80211softmac_send_disassoc_req(mac, reason); |
501 | mac->associnfo.associated = 0; | 502 | mac->associnfo.associated = 0; |