diff options
Diffstat (limited to 'drivers/net')
368 files changed, 11806 insertions, 11242 deletions
diff --git a/drivers/net/3c501.c b/drivers/net/3c501.c index 367bec63620c..e29fb1a4a611 100644 --- a/drivers/net/3c501.c +++ b/drivers/net/3c501.c | |||
@@ -485,7 +485,7 @@ static int el_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
485 | if (el_debug > 2) | 485 | if (el_debug > 2) |
486 | pr_debug(" queued xmit.\n"); | 486 | pr_debug(" queued xmit.\n"); |
487 | dev_kfree_skb(skb); | 487 | dev_kfree_skb(skb); |
488 | return 0; | 488 | return NETDEV_TX_OK; |
489 | } | 489 | } |
490 | /* A receive upset our load, despite our best efforts */ | 490 | /* A receive upset our load, despite our best efforts */ |
491 | if (el_debug > 2) | 491 | if (el_debug > 2) |
diff --git a/drivers/net/3c505.c b/drivers/net/3c505.c index f71b35402755..7bba480d7220 100644 --- a/drivers/net/3c505.c +++ b/drivers/net/3c505.c | |||
@@ -1101,7 +1101,7 @@ static int elp_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1101 | prime_rx(dev); | 1101 | prime_rx(dev); |
1102 | spin_unlock_irqrestore(&adapter->lock, flags); | 1102 | spin_unlock_irqrestore(&adapter->lock, flags); |
1103 | netif_start_queue(dev); | 1103 | netif_start_queue(dev); |
1104 | return 0; | 1104 | return NETDEV_TX_OK; |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | /****************************************************** | 1107 | /****************************************************** |
diff --git a/drivers/net/3c507.c b/drivers/net/3c507.c index 96b86659381a..9e93a0b39b6e 100644 --- a/drivers/net/3c507.c +++ b/drivers/net/3c507.c | |||
@@ -537,7 +537,7 @@ static int el16_send_packet (struct sk_buff *skb, struct net_device *dev) | |||
537 | 537 | ||
538 | /* You might need to clean up and record Tx statistics here. */ | 538 | /* You might need to clean up and record Tx statistics here. */ |
539 | 539 | ||
540 | return 0; | 540 | return NETDEV_TX_OK; |
541 | } | 541 | } |
542 | 542 | ||
543 | /* The typical workload of the driver: | 543 | /* The typical workload of the driver: |
diff --git a/drivers/net/3c509.c b/drivers/net/3c509.c index d2137efbd455..d2515d840c00 100644 --- a/drivers/net/3c509.c +++ b/drivers/net/3c509.c | |||
@@ -892,7 +892,7 @@ el3_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
892 | outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ | 892 | outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */ |
893 | } | 893 | } |
894 | } | 894 | } |
895 | return 0; | 895 | return NETDEV_TX_OK; |
896 | } | 896 | } |
897 | 897 | ||
898 | /* The EL3 interrupt handler. */ | 898 | /* The EL3 interrupt handler. */ |
diff --git a/drivers/net/3c515.c b/drivers/net/3c515.c index 3e00fa8ea65f..85ffd132bada 100644 --- a/drivers/net/3c515.c +++ b/drivers/net/3c515.c | |||
@@ -1054,7 +1054,7 @@ static int corkscrew_start_xmit(struct sk_buff *skb, | |||
1054 | netif_wake_queue(dev); | 1054 | netif_wake_queue(dev); |
1055 | } | 1055 | } |
1056 | dev->trans_start = jiffies; | 1056 | dev->trans_start = jiffies; |
1057 | return 0; | 1057 | return NETDEV_TX_OK; |
1058 | } | 1058 | } |
1059 | /* Put out the doubleword header... */ | 1059 | /* Put out the doubleword header... */ |
1060 | outl(skb->len, ioaddr + TX_FIFO); | 1060 | outl(skb->len, ioaddr + TX_FIFO); |
@@ -1117,7 +1117,7 @@ static int corkscrew_start_xmit(struct sk_buff *skb, | |||
1117 | outb(0x00, ioaddr + TxStatus); /* Pop the status stack. */ | 1117 | outb(0x00, ioaddr + TxStatus); /* Pop the status stack. */ |
1118 | } | 1118 | } |
1119 | } | 1119 | } |
1120 | return 0; | 1120 | return NETDEV_TX_OK; |
1121 | } | 1121 | } |
1122 | 1122 | ||
1123 | /* The interrupt handler does all of the Rx thread work and cleans up | 1123 | /* The interrupt handler does all of the Rx thread work and cleans up |
diff --git a/drivers/net/3c523.c b/drivers/net/3c523.c index cdd955c4014c..70c701b80d99 100644 --- a/drivers/net/3c523.c +++ b/drivers/net/3c523.c | |||
@@ -1198,7 +1198,7 @@ static int elmc_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1198 | netif_wake_queue(dev); | 1198 | netif_wake_queue(dev); |
1199 | dev_kfree_skb(skb); | 1199 | dev_kfree_skb(skb); |
1200 | #endif | 1200 | #endif |
1201 | return 0; | 1201 | return NETDEV_TX_OK; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | /******************************************* | 1204 | /******************************************* |
diff --git a/drivers/net/3c527.c b/drivers/net/3c527.c index aaa8a9f405d4..72b9ed7f4641 100644 --- a/drivers/net/3c527.c +++ b/drivers/net/3c527.c | |||
@@ -1035,7 +1035,7 @@ static int mc32_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1035 | 1035 | ||
1036 | if (skb_padto(skb, ETH_ZLEN)) { | 1036 | if (skb_padto(skb, ETH_ZLEN)) { |
1037 | netif_wake_queue(dev); | 1037 | netif_wake_queue(dev); |
1038 | return 0; | 1038 | return NETDEV_TX_OK; |
1039 | } | 1039 | } |
1040 | 1040 | ||
1041 | atomic_dec(&lp->tx_count); | 1041 | atomic_dec(&lp->tx_count); |
@@ -1066,7 +1066,7 @@ static int mc32_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1066 | p->control &= ~CONTROL_EOL; | 1066 | p->control &= ~CONTROL_EOL; |
1067 | 1067 | ||
1068 | netif_wake_queue(dev); | 1068 | netif_wake_queue(dev); |
1069 | return 0; | 1069 | return NETDEV_TX_OK; |
1070 | } | 1070 | } |
1071 | 1071 | ||
1072 | 1072 | ||
diff --git a/drivers/net/3c59x.c b/drivers/net/3c59x.c index c34aee91250b..202048450eed 100644 --- a/drivers/net/3c59x.c +++ b/drivers/net/3c59x.c | |||
@@ -2083,7 +2083,7 @@ vortex_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2083 | iowrite8(0x00, ioaddr + TxStatus); /* Pop the status stack. */ | 2083 | iowrite8(0x00, ioaddr + TxStatus); /* Pop the status stack. */ |
2084 | } | 2084 | } |
2085 | } | 2085 | } |
2086 | return 0; | 2086 | return NETDEV_TX_OK; |
2087 | } | 2087 | } |
2088 | 2088 | ||
2089 | static int | 2089 | static int |
@@ -2173,7 +2173,7 @@ boomerang_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2173 | iowrite16(DownUnstall, ioaddr + EL3_CMD); | 2173 | iowrite16(DownUnstall, ioaddr + EL3_CMD); |
2174 | spin_unlock_irqrestore(&vp->lock, flags); | 2174 | spin_unlock_irqrestore(&vp->lock, flags); |
2175 | dev->trans_start = jiffies; | 2175 | dev->trans_start = jiffies; |
2176 | return 0; | 2176 | return NETDEV_TX_OK; |
2177 | } | 2177 | } |
2178 | 2178 | ||
2179 | /* The interrupt handler does all of the Rx thread work and cleans up | 2179 | /* The interrupt handler does all of the Rx thread work and cleans up |
diff --git a/drivers/net/7990.c b/drivers/net/7990.c index 69f5b7d298a6..b1e5764628c6 100644 --- a/drivers/net/7990.c +++ b/drivers/net/7990.c | |||
@@ -585,7 +585,7 @@ int lance_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
585 | lp->tx_full = 1; | 585 | lp->tx_full = 1; |
586 | spin_unlock_irqrestore (&lp->devlock, flags); | 586 | spin_unlock_irqrestore (&lp->devlock, flags); |
587 | 587 | ||
588 | return 0; | 588 | return NETDEV_TX_OK; |
589 | } | 589 | } |
590 | EXPORT_SYMBOL_GPL(lance_start_xmit); | 590 | EXPORT_SYMBOL_GPL(lance_start_xmit); |
591 | 591 | ||
diff --git a/drivers/net/8139cp.c b/drivers/net/8139cp.c index 50efde11ea6c..07919d0877ee 100644 --- a/drivers/net/8139cp.c +++ b/drivers/net/8139cp.c | |||
@@ -891,7 +891,7 @@ static int cp_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
891 | cpw8(TxPoll, NormalTxPoll); | 891 | cpw8(TxPoll, NormalTxPoll); |
892 | dev->trans_start = jiffies; | 892 | dev->trans_start = jiffies; |
893 | 893 | ||
894 | return 0; | 894 | return NETDEV_TX_OK; |
895 | } | 895 | } |
896 | 896 | ||
897 | /* Set or clear the multicast filter for this adaptor. | 897 | /* Set or clear the multicast filter for this adaptor. |
diff --git a/drivers/net/8139too.c b/drivers/net/8139too.c index 0e2ba21d4441..b39ec98345ea 100644 --- a/drivers/net/8139too.c +++ b/drivers/net/8139too.c | |||
@@ -1707,7 +1707,7 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
1707 | } else { | 1707 | } else { |
1708 | dev_kfree_skb(skb); | 1708 | dev_kfree_skb(skb); |
1709 | dev->stats.tx_dropped++; | 1709 | dev->stats.tx_dropped++; |
1710 | return 0; | 1710 | return NETDEV_TX_OK; |
1711 | } | 1711 | } |
1712 | 1712 | ||
1713 | spin_lock_irqsave(&tp->lock, flags); | 1713 | spin_lock_irqsave(&tp->lock, flags); |
@@ -1732,7 +1732,7 @@ static int rtl8139_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
1732 | pr_debug("%s: Queued Tx packet size %u to slot %d.\n", | 1732 | pr_debug("%s: Queued Tx packet size %u to slot %d.\n", |
1733 | dev->name, len, entry); | 1733 | dev->name, len, entry); |
1734 | 1734 | ||
1735 | return 0; | 1735 | return NETDEV_TX_OK; |
1736 | } | 1736 | } |
1737 | 1737 | ||
1738 | 1738 | ||
diff --git a/drivers/net/82596.c b/drivers/net/82596.c index 77547545509b..996cc9102215 100644 --- a/drivers/net/82596.c +++ b/drivers/net/82596.c | |||
@@ -1068,7 +1068,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1068 | 1068 | ||
1069 | if (skb->len < ETH_ZLEN) { | 1069 | if (skb->len < ETH_ZLEN) { |
1070 | if (skb_padto(skb, ETH_ZLEN)) | 1070 | if (skb_padto(skb, ETH_ZLEN)) |
1071 | return 0; | 1071 | return NETDEV_TX_OK; |
1072 | length = ETH_ZLEN; | 1072 | length = ETH_ZLEN; |
1073 | } | 1073 | } |
1074 | netif_stop_queue(dev); | 1074 | netif_stop_queue(dev); |
@@ -1110,7 +1110,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1110 | 1110 | ||
1111 | netif_start_queue(dev); | 1111 | netif_start_queue(dev); |
1112 | 1112 | ||
1113 | return 0; | 1113 | return NETDEV_TX_OK; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | static void print_eth(unsigned char *add, char *str) | 1116 | static void print_eth(unsigned char *add, char *str) |
diff --git a/drivers/net/a2065.c b/drivers/net/a2065.c index 85a18175730b..7302e4385bc4 100644 --- a/drivers/net/a2065.c +++ b/drivers/net/a2065.c | |||
@@ -553,11 +553,11 @@ static int lance_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
553 | volatile struct lance_regs *ll = lp->ll; | 553 | volatile struct lance_regs *ll = lp->ll; |
554 | volatile struct lance_init_block *ib = lp->init_block; | 554 | volatile struct lance_init_block *ib = lp->init_block; |
555 | int entry, skblen; | 555 | int entry, skblen; |
556 | int status = 0; | 556 | int status = NETDEV_TX_OK; |
557 | unsigned long flags; | 557 | unsigned long flags; |
558 | 558 | ||
559 | if (skb_padto(skb, ETH_ZLEN)) | 559 | if (skb_padto(skb, ETH_ZLEN)) |
560 | return 0; | 560 | return NETDEV_TX_OK; |
561 | skblen = max_t(unsigned, skb->len, ETH_ZLEN); | 561 | skblen = max_t(unsigned, skb->len, ETH_ZLEN); |
562 | 562 | ||
563 | local_irq_save(flags); | 563 | local_irq_save(flags); |
diff --git a/drivers/net/amd8111e.c b/drivers/net/amd8111e.c index 19831bd64016..61ac671f97bf 100644 --- a/drivers/net/amd8111e.c +++ b/drivers/net/amd8111e.c | |||
@@ -1346,7 +1346,7 @@ static int amd8111e_start_xmit(struct sk_buff *skb, struct net_device * dev) | |||
1346 | netif_stop_queue(dev); | 1346 | netif_stop_queue(dev); |
1347 | } | 1347 | } |
1348 | spin_unlock_irqrestore(&lp->lock, flags); | 1348 | spin_unlock_irqrestore(&lp->lock, flags); |
1349 | return 0; | 1349 | return NETDEV_TX_OK; |
1350 | } | 1350 | } |
1351 | /* | 1351 | /* |
1352 | This function returns all the memory mapped registers of the device. | 1352 | This function returns all the memory mapped registers of the device. |
diff --git a/drivers/net/appletalk/cops.c b/drivers/net/appletalk/cops.c index 7f8325419803..29b279f88efb 100644 --- a/drivers/net/appletalk/cops.c +++ b/drivers/net/appletalk/cops.c | |||
@@ -920,7 +920,7 @@ static int cops_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
920 | dev->stats.tx_bytes += skb->len; | 920 | dev->stats.tx_bytes += skb->len; |
921 | dev->trans_start = jiffies; | 921 | dev->trans_start = jiffies; |
922 | dev_kfree_skb (skb); | 922 | dev_kfree_skb (skb); |
923 | return 0; | 923 | return NETDEV_TX_OK; |
924 | } | 924 | } |
925 | 925 | ||
926 | /* | 926 | /* |
diff --git a/drivers/net/appletalk/ipddp.c b/drivers/net/appletalk/ipddp.c index 78cea5e80b1d..6cfd961bb8de 100644 --- a/drivers/net/appletalk/ipddp.c +++ b/drivers/net/appletalk/ipddp.c | |||
@@ -132,7 +132,7 @@ static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev) | |||
132 | } | 132 | } |
133 | if(rt == NULL) { | 133 | if(rt == NULL) { |
134 | spin_unlock(&ipddp_route_lock); | 134 | spin_unlock(&ipddp_route_lock); |
135 | return 0; | 135 | return NETDEV_TX_OK; |
136 | } | 136 | } |
137 | 137 | ||
138 | our_addr = atalk_find_dev_addr(rt->dev); | 138 | our_addr = atalk_find_dev_addr(rt->dev); |
@@ -181,7 +181,7 @@ static int ipddp_xmit(struct sk_buff *skb, struct net_device *dev) | |||
181 | 181 | ||
182 | spin_unlock(&ipddp_route_lock); | 182 | spin_unlock(&ipddp_route_lock); |
183 | 183 | ||
184 | return 0; | 184 | return NETDEV_TX_OK; |
185 | } | 185 | } |
186 | 186 | ||
187 | /* | 187 | /* |
diff --git a/drivers/net/appletalk/ltpc.c b/drivers/net/appletalk/ltpc.c index b642647170be..c80fb9cf8ffa 100644 --- a/drivers/net/appletalk/ltpc.c +++ b/drivers/net/appletalk/ltpc.c | |||
@@ -932,7 +932,7 @@ static int ltpc_xmit(struct sk_buff *skb, struct net_device *dev) | |||
932 | dev->stats.tx_bytes += skb->len; | 932 | dev->stats.tx_bytes += skb->len; |
933 | 933 | ||
934 | dev_kfree_skb(skb); | 934 | dev_kfree_skb(skb); |
935 | return 0; | 935 | return NETDEV_TX_OK; |
936 | } | 936 | } |
937 | 937 | ||
938 | /* initialization stuff */ | 938 | /* initialization stuff */ |
diff --git a/drivers/net/ariadne.c b/drivers/net/ariadne.c index 58e8d522e5bc..47d976cc3d7d 100644 --- a/drivers/net/ariadne.c +++ b/drivers/net/ariadne.c | |||
@@ -610,7 +610,7 @@ static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
610 | if (skb->len < ETH_ZLEN) | 610 | if (skb->len < ETH_ZLEN) |
611 | { | 611 | { |
612 | if (skb_padto(skb, ETH_ZLEN)) | 612 | if (skb_padto(skb, ETH_ZLEN)) |
613 | return 0; | 613 | return NETDEV_TX_OK; |
614 | len = ETH_ZLEN; | 614 | len = ETH_ZLEN; |
615 | } | 615 | } |
616 | 616 | ||
@@ -685,7 +685,7 @@ static int ariadne_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
685 | } | 685 | } |
686 | local_irq_restore(flags); | 686 | local_irq_restore(flags); |
687 | 687 | ||
688 | return 0; | 688 | return NETDEV_TX_OK; |
689 | } | 689 | } |
690 | 690 | ||
691 | 691 | ||
diff --git a/drivers/net/arm/am79c961a.c b/drivers/net/arm/am79c961a.c index 627bc75da17d..164b37e85eea 100644 --- a/drivers/net/arm/am79c961a.c +++ b/drivers/net/arm/am79c961a.c | |||
@@ -482,7 +482,7 @@ am79c961_sendpacket(struct sk_buff *skb, struct net_device *dev) | |||
482 | 482 | ||
483 | dev_kfree_skb(skb); | 483 | dev_kfree_skb(skb); |
484 | 484 | ||
485 | return 0; | 485 | return NETDEV_TX_OK; |
486 | } | 486 | } |
487 | 487 | ||
488 | /* | 488 | /* |
diff --git a/drivers/net/arm/at91_ether.c b/drivers/net/arm/at91_ether.c index 2e7419a61191..d46a06e20db0 100644 --- a/drivers/net/arm/at91_ether.c +++ b/drivers/net/arm/at91_ether.c | |||
@@ -834,7 +834,7 @@ static int at91ether_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
834 | we free and return(0) or don't free and return 1 */ | 834 | we free and return(0) or don't free and return 1 */ |
835 | } | 835 | } |
836 | 836 | ||
837 | return 0; | 837 | return NETDEV_TX_OK; |
838 | } | 838 | } |
839 | 839 | ||
840 | /* | 840 | /* |
diff --git a/drivers/net/arm/ether1.c b/drivers/net/arm/ether1.c index edf770f639fa..e47c0d962857 100644 --- a/drivers/net/arm/ether1.c +++ b/drivers/net/arm/ether1.c | |||
@@ -748,7 +748,7 @@ ether1_sendpacket (struct sk_buff *skb, struct net_device *dev) | |||
748 | netif_stop_queue(dev); | 748 | netif_stop_queue(dev); |
749 | 749 | ||
750 | out: | 750 | out: |
751 | return 0; | 751 | return NETDEV_TX_OK; |
752 | } | 752 | } |
753 | 753 | ||
754 | static void | 754 | static void |
diff --git a/drivers/net/arm/ether3.c b/drivers/net/arm/ether3.c index 455037134aa3..1f7a69c929a6 100644 --- a/drivers/net/arm/ether3.c +++ b/drivers/net/arm/ether3.c | |||
@@ -511,7 +511,7 @@ ether3_sendpacket(struct sk_buff *skb, struct net_device *dev) | |||
511 | dev_kfree_skb(skb); | 511 | dev_kfree_skb(skb); |
512 | priv(dev)->stats.tx_dropped ++; | 512 | priv(dev)->stats.tx_dropped ++; |
513 | netif_start_queue(dev); | 513 | netif_start_queue(dev); |
514 | return 0; | 514 | return NETDEV_TX_OK; |
515 | } | 515 | } |
516 | 516 | ||
517 | length = (length + 1) & ~1; | 517 | length = (length + 1) & ~1; |
@@ -562,7 +562,7 @@ ether3_sendpacket(struct sk_buff *skb, struct net_device *dev) | |||
562 | netif_stop_queue(dev); | 562 | netif_stop_queue(dev); |
563 | 563 | ||
564 | out: | 564 | out: |
565 | return 0; | 565 | return NETDEV_TX_OK; |
566 | } | 566 | } |
567 | 567 | ||
568 | static irqreturn_t | 568 | static irqreturn_t |
diff --git a/drivers/net/at1700.c b/drivers/net/at1700.c index 18b566ad4fd1..c2227d79673a 100644 --- a/drivers/net/at1700.c +++ b/drivers/net/at1700.c | |||
@@ -643,7 +643,7 @@ static int net_send_packet (struct sk_buff *skb, struct net_device *dev) | |||
643 | netif_start_queue (dev); | 643 | netif_start_queue (dev); |
644 | dev_kfree_skb (skb); | 644 | dev_kfree_skb (skb); |
645 | 645 | ||
646 | return 0; | 646 | return NETDEV_TX_OK; |
647 | } | 647 | } |
648 | 648 | ||
649 | /* The typical workload of the driver: | 649 | /* The typical workload of the driver: |
diff --git a/drivers/net/atarilance.c b/drivers/net/atarilance.c index 5425ab0c38c0..0c0deceb6938 100644 --- a/drivers/net/atarilance.c +++ b/drivers/net/atarilance.c | |||
@@ -796,7 +796,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev ) | |||
796 | 796 | ||
797 | if (len > skb->len) { | 797 | if (len > skb->len) { |
798 | if (skb_padto(skb, len)) | 798 | if (skb_padto(skb, len)) |
799 | return 0; | 799 | return NETDEV_TX_OK; |
800 | } | 800 | } |
801 | 801 | ||
802 | netif_stop_queue (dev); | 802 | netif_stop_queue (dev); |
@@ -846,7 +846,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev ) | |||
846 | lp->tx_full = 1; | 846 | lp->tx_full = 1; |
847 | spin_unlock_irqrestore (&lp->devlock, flags); | 847 | spin_unlock_irqrestore (&lp->devlock, flags); |
848 | 848 | ||
849 | return 0; | 849 | return NETDEV_TX_OK; |
850 | } | 850 | } |
851 | 851 | ||
852 | /* The LANCE interrupt handler. */ | 852 | /* The LANCE interrupt handler. */ |
diff --git a/drivers/net/atp.c b/drivers/net/atp.c index 4317b3edb3d7..4beacc9c909f 100644 --- a/drivers/net/atp.c +++ b/drivers/net/atp.c | |||
@@ -587,7 +587,7 @@ static int atp_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
587 | 587 | ||
588 | dev->trans_start = jiffies; | 588 | dev->trans_start = jiffies; |
589 | dev_kfree_skb (skb); | 589 | dev_kfree_skb (skb); |
590 | return 0; | 590 | return NETDEV_TX_OK; |
591 | } | 591 | } |
592 | 592 | ||
593 | 593 | ||
diff --git a/drivers/net/au1000_eth.c b/drivers/net/au1000_eth.c index d3c734f4d679..2aab1ebc6cd1 100644 --- a/drivers/net/au1000_eth.c +++ b/drivers/net/au1000_eth.c | |||
@@ -988,7 +988,7 @@ static int au1000_tx(struct sk_buff *skb, struct net_device *dev) | |||
988 | dev_kfree_skb(skb); | 988 | dev_kfree_skb(skb); |
989 | aup->tx_head = (aup->tx_head + 1) & (NUM_TX_DMA - 1); | 989 | aup->tx_head = (aup->tx_head + 1) & (NUM_TX_DMA - 1); |
990 | dev->trans_start = jiffies; | 990 | dev->trans_start = jiffies; |
991 | return 0; | 991 | return NETDEV_TX_OK; |
992 | } | 992 | } |
993 | 993 | ||
994 | /* | 994 | /* |
diff --git a/drivers/net/bfin_mac.c b/drivers/net/bfin_mac.c index c15fc281f79f..f580b21eabd1 100644 --- a/drivers/net/bfin_mac.c +++ b/drivers/net/bfin_mac.c | |||
@@ -656,7 +656,7 @@ out: | |||
656 | dev->trans_start = jiffies; | 656 | dev->trans_start = jiffies; |
657 | dev->stats.tx_packets++; | 657 | dev->stats.tx_packets++; |
658 | dev->stats.tx_bytes += (skb->len); | 658 | dev->stats.tx_bytes += (skb->len); |
659 | return 0; | 659 | return NETDEV_TX_OK; |
660 | } | 660 | } |
661 | 661 | ||
662 | static void bfin_mac_rx(struct net_device *dev) | 662 | static void bfin_mac_rx(struct net_device *dev) |
diff --git a/drivers/net/bmac.c b/drivers/net/bmac.c index 9578a3dfac01..41600011cfd0 100644 --- a/drivers/net/bmac.c +++ b/drivers/net/bmac.c | |||
@@ -1488,7 +1488,7 @@ bmac_output(struct sk_buff *skb, struct net_device *dev) | |||
1488 | struct bmac_data *bp = netdev_priv(dev); | 1488 | struct bmac_data *bp = netdev_priv(dev); |
1489 | skb_queue_tail(bp->queue, skb); | 1489 | skb_queue_tail(bp->queue, skb); |
1490 | bmac_start(dev); | 1490 | bmac_start(dev); |
1491 | return 0; | 1491 | return NETDEV_TX_OK; |
1492 | } | 1492 | } |
1493 | 1493 | ||
1494 | static void bmac_tx_timeout(unsigned long data) | 1494 | static void bmac_tx_timeout(unsigned long data) |
diff --git a/drivers/net/bonding/bond_3ad.c b/drivers/net/bonding/bond_3ad.c index d4b570886c6e..be799d2a8a8d 100644 --- a/drivers/net/bonding/bond_3ad.c +++ b/drivers/net/bonding/bond_3ad.c | |||
@@ -1109,7 +1109,8 @@ static void ad_rx_machine(struct lacpdu *lacpdu, struct port *port) | |||
1109 | //mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port. | 1109 | //mux machine in case of EXPIRED even if LINK_DOWN didn't arrive for the port. |
1110 | port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION; | 1110 | port->partner_oper.port_state &= ~AD_STATE_SYNCHRONIZATION; |
1111 | port->sm_vars &= ~AD_PORT_MATCHED; | 1111 | port->sm_vars &= ~AD_PORT_MATCHED; |
1112 | port->partner_oper.port_state |= AD_SHORT_TIMEOUT; | 1112 | port->partner_oper.port_state |= |
1113 | AD_STATE_LACP_ACTIVITY; | ||
1113 | port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT)); | 1114 | port->sm_rx_timer_counter = __ad_timer_to_ticks(AD_CURRENT_WHILE_TIMER, (u16)(AD_SHORT_TIMEOUT)); |
1114 | port->actor_oper_port_state |= AD_STATE_EXPIRED; | 1115 | port->actor_oper_port_state |= AD_STATE_EXPIRED; |
1115 | break; | 1116 | break; |
@@ -2431,7 +2432,7 @@ out: | |||
2431 | dev_kfree_skb(skb); | 2432 | dev_kfree_skb(skb); |
2432 | } | 2433 | } |
2433 | read_unlock(&bond->lock); | 2434 | read_unlock(&bond->lock); |
2434 | return 0; | 2435 | return NETDEV_TX_OK; |
2435 | } | 2436 | } |
2436 | 2437 | ||
2437 | int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev) | 2438 | int bond_3ad_lacpdu_recv(struct sk_buff *skb, struct net_device *dev, struct packet_type* ptype, struct net_device *orig_dev) |
diff --git a/drivers/net/bonding/bond_alb.c b/drivers/net/bonding/bond_alb.c index 46d312bedfb8..bf45d2002924 100644 --- a/drivers/net/bonding/bond_alb.c +++ b/drivers/net/bonding/bond_alb.c | |||
@@ -1413,7 +1413,7 @@ out: | |||
1413 | } | 1413 | } |
1414 | read_unlock(&bond->curr_slave_lock); | 1414 | read_unlock(&bond->curr_slave_lock); |
1415 | read_unlock(&bond->lock); | 1415 | read_unlock(&bond->lock); |
1416 | return 0; | 1416 | return NETDEV_TX_OK; |
1417 | } | 1417 | } |
1418 | 1418 | ||
1419 | void bond_alb_monitor(struct work_struct *work) | 1419 | void bond_alb_monitor(struct work_struct *work) |
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index aa1be1feceed..3bf0cc61e92c 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
@@ -4285,7 +4285,7 @@ out: | |||
4285 | dev_kfree_skb(skb); | 4285 | dev_kfree_skb(skb); |
4286 | } | 4286 | } |
4287 | read_unlock(&bond->lock); | 4287 | read_unlock(&bond->lock); |
4288 | return 0; | 4288 | return NETDEV_TX_OK; |
4289 | } | 4289 | } |
4290 | 4290 | ||
4291 | 4291 | ||
@@ -4316,7 +4316,7 @@ out: | |||
4316 | 4316 | ||
4317 | read_unlock(&bond->curr_slave_lock); | 4317 | read_unlock(&bond->curr_slave_lock); |
4318 | read_unlock(&bond->lock); | 4318 | read_unlock(&bond->lock); |
4319 | return 0; | 4319 | return NETDEV_TX_OK; |
4320 | } | 4320 | } |
4321 | 4321 | ||
4322 | /* | 4322 | /* |
@@ -4362,7 +4362,7 @@ out: | |||
4362 | dev_kfree_skb(skb); | 4362 | dev_kfree_skb(skb); |
4363 | } | 4363 | } |
4364 | read_unlock(&bond->lock); | 4364 | read_unlock(&bond->lock); |
4365 | return 0; | 4365 | return NETDEV_TX_OK; |
4366 | } | 4366 | } |
4367 | 4367 | ||
4368 | /* | 4368 | /* |
@@ -4422,7 +4422,7 @@ out: | |||
4422 | 4422 | ||
4423 | /* frame sent to all suitable interfaces */ | 4423 | /* frame sent to all suitable interfaces */ |
4424 | read_unlock(&bond->lock); | 4424 | read_unlock(&bond->lock); |
4425 | return 0; | 4425 | return NETDEV_TX_OK; |
4426 | } | 4426 | } |
4427 | 4427 | ||
4428 | /*------------------------- Device initialization ---------------------------*/ | 4428 | /*------------------------- Device initialization ---------------------------*/ |
diff --git a/drivers/net/can/sja1000/sja1000.c b/drivers/net/can/sja1000/sja1000.c index 571f133a8fec..1c30dbec1954 100644 --- a/drivers/net/can/sja1000/sja1000.c +++ b/drivers/net/can/sja1000/sja1000.c | |||
@@ -283,7 +283,7 @@ static int sja1000_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
283 | 283 | ||
284 | priv->write_reg(priv, REG_CMR, CMD_TR); | 284 | priv->write_reg(priv, REG_CMR, CMD_TR); |
285 | 285 | ||
286 | return 0; | 286 | return NETDEV_TX_OK; |
287 | } | 287 | } |
288 | 288 | ||
289 | static void sja1000_rx(struct net_device *dev) | 289 | static void sja1000_rx(struct net_device *dev) |
diff --git a/drivers/net/cassini.c b/drivers/net/cassini.c index eb066673c2a0..299a33b914f8 100644 --- a/drivers/net/cassini.c +++ b/drivers/net/cassini.c | |||
@@ -2928,7 +2928,7 @@ static int cas_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2928 | static int ring; | 2928 | static int ring; |
2929 | 2929 | ||
2930 | if (skb_padto(skb, cp->min_frame_size)) | 2930 | if (skb_padto(skb, cp->min_frame_size)) |
2931 | return 0; | 2931 | return NETDEV_TX_OK; |
2932 | 2932 | ||
2933 | /* XXX: we need some higher-level QoS hooks to steer packets to | 2933 | /* XXX: we need some higher-level QoS hooks to steer packets to |
2934 | * individual queues. | 2934 | * individual queues. |
@@ -2936,7 +2936,7 @@ static int cas_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2936 | if (cas_xmit_tx_ringN(cp, ring++ & N_TX_RINGS_MASK, skb)) | 2936 | if (cas_xmit_tx_ringN(cp, ring++ & N_TX_RINGS_MASK, skb)) |
2937 | return NETDEV_TX_BUSY; | 2937 | return NETDEV_TX_BUSY; |
2938 | dev->trans_start = jiffies; | 2938 | dev->trans_start = jiffies; |
2939 | return 0; | 2939 | return NETDEV_TX_OK; |
2940 | } | 2940 | } |
2941 | 2941 | ||
2942 | static void cas_init_tx_dma(struct cas *cp) | 2942 | static void cas_init_tx_dma(struct cas *cp) |
diff --git a/drivers/net/cris/eth_v10.c b/drivers/net/cris/eth_v10.c index 7a18dc7e5c7f..15c0195ebd31 100644 --- a/drivers/net/cris/eth_v10.c +++ b/drivers/net/cris/eth_v10.c | |||
@@ -1108,7 +1108,7 @@ e100_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1108 | 1108 | ||
1109 | spin_unlock_irqrestore(&np->lock, flags); | 1109 | spin_unlock_irqrestore(&np->lock, flags); |
1110 | 1110 | ||
1111 | return 0; | 1111 | return NETDEV_TX_OK; |
1112 | } | 1112 | } |
1113 | 1113 | ||
1114 | /* | 1114 | /* |
diff --git a/drivers/net/cs89x0.c b/drivers/net/cs89x0.c index 55445f980f9c..ecf88abbf99e 100644 --- a/drivers/net/cs89x0.c +++ b/drivers/net/cs89x0.c | |||
@@ -1367,7 +1367,7 @@ net_open(struct net_device *dev) | |||
1367 | spin_lock_irqsave(&lp->lock, flags); | 1367 | spin_lock_irqsave(&lp->lock, flags); |
1368 | disable_dma(dev->dma); | 1368 | disable_dma(dev->dma); |
1369 | clear_dma_ff(dev->dma); | 1369 | clear_dma_ff(dev->dma); |
1370 | set_dma_mode(dev->dma, 0x14); /* auto_init as well */ | 1370 | set_dma_mode(dev->dma, DMA_RX_MODE); /* auto_init as well */ |
1371 | set_dma_addr(dev->dma, isa_virt_to_bus(lp->dma_buff)); | 1371 | set_dma_addr(dev->dma, isa_virt_to_bus(lp->dma_buff)); |
1372 | set_dma_count(dev->dma, lp->dmasize*1024); | 1372 | set_dma_count(dev->dma, lp->dmasize*1024); |
1373 | enable_dma(dev->dma); | 1373 | enable_dma(dev->dma); |
@@ -1572,7 +1572,7 @@ static int net_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1572 | * to restart the netdevice layer | 1572 | * to restart the netdevice layer |
1573 | */ | 1573 | */ |
1574 | 1574 | ||
1575 | return 0; | 1575 | return NETDEV_TX_OK; |
1576 | } | 1576 | } |
1577 | 1577 | ||
1578 | /* The typical workload of the driver: | 1578 | /* The typical workload of the driver: |
diff --git a/drivers/net/cxgb3/adapter.h b/drivers/net/cxgb3/adapter.h index 1694fad38720..74723f2e7431 100644 --- a/drivers/net/cxgb3/adapter.h +++ b/drivers/net/cxgb3/adapter.h | |||
@@ -276,6 +276,14 @@ static inline struct port_info *adap2pinfo(struct adapter *adap, int idx) | |||
276 | return netdev_priv(adap->port[idx]); | 276 | return netdev_priv(adap->port[idx]); |
277 | } | 277 | } |
278 | 278 | ||
279 | static inline int phy2portid(struct cphy *phy) | ||
280 | { | ||
281 | struct adapter *adap = phy->adapter; | ||
282 | struct port_info *port0 = adap2pinfo(adap, 0); | ||
283 | |||
284 | return &port0->phy == phy ? 0 : 1; | ||
285 | } | ||
286 | |||
279 | #define OFFLOAD_DEVMAP_BIT 15 | 287 | #define OFFLOAD_DEVMAP_BIT 15 |
280 | 288 | ||
281 | #define tdev2adap(d) container_of(d, struct adapter, tdev) | 289 | #define tdev2adap(d) container_of(d, struct adapter, tdev) |
@@ -312,4 +320,6 @@ int t3_get_desc(const struct sge_qset *qs, unsigned int qnum, unsigned int idx, | |||
312 | unsigned char *data); | 320 | unsigned char *data); |
313 | irqreturn_t t3_sge_intr_msix(int irq, void *cookie); | 321 | irqreturn_t t3_sge_intr_msix(int irq, void *cookie); |
314 | 322 | ||
323 | int t3_get_edc_fw(struct cphy *phy, int edc_idx, int size); | ||
324 | |||
315 | #endif /* __T3_ADAPTER_H__ */ | 325 | #endif /* __T3_ADAPTER_H__ */ |
diff --git a/drivers/net/cxgb3/ael1002.c b/drivers/net/cxgb3/ael1002.c index 9fe008ec9ba5..5248f9e0b2f4 100644 --- a/drivers/net/cxgb3/ael1002.c +++ b/drivers/net/cxgb3/ael1002.c | |||
@@ -224,12 +224,6 @@ static int ael1006_reset(struct cphy *phy, int wait) | |||
224 | return t3_phy_reset(phy, MDIO_MMD_PMAPMD, wait); | 224 | return t3_phy_reset(phy, MDIO_MMD_PMAPMD, wait); |
225 | } | 225 | } |
226 | 226 | ||
227 | static int ael1006_power_down(struct cphy *phy, int enable) | ||
228 | { | ||
229 | return mdio_set_flag(&phy->mdio, phy->mdio.prtad, MDIO_MMD_PMAPMD, | ||
230 | MDIO_CTRL1, MDIO_CTRL1_LPOWER, enable); | ||
231 | } | ||
232 | |||
233 | static struct cphy_ops ael1006_ops = { | 227 | static struct cphy_ops ael1006_ops = { |
234 | .reset = ael1006_reset, | 228 | .reset = ael1006_reset, |
235 | .intr_enable = t3_phy_lasi_intr_enable, | 229 | .intr_enable = t3_phy_lasi_intr_enable, |
@@ -237,7 +231,7 @@ static struct cphy_ops ael1006_ops = { | |||
237 | .intr_clear = t3_phy_lasi_intr_clear, | 231 | .intr_clear = t3_phy_lasi_intr_clear, |
238 | .intr_handler = t3_phy_lasi_intr_handler, | 232 | .intr_handler = t3_phy_lasi_intr_handler, |
239 | .get_link_status = get_link_status_r, | 233 | .get_link_status = get_link_status_r, |
240 | .power_down = ael1006_power_down, | 234 | .power_down = ael1002_power_down, |
241 | .mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS, | 235 | .mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS, |
242 | }; | 236 | }; |
243 | 237 | ||
@@ -304,279 +298,7 @@ static int ael2005_setup_sr_edc(struct cphy *phy) | |||
304 | { MDIO_MMD_PMAPMD, 0xc04a, 0xffff, 0x5200 }, | 298 | { MDIO_MMD_PMAPMD, 0xc04a, 0xffff, 0x5200 }, |
305 | { 0, 0, 0, 0 } | 299 | { 0, 0, 0, 0 } |
306 | }; | 300 | }; |
307 | static u16 sr_edc[] = { | 301 | |
308 | 0xcc00, 0x2ff4, | ||
309 | 0xcc01, 0x3cd4, | ||
310 | 0xcc02, 0x2015, | ||
311 | 0xcc03, 0x3105, | ||
312 | 0xcc04, 0x6524, | ||
313 | 0xcc05, 0x27ff, | ||
314 | 0xcc06, 0x300f, | ||
315 | 0xcc07, 0x2c8b, | ||
316 | 0xcc08, 0x300b, | ||
317 | 0xcc09, 0x4009, | ||
318 | 0xcc0a, 0x400e, | ||
319 | 0xcc0b, 0x2f72, | ||
320 | 0xcc0c, 0x3002, | ||
321 | 0xcc0d, 0x1002, | ||
322 | 0xcc0e, 0x2172, | ||
323 | 0xcc0f, 0x3012, | ||
324 | 0xcc10, 0x1002, | ||
325 | 0xcc11, 0x25d2, | ||
326 | 0xcc12, 0x3012, | ||
327 | 0xcc13, 0x1002, | ||
328 | 0xcc14, 0xd01e, | ||
329 | 0xcc15, 0x27d2, | ||
330 | 0xcc16, 0x3012, | ||
331 | 0xcc17, 0x1002, | ||
332 | 0xcc18, 0x2004, | ||
333 | 0xcc19, 0x3c84, | ||
334 | 0xcc1a, 0x6436, | ||
335 | 0xcc1b, 0x2007, | ||
336 | 0xcc1c, 0x3f87, | ||
337 | 0xcc1d, 0x8676, | ||
338 | 0xcc1e, 0x40b7, | ||
339 | 0xcc1f, 0xa746, | ||
340 | 0xcc20, 0x4047, | ||
341 | 0xcc21, 0x5673, | ||
342 | 0xcc22, 0x2982, | ||
343 | 0xcc23, 0x3002, | ||
344 | 0xcc24, 0x13d2, | ||
345 | 0xcc25, 0x8bbd, | ||
346 | 0xcc26, 0x2862, | ||
347 | 0xcc27, 0x3012, | ||
348 | 0xcc28, 0x1002, | ||
349 | 0xcc29, 0x2092, | ||
350 | 0xcc2a, 0x3012, | ||
351 | 0xcc2b, 0x1002, | ||
352 | 0xcc2c, 0x5cc3, | ||
353 | 0xcc2d, 0x314, | ||
354 | 0xcc2e, 0x2942, | ||
355 | 0xcc2f, 0x3002, | ||
356 | 0xcc30, 0x1002, | ||
357 | 0xcc31, 0xd019, | ||
358 | 0xcc32, 0x2032, | ||
359 | 0xcc33, 0x3012, | ||
360 | 0xcc34, 0x1002, | ||
361 | 0xcc35, 0x2a04, | ||
362 | 0xcc36, 0x3c74, | ||
363 | 0xcc37, 0x6435, | ||
364 | 0xcc38, 0x2fa4, | ||
365 | 0xcc39, 0x3cd4, | ||
366 | 0xcc3a, 0x6624, | ||
367 | 0xcc3b, 0x5563, | ||
368 | 0xcc3c, 0x2d42, | ||
369 | 0xcc3d, 0x3002, | ||
370 | 0xcc3e, 0x13d2, | ||
371 | 0xcc3f, 0x464d, | ||
372 | 0xcc40, 0x2862, | ||
373 | 0xcc41, 0x3012, | ||
374 | 0xcc42, 0x1002, | ||
375 | 0xcc43, 0x2032, | ||
376 | 0xcc44, 0x3012, | ||
377 | 0xcc45, 0x1002, | ||
378 | 0xcc46, 0x2fb4, | ||
379 | 0xcc47, 0x3cd4, | ||
380 | 0xcc48, 0x6624, | ||
381 | 0xcc49, 0x5563, | ||
382 | 0xcc4a, 0x2d42, | ||
383 | 0xcc4b, 0x3002, | ||
384 | 0xcc4c, 0x13d2, | ||
385 | 0xcc4d, 0x2ed2, | ||
386 | 0xcc4e, 0x3002, | ||
387 | 0xcc4f, 0x1002, | ||
388 | 0xcc50, 0x2fd2, | ||
389 | 0xcc51, 0x3002, | ||
390 | 0xcc52, 0x1002, | ||
391 | 0xcc53, 0x004, | ||
392 | 0xcc54, 0x2942, | ||
393 | 0xcc55, 0x3002, | ||
394 | 0xcc56, 0x1002, | ||
395 | 0xcc57, 0x2092, | ||
396 | 0xcc58, 0x3012, | ||
397 | 0xcc59, 0x1002, | ||
398 | 0xcc5a, 0x5cc3, | ||
399 | 0xcc5b, 0x317, | ||
400 | 0xcc5c, 0x2f72, | ||
401 | 0xcc5d, 0x3002, | ||
402 | 0xcc5e, 0x1002, | ||
403 | 0xcc5f, 0x2942, | ||
404 | 0xcc60, 0x3002, | ||
405 | 0xcc61, 0x1002, | ||
406 | 0xcc62, 0x22cd, | ||
407 | 0xcc63, 0x301d, | ||
408 | 0xcc64, 0x2862, | ||
409 | 0xcc65, 0x3012, | ||
410 | 0xcc66, 0x1002, | ||
411 | 0xcc67, 0x2ed2, | ||
412 | 0xcc68, 0x3002, | ||
413 | 0xcc69, 0x1002, | ||
414 | 0xcc6a, 0x2d72, | ||
415 | 0xcc6b, 0x3002, | ||
416 | 0xcc6c, 0x1002, | ||
417 | 0xcc6d, 0x628f, | ||
418 | 0xcc6e, 0x2112, | ||
419 | 0xcc6f, 0x3012, | ||
420 | 0xcc70, 0x1002, | ||
421 | 0xcc71, 0x5aa3, | ||
422 | 0xcc72, 0x2dc2, | ||
423 | 0xcc73, 0x3002, | ||
424 | 0xcc74, 0x1312, | ||
425 | 0xcc75, 0x6f72, | ||
426 | 0xcc76, 0x1002, | ||
427 | 0xcc77, 0x2807, | ||
428 | 0xcc78, 0x31a7, | ||
429 | 0xcc79, 0x20c4, | ||
430 | 0xcc7a, 0x3c24, | ||
431 | 0xcc7b, 0x6724, | ||
432 | 0xcc7c, 0x1002, | ||
433 | 0xcc7d, 0x2807, | ||
434 | 0xcc7e, 0x3187, | ||
435 | 0xcc7f, 0x20c4, | ||
436 | 0xcc80, 0x3c24, | ||
437 | 0xcc81, 0x6724, | ||
438 | 0xcc82, 0x1002, | ||
439 | 0xcc83, 0x2514, | ||
440 | 0xcc84, 0x3c64, | ||
441 | 0xcc85, 0x6436, | ||
442 | 0xcc86, 0xdff4, | ||
443 | 0xcc87, 0x6436, | ||
444 | 0xcc88, 0x1002, | ||
445 | 0xcc89, 0x40a4, | ||
446 | 0xcc8a, 0x643c, | ||
447 | 0xcc8b, 0x4016, | ||
448 | 0xcc8c, 0x8c6c, | ||
449 | 0xcc8d, 0x2b24, | ||
450 | 0xcc8e, 0x3c24, | ||
451 | 0xcc8f, 0x6435, | ||
452 | 0xcc90, 0x1002, | ||
453 | 0xcc91, 0x2b24, | ||
454 | 0xcc92, 0x3c24, | ||
455 | 0xcc93, 0x643a, | ||
456 | 0xcc94, 0x4025, | ||
457 | 0xcc95, 0x8a5a, | ||
458 | 0xcc96, 0x1002, | ||
459 | 0xcc97, 0x2731, | ||
460 | 0xcc98, 0x3011, | ||
461 | 0xcc99, 0x1001, | ||
462 | 0xcc9a, 0xc7a0, | ||
463 | 0xcc9b, 0x100, | ||
464 | 0xcc9c, 0xc502, | ||
465 | 0xcc9d, 0x53ac, | ||
466 | 0xcc9e, 0xc503, | ||
467 | 0xcc9f, 0xd5d5, | ||
468 | 0xcca0, 0xc600, | ||
469 | 0xcca1, 0x2a6d, | ||
470 | 0xcca2, 0xc601, | ||
471 | 0xcca3, 0x2a4c, | ||
472 | 0xcca4, 0xc602, | ||
473 | 0xcca5, 0x111, | ||
474 | 0xcca6, 0xc60c, | ||
475 | 0xcca7, 0x5900, | ||
476 | 0xcca8, 0xc710, | ||
477 | 0xcca9, 0x700, | ||
478 | 0xccaa, 0xc718, | ||
479 | 0xccab, 0x700, | ||
480 | 0xccac, 0xc720, | ||
481 | 0xccad, 0x4700, | ||
482 | 0xccae, 0xc801, | ||
483 | 0xccaf, 0x7f50, | ||
484 | 0xccb0, 0xc802, | ||
485 | 0xccb1, 0x7760, | ||
486 | 0xccb2, 0xc803, | ||
487 | 0xccb3, 0x7fce, | ||
488 | 0xccb4, 0xc804, | ||
489 | 0xccb5, 0x5700, | ||
490 | 0xccb6, 0xc805, | ||
491 | 0xccb7, 0x5f11, | ||
492 | 0xccb8, 0xc806, | ||
493 | 0xccb9, 0x4751, | ||
494 | 0xccba, 0xc807, | ||
495 | 0xccbb, 0x57e1, | ||
496 | 0xccbc, 0xc808, | ||
497 | 0xccbd, 0x2700, | ||
498 | 0xccbe, 0xc809, | ||
499 | 0xccbf, 0x000, | ||
500 | 0xccc0, 0xc821, | ||
501 | 0xccc1, 0x002, | ||
502 | 0xccc2, 0xc822, | ||
503 | 0xccc3, 0x014, | ||
504 | 0xccc4, 0xc832, | ||
505 | 0xccc5, 0x1186, | ||
506 | 0xccc6, 0xc847, | ||
507 | 0xccc7, 0x1e02, | ||
508 | 0xccc8, 0xc013, | ||
509 | 0xccc9, 0xf341, | ||
510 | 0xccca, 0xc01a, | ||
511 | 0xcccb, 0x446, | ||
512 | 0xcccc, 0xc024, | ||
513 | 0xcccd, 0x1000, | ||
514 | 0xccce, 0xc025, | ||
515 | 0xcccf, 0xa00, | ||
516 | 0xccd0, 0xc026, | ||
517 | 0xccd1, 0xc0c, | ||
518 | 0xccd2, 0xc027, | ||
519 | 0xccd3, 0xc0c, | ||
520 | 0xccd4, 0xc029, | ||
521 | 0xccd5, 0x0a0, | ||
522 | 0xccd6, 0xc030, | ||
523 | 0xccd7, 0xa00, | ||
524 | 0xccd8, 0xc03c, | ||
525 | 0xccd9, 0x01c, | ||
526 | 0xccda, 0xc005, | ||
527 | 0xccdb, 0x7a06, | ||
528 | 0xccdc, 0x000, | ||
529 | 0xccdd, 0x2731, | ||
530 | 0xccde, 0x3011, | ||
531 | 0xccdf, 0x1001, | ||
532 | 0xcce0, 0xc620, | ||
533 | 0xcce1, 0x000, | ||
534 | 0xcce2, 0xc621, | ||
535 | 0xcce3, 0x03f, | ||
536 | 0xcce4, 0xc622, | ||
537 | 0xcce5, 0x000, | ||
538 | 0xcce6, 0xc623, | ||
539 | 0xcce7, 0x000, | ||
540 | 0xcce8, 0xc624, | ||
541 | 0xcce9, 0x000, | ||
542 | 0xccea, 0xc625, | ||
543 | 0xcceb, 0x000, | ||
544 | 0xccec, 0xc627, | ||
545 | 0xcced, 0x000, | ||
546 | 0xccee, 0xc628, | ||
547 | 0xccef, 0x000, | ||
548 | 0xccf0, 0xc62c, | ||
549 | 0xccf1, 0x000, | ||
550 | 0xccf2, 0x000, | ||
551 | 0xccf3, 0x2806, | ||
552 | 0xccf4, 0x3cb6, | ||
553 | 0xccf5, 0xc161, | ||
554 | 0xccf6, 0x6134, | ||
555 | 0xccf7, 0x6135, | ||
556 | 0xccf8, 0x5443, | ||
557 | 0xccf9, 0x303, | ||
558 | 0xccfa, 0x6524, | ||
559 | 0xccfb, 0x00b, | ||
560 | 0xccfc, 0x1002, | ||
561 | 0xccfd, 0x2104, | ||
562 | 0xccfe, 0x3c24, | ||
563 | 0xccff, 0x2105, | ||
564 | 0xcd00, 0x3805, | ||
565 | 0xcd01, 0x6524, | ||
566 | 0xcd02, 0xdff4, | ||
567 | 0xcd03, 0x4005, | ||
568 | 0xcd04, 0x6524, | ||
569 | 0xcd05, 0x1002, | ||
570 | 0xcd06, 0x5dd3, | ||
571 | 0xcd07, 0x306, | ||
572 | 0xcd08, 0x2ff7, | ||
573 | 0xcd09, 0x38f7, | ||
574 | 0xcd0a, 0x60b7, | ||
575 | 0xcd0b, 0xdffd, | ||
576 | 0xcd0c, 0x00a, | ||
577 | 0xcd0d, 0x1002, | ||
578 | 0xcd0e, 0 | ||
579 | }; | ||
580 | int i, err; | 302 | int i, err; |
581 | 303 | ||
582 | err = set_phy_regs(phy, regs); | 304 | err = set_phy_regs(phy, regs); |
@@ -585,9 +307,16 @@ static int ael2005_setup_sr_edc(struct cphy *phy) | |||
585 | 307 | ||
586 | msleep(50); | 308 | msleep(50); |
587 | 309 | ||
588 | for (i = 0; i < ARRAY_SIZE(sr_edc) && !err; i += 2) | 310 | if (phy->priv != edc_sr) |
589 | err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, sr_edc[i], | 311 | err = t3_get_edc_fw(phy, EDC_OPT_AEL2005, |
590 | sr_edc[i + 1]); | 312 | EDC_OPT_AEL2005_SIZE); |
313 | if (err) | ||
314 | return err; | ||
315 | |||
316 | for (i = 0; i < EDC_OPT_AEL2005_SIZE / sizeof(u16) && !err; i += 2) | ||
317 | err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, | ||
318 | phy->phy_cache[i], | ||
319 | phy->phy_cache[i + 1]); | ||
591 | if (!err) | 320 | if (!err) |
592 | phy->priv = edc_sr; | 321 | phy->priv = edc_sr; |
593 | return err; | 322 | return err; |
@@ -604,374 +333,6 @@ static int ael2005_setup_twinax_edc(struct cphy *phy, int modtype) | |||
604 | { MDIO_MMD_PMAPMD, 0xc015, 0xffff, 0xa000 }, | 333 | { MDIO_MMD_PMAPMD, 0xc015, 0xffff, 0xa000 }, |
605 | { 0, 0, 0, 0 } | 334 | { 0, 0, 0, 0 } |
606 | }; | 335 | }; |
607 | static u16 twinax_edc[] = { | ||
608 | 0xcc00, 0x4009, | ||
609 | 0xcc01, 0x27ff, | ||
610 | 0xcc02, 0x300f, | ||
611 | 0xcc03, 0x40aa, | ||
612 | 0xcc04, 0x401c, | ||
613 | 0xcc05, 0x401e, | ||
614 | 0xcc06, 0x2ff4, | ||
615 | 0xcc07, 0x3cd4, | ||
616 | 0xcc08, 0x2035, | ||
617 | 0xcc09, 0x3145, | ||
618 | 0xcc0a, 0x6524, | ||
619 | 0xcc0b, 0x26a2, | ||
620 | 0xcc0c, 0x3012, | ||
621 | 0xcc0d, 0x1002, | ||
622 | 0xcc0e, 0x29c2, | ||
623 | 0xcc0f, 0x3002, | ||
624 | 0xcc10, 0x1002, | ||
625 | 0xcc11, 0x2072, | ||
626 | 0xcc12, 0x3012, | ||
627 | 0xcc13, 0x1002, | ||
628 | 0xcc14, 0x22cd, | ||
629 | 0xcc15, 0x301d, | ||
630 | 0xcc16, 0x2e52, | ||
631 | 0xcc17, 0x3012, | ||
632 | 0xcc18, 0x1002, | ||
633 | 0xcc19, 0x28e2, | ||
634 | 0xcc1a, 0x3002, | ||
635 | 0xcc1b, 0x1002, | ||
636 | 0xcc1c, 0x628f, | ||
637 | 0xcc1d, 0x2ac2, | ||
638 | 0xcc1e, 0x3012, | ||
639 | 0xcc1f, 0x1002, | ||
640 | 0xcc20, 0x5553, | ||
641 | 0xcc21, 0x2ae2, | ||
642 | 0xcc22, 0x3002, | ||
643 | 0xcc23, 0x1302, | ||
644 | 0xcc24, 0x401e, | ||
645 | 0xcc25, 0x2be2, | ||
646 | 0xcc26, 0x3012, | ||
647 | 0xcc27, 0x1002, | ||
648 | 0xcc28, 0x2da2, | ||
649 | 0xcc29, 0x3012, | ||
650 | 0xcc2a, 0x1002, | ||
651 | 0xcc2b, 0x2ba2, | ||
652 | 0xcc2c, 0x3002, | ||
653 | 0xcc2d, 0x1002, | ||
654 | 0xcc2e, 0x5ee3, | ||
655 | 0xcc2f, 0x305, | ||
656 | 0xcc30, 0x400e, | ||
657 | 0xcc31, 0x2bc2, | ||
658 | 0xcc32, 0x3002, | ||
659 | 0xcc33, 0x1002, | ||
660 | 0xcc34, 0x2b82, | ||
661 | 0xcc35, 0x3012, | ||
662 | 0xcc36, 0x1002, | ||
663 | 0xcc37, 0x5663, | ||
664 | 0xcc38, 0x302, | ||
665 | 0xcc39, 0x401e, | ||
666 | 0xcc3a, 0x6f72, | ||
667 | 0xcc3b, 0x1002, | ||
668 | 0xcc3c, 0x628f, | ||
669 | 0xcc3d, 0x2be2, | ||
670 | 0xcc3e, 0x3012, | ||
671 | 0xcc3f, 0x1002, | ||
672 | 0xcc40, 0x22cd, | ||
673 | 0xcc41, 0x301d, | ||
674 | 0xcc42, 0x2e52, | ||
675 | 0xcc43, 0x3012, | ||
676 | 0xcc44, 0x1002, | ||
677 | 0xcc45, 0x2522, | ||
678 | 0xcc46, 0x3012, | ||
679 | 0xcc47, 0x1002, | ||
680 | 0xcc48, 0x2da2, | ||
681 | 0xcc49, 0x3012, | ||
682 | 0xcc4a, 0x1002, | ||
683 | 0xcc4b, 0x2ca2, | ||
684 | 0xcc4c, 0x3012, | ||
685 | 0xcc4d, 0x1002, | ||
686 | 0xcc4e, 0x2fa4, | ||
687 | 0xcc4f, 0x3cd4, | ||
688 | 0xcc50, 0x6624, | ||
689 | 0xcc51, 0x410b, | ||
690 | 0xcc52, 0x56b3, | ||
691 | 0xcc53, 0x3c4, | ||
692 | 0xcc54, 0x2fb2, | ||
693 | 0xcc55, 0x3002, | ||
694 | 0xcc56, 0x1002, | ||
695 | 0xcc57, 0x220b, | ||
696 | 0xcc58, 0x303b, | ||
697 | 0xcc59, 0x56b3, | ||
698 | 0xcc5a, 0x3c3, | ||
699 | 0xcc5b, 0x866b, | ||
700 | 0xcc5c, 0x400c, | ||
701 | 0xcc5d, 0x23a2, | ||
702 | 0xcc5e, 0x3012, | ||
703 | 0xcc5f, 0x1002, | ||
704 | 0xcc60, 0x2da2, | ||
705 | 0xcc61, 0x3012, | ||
706 | 0xcc62, 0x1002, | ||
707 | 0xcc63, 0x2ca2, | ||
708 | 0xcc64, 0x3012, | ||
709 | 0xcc65, 0x1002, | ||
710 | 0xcc66, 0x2fb4, | ||
711 | 0xcc67, 0x3cd4, | ||
712 | 0xcc68, 0x6624, | ||
713 | 0xcc69, 0x56b3, | ||
714 | 0xcc6a, 0x3c3, | ||
715 | 0xcc6b, 0x866b, | ||
716 | 0xcc6c, 0x401c, | ||
717 | 0xcc6d, 0x2205, | ||
718 | 0xcc6e, 0x3035, | ||
719 | 0xcc6f, 0x5b53, | ||
720 | 0xcc70, 0x2c52, | ||
721 | 0xcc71, 0x3002, | ||
722 | 0xcc72, 0x13c2, | ||
723 | 0xcc73, 0x5cc3, | ||
724 | 0xcc74, 0x317, | ||
725 | 0xcc75, 0x2522, | ||
726 | 0xcc76, 0x3012, | ||
727 | 0xcc77, 0x1002, | ||
728 | 0xcc78, 0x2da2, | ||
729 | 0xcc79, 0x3012, | ||
730 | 0xcc7a, 0x1002, | ||
731 | 0xcc7b, 0x2b82, | ||
732 | 0xcc7c, 0x3012, | ||
733 | 0xcc7d, 0x1002, | ||
734 | 0xcc7e, 0x5663, | ||
735 | 0xcc7f, 0x303, | ||
736 | 0xcc80, 0x401e, | ||
737 | 0xcc81, 0x004, | ||
738 | 0xcc82, 0x2c42, | ||
739 | 0xcc83, 0x3012, | ||
740 | 0xcc84, 0x1002, | ||
741 | 0xcc85, 0x6f72, | ||
742 | 0xcc86, 0x1002, | ||
743 | 0xcc87, 0x628f, | ||
744 | 0xcc88, 0x2304, | ||
745 | 0xcc89, 0x3c84, | ||
746 | 0xcc8a, 0x6436, | ||
747 | 0xcc8b, 0xdff4, | ||
748 | 0xcc8c, 0x6436, | ||
749 | 0xcc8d, 0x2ff5, | ||
750 | 0xcc8e, 0x3005, | ||
751 | 0xcc8f, 0x8656, | ||
752 | 0xcc90, 0xdfba, | ||
753 | 0xcc91, 0x56a3, | ||
754 | 0xcc92, 0xd05a, | ||
755 | 0xcc93, 0x21c2, | ||
756 | 0xcc94, 0x3012, | ||
757 | 0xcc95, 0x1392, | ||
758 | 0xcc96, 0xd05a, | ||
759 | 0xcc97, 0x56a3, | ||
760 | 0xcc98, 0xdfba, | ||
761 | 0xcc99, 0x383, | ||
762 | 0xcc9a, 0x6f72, | ||
763 | 0xcc9b, 0x1002, | ||
764 | 0xcc9c, 0x28c5, | ||
765 | 0xcc9d, 0x3005, | ||
766 | 0xcc9e, 0x4178, | ||
767 | 0xcc9f, 0x5653, | ||
768 | 0xcca0, 0x384, | ||
769 | 0xcca1, 0x22b2, | ||
770 | 0xcca2, 0x3012, | ||
771 | 0xcca3, 0x1002, | ||
772 | 0xcca4, 0x2be5, | ||
773 | 0xcca5, 0x3005, | ||
774 | 0xcca6, 0x41e8, | ||
775 | 0xcca7, 0x5653, | ||
776 | 0xcca8, 0x382, | ||
777 | 0xcca9, 0x002, | ||
778 | 0xccaa, 0x4258, | ||
779 | 0xccab, 0x2474, | ||
780 | 0xccac, 0x3c84, | ||
781 | 0xccad, 0x6437, | ||
782 | 0xccae, 0xdff4, | ||
783 | 0xccaf, 0x6437, | ||
784 | 0xccb0, 0x2ff5, | ||
785 | 0xccb1, 0x3c05, | ||
786 | 0xccb2, 0x8757, | ||
787 | 0xccb3, 0xb888, | ||
788 | 0xccb4, 0x9787, | ||
789 | 0xccb5, 0xdff4, | ||
790 | 0xccb6, 0x6724, | ||
791 | 0xccb7, 0x866a, | ||
792 | 0xccb8, 0x6f72, | ||
793 | 0xccb9, 0x1002, | ||
794 | 0xccba, 0x2d01, | ||
795 | 0xccbb, 0x3011, | ||
796 | 0xccbc, 0x1001, | ||
797 | 0xccbd, 0xc620, | ||
798 | 0xccbe, 0x14e5, | ||
799 | 0xccbf, 0xc621, | ||
800 | 0xccc0, 0xc53d, | ||
801 | 0xccc1, 0xc622, | ||
802 | 0xccc2, 0x3cbe, | ||
803 | 0xccc3, 0xc623, | ||
804 | 0xccc4, 0x4452, | ||
805 | 0xccc5, 0xc624, | ||
806 | 0xccc6, 0xc5c5, | ||
807 | 0xccc7, 0xc625, | ||
808 | 0xccc8, 0xe01e, | ||
809 | 0xccc9, 0xc627, | ||
810 | 0xccca, 0x000, | ||
811 | 0xcccb, 0xc628, | ||
812 | 0xcccc, 0x000, | ||
813 | 0xcccd, 0xc62b, | ||
814 | 0xccce, 0x000, | ||
815 | 0xcccf, 0xc62c, | ||
816 | 0xccd0, 0x000, | ||
817 | 0xccd1, 0x000, | ||
818 | 0xccd2, 0x2d01, | ||
819 | 0xccd3, 0x3011, | ||
820 | 0xccd4, 0x1001, | ||
821 | 0xccd5, 0xc620, | ||
822 | 0xccd6, 0x000, | ||
823 | 0xccd7, 0xc621, | ||
824 | 0xccd8, 0x000, | ||
825 | 0xccd9, 0xc622, | ||
826 | 0xccda, 0x0ce, | ||
827 | 0xccdb, 0xc623, | ||
828 | 0xccdc, 0x07f, | ||
829 | 0xccdd, 0xc624, | ||
830 | 0xccde, 0x032, | ||
831 | 0xccdf, 0xc625, | ||
832 | 0xcce0, 0x000, | ||
833 | 0xcce1, 0xc627, | ||
834 | 0xcce2, 0x000, | ||
835 | 0xcce3, 0xc628, | ||
836 | 0xcce4, 0x000, | ||
837 | 0xcce5, 0xc62b, | ||
838 | 0xcce6, 0x000, | ||
839 | 0xcce7, 0xc62c, | ||
840 | 0xcce8, 0x000, | ||
841 | 0xcce9, 0x000, | ||
842 | 0xccea, 0x2d01, | ||
843 | 0xcceb, 0x3011, | ||
844 | 0xccec, 0x1001, | ||
845 | 0xcced, 0xc502, | ||
846 | 0xccee, 0x609f, | ||
847 | 0xccef, 0xc600, | ||
848 | 0xccf0, 0x2a6e, | ||
849 | 0xccf1, 0xc601, | ||
850 | 0xccf2, 0x2a2c, | ||
851 | 0xccf3, 0xc60c, | ||
852 | 0xccf4, 0x5400, | ||
853 | 0xccf5, 0xc710, | ||
854 | 0xccf6, 0x700, | ||
855 | 0xccf7, 0xc718, | ||
856 | 0xccf8, 0x700, | ||
857 | 0xccf9, 0xc720, | ||
858 | 0xccfa, 0x4700, | ||
859 | 0xccfb, 0xc728, | ||
860 | 0xccfc, 0x700, | ||
861 | 0xccfd, 0xc729, | ||
862 | 0xccfe, 0x1207, | ||
863 | 0xccff, 0xc801, | ||
864 | 0xcd00, 0x7f50, | ||
865 | 0xcd01, 0xc802, | ||
866 | 0xcd02, 0x7760, | ||
867 | 0xcd03, 0xc803, | ||
868 | 0xcd04, 0x7fce, | ||
869 | 0xcd05, 0xc804, | ||
870 | 0xcd06, 0x520e, | ||
871 | 0xcd07, 0xc805, | ||
872 | 0xcd08, 0x5c11, | ||
873 | 0xcd09, 0xc806, | ||
874 | 0xcd0a, 0x3c51, | ||
875 | 0xcd0b, 0xc807, | ||
876 | 0xcd0c, 0x4061, | ||
877 | 0xcd0d, 0xc808, | ||
878 | 0xcd0e, 0x49c1, | ||
879 | 0xcd0f, 0xc809, | ||
880 | 0xcd10, 0x3840, | ||
881 | 0xcd11, 0xc80a, | ||
882 | 0xcd12, 0x000, | ||
883 | 0xcd13, 0xc821, | ||
884 | 0xcd14, 0x002, | ||
885 | 0xcd15, 0xc822, | ||
886 | 0xcd16, 0x046, | ||
887 | 0xcd17, 0xc844, | ||
888 | 0xcd18, 0x182f, | ||
889 | 0xcd19, 0xc013, | ||
890 | 0xcd1a, 0xf341, | ||
891 | 0xcd1b, 0xc01a, | ||
892 | 0xcd1c, 0x446, | ||
893 | 0xcd1d, 0xc024, | ||
894 | 0xcd1e, 0x1000, | ||
895 | 0xcd1f, 0xc025, | ||
896 | 0xcd20, 0xa00, | ||
897 | 0xcd21, 0xc026, | ||
898 | 0xcd22, 0xc0c, | ||
899 | 0xcd23, 0xc027, | ||
900 | 0xcd24, 0xc0c, | ||
901 | 0xcd25, 0xc029, | ||
902 | 0xcd26, 0x0a0, | ||
903 | 0xcd27, 0xc030, | ||
904 | 0xcd28, 0xa00, | ||
905 | 0xcd29, 0xc03c, | ||
906 | 0xcd2a, 0x01c, | ||
907 | 0xcd2b, 0x000, | ||
908 | 0xcd2c, 0x2b84, | ||
909 | 0xcd2d, 0x3c74, | ||
910 | 0xcd2e, 0x6435, | ||
911 | 0xcd2f, 0xdff4, | ||
912 | 0xcd30, 0x6435, | ||
913 | 0xcd31, 0x2806, | ||
914 | 0xcd32, 0x3006, | ||
915 | 0xcd33, 0x8565, | ||
916 | 0xcd34, 0x2b24, | ||
917 | 0xcd35, 0x3c24, | ||
918 | 0xcd36, 0x6436, | ||
919 | 0xcd37, 0x1002, | ||
920 | 0xcd38, 0x2b24, | ||
921 | 0xcd39, 0x3c24, | ||
922 | 0xcd3a, 0x6436, | ||
923 | 0xcd3b, 0x4045, | ||
924 | 0xcd3c, 0x8656, | ||
925 | 0xcd3d, 0x1002, | ||
926 | 0xcd3e, 0x2807, | ||
927 | 0xcd3f, 0x31a7, | ||
928 | 0xcd40, 0x20c4, | ||
929 | 0xcd41, 0x3c24, | ||
930 | 0xcd42, 0x6724, | ||
931 | 0xcd43, 0x1002, | ||
932 | 0xcd44, 0x2807, | ||
933 | 0xcd45, 0x3187, | ||
934 | 0xcd46, 0x20c4, | ||
935 | 0xcd47, 0x3c24, | ||
936 | 0xcd48, 0x6724, | ||
937 | 0xcd49, 0x1002, | ||
938 | 0xcd4a, 0x2514, | ||
939 | 0xcd4b, 0x3c64, | ||
940 | 0xcd4c, 0x6436, | ||
941 | 0xcd4d, 0xdff4, | ||
942 | 0xcd4e, 0x6436, | ||
943 | 0xcd4f, 0x1002, | ||
944 | 0xcd50, 0x2806, | ||
945 | 0xcd51, 0x3cb6, | ||
946 | 0xcd52, 0xc161, | ||
947 | 0xcd53, 0x6134, | ||
948 | 0xcd54, 0x6135, | ||
949 | 0xcd55, 0x5443, | ||
950 | 0xcd56, 0x303, | ||
951 | 0xcd57, 0x6524, | ||
952 | 0xcd58, 0x00b, | ||
953 | 0xcd59, 0x1002, | ||
954 | 0xcd5a, 0xd019, | ||
955 | 0xcd5b, 0x2104, | ||
956 | 0xcd5c, 0x3c24, | ||
957 | 0xcd5d, 0x2105, | ||
958 | 0xcd5e, 0x3805, | ||
959 | 0xcd5f, 0x6524, | ||
960 | 0xcd60, 0xdff4, | ||
961 | 0xcd61, 0x4005, | ||
962 | 0xcd62, 0x6524, | ||
963 | 0xcd63, 0x2e8d, | ||
964 | 0xcd64, 0x303d, | ||
965 | 0xcd65, 0x5dd3, | ||
966 | 0xcd66, 0x306, | ||
967 | 0xcd67, 0x2ff7, | ||
968 | 0xcd68, 0x38f7, | ||
969 | 0xcd69, 0x60b7, | ||
970 | 0xcd6a, 0xdffd, | ||
971 | 0xcd6b, 0x00a, | ||
972 | 0xcd6c, 0x1002, | ||
973 | 0xcd6d, 0 | ||
974 | }; | ||
975 | int i, err; | 336 | int i, err; |
976 | 337 | ||
977 | err = set_phy_regs(phy, regs); | 338 | err = set_phy_regs(phy, regs); |
@@ -982,9 +343,16 @@ static int ael2005_setup_twinax_edc(struct cphy *phy, int modtype) | |||
982 | 343 | ||
983 | msleep(50); | 344 | msleep(50); |
984 | 345 | ||
985 | for (i = 0; i < ARRAY_SIZE(twinax_edc) && !err; i += 2) | 346 | if (phy->priv != edc_twinax) |
986 | err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, twinax_edc[i], | 347 | err = t3_get_edc_fw(phy, EDC_TWX_AEL2005, |
987 | twinax_edc[i + 1]); | 348 | EDC_TWX_AEL2005_SIZE); |
349 | if (err) | ||
350 | return err; | ||
351 | |||
352 | for (i = 0; i < EDC_TWX_AEL2005_SIZE / sizeof(u16) && !err; i += 2) | ||
353 | err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, | ||
354 | phy->phy_cache[i], | ||
355 | phy->phy_cache[i + 1]); | ||
988 | if (!err) | 356 | if (!err) |
989 | phy->priv = edc_twinax; | 357 | phy->priv = edc_twinax; |
990 | return err; | 358 | return err; |
@@ -1201,405 +569,6 @@ static int ael2020_setup_twinax_edc(struct cphy *phy, int modtype) | |||
1201 | { MDIO_MMD_PMAPMD, 0xd092, 0xffff, 0x0000 }, | 569 | { MDIO_MMD_PMAPMD, 0xd092, 0xffff, 0x0000 }, |
1202 | { 0, 0, 0, 0 } | 570 | { 0, 0, 0, 0 } |
1203 | }; | 571 | }; |
1204 | |||
1205 | /* TWINAX EDC firmware */ | ||
1206 | static u16 twinax_edc[] = { | ||
1207 | 0xd800, 0x4009, | ||
1208 | 0xd801, 0x2fff, | ||
1209 | 0xd802, 0x300f, | ||
1210 | 0xd803, 0x40aa, | ||
1211 | 0xd804, 0x401c, | ||
1212 | 0xd805, 0x401e, | ||
1213 | 0xd806, 0x2ff4, | ||
1214 | 0xd807, 0x3dc4, | ||
1215 | 0xd808, 0x2035, | ||
1216 | 0xd809, 0x3035, | ||
1217 | 0xd80a, 0x6524, | ||
1218 | 0xd80b, 0x2cb2, | ||
1219 | 0xd80c, 0x3012, | ||
1220 | 0xd80d, 0x1002, | ||
1221 | 0xd80e, 0x26e2, | ||
1222 | 0xd80f, 0x3022, | ||
1223 | 0xd810, 0x1002, | ||
1224 | 0xd811, 0x27d2, | ||
1225 | 0xd812, 0x3022, | ||
1226 | 0xd813, 0x1002, | ||
1227 | 0xd814, 0x2822, | ||
1228 | 0xd815, 0x3012, | ||
1229 | 0xd816, 0x1002, | ||
1230 | 0xd817, 0x2492, | ||
1231 | 0xd818, 0x3022, | ||
1232 | 0xd819, 0x1002, | ||
1233 | 0xd81a, 0x2772, | ||
1234 | 0xd81b, 0x3012, | ||
1235 | 0xd81c, 0x1002, | ||
1236 | 0xd81d, 0x23d2, | ||
1237 | 0xd81e, 0x3022, | ||
1238 | 0xd81f, 0x1002, | ||
1239 | 0xd820, 0x22cd, | ||
1240 | 0xd821, 0x301d, | ||
1241 | 0xd822, 0x27f2, | ||
1242 | 0xd823, 0x3022, | ||
1243 | 0xd824, 0x1002, | ||
1244 | 0xd825, 0x5553, | ||
1245 | 0xd826, 0x0307, | ||
1246 | 0xd827, 0x2522, | ||
1247 | 0xd828, 0x3022, | ||
1248 | 0xd829, 0x1002, | ||
1249 | 0xd82a, 0x2142, | ||
1250 | 0xd82b, 0x3012, | ||
1251 | 0xd82c, 0x1002, | ||
1252 | 0xd82d, 0x4016, | ||
1253 | 0xd82e, 0x5e63, | ||
1254 | 0xd82f, 0x0344, | ||
1255 | 0xd830, 0x2142, | ||
1256 | 0xd831, 0x3012, | ||
1257 | 0xd832, 0x1002, | ||
1258 | 0xd833, 0x400e, | ||
1259 | 0xd834, 0x2522, | ||
1260 | 0xd835, 0x3022, | ||
1261 | 0xd836, 0x1002, | ||
1262 | 0xd837, 0x2b52, | ||
1263 | 0xd838, 0x3012, | ||
1264 | 0xd839, 0x1002, | ||
1265 | 0xd83a, 0x2742, | ||
1266 | 0xd83b, 0x3022, | ||
1267 | 0xd83c, 0x1002, | ||
1268 | 0xd83d, 0x25e2, | ||
1269 | 0xd83e, 0x3022, | ||
1270 | 0xd83f, 0x1002, | ||
1271 | 0xd840, 0x2fa4, | ||
1272 | 0xd841, 0x3dc4, | ||
1273 | 0xd842, 0x6624, | ||
1274 | 0xd843, 0x414b, | ||
1275 | 0xd844, 0x56b3, | ||
1276 | 0xd845, 0x03c6, | ||
1277 | 0xd846, 0x866b, | ||
1278 | 0xd847, 0x400c, | ||
1279 | 0xd848, 0x2712, | ||
1280 | 0xd849, 0x3012, | ||
1281 | 0xd84a, 0x1002, | ||
1282 | 0xd84b, 0x2c4b, | ||
1283 | 0xd84c, 0x309b, | ||
1284 | 0xd84d, 0x56b3, | ||
1285 | 0xd84e, 0x03c3, | ||
1286 | 0xd84f, 0x866b, | ||
1287 | 0xd850, 0x400c, | ||
1288 | 0xd851, 0x2272, | ||
1289 | 0xd852, 0x3022, | ||
1290 | 0xd853, 0x1002, | ||
1291 | 0xd854, 0x2742, | ||
1292 | 0xd855, 0x3022, | ||
1293 | 0xd856, 0x1002, | ||
1294 | 0xd857, 0x25e2, | ||
1295 | 0xd858, 0x3022, | ||
1296 | 0xd859, 0x1002, | ||
1297 | 0xd85a, 0x2fb4, | ||
1298 | 0xd85b, 0x3dc4, | ||
1299 | 0xd85c, 0x6624, | ||
1300 | 0xd85d, 0x56b3, | ||
1301 | 0xd85e, 0x03c3, | ||
1302 | 0xd85f, 0x866b, | ||
1303 | 0xd860, 0x401c, | ||
1304 | 0xd861, 0x2c45, | ||
1305 | 0xd862, 0x3095, | ||
1306 | 0xd863, 0x5b53, | ||
1307 | 0xd864, 0x2372, | ||
1308 | 0xd865, 0x3012, | ||
1309 | 0xd866, 0x13c2, | ||
1310 | 0xd867, 0x5cc3, | ||
1311 | 0xd868, 0x2712, | ||
1312 | 0xd869, 0x3012, | ||
1313 | 0xd86a, 0x1312, | ||
1314 | 0xd86b, 0x2b52, | ||
1315 | 0xd86c, 0x3012, | ||
1316 | 0xd86d, 0x1002, | ||
1317 | 0xd86e, 0x2742, | ||
1318 | 0xd86f, 0x3022, | ||
1319 | 0xd870, 0x1002, | ||
1320 | 0xd871, 0x2582, | ||
1321 | 0xd872, 0x3022, | ||
1322 | 0xd873, 0x1002, | ||
1323 | 0xd874, 0x2142, | ||
1324 | 0xd875, 0x3012, | ||
1325 | 0xd876, 0x1002, | ||
1326 | 0xd877, 0x628f, | ||
1327 | 0xd878, 0x2985, | ||
1328 | 0xd879, 0x33a5, | ||
1329 | 0xd87a, 0x25e2, | ||
1330 | 0xd87b, 0x3022, | ||
1331 | 0xd87c, 0x1002, | ||
1332 | 0xd87d, 0x5653, | ||
1333 | 0xd87e, 0x03d2, | ||
1334 | 0xd87f, 0x401e, | ||
1335 | 0xd880, 0x6f72, | ||
1336 | 0xd881, 0x1002, | ||
1337 | 0xd882, 0x628f, | ||
1338 | 0xd883, 0x2304, | ||
1339 | 0xd884, 0x3c84, | ||
1340 | 0xd885, 0x6436, | ||
1341 | 0xd886, 0xdff4, | ||
1342 | 0xd887, 0x6436, | ||
1343 | 0xd888, 0x2ff5, | ||
1344 | 0xd889, 0x3005, | ||
1345 | 0xd88a, 0x8656, | ||
1346 | 0xd88b, 0xdfba, | ||
1347 | 0xd88c, 0x56a3, | ||
1348 | 0xd88d, 0xd05a, | ||
1349 | 0xd88e, 0x2972, | ||
1350 | 0xd88f, 0x3012, | ||
1351 | 0xd890, 0x1392, | ||
1352 | 0xd891, 0xd05a, | ||
1353 | 0xd892, 0x56a3, | ||
1354 | 0xd893, 0xdfba, | ||
1355 | 0xd894, 0x0383, | ||
1356 | 0xd895, 0x6f72, | ||
1357 | 0xd896, 0x1002, | ||
1358 | 0xd897, 0x2b45, | ||
1359 | 0xd898, 0x3005, | ||
1360 | 0xd899, 0x4178, | ||
1361 | 0xd89a, 0x5653, | ||
1362 | 0xd89b, 0x0384, | ||
1363 | 0xd89c, 0x2a62, | ||
1364 | 0xd89d, 0x3012, | ||
1365 | 0xd89e, 0x1002, | ||
1366 | 0xd89f, 0x2f05, | ||
1367 | 0xd8a0, 0x3005, | ||
1368 | 0xd8a1, 0x41c8, | ||
1369 | 0xd8a2, 0x5653, | ||
1370 | 0xd8a3, 0x0382, | ||
1371 | 0xd8a4, 0x0002, | ||
1372 | 0xd8a5, 0x4218, | ||
1373 | 0xd8a6, 0x2474, | ||
1374 | 0xd8a7, 0x3c84, | ||
1375 | 0xd8a8, 0x6437, | ||
1376 | 0xd8a9, 0xdff4, | ||
1377 | 0xd8aa, 0x6437, | ||
1378 | 0xd8ab, 0x2ff5, | ||
1379 | 0xd8ac, 0x3c05, | ||
1380 | 0xd8ad, 0x8757, | ||
1381 | 0xd8ae, 0xb888, | ||
1382 | 0xd8af, 0x9787, | ||
1383 | 0xd8b0, 0xdff4, | ||
1384 | 0xd8b1, 0x6724, | ||
1385 | 0xd8b2, 0x866a, | ||
1386 | 0xd8b3, 0x6f72, | ||
1387 | 0xd8b4, 0x1002, | ||
1388 | 0xd8b5, 0x2641, | ||
1389 | 0xd8b6, 0x3021, | ||
1390 | 0xd8b7, 0x1001, | ||
1391 | 0xd8b8, 0xc620, | ||
1392 | 0xd8b9, 0x0000, | ||
1393 | 0xd8ba, 0xc621, | ||
1394 | 0xd8bb, 0x0000, | ||
1395 | 0xd8bc, 0xc622, | ||
1396 | 0xd8bd, 0x00ce, | ||
1397 | 0xd8be, 0xc623, | ||
1398 | 0xd8bf, 0x007f, | ||
1399 | 0xd8c0, 0xc624, | ||
1400 | 0xd8c1, 0x0032, | ||
1401 | 0xd8c2, 0xc625, | ||
1402 | 0xd8c3, 0x0000, | ||
1403 | 0xd8c4, 0xc627, | ||
1404 | 0xd8c5, 0x0000, | ||
1405 | 0xd8c6, 0xc628, | ||
1406 | 0xd8c7, 0x0000, | ||
1407 | 0xd8c8, 0xc62c, | ||
1408 | 0xd8c9, 0x0000, | ||
1409 | 0xd8ca, 0x0000, | ||
1410 | 0xd8cb, 0x2641, | ||
1411 | 0xd8cc, 0x3021, | ||
1412 | 0xd8cd, 0x1001, | ||
1413 | 0xd8ce, 0xc502, | ||
1414 | 0xd8cf, 0x53ac, | ||
1415 | 0xd8d0, 0xc503, | ||
1416 | 0xd8d1, 0x2cd3, | ||
1417 | 0xd8d2, 0xc600, | ||
1418 | 0xd8d3, 0x2a6e, | ||
1419 | 0xd8d4, 0xc601, | ||
1420 | 0xd8d5, 0x2a2c, | ||
1421 | 0xd8d6, 0xc605, | ||
1422 | 0xd8d7, 0x5557, | ||
1423 | 0xd8d8, 0xc60c, | ||
1424 | 0xd8d9, 0x5400, | ||
1425 | 0xd8da, 0xc710, | ||
1426 | 0xd8db, 0x0700, | ||
1427 | 0xd8dc, 0xc711, | ||
1428 | 0xd8dd, 0x0f06, | ||
1429 | 0xd8de, 0xc718, | ||
1430 | 0xd8df, 0x0700, | ||
1431 | 0xd8e0, 0xc719, | ||
1432 | 0xd8e1, 0x0f06, | ||
1433 | 0xd8e2, 0xc720, | ||
1434 | 0xd8e3, 0x4700, | ||
1435 | 0xd8e4, 0xc721, | ||
1436 | 0xd8e5, 0x0f06, | ||
1437 | 0xd8e6, 0xc728, | ||
1438 | 0xd8e7, 0x0700, | ||
1439 | 0xd8e8, 0xc729, | ||
1440 | 0xd8e9, 0x1207, | ||
1441 | 0xd8ea, 0xc801, | ||
1442 | 0xd8eb, 0x7f50, | ||
1443 | 0xd8ec, 0xc802, | ||
1444 | 0xd8ed, 0x7760, | ||
1445 | 0xd8ee, 0xc803, | ||
1446 | 0xd8ef, 0x7fce, | ||
1447 | 0xd8f0, 0xc804, | ||
1448 | 0xd8f1, 0x520e, | ||
1449 | 0xd8f2, 0xc805, | ||
1450 | 0xd8f3, 0x5c11, | ||
1451 | 0xd8f4, 0xc806, | ||
1452 | 0xd8f5, 0x3c51, | ||
1453 | 0xd8f6, 0xc807, | ||
1454 | 0xd8f7, 0x4061, | ||
1455 | 0xd8f8, 0xc808, | ||
1456 | 0xd8f9, 0x49c1, | ||
1457 | 0xd8fa, 0xc809, | ||
1458 | 0xd8fb, 0x3840, | ||
1459 | 0xd8fc, 0xc80a, | ||
1460 | 0xd8fd, 0x0000, | ||
1461 | 0xd8fe, 0xc821, | ||
1462 | 0xd8ff, 0x0002, | ||
1463 | 0xd900, 0xc822, | ||
1464 | 0xd901, 0x0046, | ||
1465 | 0xd902, 0xc844, | ||
1466 | 0xd903, 0x182f, | ||
1467 | 0xd904, 0xc013, | ||
1468 | 0xd905, 0xf341, | ||
1469 | 0xd906, 0xc084, | ||
1470 | 0xd907, 0x0030, | ||
1471 | 0xd908, 0xc904, | ||
1472 | 0xd909, 0x1401, | ||
1473 | 0xd90a, 0xcb0c, | ||
1474 | 0xd90b, 0x0004, | ||
1475 | 0xd90c, 0xcb0e, | ||
1476 | 0xd90d, 0xa00a, | ||
1477 | 0xd90e, 0xcb0f, | ||
1478 | 0xd90f, 0xc0c0, | ||
1479 | 0xd910, 0xcb10, | ||
1480 | 0xd911, 0xc0c0, | ||
1481 | 0xd912, 0xcb11, | ||
1482 | 0xd913, 0x00a0, | ||
1483 | 0xd914, 0xcb12, | ||
1484 | 0xd915, 0x0007, | ||
1485 | 0xd916, 0xc241, | ||
1486 | 0xd917, 0xa000, | ||
1487 | 0xd918, 0xc243, | ||
1488 | 0xd919, 0x7fe0, | ||
1489 | 0xd91a, 0xc604, | ||
1490 | 0xd91b, 0x000e, | ||
1491 | 0xd91c, 0xc609, | ||
1492 | 0xd91d, 0x00f5, | ||
1493 | 0xd91e, 0xc611, | ||
1494 | 0xd91f, 0x000e, | ||
1495 | 0xd920, 0xc660, | ||
1496 | 0xd921, 0x9600, | ||
1497 | 0xd922, 0xc687, | ||
1498 | 0xd923, 0x0004, | ||
1499 | 0xd924, 0xc60a, | ||
1500 | 0xd925, 0x04f5, | ||
1501 | 0xd926, 0x0000, | ||
1502 | 0xd927, 0x2641, | ||
1503 | 0xd928, 0x3021, | ||
1504 | 0xd929, 0x1001, | ||
1505 | 0xd92a, 0xc620, | ||
1506 | 0xd92b, 0x14e5, | ||
1507 | 0xd92c, 0xc621, | ||
1508 | 0xd92d, 0xc53d, | ||
1509 | 0xd92e, 0xc622, | ||
1510 | 0xd92f, 0x3cbe, | ||
1511 | 0xd930, 0xc623, | ||
1512 | 0xd931, 0x4452, | ||
1513 | 0xd932, 0xc624, | ||
1514 | 0xd933, 0xc5c5, | ||
1515 | 0xd934, 0xc625, | ||
1516 | 0xd935, 0xe01e, | ||
1517 | 0xd936, 0xc627, | ||
1518 | 0xd937, 0x0000, | ||
1519 | 0xd938, 0xc628, | ||
1520 | 0xd939, 0x0000, | ||
1521 | 0xd93a, 0xc62c, | ||
1522 | 0xd93b, 0x0000, | ||
1523 | 0xd93c, 0x0000, | ||
1524 | 0xd93d, 0x2b84, | ||
1525 | 0xd93e, 0x3c74, | ||
1526 | 0xd93f, 0x6435, | ||
1527 | 0xd940, 0xdff4, | ||
1528 | 0xd941, 0x6435, | ||
1529 | 0xd942, 0x2806, | ||
1530 | 0xd943, 0x3006, | ||
1531 | 0xd944, 0x8565, | ||
1532 | 0xd945, 0x2b24, | ||
1533 | 0xd946, 0x3c24, | ||
1534 | 0xd947, 0x6436, | ||
1535 | 0xd948, 0x1002, | ||
1536 | 0xd949, 0x2b24, | ||
1537 | 0xd94a, 0x3c24, | ||
1538 | 0xd94b, 0x6436, | ||
1539 | 0xd94c, 0x4045, | ||
1540 | 0xd94d, 0x8656, | ||
1541 | 0xd94e, 0x5663, | ||
1542 | 0xd94f, 0x0302, | ||
1543 | 0xd950, 0x401e, | ||
1544 | 0xd951, 0x1002, | ||
1545 | 0xd952, 0x2807, | ||
1546 | 0xd953, 0x31a7, | ||
1547 | 0xd954, 0x20c4, | ||
1548 | 0xd955, 0x3c24, | ||
1549 | 0xd956, 0x6724, | ||
1550 | 0xd957, 0x1002, | ||
1551 | 0xd958, 0x2807, | ||
1552 | 0xd959, 0x3187, | ||
1553 | 0xd95a, 0x20c4, | ||
1554 | 0xd95b, 0x3c24, | ||
1555 | 0xd95c, 0x6724, | ||
1556 | 0xd95d, 0x1002, | ||
1557 | 0xd95e, 0x24f4, | ||
1558 | 0xd95f, 0x3c64, | ||
1559 | 0xd960, 0x6436, | ||
1560 | 0xd961, 0xdff4, | ||
1561 | 0xd962, 0x6436, | ||
1562 | 0xd963, 0x1002, | ||
1563 | 0xd964, 0x2006, | ||
1564 | 0xd965, 0x3d76, | ||
1565 | 0xd966, 0xc161, | ||
1566 | 0xd967, 0x6134, | ||
1567 | 0xd968, 0x6135, | ||
1568 | 0xd969, 0x5443, | ||
1569 | 0xd96a, 0x0303, | ||
1570 | 0xd96b, 0x6524, | ||
1571 | 0xd96c, 0x00fb, | ||
1572 | 0xd96d, 0x1002, | ||
1573 | 0xd96e, 0x20d4, | ||
1574 | 0xd96f, 0x3c24, | ||
1575 | 0xd970, 0x2025, | ||
1576 | 0xd971, 0x3005, | ||
1577 | 0xd972, 0x6524, | ||
1578 | 0xd973, 0x1002, | ||
1579 | 0xd974, 0xd019, | ||
1580 | 0xd975, 0x2104, | ||
1581 | 0xd976, 0x3c24, | ||
1582 | 0xd977, 0x2105, | ||
1583 | 0xd978, 0x3805, | ||
1584 | 0xd979, 0x6524, | ||
1585 | 0xd97a, 0xdff4, | ||
1586 | 0xd97b, 0x4005, | ||
1587 | 0xd97c, 0x6524, | ||
1588 | 0xd97d, 0x2e8d, | ||
1589 | 0xd97e, 0x303d, | ||
1590 | 0xd97f, 0x2408, | ||
1591 | 0xd980, 0x35d8, | ||
1592 | 0xd981, 0x5dd3, | ||
1593 | 0xd982, 0x0307, | ||
1594 | 0xd983, 0x8887, | ||
1595 | 0xd984, 0x63a7, | ||
1596 | 0xd985, 0x8887, | ||
1597 | 0xd986, 0x63a7, | ||
1598 | 0xd987, 0xdffd, | ||
1599 | 0xd988, 0x00f9, | ||
1600 | 0xd989, 0x1002, | ||
1601 | 0xd98a, 0x0000, | ||
1602 | }; | ||
1603 | int i, err; | 572 | int i, err; |
1604 | 573 | ||
1605 | /* set uC clock and activate it */ | 574 | /* set uC clock and activate it */ |
@@ -1612,10 +581,16 @@ static int ael2020_setup_twinax_edc(struct cphy *phy, int modtype) | |||
1612 | if (err) | 581 | if (err) |
1613 | return err; | 582 | return err; |
1614 | 583 | ||
1615 | /* write TWINAX EDC firmware into PHY */ | 584 | if (phy->priv != edc_twinax) |
1616 | for (i = 0; i < ARRAY_SIZE(twinax_edc) && !err; i += 2) | 585 | err = t3_get_edc_fw(phy, EDC_TWX_AEL2020, |
1617 | err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, twinax_edc[i], | 586 | EDC_TWX_AEL2020_SIZE); |
1618 | twinax_edc[i + 1]); | 587 | if (err) |
588 | return err; | ||
589 | |||
590 | for (i = 0; i < EDC_TWX_AEL2020_SIZE / sizeof(u16) && !err; i += 2) | ||
591 | err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, | ||
592 | phy->phy_cache[i], | ||
593 | phy->phy_cache[i + 1]); | ||
1619 | /* activate uC */ | 594 | /* activate uC */ |
1620 | err = set_phy_regs(phy, uCactivate); | 595 | err = set_phy_regs(phy, uCactivate); |
1621 | if (!err) | 596 | if (!err) |
@@ -1649,9 +624,39 @@ static int ael2020_get_module_type(struct cphy *phy, int delay_ms) | |||
1649 | */ | 624 | */ |
1650 | static int ael2020_intr_enable(struct cphy *phy) | 625 | static int ael2020_intr_enable(struct cphy *phy) |
1651 | { | 626 | { |
1652 | int err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL2020_GPIO_CTRL, | 627 | struct reg_val regs[] = { |
1653 | 0x2 << (AEL2020_GPIO_MODDET*4)); | 628 | /* output Module's Loss Of Signal (LOS) to LED */ |
1654 | return err ? err : t3_phy_lasi_intr_enable(phy); | 629 | { MDIO_MMD_PMAPMD, AEL2020_GPIO_CFG+AEL2020_GPIO_LSTAT, |
630 | 0xffff, 0x4 }, | ||
631 | { MDIO_MMD_PMAPMD, AEL2020_GPIO_CTRL, | ||
632 | 0xffff, 0x8 << (AEL2020_GPIO_LSTAT*4) }, | ||
633 | |||
634 | /* enable module detect status change interrupts */ | ||
635 | { MDIO_MMD_PMAPMD, AEL2020_GPIO_CTRL, | ||
636 | 0xffff, 0x2 << (AEL2020_GPIO_MODDET*4) }, | ||
637 | |||
638 | /* end */ | ||
639 | { 0, 0, 0, 0 } | ||
640 | }; | ||
641 | int err, link_ok = 0; | ||
642 | |||
643 | /* set up "link status" LED and enable module change interrupts */ | ||
644 | err = set_phy_regs(phy, regs); | ||
645 | if (err) | ||
646 | return err; | ||
647 | |||
648 | err = get_link_status_r(phy, &link_ok, NULL, NULL, NULL); | ||
649 | if (err) | ||
650 | return err; | ||
651 | if (link_ok) | ||
652 | t3_link_changed(phy->adapter, | ||
653 | phy2portid(phy)); | ||
654 | |||
655 | err = t3_phy_lasi_intr_enable(phy); | ||
656 | if (err) | ||
657 | return err; | ||
658 | |||
659 | return 0; | ||
1655 | } | 660 | } |
1656 | 661 | ||
1657 | /* | 662 | /* |
@@ -1659,9 +664,26 @@ static int ael2020_intr_enable(struct cphy *phy) | |||
1659 | */ | 664 | */ |
1660 | static int ael2020_intr_disable(struct cphy *phy) | 665 | static int ael2020_intr_disable(struct cphy *phy) |
1661 | { | 666 | { |
1662 | int err = t3_mdio_write(phy, MDIO_MMD_PMAPMD, AEL2020_GPIO_CTRL, | 667 | struct reg_val regs[] = { |
1663 | 0x1 << (AEL2020_GPIO_MODDET*4)); | 668 | /* reset "link status" LED to "off" */ |
1664 | return err ? err : t3_phy_lasi_intr_disable(phy); | 669 | { MDIO_MMD_PMAPMD, AEL2020_GPIO_CTRL, |
670 | 0xffff, 0xb << (AEL2020_GPIO_LSTAT*4) }, | ||
671 | |||
672 | /* disable module detect status change interrupts */ | ||
673 | { MDIO_MMD_PMAPMD, AEL2020_GPIO_CTRL, | ||
674 | 0xffff, 0x1 << (AEL2020_GPIO_MODDET*4) }, | ||
675 | |||
676 | /* end */ | ||
677 | { 0, 0, 0, 0 } | ||
678 | }; | ||
679 | int err; | ||
680 | |||
681 | /* turn off "link status" LED and disable module change interrupts */ | ||
682 | err = set_phy_regs(phy, regs); | ||
683 | if (err) | ||
684 | return err; | ||
685 | |||
686 | return t3_phy_lasi_intr_disable(phy); | ||
1665 | } | 687 | } |
1666 | 688 | ||
1667 | /* | 689 | /* |
@@ -1679,31 +701,26 @@ static int ael2020_intr_clear(struct cphy *phy) | |||
1679 | return err ? err : t3_phy_lasi_intr_clear(phy); | 701 | return err ? err : t3_phy_lasi_intr_clear(phy); |
1680 | } | 702 | } |
1681 | 703 | ||
704 | static struct reg_val ael2020_reset_regs[] = { | ||
705 | /* Erratum #2: CDRLOL asserted, causing PMA link down status */ | ||
706 | { MDIO_MMD_PMAPMD, 0xc003, 0xffff, 0x3101 }, | ||
707 | |||
708 | /* force XAUI to send LF when RX_LOS is asserted */ | ||
709 | { MDIO_MMD_PMAPMD, 0xcd40, 0xffff, 0x0001 }, | ||
710 | |||
711 | /* allow writes to transceiver module EEPROM on i2c bus */ | ||
712 | { MDIO_MMD_PMAPMD, 0xff02, 0xffff, 0x0023 }, | ||
713 | { MDIO_MMD_PMAPMD, 0xff03, 0xffff, 0x0000 }, | ||
714 | { MDIO_MMD_PMAPMD, 0xff04, 0xffff, 0x0000 }, | ||
715 | |||
716 | /* end */ | ||
717 | { 0, 0, 0, 0 } | ||
718 | }; | ||
1682 | /* | 719 | /* |
1683 | * Reset the PHY and put it into a canonical operating state. | 720 | * Reset the PHY and put it into a canonical operating state. |
1684 | */ | 721 | */ |
1685 | static int ael2020_reset(struct cphy *phy, int wait) | 722 | static int ael2020_reset(struct cphy *phy, int wait) |
1686 | { | 723 | { |
1687 | static struct reg_val regs0[] = { | ||
1688 | /* Erratum #2: CDRLOL asserted, causing PMA link down status */ | ||
1689 | { MDIO_MMD_PMAPMD, 0xc003, 0xffff, 0x3101 }, | ||
1690 | |||
1691 | /* force XAUI to send LF when RX_LOS is asserted */ | ||
1692 | { MDIO_MMD_PMAPMD, 0xcd40, 0xffff, 0x0001 }, | ||
1693 | |||
1694 | /* RX_LOS pin is active high */ | ||
1695 | { MDIO_MMD_PMAPMD, AEL_OPT_SETTINGS, | ||
1696 | 0x0020, 0x0020 }, | ||
1697 | |||
1698 | /* output Module's Loss Of Signal (LOS) to LED */ | ||
1699 | { MDIO_MMD_PMAPMD, AEL2020_GPIO_CFG+AEL2020_GPIO_LSTAT, | ||
1700 | 0xffff, 0x0004 }, | ||
1701 | { MDIO_MMD_PMAPMD, AEL2020_GPIO_CTRL, | ||
1702 | 0xffff, 0x8 << (AEL2020_GPIO_LSTAT*4) }, | ||
1703 | |||
1704 | /* end */ | ||
1705 | { 0, 0, 0, 0 } | ||
1706 | }; | ||
1707 | int err; | 724 | int err; |
1708 | unsigned int lasi_ctrl; | 725 | unsigned int lasi_ctrl; |
1709 | 726 | ||
@@ -1720,7 +737,7 @@ static int ael2020_reset(struct cphy *phy, int wait) | |||
1720 | 737 | ||
1721 | /* basic initialization for all module types */ | 738 | /* basic initialization for all module types */ |
1722 | phy->priv = edc_none; | 739 | phy->priv = edc_none; |
1723 | err = set_phy_regs(phy, regs0); | 740 | err = set_phy_regs(phy, ael2020_reset_regs); |
1724 | if (err) | 741 | if (err) |
1725 | return err; | 742 | return err; |
1726 | 743 | ||
@@ -1798,10 +815,16 @@ static struct cphy_ops ael2020_ops = { | |||
1798 | int t3_ael2020_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr, | 815 | int t3_ael2020_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr, |
1799 | const struct mdio_ops *mdio_ops) | 816 | const struct mdio_ops *mdio_ops) |
1800 | { | 817 | { |
818 | int err; | ||
819 | |||
1801 | cphy_init(phy, adapter, phy_addr, &ael2020_ops, mdio_ops, | 820 | cphy_init(phy, adapter, phy_addr, &ael2020_ops, mdio_ops, |
1802 | SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE | | 821 | SUPPORTED_10000baseT_Full | SUPPORTED_AUI | SUPPORTED_FIBRE | |
1803 | SUPPORTED_IRQ, "10GBASE-R"); | 822 | SUPPORTED_IRQ, "10GBASE-R"); |
1804 | msleep(125); | 823 | msleep(125); |
824 | |||
825 | err = set_phy_regs(phy, ael2020_reset_regs); | ||
826 | if (err) | ||
827 | return err; | ||
1805 | return 0; | 828 | return 0; |
1806 | } | 829 | } |
1807 | 830 | ||
@@ -1840,7 +863,7 @@ static struct cphy_ops qt2045_ops = { | |||
1840 | .intr_clear = t3_phy_lasi_intr_clear, | 863 | .intr_clear = t3_phy_lasi_intr_clear, |
1841 | .intr_handler = t3_phy_lasi_intr_handler, | 864 | .intr_handler = t3_phy_lasi_intr_handler, |
1842 | .get_link_status = get_link_status_x, | 865 | .get_link_status = get_link_status_x, |
1843 | .power_down = ael1006_power_down, | 866 | .power_down = ael1002_power_down, |
1844 | .mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS, | 867 | .mmds = MDIO_DEVS_PMAPMD | MDIO_DEVS_PCS | MDIO_DEVS_PHYXS, |
1845 | }; | 868 | }; |
1846 | 869 | ||
diff --git a/drivers/net/cxgb3/aq100x.c b/drivers/net/cxgb3/aq100x.c index b1fd5bf836e4..341b7ef1508f 100644 --- a/drivers/net/cxgb3/aq100x.c +++ b/drivers/net/cxgb3/aq100x.c | |||
@@ -271,7 +271,8 @@ int t3_aq100x_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr, | |||
271 | 271 | ||
272 | cphy_init(phy, adapter, phy_addr, &aq100x_ops, mdio_ops, | 272 | cphy_init(phy, adapter, phy_addr, &aq100x_ops, mdio_ops, |
273 | SUPPORTED_1000baseT_Full | SUPPORTED_10000baseT_Full | | 273 | SUPPORTED_1000baseT_Full | SUPPORTED_10000baseT_Full | |
274 | SUPPORTED_Autoneg | SUPPORTED_AUI, "1000/10GBASE-T"); | 274 | SUPPORTED_TP | SUPPORTED_Autoneg | SUPPORTED_AUI, |
275 | "1000/10GBASE-T"); | ||
275 | 276 | ||
276 | /* | 277 | /* |
277 | * The PHY has been out of reset ever since the system powered up. So | 278 | * The PHY has been out of reset ever since the system powered up. So |
@@ -316,11 +317,9 @@ int t3_aq100x_phy_prep(struct cphy *phy, struct adapter *adapter, int phy_addr, | |||
316 | 317 | ||
317 | /* Firmware version check. */ | 318 | /* Firmware version check. */ |
318 | t3_mdio_read(phy, MDIO_MMD_VEND1, AQ_FW_VERSION, &v); | 319 | t3_mdio_read(phy, MDIO_MMD_VEND1, AQ_FW_VERSION, &v); |
319 | if (v != 30) { | 320 | if (v != 101) |
320 | CH_WARN(adapter, "PHY%d: unsupported firmware %d\n", | 321 | CH_WARN(adapter, "PHY%d: unsupported firmware %d\n", |
321 | phy_addr, v); | 322 | phy_addr, v); |
322 | return 0; /* allow t3_prep_adapter to succeed */ | ||
323 | } | ||
324 | 323 | ||
325 | /* | 324 | /* |
326 | * The PHY should start in really-low-power mode. Prepare it for normal | 325 | * The PHY should start in really-low-power mode. Prepare it for normal |
diff --git a/drivers/net/cxgb3/common.h b/drivers/net/cxgb3/common.h index d21b705501a9..1b2c305fb82b 100644 --- a/drivers/net/cxgb3/common.h +++ b/drivers/net/cxgb3/common.h | |||
@@ -566,6 +566,15 @@ struct cphy_ops { | |||
566 | 566 | ||
567 | u32 mmds; | 567 | u32 mmds; |
568 | }; | 568 | }; |
569 | enum { | ||
570 | EDC_OPT_AEL2005 = 0, | ||
571 | EDC_OPT_AEL2005_SIZE = 1084, | ||
572 | EDC_TWX_AEL2005 = 1, | ||
573 | EDC_TWX_AEL2005_SIZE = 1464, | ||
574 | EDC_TWX_AEL2020 = 2, | ||
575 | EDC_TWX_AEL2020_SIZE = 1628, | ||
576 | EDC_MAX_SIZE = EDC_TWX_AEL2020_SIZE, /* Max cache size */ | ||
577 | }; | ||
569 | 578 | ||
570 | /* A PHY instance */ | 579 | /* A PHY instance */ |
571 | struct cphy { | 580 | struct cphy { |
@@ -577,6 +586,7 @@ struct cphy { | |||
577 | unsigned long fifo_errors; /* FIFO over/under-flows */ | 586 | unsigned long fifo_errors; /* FIFO over/under-flows */ |
578 | const struct cphy_ops *ops; /* PHY operations */ | 587 | const struct cphy_ops *ops; /* PHY operations */ |
579 | struct mdio_if_info mdio; | 588 | struct mdio_if_info mdio; |
589 | u16 phy_cache[EDC_MAX_SIZE]; /* EDC cache */ | ||
580 | }; | 590 | }; |
581 | 591 | ||
582 | /* Convenience MDIO read/write wrappers */ | 592 | /* Convenience MDIO read/write wrappers */ |
diff --git a/drivers/net/cxgb3/cxgb3_main.c b/drivers/net/cxgb3/cxgb3_main.c index fb5df5c6203e..ec05149a9065 100644 --- a/drivers/net/cxgb3/cxgb3_main.c +++ b/drivers/net/cxgb3/cxgb3_main.c | |||
@@ -172,6 +172,23 @@ static void link_report(struct net_device *dev) | |||
172 | } | 172 | } |
173 | } | 173 | } |
174 | 174 | ||
175 | static void enable_tx_fifo_drain(struct adapter *adapter, | ||
176 | struct port_info *pi) | ||
177 | { | ||
178 | t3_set_reg_field(adapter, A_XGM_TXFIFO_CFG + pi->mac.offset, 0, | ||
179 | F_ENDROPPKT); | ||
180 | t3_write_reg(adapter, A_XGM_RX_CTRL + pi->mac.offset, 0); | ||
181 | t3_write_reg(adapter, A_XGM_TX_CTRL + pi->mac.offset, F_TXEN); | ||
182 | t3_write_reg(adapter, A_XGM_RX_CTRL + pi->mac.offset, F_RXEN); | ||
183 | } | ||
184 | |||
185 | static void disable_tx_fifo_drain(struct adapter *adapter, | ||
186 | struct port_info *pi) | ||
187 | { | ||
188 | t3_set_reg_field(adapter, A_XGM_TXFIFO_CFG + pi->mac.offset, | ||
189 | F_ENDROPPKT, 0); | ||
190 | } | ||
191 | |||
175 | void t3_os_link_fault(struct adapter *adap, int port_id, int state) | 192 | void t3_os_link_fault(struct adapter *adap, int port_id, int state) |
176 | { | 193 | { |
177 | struct net_device *dev = adap->port[port_id]; | 194 | struct net_device *dev = adap->port[port_id]; |
@@ -185,6 +202,8 @@ void t3_os_link_fault(struct adapter *adap, int port_id, int state) | |||
185 | 202 | ||
186 | netif_carrier_on(dev); | 203 | netif_carrier_on(dev); |
187 | 204 | ||
205 | disable_tx_fifo_drain(adap, pi); | ||
206 | |||
188 | /* Clear local faults */ | 207 | /* Clear local faults */ |
189 | t3_xgm_intr_disable(adap, pi->port_id); | 208 | t3_xgm_intr_disable(adap, pi->port_id); |
190 | t3_read_reg(adap, A_XGM_INT_STATUS + | 209 | t3_read_reg(adap, A_XGM_INT_STATUS + |
@@ -200,9 +219,12 @@ void t3_os_link_fault(struct adapter *adap, int port_id, int state) | |||
200 | t3_xgm_intr_enable(adap, pi->port_id); | 219 | t3_xgm_intr_enable(adap, pi->port_id); |
201 | 220 | ||
202 | t3_mac_enable(mac, MAC_DIRECTION_TX); | 221 | t3_mac_enable(mac, MAC_DIRECTION_TX); |
203 | } else | 222 | } else { |
204 | netif_carrier_off(dev); | 223 | netif_carrier_off(dev); |
205 | 224 | ||
225 | /* Flush TX FIFO */ | ||
226 | enable_tx_fifo_drain(adap, pi); | ||
227 | } | ||
206 | link_report(dev); | 228 | link_report(dev); |
207 | } | 229 | } |
208 | 230 | ||
@@ -232,6 +254,8 @@ void t3_os_link_changed(struct adapter *adapter, int port_id, int link_stat, | |||
232 | 254 | ||
233 | if (link_stat != netif_carrier_ok(dev)) { | 255 | if (link_stat != netif_carrier_ok(dev)) { |
234 | if (link_stat) { | 256 | if (link_stat) { |
257 | disable_tx_fifo_drain(adapter, pi); | ||
258 | |||
235 | t3_mac_enable(mac, MAC_DIRECTION_RX); | 259 | t3_mac_enable(mac, MAC_DIRECTION_RX); |
236 | 260 | ||
237 | /* Clear local faults */ | 261 | /* Clear local faults */ |
@@ -263,6 +287,9 @@ void t3_os_link_changed(struct adapter *adapter, int port_id, int link_stat, | |||
263 | t3_read_reg(adapter, A_XGM_INT_STATUS + pi->mac.offset); | 287 | t3_read_reg(adapter, A_XGM_INT_STATUS + pi->mac.offset); |
264 | t3_mac_disable(mac, MAC_DIRECTION_RX); | 288 | t3_mac_disable(mac, MAC_DIRECTION_RX); |
265 | t3_link_start(&pi->phy, mac, &pi->link_config); | 289 | t3_link_start(&pi->phy, mac, &pi->link_config); |
290 | |||
291 | /* Flush TX FIFO */ | ||
292 | enable_tx_fifo_drain(adapter, pi); | ||
266 | } | 293 | } |
267 | 294 | ||
268 | link_report(dev); | 295 | link_report(dev); |
@@ -443,6 +470,7 @@ static int init_tp_parity(struct adapter *adap) | |||
443 | memset(req, 0, sizeof(*req)); | 470 | memset(req, 0, sizeof(*req)); |
444 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); | 471 | req->wr.wr_hi = htonl(V_WR_OP(FW_WROPCODE_FORWARD)); |
445 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SMT_WRITE_REQ, i)); | 472 | OPCODE_TID(req) = htonl(MK_OPCODE_TID(CPL_SMT_WRITE_REQ, i)); |
473 | req->mtu_idx = NMTUS - 1; | ||
446 | req->iff = i; | 474 | req->iff = i; |
447 | t3_mgmt_tx(adap, skb); | 475 | t3_mgmt_tx(adap, skb); |
448 | if (skb == adap->nofail_skb) { | 476 | if (skb == adap->nofail_skb) { |
@@ -963,6 +991,75 @@ static int bind_qsets(struct adapter *adap) | |||
963 | 991 | ||
964 | #define FW_FNAME "cxgb3/t3fw-%d.%d.%d.bin" | 992 | #define FW_FNAME "cxgb3/t3fw-%d.%d.%d.bin" |
965 | #define TPSRAM_NAME "cxgb3/t3%c_psram-%d.%d.%d.bin" | 993 | #define TPSRAM_NAME "cxgb3/t3%c_psram-%d.%d.%d.bin" |
994 | #define AEL2005_OPT_EDC_NAME "cxgb3/ael2005_opt_edc.bin" | ||
995 | #define AEL2005_TWX_EDC_NAME "cxgb3/ael2005_twx_edc.bin" | ||
996 | #define AEL2020_TWX_EDC_NAME "cxgb3/ael2005_twx_edc.bin" | ||
997 | |||
998 | static inline const char *get_edc_fw_name(int edc_idx) | ||
999 | { | ||
1000 | const char *fw_name = NULL; | ||
1001 | |||
1002 | switch (edc_idx) { | ||
1003 | case EDC_OPT_AEL2005: | ||
1004 | fw_name = AEL2005_OPT_EDC_NAME; | ||
1005 | break; | ||
1006 | case EDC_TWX_AEL2005: | ||
1007 | fw_name = AEL2005_TWX_EDC_NAME; | ||
1008 | break; | ||
1009 | case EDC_TWX_AEL2020: | ||
1010 | fw_name = AEL2020_TWX_EDC_NAME; | ||
1011 | break; | ||
1012 | } | ||
1013 | return fw_name; | ||
1014 | } | ||
1015 | |||
1016 | int t3_get_edc_fw(struct cphy *phy, int edc_idx, int size) | ||
1017 | { | ||
1018 | struct adapter *adapter = phy->adapter; | ||
1019 | const struct firmware *fw; | ||
1020 | char buf[64]; | ||
1021 | u32 csum; | ||
1022 | const __be32 *p; | ||
1023 | u16 *cache = phy->phy_cache; | ||
1024 | int i, ret; | ||
1025 | |||
1026 | snprintf(buf, sizeof(buf), get_edc_fw_name(edc_idx)); | ||
1027 | |||
1028 | ret = request_firmware(&fw, buf, &adapter->pdev->dev); | ||
1029 | if (ret < 0) { | ||
1030 | dev_err(&adapter->pdev->dev, | ||
1031 | "could not upgrade firmware: unable to load %s\n", | ||
1032 | buf); | ||
1033 | return ret; | ||
1034 | } | ||
1035 | |||
1036 | /* check size, take checksum in account */ | ||
1037 | if (fw->size > size + 4) { | ||
1038 | CH_ERR(adapter, "firmware image too large %u, expected %d\n", | ||
1039 | (unsigned int)fw->size, size + 4); | ||
1040 | ret = -EINVAL; | ||
1041 | } | ||
1042 | |||
1043 | /* compute checksum */ | ||
1044 | p = (const __be32 *)fw->data; | ||
1045 | for (csum = 0, i = 0; i < fw->size / sizeof(csum); i++) | ||
1046 | csum += ntohl(p[i]); | ||
1047 | |||
1048 | if (csum != 0xffffffff) { | ||
1049 | CH_ERR(adapter, "corrupted firmware image, checksum %u\n", | ||
1050 | csum); | ||
1051 | ret = -EINVAL; | ||
1052 | } | ||
1053 | |||
1054 | for (i = 0; i < size / 4 ; i++) { | ||
1055 | *cache++ = (be32_to_cpu(p[i]) & 0xffff0000) >> 16; | ||
1056 | *cache++ = be32_to_cpu(p[i]) & 0xffff; | ||
1057 | } | ||
1058 | |||
1059 | release_firmware(fw); | ||
1060 | |||
1061 | return ret; | ||
1062 | } | ||
966 | 1063 | ||
967 | static int upgrade_fw(struct adapter *adap) | 1064 | static int upgrade_fw(struct adapter *adap) |
968 | { | 1065 | { |
diff --git a/drivers/net/cxgb3/t3_hw.c b/drivers/net/cxgb3/t3_hw.c index 870d44992c70..e78d341cbd60 100644 --- a/drivers/net/cxgb3/t3_hw.c +++ b/drivers/net/cxgb3/t3_hw.c | |||
@@ -3682,6 +3682,8 @@ static void mc7_prep(struct adapter *adapter, struct mc7 *mc7, | |||
3682 | void mac_prep(struct cmac *mac, struct adapter *adapter, int index) | 3682 | void mac_prep(struct cmac *mac, struct adapter *adapter, int index) |
3683 | { | 3683 | { |
3684 | mac->adapter = adapter; | 3684 | mac->adapter = adapter; |
3685 | if (!adapter->params.vpd.xauicfg[1]) | ||
3686 | index = 0; | ||
3685 | mac->offset = (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR) * index; | 3687 | mac->offset = (XGMAC0_1_BASE_ADDR - XGMAC0_0_BASE_ADDR) * index; |
3686 | mac->nucast = 1; | 3688 | mac->nucast = 1; |
3687 | 3689 | ||
diff --git a/drivers/net/cxgb3/xgmac.c b/drivers/net/cxgb3/xgmac.c index f87f9435049f..0109ee4f2f91 100644 --- a/drivers/net/cxgb3/xgmac.c +++ b/drivers/net/cxgb3/xgmac.c | |||
@@ -447,11 +447,12 @@ int t3_mac_set_speed_duplex_fc(struct cmac *mac, int speed, int duplex, int fc) | |||
447 | 447 | ||
448 | val = t3_read_reg(adap, A_XGM_RXFIFO_CFG + oft); | 448 | val = t3_read_reg(adap, A_XGM_RXFIFO_CFG + oft); |
449 | val &= ~V_RXFIFOPAUSEHWM(M_RXFIFOPAUSEHWM); | 449 | val &= ~V_RXFIFOPAUSEHWM(M_RXFIFOPAUSEHWM); |
450 | if (fc & PAUSE_TX) | 450 | if (fc & PAUSE_TX) { |
451 | val |= V_RXFIFOPAUSEHWM(rx_fifo_hwm( | 451 | u32 rx_max_pkt_size = |
452 | t3_read_reg(adap, | 452 | G_RXMAXPKTSIZE(t3_read_reg(adap, |
453 | A_XGM_RX_MAX_PKT_SIZE | 453 | A_XGM_RX_MAX_PKT_SIZE + oft)); |
454 | + oft)) / 8); | 454 | val |= V_RXFIFOPAUSEHWM(rx_fifo_hwm(rx_max_pkt_size) / 8); |
455 | } | ||
455 | t3_write_reg(adap, A_XGM_RXFIFO_CFG + oft, val); | 456 | t3_write_reg(adap, A_XGM_RXFIFO_CFG + oft, val); |
456 | 457 | ||
457 | t3_set_reg_field(adap, A_XGM_TX_CFG + oft, F_TXPAUSEEN, | 458 | t3_set_reg_field(adap, A_XGM_TX_CFG + oft, F_TXPAUSEEN, |
diff --git a/drivers/net/de600.c b/drivers/net/de600.c index e1af089064bc..6b13f4fd2e96 100644 --- a/drivers/net/de600.c +++ b/drivers/net/de600.c | |||
@@ -226,7 +226,7 @@ static int de600_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
226 | } | 226 | } |
227 | spin_unlock_irqrestore(&de600_lock, flags); | 227 | spin_unlock_irqrestore(&de600_lock, flags); |
228 | dev_kfree_skb(skb); | 228 | dev_kfree_skb(skb); |
229 | return 0; | 229 | return NETDEV_TX_OK; |
230 | } | 230 | } |
231 | 231 | ||
232 | /* | 232 | /* |
diff --git a/drivers/net/de620.c b/drivers/net/de620.c index 55d2bb67cffa..45794f6cb0f6 100644 --- a/drivers/net/de620.c +++ b/drivers/net/de620.c | |||
@@ -542,7 +542,7 @@ static int de620_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
542 | dev->stats.tx_packets++; | 542 | dev->stats.tx_packets++; |
543 | spin_unlock_irqrestore(&de620_lock, flags); | 543 | spin_unlock_irqrestore(&de620_lock, flags); |
544 | dev_kfree_skb (skb); | 544 | dev_kfree_skb (skb); |
545 | return 0; | 545 | return NETDEV_TX_OK; |
546 | } | 546 | } |
547 | 547 | ||
548 | /***************************************************** | 548 | /***************************************************** |
diff --git a/drivers/net/declance.c b/drivers/net/declance.c index 2b22e580c4de..a31696a3928e 100644 --- a/drivers/net/declance.c +++ b/drivers/net/declance.c | |||
@@ -902,7 +902,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
902 | 902 | ||
903 | if (len < ETH_ZLEN) { | 903 | if (len < ETH_ZLEN) { |
904 | if (skb_padto(skb, ETH_ZLEN)) | 904 | if (skb_padto(skb, ETH_ZLEN)) |
905 | return 0; | 905 | return NETDEV_TX_OK; |
906 | len = ETH_ZLEN; | 906 | len = ETH_ZLEN; |
907 | } | 907 | } |
908 | 908 | ||
@@ -933,7 +933,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
933 | dev->trans_start = jiffies; | 933 | dev->trans_start = jiffies; |
934 | dev_kfree_skb(skb); | 934 | dev_kfree_skb(skb); |
935 | 935 | ||
936 | return 0; | 936 | return NETDEV_TX_OK; |
937 | } | 937 | } |
938 | 938 | ||
939 | static void lance_load_multicast(struct net_device *dev) | 939 | static void lance_load_multicast(struct net_device *dev) |
diff --git a/drivers/net/defxx.c b/drivers/net/defxx.c index 102b8d439714..b2e0a8fc21d7 100644 --- a/drivers/net/defxx.c +++ b/drivers/net/defxx.c | |||
@@ -3218,7 +3218,7 @@ static int dfx_xmt_queue_pkt( | |||
3218 | bp->xmt_length_errors++; /* bump error counter */ | 3218 | bp->xmt_length_errors++; /* bump error counter */ |
3219 | netif_wake_queue(dev); | 3219 | netif_wake_queue(dev); |
3220 | dev_kfree_skb(skb); | 3220 | dev_kfree_skb(skb); |
3221 | return(0); /* return "success" */ | 3221 | return NETDEV_TX_OK; /* return "success" */ |
3222 | } | 3222 | } |
3223 | /* | 3223 | /* |
3224 | * See if adapter link is available, if not, free buffer | 3224 | * See if adapter link is available, if not, free buffer |
@@ -3241,7 +3241,7 @@ static int dfx_xmt_queue_pkt( | |||
3241 | bp->xmt_discards++; /* bump error counter */ | 3241 | bp->xmt_discards++; /* bump error counter */ |
3242 | dev_kfree_skb(skb); /* free sk_buff now */ | 3242 | dev_kfree_skb(skb); /* free sk_buff now */ |
3243 | netif_wake_queue(dev); | 3243 | netif_wake_queue(dev); |
3244 | return(0); /* return "success" */ | 3244 | return NETDEV_TX_OK; /* return "success" */ |
3245 | } | 3245 | } |
3246 | } | 3246 | } |
3247 | 3247 | ||
@@ -3345,7 +3345,7 @@ static int dfx_xmt_queue_pkt( | |||
3345 | dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword); | 3345 | dfx_port_write_long(bp, PI_PDQ_K_REG_TYPE_2_PROD, bp->rcv_xmt_reg.lword); |
3346 | spin_unlock_irqrestore(&bp->lock, flags); | 3346 | spin_unlock_irqrestore(&bp->lock, flags); |
3347 | netif_wake_queue(dev); | 3347 | netif_wake_queue(dev); |
3348 | return(0); /* packet queued to adapter */ | 3348 | return NETDEV_TX_OK; /* packet queued to adapter */ |
3349 | } | 3349 | } |
3350 | 3350 | ||
3351 | 3351 | ||
diff --git a/drivers/net/depca.c b/drivers/net/depca.c index 97ea2d6d3fe1..adb997c5bb5d 100644 --- a/drivers/net/depca.c +++ b/drivers/net/depca.c | |||
@@ -1793,7 +1793,7 @@ static int __init get_hw_addr(struct net_device *dev) | |||
1793 | static int load_packet(struct net_device *dev, struct sk_buff *skb) | 1793 | static int load_packet(struct net_device *dev, struct sk_buff *skb) |
1794 | { | 1794 | { |
1795 | struct depca_private *lp = netdev_priv(dev); | 1795 | struct depca_private *lp = netdev_priv(dev); |
1796 | int i, entry, end, len, status = 0; | 1796 | int i, entry, end, len, status = NETDEV_TX_OK; |
1797 | 1797 | ||
1798 | entry = lp->tx_new; /* Ring around buffer number. */ | 1798 | entry = lp->tx_new; /* Ring around buffer number. */ |
1799 | end = (entry + (skb->len - 1) / TX_BUFF_SZ) & lp->txRingMask; | 1799 | end = (entry + (skb->len - 1) / TX_BUFF_SZ) & lp->txRingMask; |
diff --git a/drivers/net/dm9000.c b/drivers/net/dm9000.c index dd771dea6ae6..8603806be898 100644 --- a/drivers/net/dm9000.c +++ b/drivers/net/dm9000.c | |||
@@ -92,6 +92,7 @@ typedef struct board_info { | |||
92 | u16 tx_pkt_cnt; | 92 | u16 tx_pkt_cnt; |
93 | u16 queue_pkt_len; | 93 | u16 queue_pkt_len; |
94 | u16 queue_start_addr; | 94 | u16 queue_start_addr; |
95 | u16 queue_ip_summed; | ||
95 | u16 dbug_cnt; | 96 | u16 dbug_cnt; |
96 | u8 io_mode; /* 0:word, 2:byte */ | 97 | u8 io_mode; /* 0:word, 2:byte */ |
97 | u8 phy_addr; | 98 | u8 phy_addr; |
@@ -124,6 +125,10 @@ typedef struct board_info { | |||
124 | 125 | ||
125 | struct mii_if_info mii; | 126 | struct mii_if_info mii; |
126 | u32 msg_enable; | 127 | u32 msg_enable; |
128 | |||
129 | int rx_csum; | ||
130 | int can_csum; | ||
131 | int ip_summed; | ||
127 | } board_info_t; | 132 | } board_info_t; |
128 | 133 | ||
129 | /* debug code */ | 134 | /* debug code */ |
@@ -460,6 +465,40 @@ static int dm9000_nway_reset(struct net_device *dev) | |||
460 | return mii_nway_restart(&dm->mii); | 465 | return mii_nway_restart(&dm->mii); |
461 | } | 466 | } |
462 | 467 | ||
468 | static uint32_t dm9000_get_rx_csum(struct net_device *dev) | ||
469 | { | ||
470 | board_info_t *dm = to_dm9000_board(dev); | ||
471 | return dm->rx_csum; | ||
472 | } | ||
473 | |||
474 | static int dm9000_set_rx_csum(struct net_device *dev, uint32_t data) | ||
475 | { | ||
476 | board_info_t *dm = to_dm9000_board(dev); | ||
477 | unsigned long flags; | ||
478 | |||
479 | if (dm->can_csum) { | ||
480 | dm->rx_csum = data; | ||
481 | |||
482 | spin_lock_irqsave(&dm->lock, flags); | ||
483 | iow(dm, DM9000_RCSR, dm->rx_csum ? RCSR_CSUM : 0); | ||
484 | spin_unlock_irqrestore(&dm->lock, flags); | ||
485 | |||
486 | return 0; | ||
487 | } | ||
488 | |||
489 | return -EOPNOTSUPP; | ||
490 | } | ||
491 | |||
492 | static int dm9000_set_tx_csum(struct net_device *dev, uint32_t data) | ||
493 | { | ||
494 | board_info_t *dm = to_dm9000_board(dev); | ||
495 | int ret = -EOPNOTSUPP; | ||
496 | |||
497 | if (dm->can_csum) | ||
498 | ret = ethtool_op_set_tx_csum(dev, data); | ||
499 | return ret; | ||
500 | } | ||
501 | |||
463 | static u32 dm9000_get_link(struct net_device *dev) | 502 | static u32 dm9000_get_link(struct net_device *dev) |
464 | { | 503 | { |
465 | board_info_t *dm = to_dm9000_board(dev); | 504 | board_info_t *dm = to_dm9000_board(dev); |
@@ -540,6 +579,10 @@ static const struct ethtool_ops dm9000_ethtool_ops = { | |||
540 | .get_eeprom_len = dm9000_get_eeprom_len, | 579 | .get_eeprom_len = dm9000_get_eeprom_len, |
541 | .get_eeprom = dm9000_get_eeprom, | 580 | .get_eeprom = dm9000_get_eeprom, |
542 | .set_eeprom = dm9000_set_eeprom, | 581 | .set_eeprom = dm9000_set_eeprom, |
582 | .get_rx_csum = dm9000_get_rx_csum, | ||
583 | .set_rx_csum = dm9000_set_rx_csum, | ||
584 | .get_tx_csum = ethtool_op_get_tx_csum, | ||
585 | .set_tx_csum = dm9000_set_tx_csum, | ||
543 | }; | 586 | }; |
544 | 587 | ||
545 | static void dm9000_show_carrier(board_info_t *db, | 588 | static void dm9000_show_carrier(board_info_t *db, |
@@ -685,6 +728,9 @@ dm9000_init_dm9000(struct net_device *dev) | |||
685 | /* I/O mode */ | 728 | /* I/O mode */ |
686 | db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */ | 729 | db->io_mode = ior(db, DM9000_ISR) >> 6; /* ISR bit7:6 keeps I/O mode */ |
687 | 730 | ||
731 | /* Checksum mode */ | ||
732 | dm9000_set_rx_csum(dev, db->rx_csum); | ||
733 | |||
688 | /* GPIO0 on pre-activate PHY */ | 734 | /* GPIO0 on pre-activate PHY */ |
689 | iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */ | 735 | iow(db, DM9000_GPR, 0); /* REG_1F bit0 activate phyxcer */ |
690 | iow(db, DM9000_GPCR, GPCR_GEP_CNTL); /* Let GPIO0 output */ | 736 | iow(db, DM9000_GPCR, GPCR_GEP_CNTL); /* Let GPIO0 output */ |
@@ -743,6 +789,29 @@ static void dm9000_timeout(struct net_device *dev) | |||
743 | spin_unlock_irqrestore(&db->lock, flags); | 789 | spin_unlock_irqrestore(&db->lock, flags); |
744 | } | 790 | } |
745 | 791 | ||
792 | static void dm9000_send_packet(struct net_device *dev, | ||
793 | int ip_summed, | ||
794 | u16 pkt_len) | ||
795 | { | ||
796 | board_info_t *dm = to_dm9000_board(dev); | ||
797 | |||
798 | /* The DM9000 is not smart enough to leave fragmented packets alone. */ | ||
799 | if (dm->ip_summed != ip_summed) { | ||
800 | if (ip_summed == CHECKSUM_NONE) | ||
801 | iow(dm, DM9000_TCCR, 0); | ||
802 | else | ||
803 | iow(dm, DM9000_TCCR, TCCR_IP | TCCR_UDP | TCCR_TCP); | ||
804 | dm->ip_summed = ip_summed; | ||
805 | } | ||
806 | |||
807 | /* Set TX length to DM9000 */ | ||
808 | iow(dm, DM9000_TXPLL, pkt_len); | ||
809 | iow(dm, DM9000_TXPLH, pkt_len >> 8); | ||
810 | |||
811 | /* Issue TX polling command */ | ||
812 | iow(dm, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */ | ||
813 | } | ||
814 | |||
746 | /* | 815 | /* |
747 | * Hardware start transmission. | 816 | * Hardware start transmission. |
748 | * Send a packet to media from the upper layer. | 817 | * Send a packet to media from the upper layer. |
@@ -769,17 +838,11 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
769 | db->tx_pkt_cnt++; | 838 | db->tx_pkt_cnt++; |
770 | /* TX control: First packet immediately send, second packet queue */ | 839 | /* TX control: First packet immediately send, second packet queue */ |
771 | if (db->tx_pkt_cnt == 1) { | 840 | if (db->tx_pkt_cnt == 1) { |
772 | /* Set TX length to DM9000 */ | 841 | dm9000_send_packet(dev, skb->ip_summed, skb->len); |
773 | iow(db, DM9000_TXPLL, skb->len); | ||
774 | iow(db, DM9000_TXPLH, skb->len >> 8); | ||
775 | |||
776 | /* Issue TX polling command */ | ||
777 | iow(db, DM9000_TCR, TCR_TXREQ); /* Cleared after TX complete */ | ||
778 | |||
779 | dev->trans_start = jiffies; /* save the time stamp */ | ||
780 | } else { | 842 | } else { |
781 | /* Second packet */ | 843 | /* Second packet */ |
782 | db->queue_pkt_len = skb->len; | 844 | db->queue_pkt_len = skb->len; |
845 | db->queue_ip_summed = skb->ip_summed; | ||
783 | netif_stop_queue(dev); | 846 | netif_stop_queue(dev); |
784 | } | 847 | } |
785 | 848 | ||
@@ -788,7 +851,7 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
788 | /* free this SKB */ | 851 | /* free this SKB */ |
789 | dev_kfree_skb(skb); | 852 | dev_kfree_skb(skb); |
790 | 853 | ||
791 | return 0; | 854 | return NETDEV_TX_OK; |
792 | } | 855 | } |
793 | 856 | ||
794 | /* | 857 | /* |
@@ -809,12 +872,9 @@ static void dm9000_tx_done(struct net_device *dev, board_info_t *db) | |||
809 | dev_dbg(db->dev, "tx done, NSR %02x\n", tx_status); | 872 | dev_dbg(db->dev, "tx done, NSR %02x\n", tx_status); |
810 | 873 | ||
811 | /* Queue packet check & send */ | 874 | /* Queue packet check & send */ |
812 | if (db->tx_pkt_cnt > 0) { | 875 | if (db->tx_pkt_cnt > 0) |
813 | iow(db, DM9000_TXPLL, db->queue_pkt_len); | 876 | dm9000_send_packet(dev, db->queue_ip_summed, |
814 | iow(db, DM9000_TXPLH, db->queue_pkt_len >> 8); | 877 | db->queue_pkt_len); |
815 | iow(db, DM9000_TCR, TCR_TXREQ); | ||
816 | dev->trans_start = jiffies; | ||
817 | } | ||
818 | netif_wake_queue(dev); | 878 | netif_wake_queue(dev); |
819 | } | 879 | } |
820 | } | 880 | } |
@@ -846,14 +906,14 @@ dm9000_rx(struct net_device *dev) | |||
846 | rxbyte = readb(db->io_data); | 906 | rxbyte = readb(db->io_data); |
847 | 907 | ||
848 | /* Status check: this byte must be 0 or 1 */ | 908 | /* Status check: this byte must be 0 or 1 */ |
849 | if (rxbyte > DM9000_PKT_RDY) { | 909 | if (rxbyte & DM9000_PKT_ERR) { |
850 | dev_warn(db->dev, "status check fail: %d\n", rxbyte); | 910 | dev_warn(db->dev, "status check fail: %d\n", rxbyte); |
851 | iow(db, DM9000_RCR, 0x00); /* Stop Device */ | 911 | iow(db, DM9000_RCR, 0x00); /* Stop Device */ |
852 | iow(db, DM9000_ISR, IMR_PAR); /* Stop INT request */ | 912 | iow(db, DM9000_ISR, IMR_PAR); /* Stop INT request */ |
853 | return; | 913 | return; |
854 | } | 914 | } |
855 | 915 | ||
856 | if (rxbyte != DM9000_PKT_RDY) | 916 | if (!(rxbyte & DM9000_PKT_RDY)) |
857 | return; | 917 | return; |
858 | 918 | ||
859 | /* A packet ready now & Get status/length */ | 919 | /* A packet ready now & Get status/length */ |
@@ -914,6 +974,12 @@ dm9000_rx(struct net_device *dev) | |||
914 | 974 | ||
915 | /* Pass to upper layer */ | 975 | /* Pass to upper layer */ |
916 | skb->protocol = eth_type_trans(skb, dev); | 976 | skb->protocol = eth_type_trans(skb, dev); |
977 | if (db->rx_csum) { | ||
978 | if ((((rxbyte & 0x1c) << 3) & rxbyte) == 0) | ||
979 | skb->ip_summed = CHECKSUM_UNNECESSARY; | ||
980 | else | ||
981 | skb->ip_summed = CHECKSUM_NONE; | ||
982 | } | ||
917 | netif_rx(skb); | 983 | netif_rx(skb); |
918 | dev->stats.rx_packets++; | 984 | dev->stats.rx_packets++; |
919 | 985 | ||
@@ -922,7 +988,7 @@ dm9000_rx(struct net_device *dev) | |||
922 | 988 | ||
923 | (db->dumpblk)(db->io_data, RxLen); | 989 | (db->dumpblk)(db->io_data, RxLen); |
924 | } | 990 | } |
925 | } while (rxbyte == DM9000_PKT_RDY); | 991 | } while (rxbyte & DM9000_PKT_RDY); |
926 | } | 992 | } |
927 | 993 | ||
928 | static irqreturn_t dm9000_interrupt(int irq, void *dev_id) | 994 | static irqreturn_t dm9000_interrupt(int irq, void *dev_id) |
@@ -1349,6 +1415,13 @@ dm9000_probe(struct platform_device *pdev) | |||
1349 | db->type = TYPE_DM9000E; | 1415 | db->type = TYPE_DM9000E; |
1350 | } | 1416 | } |
1351 | 1417 | ||
1418 | /* dm9000a/b are capable of hardware checksum offload */ | ||
1419 | if (db->type == TYPE_DM9000A || db->type == TYPE_DM9000B) { | ||
1420 | db->can_csum = 1; | ||
1421 | db->rx_csum = 1; | ||
1422 | ndev->features |= NETIF_F_IP_CSUM; | ||
1423 | } | ||
1424 | |||
1352 | /* from this point we assume that we have found a DM9000 */ | 1425 | /* from this point we assume that we have found a DM9000 */ |
1353 | 1426 | ||
1354 | /* driver system function */ | 1427 | /* driver system function */ |
diff --git a/drivers/net/dm9000.h b/drivers/net/dm9000.h index ba25cf541420..80817c2edfb3 100644 --- a/drivers/net/dm9000.h +++ b/drivers/net/dm9000.h | |||
@@ -45,6 +45,10 @@ | |||
45 | #define DM9000_CHIPR 0x2C | 45 | #define DM9000_CHIPR 0x2C |
46 | #define DM9000_SMCR 0x2F | 46 | #define DM9000_SMCR 0x2F |
47 | 47 | ||
48 | #define DM9000_ETXCSR 0x30 | ||
49 | #define DM9000_TCCR 0x31 | ||
50 | #define DM9000_RCSR 0x32 | ||
51 | |||
48 | #define CHIPR_DM9000A 0x19 | 52 | #define CHIPR_DM9000A 0x19 |
49 | #define CHIPR_DM9000B 0x1B | 53 | #define CHIPR_DM9000B 0x1B |
50 | 54 | ||
@@ -131,7 +135,21 @@ | |||
131 | 135 | ||
132 | #define GPCR_GEP_CNTL (1<<0) | 136 | #define GPCR_GEP_CNTL (1<<0) |
133 | 137 | ||
138 | #define TCCR_IP (1<<0) | ||
139 | #define TCCR_TCP (1<<1) | ||
140 | #define TCCR_UDP (1<<2) | ||
141 | |||
142 | #define RCSR_UDP_BAD (1<<7) | ||
143 | #define RCSR_TCP_BAD (1<<6) | ||
144 | #define RCSR_IP_BAD (1<<5) | ||
145 | #define RCSR_UDP (1<<4) | ||
146 | #define RCSR_TCP (1<<3) | ||
147 | #define RCSR_IP (1<<2) | ||
148 | #define RCSR_CSUM (1<<1) | ||
149 | #define RCSR_DISCARD (1<<0) | ||
150 | |||
134 | #define DM9000_PKT_RDY 0x01 /* Packet ready to receive */ | 151 | #define DM9000_PKT_RDY 0x01 /* Packet ready to receive */ |
152 | #define DM9000_PKT_ERR 0x02 | ||
135 | #define DM9000_PKT_MAX 1536 /* Received packet max size */ | 153 | #define DM9000_PKT_MAX 1536 /* Received packet max size */ |
136 | 154 | ||
137 | /* DM9000A / DM9000B definitions */ | 155 | /* DM9000A / DM9000B definitions */ |
diff --git a/drivers/net/dnet.c b/drivers/net/dnet.c index 33fa9eee4cac..2818d5de3940 100644 --- a/drivers/net/dnet.c +++ b/drivers/net/dnet.c | |||
@@ -596,7 +596,7 @@ static int dnet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
596 | 596 | ||
597 | dev->trans_start = jiffies; | 597 | dev->trans_start = jiffies; |
598 | 598 | ||
599 | return 0; | 599 | return NETDEV_TX_OK; |
600 | } | 600 | } |
601 | 601 | ||
602 | static void dnet_reset_hw(struct dnet *bp) | 602 | static void dnet_reset_hw(struct dnet *bp) |
diff --git a/drivers/net/dummy.c b/drivers/net/dummy.c index 8ebd7d789405..713ce6c532c5 100644 --- a/drivers/net/dummy.c +++ b/drivers/net/dummy.c | |||
@@ -85,7 +85,7 @@ static int dummy_xmit(struct sk_buff *skb, struct net_device *dev) | |||
85 | dev->stats.tx_bytes += skb->len; | 85 | dev->stats.tx_bytes += skb->len; |
86 | 86 | ||
87 | dev_kfree_skb(skb); | 87 | dev_kfree_skb(skb); |
88 | return 0; | 88 | return NETDEV_TX_OK; |
89 | } | 89 | } |
90 | 90 | ||
91 | static int dummy_validate(struct nlattr *tb[], struct nlattr *data[]) | 91 | static int dummy_validate(struct nlattr *tb[], struct nlattr *data[]) |
diff --git a/drivers/net/e100.c b/drivers/net/e100.c index 41b648a67fec..569df19f0df5 100644 --- a/drivers/net/e100.c +++ b/drivers/net/e100.c | |||
@@ -1720,7 +1720,7 @@ static int e100_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1720 | } | 1720 | } |
1721 | 1721 | ||
1722 | netdev->trans_start = jiffies; | 1722 | netdev->trans_start = jiffies; |
1723 | return 0; | 1723 | return NETDEV_TX_OK; |
1724 | } | 1724 | } |
1725 | 1725 | ||
1726 | static int e100_tx_clean(struct nic *nic) | 1726 | static int e100_tx_clean(struct nic *nic) |
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h index e9a416f40162..1a4f89c66a26 100644 --- a/drivers/net/e1000/e1000.h +++ b/drivers/net/e1000/e1000.h | |||
@@ -111,6 +111,9 @@ do { \ | |||
111 | #define E1000_MIN_RXD 80 | 111 | #define E1000_MIN_RXD 80 |
112 | #define E1000_MAX_82544_RXD 4096 | 112 | #define E1000_MAX_82544_RXD 4096 |
113 | 113 | ||
114 | #define E1000_MIN_ITR_USECS 10 /* 100000 irq/sec */ | ||
115 | #define E1000_MAX_ITR_USECS 10000 /* 100 irq/sec */ | ||
116 | |||
114 | /* this is the size past which hardware will drop packets when setting LPE=0 */ | 117 | /* this is the size past which hardware will drop packets when setting LPE=0 */ |
115 | #define MAXIMUM_ETHERNET_VLAN_SIZE 1522 | 118 | #define MAXIMUM_ETHERNET_VLAN_SIZE 1522 |
116 | 119 | ||
@@ -137,7 +140,7 @@ do { \ | |||
137 | #define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */ | 140 | #define E1000_FC_HIGH_DIFF 0x1638 /* High: 5688 bytes below Rx FIFO size */ |
138 | #define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */ | 141 | #define E1000_FC_LOW_DIFF 0x1640 /* Low: 5696 bytes below Rx FIFO size */ |
139 | 142 | ||
140 | #define E1000_FC_PAUSE_TIME 0x0680 /* 858 usec */ | 143 | #define E1000_FC_PAUSE_TIME 0xFFFF /* pause for the max or until send xon */ |
141 | 144 | ||
142 | /* How many Tx Descriptors do we need to call netif_wake_queue ? */ | 145 | /* How many Tx Descriptors do we need to call netif_wake_queue ? */ |
143 | #define E1000_TX_QUEUE_WAKE 16 | 146 | #define E1000_TX_QUEUE_WAKE 16 |
@@ -161,6 +164,7 @@ do { \ | |||
161 | struct e1000_buffer { | 164 | struct e1000_buffer { |
162 | struct sk_buff *skb; | 165 | struct sk_buff *skb; |
163 | dma_addr_t dma; | 166 | dma_addr_t dma; |
167 | struct page *page; | ||
164 | unsigned long time_stamp; | 168 | unsigned long time_stamp; |
165 | u16 length; | 169 | u16 length; |
166 | u16 next_to_watch; | 170 | u16 next_to_watch; |
@@ -202,6 +206,7 @@ struct e1000_rx_ring { | |||
202 | unsigned int next_to_clean; | 206 | unsigned int next_to_clean; |
203 | /* array of buffer information structs */ | 207 | /* array of buffer information structs */ |
204 | struct e1000_buffer *buffer_info; | 208 | struct e1000_buffer *buffer_info; |
209 | struct sk_buff *rx_skb_top; | ||
205 | 210 | ||
206 | /* cpu for rx queue */ | 211 | /* cpu for rx queue */ |
207 | int cpu; | 212 | int cpu; |
diff --git a/drivers/net/e1000/e1000_ethtool.c b/drivers/net/e1000/e1000_ethtool.c index c854c96f5ab3..27f996a2010f 100644 --- a/drivers/net/e1000/e1000_ethtool.c +++ b/drivers/net/e1000/e1000_ethtool.c | |||
@@ -1904,6 +1904,53 @@ static int e1000_phys_id(struct net_device *netdev, u32 data) | |||
1904 | return 0; | 1904 | return 0; |
1905 | } | 1905 | } |
1906 | 1906 | ||
1907 | static int e1000_get_coalesce(struct net_device *netdev, | ||
1908 | struct ethtool_coalesce *ec) | ||
1909 | { | ||
1910 | struct e1000_adapter *adapter = netdev_priv(netdev); | ||
1911 | |||
1912 | if (adapter->hw.mac_type < e1000_82545) | ||
1913 | return -EOPNOTSUPP; | ||
1914 | |||
1915 | if (adapter->itr_setting <= 3) | ||
1916 | ec->rx_coalesce_usecs = adapter->itr_setting; | ||
1917 | else | ||
1918 | ec->rx_coalesce_usecs = 1000000 / adapter->itr_setting; | ||
1919 | |||
1920 | return 0; | ||
1921 | } | ||
1922 | |||
1923 | static int e1000_set_coalesce(struct net_device *netdev, | ||
1924 | struct ethtool_coalesce *ec) | ||
1925 | { | ||
1926 | struct e1000_adapter *adapter = netdev_priv(netdev); | ||
1927 | struct e1000_hw *hw = &adapter->hw; | ||
1928 | |||
1929 | if (hw->mac_type < e1000_82545) | ||
1930 | return -EOPNOTSUPP; | ||
1931 | |||
1932 | if ((ec->rx_coalesce_usecs > E1000_MAX_ITR_USECS) || | ||
1933 | ((ec->rx_coalesce_usecs > 3) && | ||
1934 | (ec->rx_coalesce_usecs < E1000_MIN_ITR_USECS)) || | ||
1935 | (ec->rx_coalesce_usecs == 2)) | ||
1936 | return -EINVAL; | ||
1937 | |||
1938 | if (ec->rx_coalesce_usecs <= 3) { | ||
1939 | adapter->itr = 20000; | ||
1940 | adapter->itr_setting = ec->rx_coalesce_usecs; | ||
1941 | } else { | ||
1942 | adapter->itr = (1000000 / ec->rx_coalesce_usecs); | ||
1943 | adapter->itr_setting = adapter->itr & ~3; | ||
1944 | } | ||
1945 | |||
1946 | if (adapter->itr_setting != 0) | ||
1947 | ew32(ITR, 1000000000 / (adapter->itr * 256)); | ||
1948 | else | ||
1949 | ew32(ITR, 0); | ||
1950 | |||
1951 | return 0; | ||
1952 | } | ||
1953 | |||
1907 | static int e1000_nway_reset(struct net_device *netdev) | 1954 | static int e1000_nway_reset(struct net_device *netdev) |
1908 | { | 1955 | { |
1909 | struct e1000_adapter *adapter = netdev_priv(netdev); | 1956 | struct e1000_adapter *adapter = netdev_priv(netdev); |
@@ -1978,7 +2025,9 @@ static const struct ethtool_ops e1000_ethtool_ops = { | |||
1978 | .get_strings = e1000_get_strings, | 2025 | .get_strings = e1000_get_strings, |
1979 | .phys_id = e1000_phys_id, | 2026 | .phys_id = e1000_phys_id, |
1980 | .get_ethtool_stats = e1000_get_ethtool_stats, | 2027 | .get_ethtool_stats = e1000_get_ethtool_stats, |
1981 | .get_sset_count = e1000_get_sset_count, | 2028 | .get_sset_count = e1000_get_sset_count, |
2029 | .get_coalesce = e1000_get_coalesce, | ||
2030 | .set_coalesce = e1000_set_coalesce, | ||
1982 | }; | 2031 | }; |
1983 | 2032 | ||
1984 | void e1000_set_ethtool_ops(struct net_device *netdev) | 2033 | void e1000_set_ethtool_ops(struct net_device *netdev) |
diff --git a/drivers/net/e1000/e1000_hw.c b/drivers/net/e1000/e1000_hw.c index e1a3fc1303ee..1e5ae112d57a 100644 --- a/drivers/net/e1000/e1000_hw.c +++ b/drivers/net/e1000/e1000_hw.c | |||
@@ -1955,7 +1955,7 @@ static s32 e1000_setup_copper_link(struct e1000_hw *hw) | |||
1955 | s32 ret_val; | 1955 | s32 ret_val; |
1956 | u16 i; | 1956 | u16 i; |
1957 | u16 phy_data; | 1957 | u16 phy_data; |
1958 | u16 reg_data; | 1958 | u16 reg_data = 0; |
1959 | 1959 | ||
1960 | DEBUGFUNC("e1000_setup_copper_link"); | 1960 | DEBUGFUNC("e1000_setup_copper_link"); |
1961 | 1961 | ||
diff --git a/drivers/net/e1000/e1000_hw.h b/drivers/net/e1000/e1000_hw.h index 99fce2c5dd26..a8866bdbb671 100644 --- a/drivers/net/e1000/e1000_hw.h +++ b/drivers/net/e1000/e1000_hw.h | |||
@@ -523,11 +523,8 @@ s32 e1000_check_phy_reset_block(struct e1000_hw *hw); | |||
523 | 523 | ||
524 | /* The sizes (in bytes) of a ethernet packet */ | 524 | /* The sizes (in bytes) of a ethernet packet */ |
525 | #define ENET_HEADER_SIZE 14 | 525 | #define ENET_HEADER_SIZE 14 |
526 | #define MAXIMUM_ETHERNET_FRAME_SIZE 1518 /* With FCS */ | ||
527 | #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ | 526 | #define MINIMUM_ETHERNET_FRAME_SIZE 64 /* With FCS */ |
528 | #define ETHERNET_FCS_SIZE 4 | 527 | #define ETHERNET_FCS_SIZE 4 |
529 | #define MAXIMUM_ETHERNET_PACKET_SIZE \ | ||
530 | (MAXIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE) | ||
531 | #define MINIMUM_ETHERNET_PACKET_SIZE \ | 528 | #define MINIMUM_ETHERNET_PACKET_SIZE \ |
532 | (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE) | 529 | (MINIMUM_ETHERNET_FRAME_SIZE - ETHERNET_FCS_SIZE) |
533 | #define CRC_LENGTH ETHERNET_FCS_SIZE | 530 | #define CRC_LENGTH ETHERNET_FCS_SIZE |
diff --git a/drivers/net/e1000/e1000_main.c b/drivers/net/e1000/e1000_main.c index 5b8cbdb4b520..d7df00c2dbd6 100644 --- a/drivers/net/e1000/e1000_main.c +++ b/drivers/net/e1000/e1000_main.c | |||
@@ -137,9 +137,15 @@ static int e1000_clean(struct napi_struct *napi, int budget); | |||
137 | static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | 137 | static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, |
138 | struct e1000_rx_ring *rx_ring, | 138 | struct e1000_rx_ring *rx_ring, |
139 | int *work_done, int work_to_do); | 139 | int *work_done, int work_to_do); |
140 | static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, | ||
141 | struct e1000_rx_ring *rx_ring, | ||
142 | int *work_done, int work_to_do); | ||
140 | static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, | 143 | static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, |
141 | struct e1000_rx_ring *rx_ring, | 144 | struct e1000_rx_ring *rx_ring, |
142 | int cleaned_count); | 145 | int cleaned_count); |
146 | static void e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, | ||
147 | struct e1000_rx_ring *rx_ring, | ||
148 | int cleaned_count); | ||
143 | static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); | 149 | static int e1000_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd); |
144 | static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, | 150 | static int e1000_mii_ioctl(struct net_device *netdev, struct ifreq *ifr, |
145 | int cmd); | 151 | int cmd); |
@@ -635,8 +641,8 @@ void e1000_reset(struct e1000_adapter *adapter) | |||
635 | { | 641 | { |
636 | struct e1000_hw *hw = &adapter->hw; | 642 | struct e1000_hw *hw = &adapter->hw; |
637 | u32 pba = 0, tx_space, min_tx_space, min_rx_space; | 643 | u32 pba = 0, tx_space, min_tx_space, min_rx_space; |
638 | u16 fc_high_water_mark = E1000_FC_HIGH_DIFF; | ||
639 | bool legacy_pba_adjust = false; | 644 | bool legacy_pba_adjust = false; |
645 | u16 hwm; | ||
640 | 646 | ||
641 | /* Repartition Pba for greater than 9k mtu | 647 | /* Repartition Pba for greater than 9k mtu |
642 | * To take effect CTRL.RST is required. | 648 | * To take effect CTRL.RST is required. |
@@ -680,7 +686,7 @@ void e1000_reset(struct e1000_adapter *adapter) | |||
680 | } | 686 | } |
681 | 687 | ||
682 | if (legacy_pba_adjust) { | 688 | if (legacy_pba_adjust) { |
683 | if (adapter->netdev->mtu > E1000_RXBUFFER_8192) | 689 | if (hw->max_frame_size > E1000_RXBUFFER_8192) |
684 | pba -= 8; /* allocate more FIFO for Tx */ | 690 | pba -= 8; /* allocate more FIFO for Tx */ |
685 | 691 | ||
686 | if (hw->mac_type == e1000_82547) { | 692 | if (hw->mac_type == e1000_82547) { |
@@ -690,14 +696,14 @@ void e1000_reset(struct e1000_adapter *adapter) | |||
690 | (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT; | 696 | (E1000_PBA_40K - pba) << E1000_PBA_BYTES_SHIFT; |
691 | atomic_set(&adapter->tx_fifo_stall, 0); | 697 | atomic_set(&adapter->tx_fifo_stall, 0); |
692 | } | 698 | } |
693 | } else if (hw->max_frame_size > MAXIMUM_ETHERNET_FRAME_SIZE) { | 699 | } else if (hw->max_frame_size > ETH_FRAME_LEN + ETH_FCS_LEN) { |
694 | /* adjust PBA for jumbo frames */ | 700 | /* adjust PBA for jumbo frames */ |
695 | ew32(PBA, pba); | 701 | ew32(PBA, pba); |
696 | 702 | ||
697 | /* To maintain wire speed transmits, the Tx FIFO should be | 703 | /* To maintain wire speed transmits, the Tx FIFO should be |
698 | * large enough to accomodate two full transmit packets, | 704 | * large enough to accommodate two full transmit packets, |
699 | * rounded up to the next 1KB and expressed in KB. Likewise, | 705 | * rounded up to the next 1KB and expressed in KB. Likewise, |
700 | * the Rx FIFO should be large enough to accomodate at least | 706 | * the Rx FIFO should be large enough to accommodate at least |
701 | * one full receive packet and is similarly rounded up and | 707 | * one full receive packet and is similarly rounded up and |
702 | * expressed in KB. */ | 708 | * expressed in KB. */ |
703 | pba = er32(PBA); | 709 | pba = er32(PBA); |
@@ -705,13 +711,17 @@ void e1000_reset(struct e1000_adapter *adapter) | |||
705 | tx_space = pba >> 16; | 711 | tx_space = pba >> 16; |
706 | /* lower 16 bits has Rx packet buffer allocation size in KB */ | 712 | /* lower 16 bits has Rx packet buffer allocation size in KB */ |
707 | pba &= 0xffff; | 713 | pba &= 0xffff; |
708 | /* don't include ethernet FCS because hardware appends/strips */ | 714 | /* |
709 | min_rx_space = adapter->netdev->mtu + ENET_HEADER_SIZE + | 715 | * the tx fifo also stores 16 bytes of information about the tx |
710 | VLAN_TAG_SIZE; | 716 | * but don't include ethernet FCS because hardware appends it |
711 | min_tx_space = min_rx_space; | 717 | */ |
712 | min_tx_space *= 2; | 718 | min_tx_space = (hw->max_frame_size + |
719 | sizeof(struct e1000_tx_desc) - | ||
720 | ETH_FCS_LEN) * 2; | ||
713 | min_tx_space = ALIGN(min_tx_space, 1024); | 721 | min_tx_space = ALIGN(min_tx_space, 1024); |
714 | min_tx_space >>= 10; | 722 | min_tx_space >>= 10; |
723 | /* software strips receive CRC, so leave room for it */ | ||
724 | min_rx_space = hw->max_frame_size; | ||
715 | min_rx_space = ALIGN(min_rx_space, 1024); | 725 | min_rx_space = ALIGN(min_rx_space, 1024); |
716 | min_rx_space >>= 10; | 726 | min_rx_space >>= 10; |
717 | 727 | ||
@@ -748,23 +758,22 @@ void e1000_reset(struct e1000_adapter *adapter) | |||
748 | 758 | ||
749 | ew32(PBA, pba); | 759 | ew32(PBA, pba); |
750 | 760 | ||
751 | /* flow control settings */ | 761 | /* |
752 | /* Set the FC high water mark to 90% of the FIFO size. | 762 | * flow control settings: |
753 | * Required to clear last 3 LSB */ | 763 | * The high water mark must be low enough to fit one full frame |
754 | fc_high_water_mark = ((pba * 9216)/10) & 0xFFF8; | 764 | * (or the size used for early receive) above it in the Rx FIFO. |
755 | /* We can't use 90% on small FIFOs because the remainder | 765 | * Set it to the lower of: |
756 | * would be less than 1 full frame. In this case, we size | 766 | * - 90% of the Rx FIFO size, and |
757 | * it to allow at least a full frame above the high water | 767 | * - the full Rx FIFO size minus the early receive size (for parts |
758 | * mark. */ | 768 | * with ERT support assuming ERT set to E1000_ERT_2048), or |
759 | if (pba < E1000_PBA_16K) | 769 | * - the full Rx FIFO size minus one full frame |
760 | fc_high_water_mark = (pba * 1024) - 1600; | 770 | */ |
761 | 771 | hwm = min(((pba << 10) * 9 / 10), | |
762 | hw->fc_high_water = fc_high_water_mark; | 772 | ((pba << 10) - hw->max_frame_size)); |
763 | hw->fc_low_water = fc_high_water_mark - 8; | 773 | |
764 | if (hw->mac_type == e1000_80003es2lan) | 774 | hw->fc_high_water = hwm & 0xFFF8; /* 8-byte granularity */ |
765 | hw->fc_pause_time = 0xFFFF; | 775 | hw->fc_low_water = hw->fc_high_water - 8; |
766 | else | 776 | hw->fc_pause_time = E1000_FC_PAUSE_TIME; |
767 | hw->fc_pause_time = E1000_FC_PAUSE_TIME; | ||
768 | hw->fc_send_xon = 1; | 777 | hw->fc_send_xon = 1; |
769 | hw->fc = hw->original_fc; | 778 | hw->fc = hw->original_fc; |
770 | 779 | ||
@@ -1862,6 +1871,7 @@ setup_rx_desc_die: | |||
1862 | 1871 | ||
1863 | rxdr->next_to_clean = 0; | 1872 | rxdr->next_to_clean = 0; |
1864 | rxdr->next_to_use = 0; | 1873 | rxdr->next_to_use = 0; |
1874 | rxdr->rx_skb_top = NULL; | ||
1865 | 1875 | ||
1866 | return 0; | 1876 | return 0; |
1867 | } | 1877 | } |
@@ -1968,10 +1978,17 @@ static void e1000_configure_rx(struct e1000_adapter *adapter) | |||
1968 | struct e1000_hw *hw = &adapter->hw; | 1978 | struct e1000_hw *hw = &adapter->hw; |
1969 | u32 rdlen, rctl, rxcsum, ctrl_ext; | 1979 | u32 rdlen, rctl, rxcsum, ctrl_ext; |
1970 | 1980 | ||
1971 | rdlen = adapter->rx_ring[0].count * | 1981 | if (adapter->netdev->mtu > ETH_DATA_LEN) { |
1972 | sizeof(struct e1000_rx_desc); | 1982 | rdlen = adapter->rx_ring[0].count * |
1973 | adapter->clean_rx = e1000_clean_rx_irq; | 1983 | sizeof(struct e1000_rx_desc); |
1974 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers; | 1984 | adapter->clean_rx = e1000_clean_jumbo_rx_irq; |
1985 | adapter->alloc_rx_buf = e1000_alloc_jumbo_rx_buffers; | ||
1986 | } else { | ||
1987 | rdlen = adapter->rx_ring[0].count * | ||
1988 | sizeof(struct e1000_rx_desc); | ||
1989 | adapter->clean_rx = e1000_clean_rx_irq; | ||
1990 | adapter->alloc_rx_buf = e1000_alloc_rx_buffers; | ||
1991 | } | ||
1975 | 1992 | ||
1976 | /* disable receives while setting up the descriptors */ | 1993 | /* disable receives while setting up the descriptors */ |
1977 | rctl = er32(RCTL); | 1994 | rctl = er32(RCTL); |
@@ -2185,26 +2202,39 @@ static void e1000_clean_rx_ring(struct e1000_adapter *adapter, | |||
2185 | /* Free all the Rx ring sk_buffs */ | 2202 | /* Free all the Rx ring sk_buffs */ |
2186 | for (i = 0; i < rx_ring->count; i++) { | 2203 | for (i = 0; i < rx_ring->count; i++) { |
2187 | buffer_info = &rx_ring->buffer_info[i]; | 2204 | buffer_info = &rx_ring->buffer_info[i]; |
2188 | if (buffer_info->dma) { | 2205 | if (buffer_info->dma && |
2189 | pci_unmap_single(pdev, | 2206 | adapter->clean_rx == e1000_clean_rx_irq) { |
2190 | buffer_info->dma, | 2207 | pci_unmap_single(pdev, buffer_info->dma, |
2191 | buffer_info->length, | 2208 | buffer_info->length, |
2192 | PCI_DMA_FROMDEVICE); | 2209 | PCI_DMA_FROMDEVICE); |
2210 | } else if (buffer_info->dma && | ||
2211 | adapter->clean_rx == e1000_clean_jumbo_rx_irq) { | ||
2212 | pci_unmap_page(pdev, buffer_info->dma, | ||
2213 | buffer_info->length, | ||
2214 | PCI_DMA_FROMDEVICE); | ||
2193 | } | 2215 | } |
2194 | 2216 | ||
2195 | buffer_info->dma = 0; | 2217 | buffer_info->dma = 0; |
2196 | 2218 | if (buffer_info->page) { | |
2219 | put_page(buffer_info->page); | ||
2220 | buffer_info->page = NULL; | ||
2221 | } | ||
2197 | if (buffer_info->skb) { | 2222 | if (buffer_info->skb) { |
2198 | dev_kfree_skb(buffer_info->skb); | 2223 | dev_kfree_skb(buffer_info->skb); |
2199 | buffer_info->skb = NULL; | 2224 | buffer_info->skb = NULL; |
2200 | } | 2225 | } |
2201 | } | 2226 | } |
2202 | 2227 | ||
2228 | /* there also may be some cached data from a chained receive */ | ||
2229 | if (rx_ring->rx_skb_top) { | ||
2230 | dev_kfree_skb(rx_ring->rx_skb_top); | ||
2231 | rx_ring->rx_skb_top = NULL; | ||
2232 | } | ||
2233 | |||
2203 | size = sizeof(struct e1000_buffer) * rx_ring->count; | 2234 | size = sizeof(struct e1000_buffer) * rx_ring->count; |
2204 | memset(rx_ring->buffer_info, 0, size); | 2235 | memset(rx_ring->buffer_info, 0, size); |
2205 | 2236 | ||
2206 | /* Zero out the descriptor ring */ | 2237 | /* Zero out the descriptor ring */ |
2207 | |||
2208 | memset(rx_ring->desc, 0, rx_ring->size); | 2238 | memset(rx_ring->desc, 0, rx_ring->size); |
2209 | 2239 | ||
2210 | rx_ring->next_to_clean = 0; | 2240 | rx_ring->next_to_clean = 0; |
@@ -3450,7 +3480,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
3450 | switch (hw->mac_type) { | 3480 | switch (hw->mac_type) { |
3451 | case e1000_undefined ... e1000_82542_rev2_1: | 3481 | case e1000_undefined ... e1000_82542_rev2_1: |
3452 | case e1000_ich8lan: | 3482 | case e1000_ich8lan: |
3453 | if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { | 3483 | if (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) { |
3454 | DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n"); | 3484 | DPRINTK(PROBE, ERR, "Jumbo Frames not supported.\n"); |
3455 | return -EINVAL; | 3485 | return -EINVAL; |
3456 | } | 3486 | } |
@@ -3463,7 +3493,7 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
3463 | &eeprom_data); | 3493 | &eeprom_data); |
3464 | if ((hw->device_id != E1000_DEV_ID_82573L) || | 3494 | if ((hw->device_id != E1000_DEV_ID_82573L) || |
3465 | (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) { | 3495 | (eeprom_data & EEPROM_WORD1A_ASPM_MASK)) { |
3466 | if (max_frame > MAXIMUM_ETHERNET_FRAME_SIZE) { | 3496 | if (max_frame > (ETH_FRAME_LEN + ETH_FCS_LEN)) { |
3467 | DPRINTK(PROBE, ERR, | 3497 | DPRINTK(PROBE, ERR, |
3468 | "Jumbo Frames not supported.\n"); | 3498 | "Jumbo Frames not supported.\n"); |
3469 | return -EINVAL; | 3499 | return -EINVAL; |
@@ -3489,8 +3519,10 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
3489 | 3519 | ||
3490 | /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN | 3520 | /* NOTE: netdev_alloc_skb reserves 16 bytes, and typically NET_IP_ALIGN |
3491 | * means we reserve 2 more, this pushes us to allocate from the next | 3521 | * means we reserve 2 more, this pushes us to allocate from the next |
3492 | * larger slab size | 3522 | * larger slab size. |
3493 | * i.e. RXBUFFER_2048 --> size-4096 slab */ | 3523 | * i.e. RXBUFFER_2048 --> size-4096 slab |
3524 | * however with the new *_jumbo_rx* routines, jumbo receives will use | ||
3525 | * fragmented skbs */ | ||
3494 | 3526 | ||
3495 | if (max_frame <= E1000_RXBUFFER_256) | 3527 | if (max_frame <= E1000_RXBUFFER_256) |
3496 | adapter->rx_buffer_len = E1000_RXBUFFER_256; | 3528 | adapter->rx_buffer_len = E1000_RXBUFFER_256; |
@@ -3500,16 +3532,16 @@ static int e1000_change_mtu(struct net_device *netdev, int new_mtu) | |||
3500 | adapter->rx_buffer_len = E1000_RXBUFFER_1024; | 3532 | adapter->rx_buffer_len = E1000_RXBUFFER_1024; |
3501 | else if (max_frame <= E1000_RXBUFFER_2048) | 3533 | else if (max_frame <= E1000_RXBUFFER_2048) |
3502 | adapter->rx_buffer_len = E1000_RXBUFFER_2048; | 3534 | adapter->rx_buffer_len = E1000_RXBUFFER_2048; |
3503 | else if (max_frame <= E1000_RXBUFFER_4096) | 3535 | else |
3504 | adapter->rx_buffer_len = E1000_RXBUFFER_4096; | 3536 | #if (PAGE_SIZE >= E1000_RXBUFFER_16384) |
3505 | else if (max_frame <= E1000_RXBUFFER_8192) | ||
3506 | adapter->rx_buffer_len = E1000_RXBUFFER_8192; | ||
3507 | else if (max_frame <= E1000_RXBUFFER_16384) | ||
3508 | adapter->rx_buffer_len = E1000_RXBUFFER_16384; | 3537 | adapter->rx_buffer_len = E1000_RXBUFFER_16384; |
3538 | #elif (PAGE_SIZE >= E1000_RXBUFFER_4096) | ||
3539 | adapter->rx_buffer_len = PAGE_SIZE; | ||
3540 | #endif | ||
3509 | 3541 | ||
3510 | /* adjust allocation if LPE protects us, and we aren't using SBP */ | 3542 | /* adjust allocation if LPE protects us, and we aren't using SBP */ |
3511 | if (!hw->tbi_compatibility_on && | 3543 | if (!hw->tbi_compatibility_on && |
3512 | ((max_frame == MAXIMUM_ETHERNET_FRAME_SIZE) || | 3544 | ((max_frame == (ETH_FRAME_LEN + ETH_FCS_LEN)) || |
3513 | (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE))) | 3545 | (max_frame == MAXIMUM_ETHERNET_VLAN_SIZE))) |
3514 | adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; | 3546 | adapter->rx_buffer_len = MAXIMUM_ETHERNET_VLAN_SIZE; |
3515 | 3547 | ||
@@ -3987,9 +4019,227 @@ static void e1000_rx_checksum(struct e1000_adapter *adapter, u32 status_err, | |||
3987 | } | 4019 | } |
3988 | 4020 | ||
3989 | /** | 4021 | /** |
4022 | * e1000_consume_page - helper function | ||
4023 | **/ | ||
4024 | static void e1000_consume_page(struct e1000_buffer *bi, struct sk_buff *skb, | ||
4025 | u16 length) | ||
4026 | { | ||
4027 | bi->page = NULL; | ||
4028 | skb->len += length; | ||
4029 | skb->data_len += length; | ||
4030 | skb->truesize += length; | ||
4031 | } | ||
4032 | |||
4033 | /** | ||
4034 | * e1000_receive_skb - helper function to handle rx indications | ||
4035 | * @adapter: board private structure | ||
4036 | * @status: descriptor status field as written by hardware | ||
4037 | * @vlan: descriptor vlan field as written by hardware (no le/be conversion) | ||
4038 | * @skb: pointer to sk_buff to be indicated to stack | ||
4039 | */ | ||
4040 | static void e1000_receive_skb(struct e1000_adapter *adapter, u8 status, | ||
4041 | __le16 vlan, struct sk_buff *skb) | ||
4042 | { | ||
4043 | if (unlikely(adapter->vlgrp && (status & E1000_RXD_STAT_VP))) { | ||
4044 | vlan_hwaccel_receive_skb(skb, adapter->vlgrp, | ||
4045 | le16_to_cpu(vlan) & | ||
4046 | E1000_RXD_SPC_VLAN_MASK); | ||
4047 | } else { | ||
4048 | netif_receive_skb(skb); | ||
4049 | } | ||
4050 | } | ||
4051 | |||
4052 | /** | ||
4053 | * e1000_clean_jumbo_rx_irq - Send received data up the network stack; legacy | ||
4054 | * @adapter: board private structure | ||
4055 | * @rx_ring: ring to clean | ||
4056 | * @work_done: amount of napi work completed this call | ||
4057 | * @work_to_do: max amount of work allowed for this call to do | ||
4058 | * | ||
4059 | * the return value indicates whether actual cleaning was done, there | ||
4060 | * is no guarantee that everything was cleaned | ||
4061 | */ | ||
4062 | static bool e1000_clean_jumbo_rx_irq(struct e1000_adapter *adapter, | ||
4063 | struct e1000_rx_ring *rx_ring, | ||
4064 | int *work_done, int work_to_do) | ||
4065 | { | ||
4066 | struct e1000_hw *hw = &adapter->hw; | ||
4067 | struct net_device *netdev = adapter->netdev; | ||
4068 | struct pci_dev *pdev = adapter->pdev; | ||
4069 | struct e1000_rx_desc *rx_desc, *next_rxd; | ||
4070 | struct e1000_buffer *buffer_info, *next_buffer; | ||
4071 | unsigned long irq_flags; | ||
4072 | u32 length; | ||
4073 | unsigned int i; | ||
4074 | int cleaned_count = 0; | ||
4075 | bool cleaned = false; | ||
4076 | unsigned int total_rx_bytes=0, total_rx_packets=0; | ||
4077 | |||
4078 | i = rx_ring->next_to_clean; | ||
4079 | rx_desc = E1000_RX_DESC(*rx_ring, i); | ||
4080 | buffer_info = &rx_ring->buffer_info[i]; | ||
4081 | |||
4082 | while (rx_desc->status & E1000_RXD_STAT_DD) { | ||
4083 | struct sk_buff *skb; | ||
4084 | u8 status; | ||
4085 | |||
4086 | if (*work_done >= work_to_do) | ||
4087 | break; | ||
4088 | (*work_done)++; | ||
4089 | |||
4090 | status = rx_desc->status; | ||
4091 | skb = buffer_info->skb; | ||
4092 | buffer_info->skb = NULL; | ||
4093 | |||
4094 | if (++i == rx_ring->count) i = 0; | ||
4095 | next_rxd = E1000_RX_DESC(*rx_ring, i); | ||
4096 | prefetch(next_rxd); | ||
4097 | |||
4098 | next_buffer = &rx_ring->buffer_info[i]; | ||
4099 | |||
4100 | cleaned = true; | ||
4101 | cleaned_count++; | ||
4102 | pci_unmap_page(pdev, buffer_info->dma, buffer_info->length, | ||
4103 | PCI_DMA_FROMDEVICE); | ||
4104 | buffer_info->dma = 0; | ||
4105 | |||
4106 | length = le16_to_cpu(rx_desc->length); | ||
4107 | |||
4108 | /* errors is only valid for DD + EOP descriptors */ | ||
4109 | if (unlikely((status & E1000_RXD_STAT_EOP) && | ||
4110 | (rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK))) { | ||
4111 | u8 last_byte = *(skb->data + length - 1); | ||
4112 | if (TBI_ACCEPT(hw, status, rx_desc->errors, length, | ||
4113 | last_byte)) { | ||
4114 | spin_lock_irqsave(&adapter->stats_lock, | ||
4115 | irq_flags); | ||
4116 | e1000_tbi_adjust_stats(hw, &adapter->stats, | ||
4117 | length, skb->data); | ||
4118 | spin_unlock_irqrestore(&adapter->stats_lock, | ||
4119 | irq_flags); | ||
4120 | length--; | ||
4121 | } else { | ||
4122 | /* recycle both page and skb */ | ||
4123 | buffer_info->skb = skb; | ||
4124 | /* an error means any chain goes out the window | ||
4125 | * too */ | ||
4126 | if (rx_ring->rx_skb_top) | ||
4127 | dev_kfree_skb(rx_ring->rx_skb_top); | ||
4128 | rx_ring->rx_skb_top = NULL; | ||
4129 | goto next_desc; | ||
4130 | } | ||
4131 | } | ||
4132 | |||
4133 | #define rxtop rx_ring->rx_skb_top | ||
4134 | if (!(status & E1000_RXD_STAT_EOP)) { | ||
4135 | /* this descriptor is only the beginning (or middle) */ | ||
4136 | if (!rxtop) { | ||
4137 | /* this is the beginning of a chain */ | ||
4138 | rxtop = skb; | ||
4139 | skb_fill_page_desc(rxtop, 0, buffer_info->page, | ||
4140 | 0, length); | ||
4141 | } else { | ||
4142 | /* this is the middle of a chain */ | ||
4143 | skb_fill_page_desc(rxtop, | ||
4144 | skb_shinfo(rxtop)->nr_frags, | ||
4145 | buffer_info->page, 0, length); | ||
4146 | /* re-use the skb, only consumed the page */ | ||
4147 | buffer_info->skb = skb; | ||
4148 | } | ||
4149 | e1000_consume_page(buffer_info, rxtop, length); | ||
4150 | goto next_desc; | ||
4151 | } else { | ||
4152 | if (rxtop) { | ||
4153 | /* end of the chain */ | ||
4154 | skb_fill_page_desc(rxtop, | ||
4155 | skb_shinfo(rxtop)->nr_frags, | ||
4156 | buffer_info->page, 0, length); | ||
4157 | /* re-use the current skb, we only consumed the | ||
4158 | * page */ | ||
4159 | buffer_info->skb = skb; | ||
4160 | skb = rxtop; | ||
4161 | rxtop = NULL; | ||
4162 | e1000_consume_page(buffer_info, skb, length); | ||
4163 | } else { | ||
4164 | /* no chain, got EOP, this buf is the packet | ||
4165 | * copybreak to save the put_page/alloc_page */ | ||
4166 | if (length <= copybreak && | ||
4167 | skb_tailroom(skb) >= length) { | ||
4168 | u8 *vaddr; | ||
4169 | vaddr = kmap_atomic(buffer_info->page, | ||
4170 | KM_SKB_DATA_SOFTIRQ); | ||
4171 | memcpy(skb_tail_pointer(skb), vaddr, length); | ||
4172 | kunmap_atomic(vaddr, | ||
4173 | KM_SKB_DATA_SOFTIRQ); | ||
4174 | /* re-use the page, so don't erase | ||
4175 | * buffer_info->page */ | ||
4176 | skb_put(skb, length); | ||
4177 | } else { | ||
4178 | skb_fill_page_desc(skb, 0, | ||
4179 | buffer_info->page, 0, | ||
4180 | length); | ||
4181 | e1000_consume_page(buffer_info, skb, | ||
4182 | length); | ||
4183 | } | ||
4184 | } | ||
4185 | } | ||
4186 | |||
4187 | /* Receive Checksum Offload XXX recompute due to CRC strip? */ | ||
4188 | e1000_rx_checksum(adapter, | ||
4189 | (u32)(status) | | ||
4190 | ((u32)(rx_desc->errors) << 24), | ||
4191 | le16_to_cpu(rx_desc->csum), skb); | ||
4192 | |||
4193 | pskb_trim(skb, skb->len - 4); | ||
4194 | |||
4195 | /* probably a little skewed due to removing CRC */ | ||
4196 | total_rx_bytes += skb->len; | ||
4197 | total_rx_packets++; | ||
4198 | |||
4199 | /* eth type trans needs skb->data to point to something */ | ||
4200 | if (!pskb_may_pull(skb, ETH_HLEN)) { | ||
4201 | DPRINTK(DRV, ERR, "pskb_may_pull failed.\n"); | ||
4202 | dev_kfree_skb(skb); | ||
4203 | goto next_desc; | ||
4204 | } | ||
4205 | |||
4206 | skb->protocol = eth_type_trans(skb, netdev); | ||
4207 | |||
4208 | e1000_receive_skb(adapter, status, rx_desc->special, skb); | ||
4209 | |||
4210 | next_desc: | ||
4211 | rx_desc->status = 0; | ||
4212 | |||
4213 | /* return some buffers to hardware, one at a time is too slow */ | ||
4214 | if (unlikely(cleaned_count >= E1000_RX_BUFFER_WRITE)) { | ||
4215 | adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); | ||
4216 | cleaned_count = 0; | ||
4217 | } | ||
4218 | |||
4219 | /* use prefetched values */ | ||
4220 | rx_desc = next_rxd; | ||
4221 | buffer_info = next_buffer; | ||
4222 | } | ||
4223 | rx_ring->next_to_clean = i; | ||
4224 | |||
4225 | cleaned_count = E1000_DESC_UNUSED(rx_ring); | ||
4226 | if (cleaned_count) | ||
4227 | adapter->alloc_rx_buf(adapter, rx_ring, cleaned_count); | ||
4228 | |||
4229 | adapter->total_rx_packets += total_rx_packets; | ||
4230 | adapter->total_rx_bytes += total_rx_bytes; | ||
4231 | adapter->net_stats.rx_bytes += total_rx_bytes; | ||
4232 | adapter->net_stats.rx_packets += total_rx_packets; | ||
4233 | return cleaned; | ||
4234 | } | ||
4235 | |||
4236 | /** | ||
3990 | * e1000_clean_rx_irq - Send received data up the network stack; legacy | 4237 | * e1000_clean_rx_irq - Send received data up the network stack; legacy |
3991 | * @adapter: board private structure | 4238 | * @adapter: board private structure |
3992 | **/ | 4239 | * @rx_ring: ring to clean |
4240 | * @work_done: amount of napi work completed this call | ||
4241 | * @work_to_do: max amount of work allowed for this call to do | ||
4242 | */ | ||
3993 | static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | 4243 | static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, |
3994 | struct e1000_rx_ring *rx_ring, | 4244 | struct e1000_rx_ring *rx_ring, |
3995 | int *work_done, int work_to_do) | 4245 | int *work_done, int work_to_do) |
@@ -4001,7 +4251,6 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
4001 | struct e1000_buffer *buffer_info, *next_buffer; | 4251 | struct e1000_buffer *buffer_info, *next_buffer; |
4002 | unsigned long flags; | 4252 | unsigned long flags; |
4003 | u32 length; | 4253 | u32 length; |
4004 | u8 last_byte; | ||
4005 | unsigned int i; | 4254 | unsigned int i; |
4006 | int cleaned_count = 0; | 4255 | int cleaned_count = 0; |
4007 | bool cleaned = false; | 4256 | bool cleaned = false; |
@@ -4033,9 +4282,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
4033 | 4282 | ||
4034 | cleaned = true; | 4283 | cleaned = true; |
4035 | cleaned_count++; | 4284 | cleaned_count++; |
4036 | pci_unmap_single(pdev, | 4285 | pci_unmap_single(pdev, buffer_info->dma, buffer_info->length, |
4037 | buffer_info->dma, | ||
4038 | buffer_info->length, | ||
4039 | PCI_DMA_FROMDEVICE); | 4286 | PCI_DMA_FROMDEVICE); |
4040 | buffer_info->dma = 0; | 4287 | buffer_info->dma = 0; |
4041 | 4288 | ||
@@ -4052,7 +4299,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
4052 | } | 4299 | } |
4053 | 4300 | ||
4054 | if (unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { | 4301 | if (unlikely(rx_desc->errors & E1000_RXD_ERR_FRAME_ERR_MASK)) { |
4055 | last_byte = *(skb->data + length - 1); | 4302 | u8 last_byte = *(skb->data + length - 1); |
4056 | if (TBI_ACCEPT(hw, status, rx_desc->errors, length, | 4303 | if (TBI_ACCEPT(hw, status, rx_desc->errors, length, |
4057 | last_byte)) { | 4304 | last_byte)) { |
4058 | spin_lock_irqsave(&adapter->stats_lock, flags); | 4305 | spin_lock_irqsave(&adapter->stats_lock, flags); |
@@ -4107,13 +4354,7 @@ static bool e1000_clean_rx_irq(struct e1000_adapter *adapter, | |||
4107 | 4354 | ||
4108 | skb->protocol = eth_type_trans(skb, netdev); | 4355 | skb->protocol = eth_type_trans(skb, netdev); |
4109 | 4356 | ||
4110 | if (unlikely(adapter->vlgrp && | 4357 | e1000_receive_skb(adapter, status, rx_desc->special, skb); |
4111 | (status & E1000_RXD_STAT_VP))) { | ||
4112 | vlan_hwaccel_receive_skb(skb, adapter->vlgrp, | ||
4113 | le16_to_cpu(rx_desc->special)); | ||
4114 | } else { | ||
4115 | netif_receive_skb(skb); | ||
4116 | } | ||
4117 | 4358 | ||
4118 | next_desc: | 4359 | next_desc: |
4119 | rx_desc->status = 0; | 4360 | rx_desc->status = 0; |
@@ -4142,6 +4383,114 @@ next_desc: | |||
4142 | } | 4383 | } |
4143 | 4384 | ||
4144 | /** | 4385 | /** |
4386 | * e1000_alloc_jumbo_rx_buffers - Replace used jumbo receive buffers | ||
4387 | * @adapter: address of board private structure | ||
4388 | * @rx_ring: pointer to receive ring structure | ||
4389 | * @cleaned_count: number of buffers to allocate this pass | ||
4390 | **/ | ||
4391 | |||
4392 | static void | ||
4393 | e1000_alloc_jumbo_rx_buffers(struct e1000_adapter *adapter, | ||
4394 | struct e1000_rx_ring *rx_ring, int cleaned_count) | ||
4395 | { | ||
4396 | struct net_device *netdev = adapter->netdev; | ||
4397 | struct pci_dev *pdev = adapter->pdev; | ||
4398 | struct e1000_rx_desc *rx_desc; | ||
4399 | struct e1000_buffer *buffer_info; | ||
4400 | struct sk_buff *skb; | ||
4401 | unsigned int i; | ||
4402 | unsigned int bufsz = 256 - | ||
4403 | 16 /*for skb_reserve */ - | ||
4404 | NET_IP_ALIGN; | ||
4405 | |||
4406 | i = rx_ring->next_to_use; | ||
4407 | buffer_info = &rx_ring->buffer_info[i]; | ||
4408 | |||
4409 | while (cleaned_count--) { | ||
4410 | skb = buffer_info->skb; | ||
4411 | if (skb) { | ||
4412 | skb_trim(skb, 0); | ||
4413 | goto check_page; | ||
4414 | } | ||
4415 | |||
4416 | skb = netdev_alloc_skb(netdev, bufsz); | ||
4417 | if (unlikely(!skb)) { | ||
4418 | /* Better luck next round */ | ||
4419 | adapter->alloc_rx_buff_failed++; | ||
4420 | break; | ||
4421 | } | ||
4422 | |||
4423 | /* Fix for errata 23, can't cross 64kB boundary */ | ||
4424 | if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) { | ||
4425 | struct sk_buff *oldskb = skb; | ||
4426 | DPRINTK(PROBE, ERR, "skb align check failed: %u bytes " | ||
4427 | "at %p\n", bufsz, skb->data); | ||
4428 | /* Try again, without freeing the previous */ | ||
4429 | skb = netdev_alloc_skb(netdev, bufsz); | ||
4430 | /* Failed allocation, critical failure */ | ||
4431 | if (!skb) { | ||
4432 | dev_kfree_skb(oldskb); | ||
4433 | adapter->alloc_rx_buff_failed++; | ||
4434 | break; | ||
4435 | } | ||
4436 | |||
4437 | if (!e1000_check_64k_bound(adapter, skb->data, bufsz)) { | ||
4438 | /* give up */ | ||
4439 | dev_kfree_skb(skb); | ||
4440 | dev_kfree_skb(oldskb); | ||
4441 | break; /* while (cleaned_count--) */ | ||
4442 | } | ||
4443 | |||
4444 | /* Use new allocation */ | ||
4445 | dev_kfree_skb(oldskb); | ||
4446 | } | ||
4447 | /* Make buffer alignment 2 beyond a 16 byte boundary | ||
4448 | * this will result in a 16 byte aligned IP header after | ||
4449 | * the 14 byte MAC header is removed | ||
4450 | */ | ||
4451 | skb_reserve(skb, NET_IP_ALIGN); | ||
4452 | |||
4453 | buffer_info->skb = skb; | ||
4454 | buffer_info->length = adapter->rx_buffer_len; | ||
4455 | check_page: | ||
4456 | /* allocate a new page if necessary */ | ||
4457 | if (!buffer_info->page) { | ||
4458 | buffer_info->page = alloc_page(GFP_ATOMIC); | ||
4459 | if (unlikely(!buffer_info->page)) { | ||
4460 | adapter->alloc_rx_buff_failed++; | ||
4461 | break; | ||
4462 | } | ||
4463 | } | ||
4464 | |||
4465 | if (!buffer_info->dma) | ||
4466 | buffer_info->dma = pci_map_page(pdev, | ||
4467 | buffer_info->page, 0, | ||
4468 | buffer_info->length, | ||
4469 | PCI_DMA_FROMDEVICE); | ||
4470 | |||
4471 | rx_desc = E1000_RX_DESC(*rx_ring, i); | ||
4472 | rx_desc->buffer_addr = cpu_to_le64(buffer_info->dma); | ||
4473 | |||
4474 | if (unlikely(++i == rx_ring->count)) | ||
4475 | i = 0; | ||
4476 | buffer_info = &rx_ring->buffer_info[i]; | ||
4477 | } | ||
4478 | |||
4479 | if (likely(rx_ring->next_to_use != i)) { | ||
4480 | rx_ring->next_to_use = i; | ||
4481 | if (unlikely(i-- == 0)) | ||
4482 | i = (rx_ring->count - 1); | ||
4483 | |||
4484 | /* Force memory writes to complete before letting h/w | ||
4485 | * know there are new descriptors to fetch. (Only | ||
4486 | * applicable for weak-ordered memory model archs, | ||
4487 | * such as IA-64). */ | ||
4488 | wmb(); | ||
4489 | writel(i, adapter->hw.hw_addr + rx_ring->rdt); | ||
4490 | } | ||
4491 | } | ||
4492 | |||
4493 | /** | ||
4145 | * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended | 4494 | * e1000_alloc_rx_buffers - Replace used receive buffers; legacy & extended |
4146 | * @adapter: address of board private structure | 4495 | * @adapter: address of board private structure |
4147 | **/ | 4496 | **/ |
@@ -4186,6 +4535,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, | |||
4186 | /* Failed allocation, critical failure */ | 4535 | /* Failed allocation, critical failure */ |
4187 | if (!skb) { | 4536 | if (!skb) { |
4188 | dev_kfree_skb(oldskb); | 4537 | dev_kfree_skb(oldskb); |
4538 | adapter->alloc_rx_buff_failed++; | ||
4189 | break; | 4539 | break; |
4190 | } | 4540 | } |
4191 | 4541 | ||
@@ -4193,6 +4543,7 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, | |||
4193 | /* give up */ | 4543 | /* give up */ |
4194 | dev_kfree_skb(skb); | 4544 | dev_kfree_skb(skb); |
4195 | dev_kfree_skb(oldskb); | 4545 | dev_kfree_skb(oldskb); |
4546 | adapter->alloc_rx_buff_failed++; | ||
4196 | break; /* while !buffer_info->skb */ | 4547 | break; /* while !buffer_info->skb */ |
4197 | } | 4548 | } |
4198 | 4549 | ||
@@ -4210,9 +4561,14 @@ static void e1000_alloc_rx_buffers(struct e1000_adapter *adapter, | |||
4210 | map_skb: | 4561 | map_skb: |
4211 | buffer_info->dma = pci_map_single(pdev, | 4562 | buffer_info->dma = pci_map_single(pdev, |
4212 | skb->data, | 4563 | skb->data, |
4213 | adapter->rx_buffer_len, | 4564 | buffer_info->length, |
4214 | PCI_DMA_FROMDEVICE); | 4565 | PCI_DMA_FROMDEVICE); |
4215 | 4566 | ||
4567 | /* | ||
4568 | * XXX if it was allocated cleanly it will never map to a | ||
4569 | * boundary crossing | ||
4570 | */ | ||
4571 | |||
4216 | /* Fix for errata 23, can't cross 64kB boundary */ | 4572 | /* Fix for errata 23, can't cross 64kB boundary */ |
4217 | if (!e1000_check_64k_bound(adapter, | 4573 | if (!e1000_check_64k_bound(adapter, |
4218 | (void *)(unsigned long)buffer_info->dma, | 4574 | (void *)(unsigned long)buffer_info->dma, |
@@ -4229,6 +4585,7 @@ map_skb: | |||
4229 | PCI_DMA_FROMDEVICE); | 4585 | PCI_DMA_FROMDEVICE); |
4230 | buffer_info->dma = 0; | 4586 | buffer_info->dma = 0; |
4231 | 4587 | ||
4588 | adapter->alloc_rx_buff_failed++; | ||
4232 | break; /* while !buffer_info->skb */ | 4589 | break; /* while !buffer_info->skb */ |
4233 | } | 4590 | } |
4234 | rx_desc = E1000_RX_DESC(*rx_ring, i); | 4591 | rx_desc = E1000_RX_DESC(*rx_ring, i); |
diff --git a/drivers/net/eepro.c b/drivers/net/eepro.c index cc2ab6412c73..71605d63708c 100644 --- a/drivers/net/eepro.c +++ b/drivers/net/eepro.c | |||
@@ -1145,7 +1145,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1145 | 1145 | ||
1146 | if (length < ETH_ZLEN) { | 1146 | if (length < ETH_ZLEN) { |
1147 | if (skb_padto(skb, ETH_ZLEN)) | 1147 | if (skb_padto(skb, ETH_ZLEN)) |
1148 | return 0; | 1148 | return NETDEV_TX_OK; |
1149 | length = ETH_ZLEN; | 1149 | length = ETH_ZLEN; |
1150 | } | 1150 | } |
1151 | netif_stop_queue (dev); | 1151 | netif_stop_queue (dev); |
@@ -1178,7 +1178,7 @@ static int eepro_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1178 | eepro_en_int(ioaddr); | 1178 | eepro_en_int(ioaddr); |
1179 | spin_unlock_irqrestore(&lp->lock, flags); | 1179 | spin_unlock_irqrestore(&lp->lock, flags); |
1180 | 1180 | ||
1181 | return 0; | 1181 | return NETDEV_TX_OK; |
1182 | } | 1182 | } |
1183 | 1183 | ||
1184 | 1184 | ||
diff --git a/drivers/net/eexpress.c b/drivers/net/eexpress.c index 1686dca28748..8c44ef4ba357 100644 --- a/drivers/net/eexpress.c +++ b/drivers/net/eexpress.c | |||
@@ -664,7 +664,7 @@ static int eexp_xmit(struct sk_buff *buf, struct net_device *dev) | |||
664 | 664 | ||
665 | if (buf->len < ETH_ZLEN) { | 665 | if (buf->len < ETH_ZLEN) { |
666 | if (skb_padto(buf, ETH_ZLEN)) | 666 | if (skb_padto(buf, ETH_ZLEN)) |
667 | return 0; | 667 | return NETDEV_TX_OK; |
668 | length = ETH_ZLEN; | 668 | length = ETH_ZLEN; |
669 | } | 669 | } |
670 | 670 | ||
@@ -691,7 +691,7 @@ static int eexp_xmit(struct sk_buff *buf, struct net_device *dev) | |||
691 | spin_unlock_irqrestore(&lp->lock, flags); | 691 | spin_unlock_irqrestore(&lp->lock, flags); |
692 | #endif | 692 | #endif |
693 | enable_irq(dev->irq); | 693 | enable_irq(dev->irq); |
694 | return 0; | 694 | return NETDEV_TX_OK; |
695 | } | 695 | } |
696 | 696 | ||
697 | /* | 697 | /* |
diff --git a/drivers/net/enc28j60.c b/drivers/net/enc28j60.c index fc6cc038c7b8..372d6c6a4e7f 100644 --- a/drivers/net/enc28j60.c +++ b/drivers/net/enc28j60.c | |||
@@ -1299,7 +1299,7 @@ static int enc28j60_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1299 | priv->tx_skb = skb; | 1299 | priv->tx_skb = skb; |
1300 | schedule_work(&priv->tx_work); | 1300 | schedule_work(&priv->tx_work); |
1301 | 1301 | ||
1302 | return 0; | 1302 | return NETDEV_TX_OK; |
1303 | } | 1303 | } |
1304 | 1304 | ||
1305 | static void enc28j60_tx_work_handler(struct work_struct *work) | 1305 | static void enc28j60_tx_work_handler(struct work_struct *work) |
diff --git a/drivers/net/epic100.c b/drivers/net/epic100.c index b60e27dfcfa7..d6a7aa3142f9 100644 --- a/drivers/net/epic100.c +++ b/drivers/net/epic100.c | |||
@@ -970,7 +970,7 @@ static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
970 | unsigned long flags; | 970 | unsigned long flags; |
971 | 971 | ||
972 | if (skb_padto(skb, ETH_ZLEN)) | 972 | if (skb_padto(skb, ETH_ZLEN)) |
973 | return 0; | 973 | return NETDEV_TX_OK; |
974 | 974 | ||
975 | /* Caution: the write order is important here, set the field with the | 975 | /* Caution: the write order is important here, set the field with the |
976 | "ownership" bit last. */ | 976 | "ownership" bit last. */ |
@@ -1014,7 +1014,7 @@ static int epic_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1014 | dev->name, (int)skb->len, entry, ctrl_word, | 1014 | dev->name, (int)skb->len, entry, ctrl_word, |
1015 | (int)inl(dev->base_addr + TxSTAT)); | 1015 | (int)inl(dev->base_addr + TxSTAT)); |
1016 | 1016 | ||
1017 | return 0; | 1017 | return NETDEV_TX_OK; |
1018 | } | 1018 | } |
1019 | 1019 | ||
1020 | static void epic_tx_error(struct net_device *dev, struct epic_private *ep, | 1020 | static void epic_tx_error(struct net_device *dev, struct epic_private *ep, |
diff --git a/drivers/net/eql.c b/drivers/net/eql.c index 19b7dd983944..c0e69c5cae84 100644 --- a/drivers/net/eql.c +++ b/drivers/net/eql.c | |||
@@ -348,7 +348,7 @@ static int eql_slave_xmit(struct sk_buff *skb, struct net_device *dev) | |||
348 | 348 | ||
349 | spin_unlock(&eql->queue.lock); | 349 | spin_unlock(&eql->queue.lock); |
350 | 350 | ||
351 | return 0; | 351 | return NETDEV_TX_OK; |
352 | } | 352 | } |
353 | 353 | ||
354 | /* | 354 | /* |
diff --git a/drivers/net/eth16i.c b/drivers/net/eth16i.c index 0d8b6da046f2..97d5205edc8f 100644 --- a/drivers/net/eth16i.c +++ b/drivers/net/eth16i.c | |||
@@ -1064,7 +1064,7 @@ static int eth16i_tx(struct sk_buff *skb, struct net_device *dev) | |||
1064 | 1064 | ||
1065 | if (length < ETH_ZLEN) { | 1065 | if (length < ETH_ZLEN) { |
1066 | if (skb_padto(skb, ETH_ZLEN)) | 1066 | if (skb_padto(skb, ETH_ZLEN)) |
1067 | return 0; | 1067 | return NETDEV_TX_OK; |
1068 | length = ETH_ZLEN; | 1068 | length = ETH_ZLEN; |
1069 | } | 1069 | } |
1070 | buf = skb->data; | 1070 | buf = skb->data; |
@@ -1126,7 +1126,7 @@ static int eth16i_tx(struct sk_buff *skb, struct net_device *dev) | |||
1126 | /* outb(TX_INTR_DONE | TX_INTR_16_COL, ioaddr + TX_INTR_REG); */ | 1126 | /* outb(TX_INTR_DONE | TX_INTR_16_COL, ioaddr + TX_INTR_REG); */ |
1127 | status = 0; | 1127 | status = 0; |
1128 | dev_kfree_skb(skb); | 1128 | dev_kfree_skb(skb); |
1129 | return 0; | 1129 | return NETDEV_TX_OK; |
1130 | } | 1130 | } |
1131 | 1131 | ||
1132 | static void eth16i_rx(struct net_device *dev) | 1132 | static void eth16i_rx(struct net_device *dev) |
diff --git a/drivers/net/ewrk3.c b/drivers/net/ewrk3.c index 1e9723281405..9c51bc813ad3 100644 --- a/drivers/net/ewrk3.c +++ b/drivers/net/ewrk3.c | |||
@@ -868,7 +868,7 @@ static int ewrk3_queue_pkt (struct sk_buff *skb, struct net_device *dev) | |||
868 | if (inb (EWRK3_FMQC) == 0) | 868 | if (inb (EWRK3_FMQC) == 0) |
869 | netif_stop_queue (dev); | 869 | netif_stop_queue (dev); |
870 | 870 | ||
871 | return 0; | 871 | return NETDEV_TX_OK; |
872 | 872 | ||
873 | err_out: | 873 | err_out: |
874 | ENABLE_IRQs; | 874 | ENABLE_IRQs; |
diff --git a/drivers/net/fealnx.c b/drivers/net/fealnx.c index 891be28a7d4f..75e5fe5153d9 100644 --- a/drivers/net/fealnx.c +++ b/drivers/net/fealnx.c | |||
@@ -1374,7 +1374,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1374 | dev->trans_start = jiffies; | 1374 | dev->trans_start = jiffies; |
1375 | 1375 | ||
1376 | spin_unlock_irqrestore(&np->lock, flags); | 1376 | spin_unlock_irqrestore(&np->lock, flags); |
1377 | return 0; | 1377 | return NETDEV_TX_OK; |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | 1380 | ||
diff --git a/drivers/net/fec.c b/drivers/net/fec.c index d4b98074b1b7..e3d99fe53ce6 100644 --- a/drivers/net/fec.c +++ b/drivers/net/fec.c | |||
@@ -366,7 +366,7 @@ fec_enet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
366 | 366 | ||
367 | spin_unlock_irqrestore(&fep->hw_lock, flags); | 367 | spin_unlock_irqrestore(&fep->hw_lock, flags); |
368 | 368 | ||
369 | return 0; | 369 | return NETDEV_TX_OK; |
370 | } | 370 | } |
371 | 371 | ||
372 | static void | 372 | static void |
diff --git a/drivers/net/gianfar.c b/drivers/net/gianfar.c index 43d813ed9f45..b2db449966e2 100644 --- a/drivers/net/gianfar.c +++ b/drivers/net/gianfar.c | |||
@@ -306,7 +306,6 @@ static int gfar_probe(struct of_device *ofdev, | |||
306 | u32 tempval; | 306 | u32 tempval; |
307 | struct net_device *dev = NULL; | 307 | struct net_device *dev = NULL; |
308 | struct gfar_private *priv = NULL; | 308 | struct gfar_private *priv = NULL; |
309 | DECLARE_MAC_BUF(mac); | ||
310 | int err = 0; | 309 | int err = 0; |
311 | int len_devname; | 310 | int len_devname; |
312 | 311 | ||
diff --git a/drivers/net/hamachi.c b/drivers/net/hamachi.c index 9d5b62cb30f7..4e8d3728e820 100644 --- a/drivers/net/hamachi.c +++ b/drivers/net/hamachi.c | |||
@@ -1369,7 +1369,7 @@ static int hamachi_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1369 | printk(KERN_DEBUG "%s: Hamachi transmit frame #%d queued in slot %d.\n", | 1369 | printk(KERN_DEBUG "%s: Hamachi transmit frame #%d queued in slot %d.\n", |
1370 | dev->name, hmp->cur_tx, entry); | 1370 | dev->name, hmp->cur_tx, entry); |
1371 | } | 1371 | } |
1372 | return 0; | 1372 | return NETDEV_TX_OK; |
1373 | } | 1373 | } |
1374 | 1374 | ||
1375 | /* The interrupt handler does all of the Rx thread work and cleans up | 1375 | /* The interrupt handler does all of the Rx thread work and cleans up |
diff --git a/drivers/net/hamradio/6pack.c b/drivers/net/hamradio/6pack.c index 155160052c8b..e88209fc2a2b 100644 --- a/drivers/net/hamradio/6pack.c +++ b/drivers/net/hamradio/6pack.c | |||
@@ -255,7 +255,7 @@ static int sp_xmit(struct sk_buff *skb, struct net_device *dev) | |||
255 | 255 | ||
256 | dev_kfree_skb(skb); | 256 | dev_kfree_skb(skb); |
257 | 257 | ||
258 | return 0; | 258 | return NETDEV_TX_OK; |
259 | } | 259 | } |
260 | 260 | ||
261 | static int sp_open_dev(struct net_device *dev) | 261 | static int sp_open_dev(struct net_device *dev) |
diff --git a/drivers/net/hamradio/baycom_epp.c b/drivers/net/hamradio/baycom_epp.c index 5e4b7afd0683..e229edf3261a 100644 --- a/drivers/net/hamradio/baycom_epp.c +++ b/drivers/net/hamradio/baycom_epp.c | |||
@@ -774,18 +774,18 @@ static int baycom_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
774 | if (skb->data[0] != 0) { | 774 | if (skb->data[0] != 0) { |
775 | do_kiss_params(bc, skb->data, skb->len); | 775 | do_kiss_params(bc, skb->data, skb->len); |
776 | dev_kfree_skb(skb); | 776 | dev_kfree_skb(skb); |
777 | return 0; | 777 | return NETDEV_TX_OK; |
778 | } | 778 | } |
779 | if (bc->skb) | 779 | if (bc->skb) |
780 | return NETDEV_TX_LOCKED; | 780 | return NETDEV_TX_LOCKED; |
781 | /* strip KISS byte */ | 781 | /* strip KISS byte */ |
782 | if (skb->len >= HDLCDRV_MAXFLEN+1 || skb->len < 3) { | 782 | if (skb->len >= HDLCDRV_MAXFLEN+1 || skb->len < 3) { |
783 | dev_kfree_skb(skb); | 783 | dev_kfree_skb(skb); |
784 | return 0; | 784 | return NETDEV_TX_OK; |
785 | } | 785 | } |
786 | netif_stop_queue(dev); | 786 | netif_stop_queue(dev); |
787 | bc->skb = skb; | 787 | bc->skb = skb; |
788 | return 0; | 788 | return NETDEV_TX_OK; |
789 | } | 789 | } |
790 | 790 | ||
791 | /* --------------------------------------------------------------------- */ | 791 | /* --------------------------------------------------------------------- */ |
diff --git a/drivers/net/hamradio/bpqether.c b/drivers/net/hamradio/bpqether.c index abcd19a8bff9..4c5f4dfbe05e 100644 --- a/drivers/net/hamradio/bpqether.c +++ b/drivers/net/hamradio/bpqether.c | |||
@@ -305,7 +305,7 @@ static int bpq_xmit(struct sk_buff *skb, struct net_device *dev) | |||
305 | 305 | ||
306 | dev_queue_xmit(skb); | 306 | dev_queue_xmit(skb); |
307 | netif_wake_queue(dev); | 307 | netif_wake_queue(dev); |
308 | return 0; | 308 | return NETDEV_TX_OK; |
309 | } | 309 | } |
310 | 310 | ||
311 | /* | 311 | /* |
diff --git a/drivers/net/hamradio/dmascc.c b/drivers/net/hamradio/dmascc.c index 7459b3ac77a9..950f3bb21f9d 100644 --- a/drivers/net/hamradio/dmascc.c +++ b/drivers/net/hamradio/dmascc.c | |||
@@ -959,7 +959,7 @@ static int scc_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
959 | spin_unlock_irqrestore(&priv->ring_lock, flags); | 959 | spin_unlock_irqrestore(&priv->ring_lock, flags); |
960 | dev_kfree_skb(skb); | 960 | dev_kfree_skb(skb); |
961 | 961 | ||
962 | return 0; | 962 | return NETDEV_TX_OK; |
963 | } | 963 | } |
964 | 964 | ||
965 | 965 | ||
diff --git a/drivers/net/hamradio/hdlcdrv.c b/drivers/net/hamradio/hdlcdrv.c index d034f8ca63cb..16b060b92117 100644 --- a/drivers/net/hamradio/hdlcdrv.c +++ b/drivers/net/hamradio/hdlcdrv.c | |||
@@ -406,13 +406,13 @@ static int hdlcdrv_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
406 | if (skb->data[0] != 0) { | 406 | if (skb->data[0] != 0) { |
407 | do_kiss_params(sm, skb->data, skb->len); | 407 | do_kiss_params(sm, skb->data, skb->len); |
408 | dev_kfree_skb(skb); | 408 | dev_kfree_skb(skb); |
409 | return 0; | 409 | return NETDEV_TX_OK; |
410 | } | 410 | } |
411 | if (sm->skb) | 411 | if (sm->skb) |
412 | return NETDEV_TX_LOCKED; | 412 | return NETDEV_TX_LOCKED; |
413 | netif_stop_queue(dev); | 413 | netif_stop_queue(dev); |
414 | sm->skb = skb; | 414 | sm->skb = skb; |
415 | return 0; | 415 | return NETDEV_TX_OK; |
416 | } | 416 | } |
417 | 417 | ||
418 | /* --------------------------------------------------------------------- */ | 418 | /* --------------------------------------------------------------------- */ |
diff --git a/drivers/net/hamradio/mkiss.c b/drivers/net/hamradio/mkiss.c index fda2fc83e9a1..ac191ef2119b 100644 --- a/drivers/net/hamradio/mkiss.c +++ b/drivers/net/hamradio/mkiss.c | |||
@@ -560,7 +560,7 @@ static int ax_xmit(struct sk_buff *skb, struct net_device *dev) | |||
560 | kfree_skb(skb); | 560 | kfree_skb(skb); |
561 | } | 561 | } |
562 | 562 | ||
563 | return 0; | 563 | return NETDEV_TX_OK; |
564 | } | 564 | } |
565 | 565 | ||
566 | static int ax_open_dev(struct net_device *dev) | 566 | static int ax_open_dev(struct net_device *dev) |
diff --git a/drivers/net/hamradio/scc.c b/drivers/net/hamradio/scc.c index d712e7af780c..c5406525c1ad 100644 --- a/drivers/net/hamradio/scc.c +++ b/drivers/net/hamradio/scc.c | |||
@@ -1643,7 +1643,7 @@ static int scc_net_tx(struct sk_buff *skb, struct net_device *dev) | |||
1643 | if (skb->len > scc->stat.bufsize || skb->len < 2) { | 1643 | if (skb->len > scc->stat.bufsize || skb->len < 2) { |
1644 | scc->dev_stat.tx_dropped++; /* bogus frame */ | 1644 | scc->dev_stat.tx_dropped++; /* bogus frame */ |
1645 | dev_kfree_skb(skb); | 1645 | dev_kfree_skb(skb); |
1646 | return 0; | 1646 | return NETDEV_TX_OK; |
1647 | } | 1647 | } |
1648 | 1648 | ||
1649 | scc->dev_stat.tx_packets++; | 1649 | scc->dev_stat.tx_packets++; |
@@ -1656,7 +1656,7 @@ static int scc_net_tx(struct sk_buff *skb, struct net_device *dev) | |||
1656 | if (kisscmd) { | 1656 | if (kisscmd) { |
1657 | scc_set_param(scc, kisscmd, *skb->data); | 1657 | scc_set_param(scc, kisscmd, *skb->data); |
1658 | dev_kfree_skb(skb); | 1658 | dev_kfree_skb(skb); |
1659 | return 0; | 1659 | return NETDEV_TX_OK; |
1660 | } | 1660 | } |
1661 | 1661 | ||
1662 | spin_lock_irqsave(&scc->lock, flags); | 1662 | spin_lock_irqsave(&scc->lock, flags); |
@@ -1684,7 +1684,7 @@ static int scc_net_tx(struct sk_buff *skb, struct net_device *dev) | |||
1684 | __scc_start_tx_timer(scc, t_dwait, 0); | 1684 | __scc_start_tx_timer(scc, t_dwait, 0); |
1685 | } | 1685 | } |
1686 | spin_unlock_irqrestore(&scc->lock, flags); | 1686 | spin_unlock_irqrestore(&scc->lock, flags); |
1687 | return 0; | 1687 | return NETDEV_TX_OK; |
1688 | } | 1688 | } |
1689 | 1689 | ||
1690 | /* ----> ioctl functions <---- */ | 1690 | /* ----> ioctl functions <---- */ |
diff --git a/drivers/net/hamradio/yam.c b/drivers/net/hamradio/yam.c index b06691937ce9..b85aa162314e 100644 --- a/drivers/net/hamradio/yam.c +++ b/drivers/net/hamradio/yam.c | |||
@@ -600,7 +600,7 @@ static int yam_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
600 | 600 | ||
601 | skb_queue_tail(&yp->send_queue, skb); | 601 | skb_queue_tail(&yp->send_queue, skb); |
602 | dev->trans_start = jiffies; | 602 | dev->trans_start = jiffies; |
603 | return 0; | 603 | return NETDEV_TX_OK; |
604 | } | 604 | } |
605 | 605 | ||
606 | static void yam_start_tx(struct net_device *dev, struct yam_port *yp) | 606 | static void yam_start_tx(struct net_device *dev, struct yam_port *yp) |
diff --git a/drivers/net/hp100.c b/drivers/net/hp100.c index 1d3429a415e6..d1b63387e9bc 100644 --- a/drivers/net/hp100.c +++ b/drivers/net/hp100.c | |||
@@ -1499,7 +1499,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev) | |||
1499 | goto drop; | 1499 | goto drop; |
1500 | 1500 | ||
1501 | if (lp->chip == HP100_CHIPID_SHASTA && skb_padto(skb, ETH_ZLEN)) | 1501 | if (lp->chip == HP100_CHIPID_SHASTA && skb_padto(skb, ETH_ZLEN)) |
1502 | return 0; | 1502 | return NETDEV_TX_OK; |
1503 | 1503 | ||
1504 | /* Get Tx ring tail pointer */ | 1504 | /* Get Tx ring tail pointer */ |
1505 | if (lp->txrtail->next == lp->txrhead) { | 1505 | if (lp->txrtail->next == lp->txrhead) { |
@@ -1585,7 +1585,7 @@ static int hp100_start_xmit_bm(struct sk_buff *skb, struct net_device *dev) | |||
1585 | lp->stats.tx_bytes += skb->len; | 1585 | lp->stats.tx_bytes += skb->len; |
1586 | dev->trans_start = jiffies; | 1586 | dev->trans_start = jiffies; |
1587 | 1587 | ||
1588 | return 0; | 1588 | return NETDEV_TX_OK; |
1589 | 1589 | ||
1590 | drop: | 1590 | drop: |
1591 | dev_kfree_skb(skb); | 1591 | dev_kfree_skb(skb); |
@@ -1752,7 +1752,7 @@ static int hp100_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1752 | printk("hp100: %s: start_xmit: end\n", dev->name); | 1752 | printk("hp100: %s: start_xmit: end\n", dev->name); |
1753 | #endif | 1753 | #endif |
1754 | 1754 | ||
1755 | return 0; | 1755 | return NETDEV_TX_OK; |
1756 | 1756 | ||
1757 | drop: | 1757 | drop: |
1758 | dev_kfree_skb(skb); | 1758 | dev_kfree_skb(skb); |
diff --git a/drivers/net/ibm_newemac/core.c b/drivers/net/ibm_newemac/core.c index beb84213b671..5443558c439d 100644 --- a/drivers/net/ibm_newemac/core.c +++ b/drivers/net/ibm_newemac/core.c | |||
@@ -1342,7 +1342,7 @@ static inline int emac_xmit_finish(struct emac_instance *dev, int len) | |||
1342 | ++dev->stats.tx_packets; | 1342 | ++dev->stats.tx_packets; |
1343 | dev->stats.tx_bytes += len; | 1343 | dev->stats.tx_bytes += len; |
1344 | 1344 | ||
1345 | return 0; | 1345 | return NETDEV_TX_OK; |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | /* Tx lock BH */ | 1348 | /* Tx lock BH */ |
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c index 0995c438f286..76b295a18185 100644 --- a/drivers/net/ibmveth.c +++ b/drivers/net/ibmveth.c | |||
@@ -971,7 +971,7 @@ out: spin_lock_irqsave(&adapter->stats_lock, flags); | |||
971 | spin_unlock_irqrestore(&adapter->stats_lock, flags); | 971 | spin_unlock_irqrestore(&adapter->stats_lock, flags); |
972 | 972 | ||
973 | dev_kfree_skb(skb); | 973 | dev_kfree_skb(skb); |
974 | return 0; | 974 | return NETDEV_TX_OK; |
975 | } | 975 | } |
976 | 976 | ||
977 | static int ibmveth_poll(struct napi_struct *napi, int budget) | 977 | static int ibmveth_poll(struct napi_struct *napi, int budget) |
diff --git a/drivers/net/ifb.c b/drivers/net/ifb.c index 96713ef06298..0a79b4517804 100644 --- a/drivers/net/ifb.c +++ b/drivers/net/ifb.c | |||
@@ -164,7 +164,7 @@ static int ifb_xmit(struct sk_buff *skb, struct net_device *dev) | |||
164 | { | 164 | { |
165 | struct ifb_private *dp = netdev_priv(dev); | 165 | struct ifb_private *dp = netdev_priv(dev); |
166 | struct net_device_stats *stats = &dev->stats; | 166 | struct net_device_stats *stats = &dev->stats; |
167 | int ret = 0; | 167 | int ret = NETDEV_TX_OK; |
168 | u32 from = G_TC_FROM(skb->tc_verd); | 168 | u32 from = G_TC_FROM(skb->tc_verd); |
169 | 169 | ||
170 | stats->rx_packets++; | 170 | stats->rx_packets++; |
diff --git a/drivers/net/ioc3-eth.c b/drivers/net/ioc3-eth.c index e3cfefab670c..8ec15ab8c8c2 100644 --- a/drivers/net/ioc3-eth.c +++ b/drivers/net/ioc3-eth.c | |||
@@ -1515,7 +1515,7 @@ static int ioc3_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1515 | 1515 | ||
1516 | spin_unlock_irq(&ip->ioc3_lock); | 1516 | spin_unlock_irq(&ip->ioc3_lock); |
1517 | 1517 | ||
1518 | return 0; | 1518 | return NETDEV_TX_OK; |
1519 | } | 1519 | } |
1520 | 1520 | ||
1521 | static void ioc3_timeout(struct net_device *dev) | 1521 | static void ioc3_timeout(struct net_device *dev) |
diff --git a/drivers/net/irda/ali-ircc.c b/drivers/net/irda/ali-ircc.c index ad1795580028..f0d0cea6e329 100644 --- a/drivers/net/irda/ali-ircc.c +++ b/drivers/net/irda/ali-ircc.c | |||
@@ -1466,7 +1466,7 @@ static int ali_ircc_fir_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1466 | dev->trans_start = jiffies; | 1466 | dev->trans_start = jiffies; |
1467 | spin_unlock_irqrestore(&self->lock, flags); | 1467 | spin_unlock_irqrestore(&self->lock, flags); |
1468 | dev_kfree_skb(skb); | 1468 | dev_kfree_skb(skb); |
1469 | return 0; | 1469 | return NETDEV_TX_OK; |
1470 | } else | 1470 | } else |
1471 | self->new_speed = speed; | 1471 | self->new_speed = speed; |
1472 | } | 1472 | } |
@@ -1577,7 +1577,7 @@ static int ali_ircc_fir_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1577 | dev_kfree_skb(skb); | 1577 | dev_kfree_skb(skb); |
1578 | 1578 | ||
1579 | IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ ); | 1579 | IRDA_DEBUG(1, "%s(), ----------------- End ------------------\n", __func__ ); |
1580 | return 0; | 1580 | return NETDEV_TX_OK; |
1581 | } | 1581 | } |
1582 | 1582 | ||
1583 | 1583 | ||
@@ -1966,10 +1966,10 @@ static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1966 | 1966 | ||
1967 | IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ ); | 1967 | IRDA_DEBUG(2, "%s(), ---------------- Start ----------------\n", __func__ ); |
1968 | 1968 | ||
1969 | IRDA_ASSERT(dev != NULL, return 0;); | 1969 | IRDA_ASSERT(dev != NULL, return NETDEV_TX_OK;); |
1970 | 1970 | ||
1971 | self = netdev_priv(dev); | 1971 | self = netdev_priv(dev); |
1972 | IRDA_ASSERT(self != NULL, return 0;); | 1972 | IRDA_ASSERT(self != NULL, return NETDEV_TX_OK;); |
1973 | 1973 | ||
1974 | iobase = self->io.sir_base; | 1974 | iobase = self->io.sir_base; |
1975 | 1975 | ||
@@ -1991,7 +1991,7 @@ static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1991 | dev->trans_start = jiffies; | 1991 | dev->trans_start = jiffies; |
1992 | spin_unlock_irqrestore(&self->lock, flags); | 1992 | spin_unlock_irqrestore(&self->lock, flags); |
1993 | dev_kfree_skb(skb); | 1993 | dev_kfree_skb(skb); |
1994 | return 0; | 1994 | return NETDEV_TX_OK; |
1995 | } else | 1995 | } else |
1996 | self->new_speed = speed; | 1996 | self->new_speed = speed; |
1997 | } | 1997 | } |
@@ -2015,7 +2015,7 @@ static int ali_ircc_sir_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2015 | 2015 | ||
2016 | IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ ); | 2016 | IRDA_DEBUG(2, "%s(), ----------------- End ------------------\n", __func__ ); |
2017 | 2017 | ||
2018 | return 0; | 2018 | return NETDEV_TX_OK; |
2019 | } | 2019 | } |
2020 | 2020 | ||
2021 | 2021 | ||
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c index c4361d466597..22baf65e1563 100644 --- a/drivers/net/irda/au1k_ir.c +++ b/drivers/net/irda/au1k_ir.c | |||
@@ -502,7 +502,7 @@ static int au1k_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
502 | aup->newspeed = 0; | 502 | aup->newspeed = 0; |
503 | } | 503 | } |
504 | dev_kfree_skb(skb); | 504 | dev_kfree_skb(skb); |
505 | return 0; | 505 | return NETDEV_TX_OK; |
506 | } | 506 | } |
507 | 507 | ||
508 | ptxd = aup->tx_ring[aup->tx_head]; | 508 | ptxd = aup->tx_ring[aup->tx_head]; |
@@ -555,7 +555,7 @@ static int au1k_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
555 | dev_kfree_skb(skb); | 555 | dev_kfree_skb(skb); |
556 | aup->tx_head = (aup->tx_head + 1) & (NUM_IR_DESC - 1); | 556 | aup->tx_head = (aup->tx_head + 1) & (NUM_IR_DESC - 1); |
557 | dev->trans_start = jiffies; | 557 | dev->trans_start = jiffies; |
558 | return 0; | 558 | return NETDEV_TX_OK; |
559 | } | 559 | } |
560 | 560 | ||
561 | 561 | ||
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c index 9a0346e751ac..e4e905698dc7 100644 --- a/drivers/net/irda/donauboe.c +++ b/drivers/net/irda/donauboe.c | |||
@@ -981,7 +981,7 @@ toshoboe_hard_xmit (struct sk_buff *skb, struct net_device *dev) | |||
981 | 981 | ||
982 | self = netdev_priv(dev); | 982 | self = netdev_priv(dev); |
983 | 983 | ||
984 | IRDA_ASSERT (self != NULL, return 0; ); | 984 | IRDA_ASSERT (self != NULL, return NETDEV_TX_OK; ); |
985 | 985 | ||
986 | IRDA_DEBUG (1, "%s.tx:%x(%x)%x\n", __func__ | 986 | IRDA_DEBUG (1, "%s.tx:%x(%x)%x\n", __func__ |
987 | ,skb->len,self->txpending,INB (OBOE_ENABLEH)); | 987 | ,skb->len,self->txpending,INB (OBOE_ENABLEH)); |
@@ -1021,7 +1021,7 @@ toshoboe_hard_xmit (struct sk_buff *skb, struct net_device *dev) | |||
1021 | { | 1021 | { |
1022 | spin_unlock_irqrestore(&self->spinlock, flags); | 1022 | spin_unlock_irqrestore(&self->spinlock, flags); |
1023 | dev_kfree_skb (skb); | 1023 | dev_kfree_skb (skb); |
1024 | return 0; | 1024 | return NETDEV_TX_OK; |
1025 | } | 1025 | } |
1026 | /* True packet, go on, but */ | 1026 | /* True packet, go on, but */ |
1027 | /* do not accept anything before change speed execution */ | 1027 | /* do not accept anything before change speed execution */ |
@@ -1036,7 +1036,7 @@ toshoboe_hard_xmit (struct sk_buff *skb, struct net_device *dev) | |||
1036 | toshoboe_setbaud (self); | 1036 | toshoboe_setbaud (self); |
1037 | spin_unlock_irqrestore(&self->spinlock, flags); | 1037 | spin_unlock_irqrestore(&self->spinlock, flags); |
1038 | dev_kfree_skb (skb); | 1038 | dev_kfree_skb (skb); |
1039 | return 0; | 1039 | return NETDEV_TX_OK; |
1040 | } | 1040 | } |
1041 | 1041 | ||
1042 | } | 1042 | } |
@@ -1143,7 +1143,7 @@ dumpbufs(skb->data,skb->len,'>'); | |||
1143 | spin_unlock_irqrestore(&self->spinlock, flags); | 1143 | spin_unlock_irqrestore(&self->spinlock, flags); |
1144 | dev_kfree_skb (skb); | 1144 | dev_kfree_skb (skb); |
1145 | 1145 | ||
1146 | return 0; | 1146 | return NETDEV_TX_OK; |
1147 | } | 1147 | } |
1148 | 1148 | ||
1149 | /*interrupt handler */ | 1149 | /*interrupt handler */ |
diff --git a/drivers/net/irda/irda-usb.c b/drivers/net/irda/irda-usb.c index 0c0831c03f64..6a1aa7a40fe2 100644 --- a/drivers/net/irda/irda-usb.c +++ b/drivers/net/irda/irda-usb.c | |||
@@ -534,7 +534,7 @@ static int irda_usb_hard_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
534 | } | 534 | } |
535 | spin_unlock_irqrestore(&self->lock, flags); | 535 | spin_unlock_irqrestore(&self->lock, flags); |
536 | 536 | ||
537 | return 0; | 537 | return NETDEV_TX_OK; |
538 | 538 | ||
539 | drop: | 539 | drop: |
540 | /* Drop silently the skb and exit */ | 540 | /* Drop silently the skb and exit */ |
diff --git a/drivers/net/irda/nsc-ircc.c b/drivers/net/irda/nsc-ircc.c index 45fd9c1eb343..51ca89c9a0ba 100644 --- a/drivers/net/irda/nsc-ircc.c +++ b/drivers/net/irda/nsc-ircc.c | |||
@@ -1365,7 +1365,7 @@ static int nsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev) | |||
1365 | 1365 | ||
1366 | self = netdev_priv(dev); | 1366 | self = netdev_priv(dev); |
1367 | 1367 | ||
1368 | IRDA_ASSERT(self != NULL, return 0;); | 1368 | IRDA_ASSERT(self != NULL, return NETDEV_TX_OK;); |
1369 | 1369 | ||
1370 | iobase = self->io.fir_base; | 1370 | iobase = self->io.fir_base; |
1371 | 1371 | ||
@@ -1397,7 +1397,7 @@ static int nsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev) | |||
1397 | dev->trans_start = jiffies; | 1397 | dev->trans_start = jiffies; |
1398 | spin_unlock_irqrestore(&self->lock, flags); | 1398 | spin_unlock_irqrestore(&self->lock, flags); |
1399 | dev_kfree_skb(skb); | 1399 | dev_kfree_skb(skb); |
1400 | return 0; | 1400 | return NETDEV_TX_OK; |
1401 | } else | 1401 | } else |
1402 | self->new_speed = speed; | 1402 | self->new_speed = speed; |
1403 | } | 1403 | } |
@@ -1424,7 +1424,7 @@ static int nsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev) | |||
1424 | 1424 | ||
1425 | dev_kfree_skb(skb); | 1425 | dev_kfree_skb(skb); |
1426 | 1426 | ||
1427 | return 0; | 1427 | return NETDEV_TX_OK; |
1428 | } | 1428 | } |
1429 | 1429 | ||
1430 | static int nsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) | 1430 | static int nsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) |
@@ -1467,7 +1467,7 @@ static int nsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) | |||
1467 | dev->trans_start = jiffies; | 1467 | dev->trans_start = jiffies; |
1468 | spin_unlock_irqrestore(&self->lock, flags); | 1468 | spin_unlock_irqrestore(&self->lock, flags); |
1469 | dev_kfree_skb(skb); | 1469 | dev_kfree_skb(skb); |
1470 | return 0; | 1470 | return NETDEV_TX_OK; |
1471 | } else { | 1471 | } else { |
1472 | /* Change speed after current frame */ | 1472 | /* Change speed after current frame */ |
1473 | self->new_speed = speed; | 1473 | self->new_speed = speed; |
@@ -1554,7 +1554,7 @@ static int nsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) | |||
1554 | spin_unlock_irqrestore(&self->lock, flags); | 1554 | spin_unlock_irqrestore(&self->lock, flags); |
1555 | dev_kfree_skb(skb); | 1555 | dev_kfree_skb(skb); |
1556 | 1556 | ||
1557 | return 0; | 1557 | return NETDEV_TX_OK; |
1558 | } | 1558 | } |
1559 | 1559 | ||
1560 | /* | 1560 | /* |
diff --git a/drivers/net/irda/pxaficp_ir.c b/drivers/net/irda/pxaficp_ir.c index 3376a4f39e0a..e76a083f901a 100644 --- a/drivers/net/irda/pxaficp_ir.c +++ b/drivers/net/irda/pxaficp_ir.c | |||
@@ -504,7 +504,7 @@ static int pxa_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
504 | pxa_irda_set_speed(si, speed); | 504 | pxa_irda_set_speed(si, speed); |
505 | } | 505 | } |
506 | dev_kfree_skb(skb); | 506 | dev_kfree_skb(skb); |
507 | return 0; | 507 | return NETDEV_TX_OK; |
508 | } | 508 | } |
509 | 509 | ||
510 | netif_stop_queue(dev); | 510 | netif_stop_queue(dev); |
@@ -539,7 +539,7 @@ static int pxa_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
539 | 539 | ||
540 | dev_kfree_skb(skb); | 540 | dev_kfree_skb(skb); |
541 | dev->trans_start = jiffies; | 541 | dev->trans_start = jiffies; |
542 | return 0; | 542 | return NETDEV_TX_OK; |
543 | } | 543 | } |
544 | 544 | ||
545 | static int pxa_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd) | 545 | static int pxa_irda_ioctl(struct net_device *dev, struct ifreq *ifreq, int cmd) |
diff --git a/drivers/net/irda/sa1100_ir.c b/drivers/net/irda/sa1100_ir.c index 2aeb2e6aec1b..70e6acc597b0 100644 --- a/drivers/net/irda/sa1100_ir.c +++ b/drivers/net/irda/sa1100_ir.c | |||
@@ -667,7 +667,7 @@ static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
667 | sa1100_irda_set_speed(si, speed); | 667 | sa1100_irda_set_speed(si, speed); |
668 | } | 668 | } |
669 | dev_kfree_skb(skb); | 669 | dev_kfree_skb(skb); |
670 | return 0; | 670 | return NETDEV_TX_OK; |
671 | } | 671 | } |
672 | 672 | ||
673 | if (!IS_FIR(si)) { | 673 | if (!IS_FIR(si)) { |
@@ -715,7 +715,7 @@ static int sa1100_irda_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
715 | 715 | ||
716 | dev->trans_start = jiffies; | 716 | dev->trans_start = jiffies; |
717 | 717 | ||
718 | return 0; | 718 | return NETDEV_TX_OK; |
719 | } | 719 | } |
720 | 720 | ||
721 | static int | 721 | static int |
diff --git a/drivers/net/irda/sir_dev.c b/drivers/net/irda/sir_dev.c index fd0796c3db3c..71dce20e62be 100644 --- a/drivers/net/irda/sir_dev.c +++ b/drivers/net/irda/sir_dev.c | |||
@@ -590,7 +590,7 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
590 | int err; | 590 | int err; |
591 | s32 speed; | 591 | s32 speed; |
592 | 592 | ||
593 | IRDA_ASSERT(dev != NULL, return 0;); | 593 | IRDA_ASSERT(dev != NULL, return NETDEV_TX_OK;); |
594 | 594 | ||
595 | netif_stop_queue(ndev); | 595 | netif_stop_queue(ndev); |
596 | 596 | ||
@@ -621,7 +621,7 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
621 | */ | 621 | */ |
622 | 622 | ||
623 | dev_kfree_skb_any(skb); | 623 | dev_kfree_skb_any(skb); |
624 | return 0; | 624 | return NETDEV_TX_OK; |
625 | } else | 625 | } else |
626 | dev->new_speed = speed; | 626 | dev->new_speed = speed; |
627 | } | 627 | } |
@@ -668,7 +668,7 @@ static int sirdev_hard_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
668 | } | 668 | } |
669 | spin_unlock_irqrestore(&dev->tx_lock, flags); | 669 | spin_unlock_irqrestore(&dev->tx_lock, flags); |
670 | 670 | ||
671 | return 0; | 671 | return NETDEV_TX_OK; |
672 | } | 672 | } |
673 | 673 | ||
674 | /* called from network layer with rtnl hold */ | 674 | /* called from network layer with rtnl hold */ |
diff --git a/drivers/net/irda/smsc-ircc2.c b/drivers/net/irda/smsc-ircc2.c index d0797adb5f8e..15f8a7f81600 100644 --- a/drivers/net/irda/smsc-ircc2.c +++ b/drivers/net/irda/smsc-ircc2.c | |||
@@ -886,10 +886,10 @@ static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev) | |||
886 | 886 | ||
887 | IRDA_DEBUG(1, "%s\n", __func__); | 887 | IRDA_DEBUG(1, "%s\n", __func__); |
888 | 888 | ||
889 | IRDA_ASSERT(dev != NULL, return 0;); | 889 | IRDA_ASSERT(dev != NULL, return NETDEV_TX_OK;); |
890 | 890 | ||
891 | self = netdev_priv(dev); | 891 | self = netdev_priv(dev); |
892 | IRDA_ASSERT(self != NULL, return 0;); | 892 | IRDA_ASSERT(self != NULL, return NETDEV_TX_OK;); |
893 | 893 | ||
894 | netif_stop_queue(dev); | 894 | netif_stop_queue(dev); |
895 | 895 | ||
@@ -914,7 +914,7 @@ static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev) | |||
914 | smsc_ircc_change_speed(self, speed); | 914 | smsc_ircc_change_speed(self, speed); |
915 | spin_unlock_irqrestore(&self->lock, flags); | 915 | spin_unlock_irqrestore(&self->lock, flags); |
916 | dev_kfree_skb(skb); | 916 | dev_kfree_skb(skb); |
917 | return 0; | 917 | return NETDEV_TX_OK; |
918 | } | 918 | } |
919 | self->new_speed = speed; | 919 | self->new_speed = speed; |
920 | } | 920 | } |
@@ -935,7 +935,7 @@ static int smsc_ircc_hard_xmit_sir(struct sk_buff *skb, struct net_device *dev) | |||
935 | 935 | ||
936 | dev_kfree_skb(skb); | 936 | dev_kfree_skb(skb); |
937 | 937 | ||
938 | return 0; | 938 | return NETDEV_TX_OK; |
939 | } | 939 | } |
940 | 940 | ||
941 | /* | 941 | /* |
@@ -1190,9 +1190,9 @@ static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) | |||
1190 | s32 speed; | 1190 | s32 speed; |
1191 | int mtt; | 1191 | int mtt; |
1192 | 1192 | ||
1193 | IRDA_ASSERT(dev != NULL, return 0;); | 1193 | IRDA_ASSERT(dev != NULL, return NETDEV_TX_OK;); |
1194 | self = netdev_priv(dev); | 1194 | self = netdev_priv(dev); |
1195 | IRDA_ASSERT(self != NULL, return 0;); | 1195 | IRDA_ASSERT(self != NULL, return NETDEV_TX_OK;); |
1196 | 1196 | ||
1197 | netif_stop_queue(dev); | 1197 | netif_stop_queue(dev); |
1198 | 1198 | ||
@@ -1210,7 +1210,7 @@ static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) | |||
1210 | smsc_ircc_change_speed(self, speed); | 1210 | smsc_ircc_change_speed(self, speed); |
1211 | spin_unlock_irqrestore(&self->lock, flags); | 1211 | spin_unlock_irqrestore(&self->lock, flags); |
1212 | dev_kfree_skb(skb); | 1212 | dev_kfree_skb(skb); |
1213 | return 0; | 1213 | return NETDEV_TX_OK; |
1214 | } | 1214 | } |
1215 | 1215 | ||
1216 | self->new_speed = speed; | 1216 | self->new_speed = speed; |
@@ -1242,7 +1242,7 @@ static int smsc_ircc_hard_xmit_fir(struct sk_buff *skb, struct net_device *dev) | |||
1242 | spin_unlock_irqrestore(&self->lock, flags); | 1242 | spin_unlock_irqrestore(&self->lock, flags); |
1243 | dev_kfree_skb(skb); | 1243 | dev_kfree_skb(skb); |
1244 | 1244 | ||
1245 | return 0; | 1245 | return NETDEV_TX_OK; |
1246 | } | 1246 | } |
1247 | 1247 | ||
1248 | /* | 1248 | /* |
diff --git a/drivers/net/irda/stir4200.c b/drivers/net/irda/stir4200.c index 8e5e45caf2f1..c475b23091bc 100644 --- a/drivers/net/irda/stir4200.c +++ b/drivers/net/irda/stir4200.c | |||
@@ -578,7 +578,7 @@ static int stir_hard_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
578 | dev_kfree_skb(skb); | 578 | dev_kfree_skb(skb); |
579 | } | 579 | } |
580 | 580 | ||
581 | return 0; | 581 | return NETDEV_TX_OK; |
582 | } | 582 | } |
583 | 583 | ||
584 | /* | 584 | /* |
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c index 864798502ff9..36a60748447b 100644 --- a/drivers/net/irda/via-ircc.c +++ b/drivers/net/irda/via-ircc.c | |||
@@ -832,7 +832,7 @@ static int via_ircc_hard_xmit_sir(struct sk_buff *skb, | |||
832 | __u32 speed; | 832 | __u32 speed; |
833 | 833 | ||
834 | self = netdev_priv(dev); | 834 | self = netdev_priv(dev); |
835 | IRDA_ASSERT(self != NULL, return 0;); | 835 | IRDA_ASSERT(self != NULL, return NETDEV_TX_OK;); |
836 | iobase = self->io.fir_base; | 836 | iobase = self->io.fir_base; |
837 | 837 | ||
838 | netif_stop_queue(dev); | 838 | netif_stop_queue(dev); |
@@ -844,7 +844,7 @@ static int via_ircc_hard_xmit_sir(struct sk_buff *skb, | |||
844 | via_ircc_change_speed(self, speed); | 844 | via_ircc_change_speed(self, speed); |
845 | dev->trans_start = jiffies; | 845 | dev->trans_start = jiffies; |
846 | dev_kfree_skb(skb); | 846 | dev_kfree_skb(skb); |
847 | return 0; | 847 | return NETDEV_TX_OK; |
848 | } else | 848 | } else |
849 | self->new_speed = speed; | 849 | self->new_speed = speed; |
850 | } | 850 | } |
@@ -892,7 +892,7 @@ static int via_ircc_hard_xmit_sir(struct sk_buff *skb, | |||
892 | dev->trans_start = jiffies; | 892 | dev->trans_start = jiffies; |
893 | spin_unlock_irqrestore(&self->lock, flags); | 893 | spin_unlock_irqrestore(&self->lock, flags); |
894 | dev_kfree_skb(skb); | 894 | dev_kfree_skb(skb); |
895 | return 0; | 895 | return NETDEV_TX_OK; |
896 | } | 896 | } |
897 | 897 | ||
898 | static int via_ircc_hard_xmit_fir(struct sk_buff *skb, | 898 | static int via_ircc_hard_xmit_fir(struct sk_buff *skb, |
@@ -907,7 +907,7 @@ static int via_ircc_hard_xmit_fir(struct sk_buff *skb, | |||
907 | iobase = self->io.fir_base; | 907 | iobase = self->io.fir_base; |
908 | 908 | ||
909 | if (self->st_fifo.len) | 909 | if (self->st_fifo.len) |
910 | return 0; | 910 | return NETDEV_TX_OK; |
911 | if (self->chip_id == 0x3076) | 911 | if (self->chip_id == 0x3076) |
912 | iodelay(1500); | 912 | iodelay(1500); |
913 | else | 913 | else |
@@ -919,7 +919,7 @@ static int via_ircc_hard_xmit_fir(struct sk_buff *skb, | |||
919 | via_ircc_change_speed(self, speed); | 919 | via_ircc_change_speed(self, speed); |
920 | dev->trans_start = jiffies; | 920 | dev->trans_start = jiffies; |
921 | dev_kfree_skb(skb); | 921 | dev_kfree_skb(skb); |
922 | return 0; | 922 | return NETDEV_TX_OK; |
923 | } else | 923 | } else |
924 | self->new_speed = speed; | 924 | self->new_speed = speed; |
925 | } | 925 | } |
@@ -940,7 +940,7 @@ static int via_ircc_hard_xmit_fir(struct sk_buff *skb, | |||
940 | dev->trans_start = jiffies; | 940 | dev->trans_start = jiffies; |
941 | dev_kfree_skb(skb); | 941 | dev_kfree_skb(skb); |
942 | spin_unlock_irqrestore(&self->lock, flags); | 942 | spin_unlock_irqrestore(&self->lock, flags); |
943 | return 0; | 943 | return NETDEV_TX_OK; |
944 | 944 | ||
945 | } | 945 | } |
946 | 946 | ||
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c index ac0e4b6b6b66..08e26f1297b4 100644 --- a/drivers/net/irda/vlsi_ir.c +++ b/drivers/net/irda/vlsi_ir.c | |||
@@ -915,7 +915,7 @@ static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
915 | */ | 915 | */ |
916 | spin_unlock_irqrestore(&idev->lock, flags); | 916 | spin_unlock_irqrestore(&idev->lock, flags); |
917 | dev_kfree_skb_any(skb); | 917 | dev_kfree_skb_any(skb); |
918 | return 0; | 918 | return NETDEV_TX_OK; |
919 | } | 919 | } |
920 | 920 | ||
921 | /* sanity checks - simply drop the packet */ | 921 | /* sanity checks - simply drop the packet */ |
@@ -1044,7 +1044,7 @@ static int vlsi_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
1044 | } | 1044 | } |
1045 | spin_unlock_irqrestore(&idev->lock, flags); | 1045 | spin_unlock_irqrestore(&idev->lock, flags); |
1046 | 1046 | ||
1047 | return 0; | 1047 | return NETDEV_TX_OK; |
1048 | 1048 | ||
1049 | drop_unlock: | 1049 | drop_unlock: |
1050 | spin_unlock_irqrestore(&idev->lock, flags); | 1050 | spin_unlock_irqrestore(&idev->lock, flags); |
@@ -1058,7 +1058,7 @@ drop: | |||
1058 | * packet for later retry of transmission - which isn't exactly | 1058 | * packet for later retry of transmission - which isn't exactly |
1059 | * what we want after we've just called dev_kfree_skb_any ;-) | 1059 | * what we want after we've just called dev_kfree_skb_any ;-) |
1060 | */ | 1060 | */ |
1061 | return 0; | 1061 | return NETDEV_TX_OK; |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | static void vlsi_tx_interrupt(struct net_device *ndev) | 1064 | static void vlsi_tx_interrupt(struct net_device *ndev) |
diff --git a/drivers/net/irda/w83977af_ir.c b/drivers/net/irda/w83977af_ir.c index d0883835b0c6..49ef76320f51 100644 --- a/drivers/net/irda/w83977af_ir.c +++ b/drivers/net/irda/w83977af_ir.c | |||
@@ -516,7 +516,7 @@ static int w83977af_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
516 | w83977af_change_speed(self, speed); | 516 | w83977af_change_speed(self, speed); |
517 | dev->trans_start = jiffies; | 517 | dev->trans_start = jiffies; |
518 | dev_kfree_skb(skb); | 518 | dev_kfree_skb(skb); |
519 | return 0; | 519 | return NETDEV_TX_OK; |
520 | } else | 520 | } else |
521 | self->new_speed = speed; | 521 | self->new_speed = speed; |
522 | } | 522 | } |
@@ -576,7 +576,7 @@ static int w83977af_hard_xmit(struct sk_buff *skb, struct net_device *dev) | |||
576 | /* Restore set register */ | 576 | /* Restore set register */ |
577 | outb(set, iobase+SSR); | 577 | outb(set, iobase+SSR); |
578 | 578 | ||
579 | return 0; | 579 | return NETDEV_TX_OK; |
580 | } | 580 | } |
581 | 581 | ||
582 | /* | 582 | /* |
diff --git a/drivers/net/isa-skeleton.c b/drivers/net/isa-skeleton.c index d12377b84358..9706e64e367b 100644 --- a/drivers/net/isa-skeleton.c +++ b/drivers/net/isa-skeleton.c | |||
@@ -468,7 +468,7 @@ static int net_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
468 | dev_kfree_skb (skb); | 468 | dev_kfree_skb (skb); |
469 | #endif | 469 | #endif |
470 | 470 | ||
471 | return 0; | 471 | return NETDEV_TX_OK; |
472 | } | 472 | } |
473 | 473 | ||
474 | #if TX_RING | 474 | #if TX_RING |
diff --git a/drivers/net/iseries_veth.c b/drivers/net/iseries_veth.c index e44215cb1882..e36e951cbc65 100644 --- a/drivers/net/iseries_veth.c +++ b/drivers/net/iseries_veth.c | |||
@@ -1205,7 +1205,7 @@ static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1205 | 1205 | ||
1206 | if ( ! ((1 << rlp) & port->lpar_map) ) { | 1206 | if ( ! ((1 << rlp) & port->lpar_map) ) { |
1207 | dev_kfree_skb(skb); | 1207 | dev_kfree_skb(skb); |
1208 | return 0; | 1208 | return NETDEV_TX_OK; |
1209 | } | 1209 | } |
1210 | 1210 | ||
1211 | lpmask = 1 << rlp; | 1211 | lpmask = 1 << rlp; |
@@ -1217,7 +1217,7 @@ static int veth_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1217 | 1217 | ||
1218 | dev_kfree_skb(skb); | 1218 | dev_kfree_skb(skb); |
1219 | 1219 | ||
1220 | return 0; | 1220 | return NETDEV_TX_OK; |
1221 | } | 1221 | } |
1222 | 1222 | ||
1223 | /* You must hold the connection's lock when you call this function. */ | 1223 | /* You must hold the connection's lock when you call this function. */ |
diff --git a/drivers/net/ixgb/ixgb_main.c b/drivers/net/ixgb/ixgb_main.c index 9c897cf86b9f..eb917f160274 100644 --- a/drivers/net/ixgb/ixgb_main.c +++ b/drivers/net/ixgb/ixgb_main.c | |||
@@ -1459,7 +1459,7 @@ ixgb_xmit_frame(struct sk_buff *skb, struct net_device *netdev) | |||
1459 | 1459 | ||
1460 | if (skb->len <= 0) { | 1460 | if (skb->len <= 0) { |
1461 | dev_kfree_skb(skb); | 1461 | dev_kfree_skb(skb); |
1462 | return 0; | 1462 | return NETDEV_TX_OK; |
1463 | } | 1463 | } |
1464 | 1464 | ||
1465 | if (unlikely(ixgb_maybe_stop_tx(netdev, &adapter->tx_ring, | 1465 | if (unlikely(ixgb_maybe_stop_tx(netdev, &adapter->tx_ring, |
diff --git a/drivers/net/ixp2000/ixpdev.c b/drivers/net/ixp2000/ixpdev.c index 2a0174b62e96..588b44d944ce 100644 --- a/drivers/net/ixp2000/ixpdev.c +++ b/drivers/net/ixp2000/ixpdev.c | |||
@@ -45,7 +45,7 @@ static int ixpdev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
45 | if (unlikely(skb->len > PAGE_SIZE)) { | 45 | if (unlikely(skb->len > PAGE_SIZE)) { |
46 | /* @@@ Count drops. */ | 46 | /* @@@ Count drops. */ |
47 | dev_kfree_skb(skb); | 47 | dev_kfree_skb(skb); |
48 | return 0; | 48 | return NETDEV_TX_OK; |
49 | } | 49 | } |
50 | 50 | ||
51 | entry = tx_pointer; | 51 | entry = tx_pointer; |
@@ -69,7 +69,7 @@ static int ixpdev_xmit(struct sk_buff *skb, struct net_device *dev) | |||
69 | netif_stop_queue(dev); | 69 | netif_stop_queue(dev); |
70 | local_irq_enable(); | 70 | local_irq_enable(); |
71 | 71 | ||
72 | return 0; | 72 | return NETDEV_TX_OK; |
73 | } | 73 | } |
74 | 74 | ||
75 | 75 | ||
diff --git a/drivers/net/jme.c b/drivers/net/jme.c index 1e3c63d67b91..e7068c7cd627 100644 --- a/drivers/net/jme.c +++ b/drivers/net/jme.c | |||
@@ -322,20 +322,6 @@ jme_stop_irq(struct jme_adapter *jme) | |||
322 | jwrite32f(jme, JME_IENC, INTR_ENABLE); | 322 | jwrite32f(jme, JME_IENC, INTR_ENABLE); |
323 | } | 323 | } |
324 | 324 | ||
325 | static inline void | ||
326 | jme_enable_shadow(struct jme_adapter *jme) | ||
327 | { | ||
328 | jwrite32(jme, | ||
329 | JME_SHBA_LO, | ||
330 | ((u32)jme->shadow_dma & ~((u32)0x1F)) | SHBA_POSTEN); | ||
331 | } | ||
332 | |||
333 | static inline void | ||
334 | jme_disable_shadow(struct jme_adapter *jme) | ||
335 | { | ||
336 | jwrite32(jme, JME_SHBA_LO, 0x0); | ||
337 | } | ||
338 | |||
339 | static u32 | 325 | static u32 |
340 | jme_linkstat_from_phy(struct jme_adapter *jme) | 326 | jme_linkstat_from_phy(struct jme_adapter *jme) |
341 | { | 327 | { |
@@ -522,12 +508,8 @@ jme_setup_tx_resources(struct jme_adapter *jme) | |||
522 | &(txring->dmaalloc), | 508 | &(txring->dmaalloc), |
523 | GFP_ATOMIC); | 509 | GFP_ATOMIC); |
524 | 510 | ||
525 | if (!txring->alloc) { | 511 | if (!txring->alloc) |
526 | txring->desc = NULL; | 512 | goto err_set_null; |
527 | txring->dmaalloc = 0; | ||
528 | txring->dma = 0; | ||
529 | return -ENOMEM; | ||
530 | } | ||
531 | 513 | ||
532 | /* | 514 | /* |
533 | * 16 Bytes align | 515 | * 16 Bytes align |
@@ -539,6 +521,11 @@ jme_setup_tx_resources(struct jme_adapter *jme) | |||
539 | atomic_set(&txring->next_to_clean, 0); | 521 | atomic_set(&txring->next_to_clean, 0); |
540 | atomic_set(&txring->nr_free, jme->tx_ring_size); | 522 | atomic_set(&txring->nr_free, jme->tx_ring_size); |
541 | 523 | ||
524 | txring->bufinf = kmalloc(sizeof(struct jme_buffer_info) * | ||
525 | jme->tx_ring_size, GFP_ATOMIC); | ||
526 | if (unlikely(!(txring->bufinf))) | ||
527 | goto err_free_txring; | ||
528 | |||
542 | /* | 529 | /* |
543 | * Initialize Transmit Descriptors | 530 | * Initialize Transmit Descriptors |
544 | */ | 531 | */ |
@@ -547,6 +534,20 @@ jme_setup_tx_resources(struct jme_adapter *jme) | |||
547 | sizeof(struct jme_buffer_info) * jme->tx_ring_size); | 534 | sizeof(struct jme_buffer_info) * jme->tx_ring_size); |
548 | 535 | ||
549 | return 0; | 536 | return 0; |
537 | |||
538 | err_free_txring: | ||
539 | dma_free_coherent(&(jme->pdev->dev), | ||
540 | TX_RING_ALLOC_SIZE(jme->tx_ring_size), | ||
541 | txring->alloc, | ||
542 | txring->dmaalloc); | ||
543 | |||
544 | err_set_null: | ||
545 | txring->desc = NULL; | ||
546 | txring->dmaalloc = 0; | ||
547 | txring->dma = 0; | ||
548 | txring->bufinf = NULL; | ||
549 | |||
550 | return -ENOMEM; | ||
550 | } | 551 | } |
551 | 552 | ||
552 | static void | 553 | static void |
@@ -554,19 +555,22 @@ jme_free_tx_resources(struct jme_adapter *jme) | |||
554 | { | 555 | { |
555 | int i; | 556 | int i; |
556 | struct jme_ring *txring = &(jme->txring[0]); | 557 | struct jme_ring *txring = &(jme->txring[0]); |
557 | struct jme_buffer_info *txbi = txring->bufinf; | 558 | struct jme_buffer_info *txbi; |
558 | 559 | ||
559 | if (txring->alloc) { | 560 | if (txring->alloc) { |
560 | for (i = 0 ; i < jme->tx_ring_size ; ++i) { | 561 | if (txring->bufinf) { |
561 | txbi = txring->bufinf + i; | 562 | for (i = 0 ; i < jme->tx_ring_size ; ++i) { |
562 | if (txbi->skb) { | 563 | txbi = txring->bufinf + i; |
563 | dev_kfree_skb(txbi->skb); | 564 | if (txbi->skb) { |
564 | txbi->skb = NULL; | 565 | dev_kfree_skb(txbi->skb); |
566 | txbi->skb = NULL; | ||
567 | } | ||
568 | txbi->mapping = 0; | ||
569 | txbi->len = 0; | ||
570 | txbi->nr_desc = 0; | ||
571 | txbi->start_xmit = 0; | ||
565 | } | 572 | } |
566 | txbi->mapping = 0; | 573 | kfree(txring->bufinf); |
567 | txbi->len = 0; | ||
568 | txbi->nr_desc = 0; | ||
569 | txbi->start_xmit = 0; | ||
570 | } | 574 | } |
571 | 575 | ||
572 | dma_free_coherent(&(jme->pdev->dev), | 576 | dma_free_coherent(&(jme->pdev->dev), |
@@ -578,11 +582,11 @@ jme_free_tx_resources(struct jme_adapter *jme) | |||
578 | txring->desc = NULL; | 582 | txring->desc = NULL; |
579 | txring->dmaalloc = 0; | 583 | txring->dmaalloc = 0; |
580 | txring->dma = 0; | 584 | txring->dma = 0; |
585 | txring->bufinf = NULL; | ||
581 | } | 586 | } |
582 | txring->next_to_use = 0; | 587 | txring->next_to_use = 0; |
583 | atomic_set(&txring->next_to_clean, 0); | 588 | atomic_set(&txring->next_to_clean, 0); |
584 | atomic_set(&txring->nr_free, 0); | 589 | atomic_set(&txring->nr_free, 0); |
585 | |||
586 | } | 590 | } |
587 | 591 | ||
588 | static inline void | 592 | static inline void |
@@ -653,7 +657,7 @@ jme_disable_tx_engine(struct jme_adapter *jme) | |||
653 | static void | 657 | static void |
654 | jme_set_clean_rxdesc(struct jme_adapter *jme, int i) | 658 | jme_set_clean_rxdesc(struct jme_adapter *jme, int i) |
655 | { | 659 | { |
656 | struct jme_ring *rxring = jme->rxring; | 660 | struct jme_ring *rxring = &(jme->rxring[0]); |
657 | register struct rxdesc *rxdesc = rxring->desc; | 661 | register struct rxdesc *rxdesc = rxring->desc; |
658 | struct jme_buffer_info *rxbi = rxring->bufinf; | 662 | struct jme_buffer_info *rxbi = rxring->bufinf; |
659 | rxdesc += i; | 663 | rxdesc += i; |
@@ -720,8 +724,11 @@ jme_free_rx_resources(struct jme_adapter *jme) | |||
720 | struct jme_ring *rxring = &(jme->rxring[0]); | 724 | struct jme_ring *rxring = &(jme->rxring[0]); |
721 | 725 | ||
722 | if (rxring->alloc) { | 726 | if (rxring->alloc) { |
723 | for (i = 0 ; i < jme->rx_ring_size ; ++i) | 727 | if (rxring->bufinf) { |
724 | jme_free_rx_buf(jme, i); | 728 | for (i = 0 ; i < jme->rx_ring_size ; ++i) |
729 | jme_free_rx_buf(jme, i); | ||
730 | kfree(rxring->bufinf); | ||
731 | } | ||
725 | 732 | ||
726 | dma_free_coherent(&(jme->pdev->dev), | 733 | dma_free_coherent(&(jme->pdev->dev), |
727 | RX_RING_ALLOC_SIZE(jme->rx_ring_size), | 734 | RX_RING_ALLOC_SIZE(jme->rx_ring_size), |
@@ -731,6 +738,7 @@ jme_free_rx_resources(struct jme_adapter *jme) | |||
731 | rxring->desc = NULL; | 738 | rxring->desc = NULL; |
732 | rxring->dmaalloc = 0; | 739 | rxring->dmaalloc = 0; |
733 | rxring->dma = 0; | 740 | rxring->dma = 0; |
741 | rxring->bufinf = NULL; | ||
734 | } | 742 | } |
735 | rxring->next_to_use = 0; | 743 | rxring->next_to_use = 0; |
736 | atomic_set(&rxring->next_to_clean, 0); | 744 | atomic_set(&rxring->next_to_clean, 0); |
@@ -746,12 +754,8 @@ jme_setup_rx_resources(struct jme_adapter *jme) | |||
746 | RX_RING_ALLOC_SIZE(jme->rx_ring_size), | 754 | RX_RING_ALLOC_SIZE(jme->rx_ring_size), |
747 | &(rxring->dmaalloc), | 755 | &(rxring->dmaalloc), |
748 | GFP_ATOMIC); | 756 | GFP_ATOMIC); |
749 | if (!rxring->alloc) { | 757 | if (!rxring->alloc) |
750 | rxring->desc = NULL; | 758 | goto err_set_null; |
751 | rxring->dmaalloc = 0; | ||
752 | rxring->dma = 0; | ||
753 | return -ENOMEM; | ||
754 | } | ||
755 | 759 | ||
756 | /* | 760 | /* |
757 | * 16 Bytes align | 761 | * 16 Bytes align |
@@ -762,9 +766,16 @@ jme_setup_rx_resources(struct jme_adapter *jme) | |||
762 | rxring->next_to_use = 0; | 766 | rxring->next_to_use = 0; |
763 | atomic_set(&rxring->next_to_clean, 0); | 767 | atomic_set(&rxring->next_to_clean, 0); |
764 | 768 | ||
769 | rxring->bufinf = kmalloc(sizeof(struct jme_buffer_info) * | ||
770 | jme->rx_ring_size, GFP_ATOMIC); | ||
771 | if (unlikely(!(rxring->bufinf))) | ||
772 | goto err_free_rxring; | ||
773 | |||
765 | /* | 774 | /* |
766 | * Initiallize Receive Descriptors | 775 | * Initiallize Receive Descriptors |
767 | */ | 776 | */ |
777 | memset(rxring->bufinf, 0, | ||
778 | sizeof(struct jme_buffer_info) * jme->rx_ring_size); | ||
768 | for (i = 0 ; i < jme->rx_ring_size ; ++i) { | 779 | for (i = 0 ; i < jme->rx_ring_size ; ++i) { |
769 | if (unlikely(jme_make_new_rx_buf(jme, i))) { | 780 | if (unlikely(jme_make_new_rx_buf(jme, i))) { |
770 | jme_free_rx_resources(jme); | 781 | jme_free_rx_resources(jme); |
@@ -775,6 +786,19 @@ jme_setup_rx_resources(struct jme_adapter *jme) | |||
775 | } | 786 | } |
776 | 787 | ||
777 | return 0; | 788 | return 0; |
789 | |||
790 | err_free_rxring: | ||
791 | dma_free_coherent(&(jme->pdev->dev), | ||
792 | RX_RING_ALLOC_SIZE(jme->rx_ring_size), | ||
793 | rxring->alloc, | ||
794 | rxring->dmaalloc); | ||
795 | err_set_null: | ||
796 | rxring->desc = NULL; | ||
797 | rxring->dmaalloc = 0; | ||
798 | rxring->dma = 0; | ||
799 | rxring->bufinf = NULL; | ||
800 | |||
801 | return -ENOMEM; | ||
778 | } | 802 | } |
779 | 803 | ||
780 | static inline void | 804 | static inline void |
@@ -790,9 +814,9 @@ jme_enable_rx_engine(struct jme_adapter *jme) | |||
790 | /* | 814 | /* |
791 | * Setup RX DMA Bass Address | 815 | * Setup RX DMA Bass Address |
792 | */ | 816 | */ |
793 | jwrite32(jme, JME_RXDBA_LO, (__u64)jme->rxring[0].dma & 0xFFFFFFFFUL); | 817 | jwrite32(jme, JME_RXDBA_LO, (__u64)(jme->rxring[0].dma) & 0xFFFFFFFFUL); |
794 | jwrite32(jme, JME_RXDBA_HI, (__u64)(jme->rxring[0].dma) >> 32); | 818 | jwrite32(jme, JME_RXDBA_HI, (__u64)(jme->rxring[0].dma) >> 32); |
795 | jwrite32(jme, JME_RXNDA, (__u64)jme->rxring[0].dma & 0xFFFFFFFFUL); | 819 | jwrite32(jme, JME_RXNDA, (__u64)(jme->rxring[0].dma) & 0xFFFFFFFFUL); |
796 | 820 | ||
797 | /* | 821 | /* |
798 | * Setup RX Descriptor Count | 822 | * Setup RX Descriptor Count |
@@ -856,27 +880,27 @@ jme_rxsum_ok(struct jme_adapter *jme, u16 flags) | |||
856 | if (!(flags & (RXWBFLAG_TCPON | RXWBFLAG_UDPON | RXWBFLAG_IPV4))) | 880 | if (!(flags & (RXWBFLAG_TCPON | RXWBFLAG_UDPON | RXWBFLAG_IPV4))) |
857 | return false; | 881 | return false; |
858 | 882 | ||
859 | if (unlikely(!(flags & RXWBFLAG_MF) && | 883 | if (unlikely((flags & (RXWBFLAG_MF | RXWBFLAG_TCPON | RXWBFLAG_TCPCS)) |
860 | (flags & RXWBFLAG_TCPON) && !(flags & RXWBFLAG_TCPCS))) { | 884 | == RXWBFLAG_TCPON)) { |
861 | msg_rx_err(jme, "TCP Checksum error.\n"); | 885 | if (flags & RXWBFLAG_IPV4) |
862 | goto out_sumerr; | 886 | msg_rx_err(jme, "TCP Checksum error\n"); |
887 | return false; | ||
863 | } | 888 | } |
864 | 889 | ||
865 | if (unlikely(!(flags & RXWBFLAG_MF) && | 890 | if (unlikely((flags & (RXWBFLAG_MF | RXWBFLAG_UDPON | RXWBFLAG_UDPCS)) |
866 | (flags & RXWBFLAG_UDPON) && !(flags & RXWBFLAG_UDPCS))) { | 891 | == RXWBFLAG_UDPON)) { |
867 | msg_rx_err(jme, "UDP Checksum error.\n"); | 892 | if (flags & RXWBFLAG_IPV4) |
868 | goto out_sumerr; | 893 | msg_rx_err(jme, "UDP Checksum error.\n"); |
894 | return false; | ||
869 | } | 895 | } |
870 | 896 | ||
871 | if (unlikely((flags & RXWBFLAG_IPV4) && !(flags & RXWBFLAG_IPCS))) { | 897 | if (unlikely((flags & (RXWBFLAG_IPV4 | RXWBFLAG_IPCS)) |
898 | == RXWBFLAG_IPV4)) { | ||
872 | msg_rx_err(jme, "IPv4 Checksum error.\n"); | 899 | msg_rx_err(jme, "IPv4 Checksum error.\n"); |
873 | goto out_sumerr; | 900 | return false; |
874 | } | 901 | } |
875 | 902 | ||
876 | return true; | 903 | return true; |
877 | |||
878 | out_sumerr: | ||
879 | return false; | ||
880 | } | 904 | } |
881 | 905 | ||
882 | static void | 906 | static void |
@@ -1296,7 +1320,7 @@ jme_rx_empty_tasklet(unsigned long arg) | |||
1296 | static void | 1320 | static void |
1297 | jme_wake_queue_if_stopped(struct jme_adapter *jme) | 1321 | jme_wake_queue_if_stopped(struct jme_adapter *jme) |
1298 | { | 1322 | { |
1299 | struct jme_ring *txring = jme->txring; | 1323 | struct jme_ring *txring = &(jme->txring[0]); |
1300 | 1324 | ||
1301 | smp_wmb(); | 1325 | smp_wmb(); |
1302 | if (unlikely(netif_queue_stopped(jme->dev) && | 1326 | if (unlikely(netif_queue_stopped(jme->dev) && |
@@ -1483,12 +1507,7 @@ jme_msi(int irq, void *dev_id) | |||
1483 | struct jme_adapter *jme = netdev_priv(netdev); | 1507 | struct jme_adapter *jme = netdev_priv(netdev); |
1484 | u32 intrstat; | 1508 | u32 intrstat; |
1485 | 1509 | ||
1486 | pci_dma_sync_single_for_cpu(jme->pdev, | 1510 | intrstat = jread32(jme, JME_IEVE); |
1487 | jme->shadow_dma, | ||
1488 | sizeof(u32) * SHADOW_REG_NR, | ||
1489 | PCI_DMA_FROMDEVICE); | ||
1490 | intrstat = jme->shadow_regs[SHADOW_IEVE]; | ||
1491 | jme->shadow_regs[SHADOW_IEVE] = 0; | ||
1492 | 1511 | ||
1493 | jme_intr_msi(jme, intrstat); | 1512 | jme_intr_msi(jme, intrstat); |
1494 | 1513 | ||
@@ -1566,6 +1585,7 @@ jme_open(struct net_device *netdev) | |||
1566 | jme_clear_pm(jme); | 1585 | jme_clear_pm(jme); |
1567 | JME_NAPI_ENABLE(jme); | 1586 | JME_NAPI_ENABLE(jme); |
1568 | 1587 | ||
1588 | tasklet_enable(&jme->linkch_task); | ||
1569 | tasklet_enable(&jme->txclean_task); | 1589 | tasklet_enable(&jme->txclean_task); |
1570 | tasklet_hi_enable(&jme->rxclean_task); | 1590 | tasklet_hi_enable(&jme->rxclean_task); |
1571 | tasklet_hi_enable(&jme->rxempty_task); | 1591 | tasklet_hi_enable(&jme->rxempty_task); |
@@ -1574,7 +1594,6 @@ jme_open(struct net_device *netdev) | |||
1574 | if (rc) | 1594 | if (rc) |
1575 | goto err_out; | 1595 | goto err_out; |
1576 | 1596 | ||
1577 | jme_enable_shadow(jme); | ||
1578 | jme_start_irq(jme); | 1597 | jme_start_irq(jme); |
1579 | 1598 | ||
1580 | if (test_bit(JME_FLAG_SSET, &jme->flags)) | 1599 | if (test_bit(JME_FLAG_SSET, &jme->flags)) |
@@ -1642,15 +1661,14 @@ jme_close(struct net_device *netdev) | |||
1642 | netif_carrier_off(netdev); | 1661 | netif_carrier_off(netdev); |
1643 | 1662 | ||
1644 | jme_stop_irq(jme); | 1663 | jme_stop_irq(jme); |
1645 | jme_disable_shadow(jme); | ||
1646 | jme_free_irq(jme); | 1664 | jme_free_irq(jme); |
1647 | 1665 | ||
1648 | JME_NAPI_DISABLE(jme); | 1666 | JME_NAPI_DISABLE(jme); |
1649 | 1667 | ||
1650 | tasklet_kill(&jme->linkch_task); | 1668 | tasklet_disable(&jme->linkch_task); |
1651 | tasklet_kill(&jme->txclean_task); | 1669 | tasklet_disable(&jme->txclean_task); |
1652 | tasklet_kill(&jme->rxclean_task); | 1670 | tasklet_disable(&jme->rxclean_task); |
1653 | tasklet_kill(&jme->rxempty_task); | 1671 | tasklet_disable(&jme->rxempty_task); |
1654 | 1672 | ||
1655 | jme_reset_ghc_speed(jme); | 1673 | jme_reset_ghc_speed(jme); |
1656 | jme_disable_rx_engine(jme); | 1674 | jme_disable_rx_engine(jme); |
@@ -1668,7 +1686,7 @@ static int | |||
1668 | jme_alloc_txdesc(struct jme_adapter *jme, | 1686 | jme_alloc_txdesc(struct jme_adapter *jme, |
1669 | struct sk_buff *skb) | 1687 | struct sk_buff *skb) |
1670 | { | 1688 | { |
1671 | struct jme_ring *txring = jme->txring; | 1689 | struct jme_ring *txring = &(jme->txring[0]); |
1672 | int idx, nr_alloc, mask = jme->tx_ring_mask; | 1690 | int idx, nr_alloc, mask = jme->tx_ring_mask; |
1673 | 1691 | ||
1674 | idx = txring->next_to_use; | 1692 | idx = txring->next_to_use; |
@@ -1722,7 +1740,7 @@ jme_fill_tx_map(struct pci_dev *pdev, | |||
1722 | static void | 1740 | static void |
1723 | jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx) | 1741 | jme_map_tx_skb(struct jme_adapter *jme, struct sk_buff *skb, int idx) |
1724 | { | 1742 | { |
1725 | struct jme_ring *txring = jme->txring; | 1743 | struct jme_ring *txring = &(jme->txring[0]); |
1726 | struct txdesc *txdesc = txring->desc, *ctxdesc; | 1744 | struct txdesc *txdesc = txring->desc, *ctxdesc; |
1727 | struct jme_buffer_info *txbi = txring->bufinf, *ctxbi; | 1745 | struct jme_buffer_info *txbi = txring->bufinf, *ctxbi; |
1728 | u8 hidma = jme->dev->features & NETIF_F_HIGHDMA; | 1746 | u8 hidma = jme->dev->features & NETIF_F_HIGHDMA; |
@@ -1835,7 +1853,7 @@ jme_tx_vlan(struct sk_buff *skb, __le16 *vlan, u8 *flags) | |||
1835 | static int | 1853 | static int |
1836 | jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx) | 1854 | jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx) |
1837 | { | 1855 | { |
1838 | struct jme_ring *txring = jme->txring; | 1856 | struct jme_ring *txring = &(jme->txring[0]); |
1839 | struct txdesc *txdesc; | 1857 | struct txdesc *txdesc; |
1840 | struct jme_buffer_info *txbi; | 1858 | struct jme_buffer_info *txbi; |
1841 | u8 flags; | 1859 | u8 flags; |
@@ -1883,7 +1901,7 @@ jme_fill_tx_desc(struct jme_adapter *jme, struct sk_buff *skb, int idx) | |||
1883 | static void | 1901 | static void |
1884 | jme_stop_queue_if_full(struct jme_adapter *jme) | 1902 | jme_stop_queue_if_full(struct jme_adapter *jme) |
1885 | { | 1903 | { |
1886 | struct jme_ring *txring = jme->txring; | 1904 | struct jme_ring *txring = &(jme->txring[0]); |
1887 | struct jme_buffer_info *txbi = txring->bufinf; | 1905 | struct jme_buffer_info *txbi = txring->bufinf; |
1888 | int idx = atomic_read(&txring->next_to_clean); | 1906 | int idx = atomic_read(&txring->next_to_clean); |
1889 | 1907 | ||
@@ -2725,14 +2743,6 @@ jme_init_one(struct pci_dev *pdev, | |||
2725 | rc = -ENOMEM; | 2743 | rc = -ENOMEM; |
2726 | goto err_out_free_netdev; | 2744 | goto err_out_free_netdev; |
2727 | } | 2745 | } |
2728 | jme->shadow_regs = pci_alloc_consistent(pdev, | ||
2729 | sizeof(u32) * SHADOW_REG_NR, | ||
2730 | &(jme->shadow_dma)); | ||
2731 | if (!(jme->shadow_regs)) { | ||
2732 | jeprintk(pdev, "Allocating shadow register mapping error.\n"); | ||
2733 | rc = -ENOMEM; | ||
2734 | goto err_out_unmap; | ||
2735 | } | ||
2736 | 2746 | ||
2737 | if (no_pseudohp) { | 2747 | if (no_pseudohp) { |
2738 | apmc = jread32(jme, JME_APMC) & ~JME_APMC_PSEUDO_HP_EN; | 2748 | apmc = jread32(jme, JME_APMC) & ~JME_APMC_PSEUDO_HP_EN; |
@@ -2768,6 +2778,7 @@ jme_init_one(struct pci_dev *pdev, | |||
2768 | tasklet_init(&jme->rxempty_task, | 2778 | tasklet_init(&jme->rxempty_task, |
2769 | &jme_rx_empty_tasklet, | 2779 | &jme_rx_empty_tasklet, |
2770 | (unsigned long) jme); | 2780 | (unsigned long) jme); |
2781 | tasklet_disable_nosync(&jme->linkch_task); | ||
2771 | tasklet_disable_nosync(&jme->txclean_task); | 2782 | tasklet_disable_nosync(&jme->txclean_task); |
2772 | tasklet_disable_nosync(&jme->rxclean_task); | 2783 | tasklet_disable_nosync(&jme->rxclean_task); |
2773 | tasklet_disable_nosync(&jme->rxempty_task); | 2784 | tasklet_disable_nosync(&jme->rxempty_task); |
@@ -2817,7 +2828,7 @@ jme_init_one(struct pci_dev *pdev, | |||
2817 | if (!jme->mii_if.phy_id) { | 2828 | if (!jme->mii_if.phy_id) { |
2818 | rc = -EIO; | 2829 | rc = -EIO; |
2819 | jeprintk(pdev, "Can not find phy_id.\n"); | 2830 | jeprintk(pdev, "Can not find phy_id.\n"); |
2820 | goto err_out_free_shadow; | 2831 | goto err_out_unmap; |
2821 | } | 2832 | } |
2822 | 2833 | ||
2823 | jme->reg_ghc |= GHC_LINK_POLL; | 2834 | jme->reg_ghc |= GHC_LINK_POLL; |
@@ -2846,7 +2857,7 @@ jme_init_one(struct pci_dev *pdev, | |||
2846 | if (rc) { | 2857 | if (rc) { |
2847 | jeprintk(pdev, | 2858 | jeprintk(pdev, |
2848 | "Reload eeprom for reading MAC Address error.\n"); | 2859 | "Reload eeprom for reading MAC Address error.\n"); |
2849 | goto err_out_free_shadow; | 2860 | goto err_out_unmap; |
2850 | } | 2861 | } |
2851 | jme_load_macaddr(netdev); | 2862 | jme_load_macaddr(netdev); |
2852 | 2863 | ||
@@ -2862,7 +2873,7 @@ jme_init_one(struct pci_dev *pdev, | |||
2862 | rc = register_netdev(netdev); | 2873 | rc = register_netdev(netdev); |
2863 | if (rc) { | 2874 | if (rc) { |
2864 | jeprintk(pdev, "Cannot register net device.\n"); | 2875 | jeprintk(pdev, "Cannot register net device.\n"); |
2865 | goto err_out_free_shadow; | 2876 | goto err_out_unmap; |
2866 | } | 2877 | } |
2867 | 2878 | ||
2868 | msg_probe(jme, "%s%s ver:%x rev:%x macaddr:%pM\n", | 2879 | msg_probe(jme, "%s%s ver:%x rev:%x macaddr:%pM\n", |
@@ -2876,11 +2887,6 @@ jme_init_one(struct pci_dev *pdev, | |||
2876 | 2887 | ||
2877 | return 0; | 2888 | return 0; |
2878 | 2889 | ||
2879 | err_out_free_shadow: | ||
2880 | pci_free_consistent(pdev, | ||
2881 | sizeof(u32) * SHADOW_REG_NR, | ||
2882 | jme->shadow_regs, | ||
2883 | jme->shadow_dma); | ||
2884 | err_out_unmap: | 2890 | err_out_unmap: |
2885 | iounmap(jme->regs); | 2891 | iounmap(jme->regs); |
2886 | err_out_free_netdev: | 2892 | err_out_free_netdev: |
@@ -2901,10 +2907,6 @@ jme_remove_one(struct pci_dev *pdev) | |||
2901 | struct jme_adapter *jme = netdev_priv(netdev); | 2907 | struct jme_adapter *jme = netdev_priv(netdev); |
2902 | 2908 | ||
2903 | unregister_netdev(netdev); | 2909 | unregister_netdev(netdev); |
2904 | pci_free_consistent(pdev, | ||
2905 | sizeof(u32) * SHADOW_REG_NR, | ||
2906 | jme->shadow_regs, | ||
2907 | jme->shadow_dma); | ||
2908 | iounmap(jme->regs); | 2910 | iounmap(jme->regs); |
2909 | pci_set_drvdata(pdev, NULL); | 2911 | pci_set_drvdata(pdev, NULL); |
2910 | free_netdev(netdev); | 2912 | free_netdev(netdev); |
@@ -2930,8 +2932,6 @@ jme_suspend(struct pci_dev *pdev, pm_message_t state) | |||
2930 | tasklet_disable(&jme->rxclean_task); | 2932 | tasklet_disable(&jme->rxclean_task); |
2931 | tasklet_disable(&jme->rxempty_task); | 2933 | tasklet_disable(&jme->rxempty_task); |
2932 | 2934 | ||
2933 | jme_disable_shadow(jme); | ||
2934 | |||
2935 | if (netif_carrier_ok(netdev)) { | 2935 | if (netif_carrier_ok(netdev)) { |
2936 | if (test_bit(JME_FLAG_POLL, &jme->flags)) | 2936 | if (test_bit(JME_FLAG_POLL, &jme->flags)) |
2937 | jme_polling_mode(jme); | 2937 | jme_polling_mode(jme); |
@@ -2983,7 +2983,6 @@ jme_resume(struct pci_dev *pdev) | |||
2983 | else | 2983 | else |
2984 | jme_reset_phy_processor(jme); | 2984 | jme_reset_phy_processor(jme); |
2985 | 2985 | ||
2986 | jme_enable_shadow(jme); | ||
2987 | jme_start_irq(jme); | 2986 | jme_start_irq(jme); |
2988 | netif_device_attach(netdev); | 2987 | netif_device_attach(netdev); |
2989 | 2988 | ||
diff --git a/drivers/net/jme.h b/drivers/net/jme.h index 0996a069ac7b..251abed3817e 100644 --- a/drivers/net/jme.h +++ b/drivers/net/jme.h | |||
@@ -25,7 +25,7 @@ | |||
25 | #define __JME_H_INCLUDED__ | 25 | #define __JME_H_INCLUDED__ |
26 | 26 | ||
27 | #define DRV_NAME "jme" | 27 | #define DRV_NAME "jme" |
28 | #define DRV_VERSION "1.0.4" | 28 | #define DRV_VERSION "1.0.5" |
29 | #define PFX DRV_NAME ": " | 29 | #define PFX DRV_NAME ": " |
30 | 30 | ||
31 | #define PCI_DEVICE_ID_JMICRON_JMC250 0x0250 | 31 | #define PCI_DEVICE_ID_JMICRON_JMC250 0x0250 |
@@ -247,7 +247,7 @@ enum jme_txdesc_flags_bits { | |||
247 | }; | 247 | }; |
248 | 248 | ||
249 | #define TXDESC_MSS_SHIFT 2 | 249 | #define TXDESC_MSS_SHIFT 2 |
250 | enum jme_rxdescwb_flags_bits { | 250 | enum jme_txwbdesc_flags_bits { |
251 | TXWBFLAG_OWN = 0x80, | 251 | TXWBFLAG_OWN = 0x80, |
252 | TXWBFLAG_INT = 0x40, | 252 | TXWBFLAG_INT = 0x40, |
253 | TXWBFLAG_TMOUT = 0x20, | 253 | TXWBFLAG_TMOUT = 0x20, |
@@ -372,7 +372,6 @@ struct jme_buffer_info { | |||
372 | /* | 372 | /* |
373 | * The structure holding buffer information and ring descriptors all together. | 373 | * The structure holding buffer information and ring descriptors all together. |
374 | */ | 374 | */ |
375 | #define MAX_RING_DESC_NR 1024 | ||
376 | struct jme_ring { | 375 | struct jme_ring { |
377 | void *alloc; /* pointer to allocated memory */ | 376 | void *alloc; /* pointer to allocated memory */ |
378 | void *desc; /* pointer to ring memory */ | 377 | void *desc; /* pointer to ring memory */ |
@@ -380,7 +379,7 @@ struct jme_ring { | |||
380 | dma_addr_t dma; /* phys address for ring dma */ | 379 | dma_addr_t dma; /* phys address for ring dma */ |
381 | 380 | ||
382 | /* Buffer information corresponding to each descriptor */ | 381 | /* Buffer information corresponding to each descriptor */ |
383 | struct jme_buffer_info bufinf[MAX_RING_DESC_NR]; | 382 | struct jme_buffer_info *bufinf; |
384 | 383 | ||
385 | int next_to_use; | 384 | int next_to_use; |
386 | atomic_t next_to_clean; | 385 | atomic_t next_to_clean; |
@@ -411,13 +410,10 @@ struct jme_ring { | |||
411 | /* | 410 | /* |
412 | * Jmac Adapter Private data | 411 | * Jmac Adapter Private data |
413 | */ | 412 | */ |
414 | #define SHADOW_REG_NR 8 | ||
415 | struct jme_adapter { | 413 | struct jme_adapter { |
416 | struct pci_dev *pdev; | 414 | struct pci_dev *pdev; |
417 | struct net_device *dev; | 415 | struct net_device *dev; |
418 | void __iomem *regs; | 416 | void __iomem *regs; |
419 | dma_addr_t shadow_dma; | ||
420 | u32 *shadow_regs; | ||
421 | struct mii_if_info mii_if; | 417 | struct mii_if_info mii_if; |
422 | struct jme_ring rxring[RX_RING_NR]; | 418 | struct jme_ring rxring[RX_RING_NR]; |
423 | struct jme_ring txring[TX_RING_NR]; | 419 | struct jme_ring txring[TX_RING_NR]; |
@@ -464,10 +460,6 @@ struct jme_adapter { | |||
464 | DECLARE_NET_DEVICE_STATS | 460 | DECLARE_NET_DEVICE_STATS |
465 | }; | 461 | }; |
466 | 462 | ||
467 | enum shadow_reg_val { | ||
468 | SHADOW_IEVE = 0, | ||
469 | }; | ||
470 | |||
471 | enum jme_flags_bits { | 463 | enum jme_flags_bits { |
472 | JME_FLAG_MSI = 1, | 464 | JME_FLAG_MSI = 1, |
473 | JME_FLAG_SSET = 2, | 465 | JME_FLAG_SSET = 2, |
@@ -1104,13 +1096,6 @@ enum jme_chipmode_shifts { | |||
1104 | }; | 1096 | }; |
1105 | 1097 | ||
1106 | /* | 1098 | /* |
1107 | * Shadow base address register bits | ||
1108 | */ | ||
1109 | enum jme_shadow_base_address_bits { | ||
1110 | SHBA_POSTEN = 0x1, | ||
1111 | }; | ||
1112 | |||
1113 | /* | ||
1114 | * Aggressive Power Mode Control | 1099 | * Aggressive Power Mode Control |
1115 | */ | 1100 | */ |
1116 | enum jme_apmc_bits { | 1101 | enum jme_apmc_bits { |
diff --git a/drivers/net/lance.c b/drivers/net/lance.c index 633808d447be..30fd4f5f1d5a 100644 --- a/drivers/net/lance.c +++ b/drivers/net/lance.c | |||
@@ -1016,7 +1016,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1016 | 1016 | ||
1017 | out: | 1017 | out: |
1018 | spin_unlock_irqrestore(&lp->devlock, flags); | 1018 | spin_unlock_irqrestore(&lp->devlock, flags); |
1019 | return 0; | 1019 | return NETDEV_TX_OK; |
1020 | } | 1020 | } |
1021 | 1021 | ||
1022 | /* The LANCE interrupt handler. */ | 1022 | /* The LANCE interrupt handler. */ |
diff --git a/drivers/net/lib82596.c b/drivers/net/lib82596.c index 070fa4500871..51e11c3e53e1 100644 --- a/drivers/net/lib82596.c +++ b/drivers/net/lib82596.c | |||
@@ -983,7 +983,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
983 | 983 | ||
984 | if (length < ETH_ZLEN) { | 984 | if (length < ETH_ZLEN) { |
985 | if (skb_padto(skb, ETH_ZLEN)) | 985 | if (skb_padto(skb, ETH_ZLEN)) |
986 | return 0; | 986 | return NETDEV_TX_OK; |
987 | length = ETH_ZLEN; | 987 | length = ETH_ZLEN; |
988 | } | 988 | } |
989 | 989 | ||
@@ -1028,7 +1028,7 @@ static int i596_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1028 | 1028 | ||
1029 | netif_start_queue(dev); | 1029 | netif_start_queue(dev); |
1030 | 1030 | ||
1031 | return 0; | 1031 | return NETDEV_TX_OK; |
1032 | } | 1032 | } |
1033 | 1033 | ||
1034 | static void print_eth(unsigned char *add, char *str) | 1034 | static void print_eth(unsigned char *add, char *str) |
diff --git a/drivers/net/lib8390.c b/drivers/net/lib8390.c index f28c23343009..d6be36000c5c 100644 --- a/drivers/net/lib8390.c +++ b/drivers/net/lib8390.c | |||
@@ -414,7 +414,7 @@ static int __ei_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
414 | dev_kfree_skb (skb); | 414 | dev_kfree_skb (skb); |
415 | dev->stats.tx_bytes += send_length; | 415 | dev->stats.tx_bytes += send_length; |
416 | 416 | ||
417 | return 0; | 417 | return NETDEV_TX_OK; |
418 | } | 418 | } |
419 | 419 | ||
420 | /** | 420 | /** |
diff --git a/drivers/net/ll_temac_main.c b/drivers/net/ll_temac_main.c index 96e7248876c1..da8d0a0ca94f 100644 --- a/drivers/net/ll_temac_main.c +++ b/drivers/net/ll_temac_main.c | |||
@@ -591,7 +591,7 @@ static int temac_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
591 | /* Kick off the transfer */ | 591 | /* Kick off the transfer */ |
592 | temac_dma_out32(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */ | 592 | temac_dma_out32(lp, TX_TAILDESC_PTR, tail_p); /* DMA start */ |
593 | 593 | ||
594 | return 0; | 594 | return NETDEV_TX_OK; |
595 | } | 595 | } |
596 | 596 | ||
597 | 597 | ||
diff --git a/drivers/net/loopback.c b/drivers/net/loopback.c index da472c687481..51bbce72bede 100644 --- a/drivers/net/loopback.c +++ b/drivers/net/loopback.c | |||
@@ -89,7 +89,7 @@ static int loopback_xmit(struct sk_buff *skb, struct net_device *dev) | |||
89 | } else | 89 | } else |
90 | lb_stats->drops++; | 90 | lb_stats->drops++; |
91 | 91 | ||
92 | return 0; | 92 | return NETDEV_TX_OK; |
93 | } | 93 | } |
94 | 94 | ||
95 | static struct net_device_stats *loopback_get_stats(struct net_device *dev) | 95 | static struct net_device_stats *loopback_get_stats(struct net_device *dev) |
diff --git a/drivers/net/lp486e.c b/drivers/net/lp486e.c index d44bddbee373..c292bad411ee 100644 --- a/drivers/net/lp486e.c +++ b/drivers/net/lp486e.c | |||
@@ -871,7 +871,7 @@ static int i596_start_xmit (struct sk_buff *skb, struct net_device *dev) { | |||
871 | 871 | ||
872 | if (length < ETH_ZLEN) { | 872 | if (length < ETH_ZLEN) { |
873 | if (skb_padto(skb, ETH_ZLEN)) | 873 | if (skb_padto(skb, ETH_ZLEN)) |
874 | return 0; | 874 | return NETDEV_TX_OK; |
875 | length = ETH_ZLEN; | 875 | length = ETH_ZLEN; |
876 | } | 876 | } |
877 | 877 | ||
@@ -906,7 +906,7 @@ static int i596_start_xmit (struct sk_buff *skb, struct net_device *dev) { | |||
906 | dev->stats.tx_packets++; | 906 | dev->stats.tx_packets++; |
907 | } | 907 | } |
908 | 908 | ||
909 | return 0; | 909 | return NETDEV_TX_OK; |
910 | } | 910 | } |
911 | 911 | ||
912 | static void | 912 | static void |
diff --git a/drivers/net/mac89x0.c b/drivers/net/mac89x0.c index dab45339d3a8..149e0ed4a055 100644 --- a/drivers/net/mac89x0.c +++ b/drivers/net/mac89x0.c | |||
@@ -411,7 +411,7 @@ net_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
411 | dev->trans_start = jiffies; | 411 | dev->trans_start = jiffies; |
412 | dev_kfree_skb (skb); | 412 | dev_kfree_skb (skb); |
413 | 413 | ||
414 | return 0; | 414 | return NETDEV_TX_OK; |
415 | } | 415 | } |
416 | 416 | ||
417 | /* The typical workload of the driver: | 417 | /* The typical workload of the driver: |
diff --git a/drivers/net/macb.c b/drivers/net/macb.c index 5b5c25368d1e..d22952c78f13 100644 --- a/drivers/net/macb.c +++ b/drivers/net/macb.c | |||
@@ -678,7 +678,7 @@ static int macb_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
678 | 678 | ||
679 | dev->trans_start = jiffies; | 679 | dev->trans_start = jiffies; |
680 | 680 | ||
681 | return 0; | 681 | return NETDEV_TX_OK; |
682 | } | 682 | } |
683 | 683 | ||
684 | static void macb_free_consistent(struct macb *bp) | 684 | static void macb_free_consistent(struct macb *bp) |
diff --git a/drivers/net/mace.c b/drivers/net/mace.c index 1427755c224d..7d7577b598ea 100644 --- a/drivers/net/mace.c +++ b/drivers/net/mace.c | |||
@@ -581,7 +581,7 @@ static int mace_xmit_start(struct sk_buff *skb, struct net_device *dev) | |||
581 | netif_stop_queue(dev); | 581 | netif_stop_queue(dev); |
582 | spin_unlock_irqrestore(&mp->lock, flags); | 582 | spin_unlock_irqrestore(&mp->lock, flags); |
583 | 583 | ||
584 | return 0; | 584 | return NETDEV_TX_OK; |
585 | } | 585 | } |
586 | 586 | ||
587 | static void mace_set_multicast(struct net_device *dev) | 587 | static void mace_set_multicast(struct net_device *dev) |
diff --git a/drivers/net/meth.c b/drivers/net/meth.c index 5d04d94f2a21..abea35de255f 100644 --- a/drivers/net/meth.c +++ b/drivers/net/meth.c | |||
@@ -715,7 +715,7 @@ static int meth_tx(struct sk_buff *skb, struct net_device *dev) | |||
715 | 715 | ||
716 | spin_unlock_irqrestore(&priv->meth_lock, flags); | 716 | spin_unlock_irqrestore(&priv->meth_lock, flags); |
717 | 717 | ||
718 | return 0; | 718 | return NETDEV_TX_OK; |
719 | } | 719 | } |
720 | 720 | ||
721 | /* | 721 | /* |
diff --git a/drivers/net/mipsnet.c b/drivers/net/mipsnet.c index b3b9a147d09a..8ea98bd89ff1 100644 --- a/drivers/net/mipsnet.c +++ b/drivers/net/mipsnet.c | |||
@@ -141,7 +141,7 @@ static int mipsnet_xmit(struct sk_buff *skb, struct net_device *dev) | |||
141 | netif_stop_queue(dev); | 141 | netif_stop_queue(dev); |
142 | mipsnet_put_todevice(dev, skb); | 142 | mipsnet_put_todevice(dev, skb); |
143 | 143 | ||
144 | return 0; | 144 | return NETDEV_TX_OK; |
145 | } | 145 | } |
146 | 146 | ||
147 | static inline ssize_t mipsnet_get_fromdev(struct net_device *dev, size_t len) | 147 | static inline ssize_t mipsnet_get_fromdev(struct net_device *dev, size_t len) |
diff --git a/drivers/net/mlx4/en_tx.c b/drivers/net/mlx4/en_tx.c index 08c43f2ae72b..d5c18c674255 100644 --- a/drivers/net/mlx4/en_tx.c +++ b/drivers/net/mlx4/en_tx.c | |||
@@ -764,7 +764,7 @@ int mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
764 | /* Poll CQ here */ | 764 | /* Poll CQ here */ |
765 | mlx4_en_xmit_poll(priv, tx_ind); | 765 | mlx4_en_xmit_poll(priv, tx_ind); |
766 | 766 | ||
767 | return 0; | 767 | return NETDEV_TX_OK; |
768 | 768 | ||
769 | tx_drop: | 769 | tx_drop: |
770 | dev_kfree_skb_any(skb); | 770 | dev_kfree_skb_any(skb); |
diff --git a/drivers/net/myri10ge/myri10ge.c b/drivers/net/myri10ge/myri10ge.c index 1f6e36ea669e..1a34f7e11d98 100644 --- a/drivers/net/myri10ge/myri10ge.c +++ b/drivers/net/myri10ge/myri10ge.c | |||
@@ -2748,7 +2748,7 @@ again: | |||
2748 | /* The packet is gone, so we must | 2748 | /* The packet is gone, so we must |
2749 | * return 0 */ | 2749 | * return 0 */ |
2750 | ss->stats.tx_dropped += 1; | 2750 | ss->stats.tx_dropped += 1; |
2751 | return 0; | 2751 | return NETDEV_TX_OK; |
2752 | } | 2752 | } |
2753 | /* adjust the len to account for the zero pad | 2753 | /* adjust the len to account for the zero pad |
2754 | * so that the nic can know how long it is */ | 2754 | * so that the nic can know how long it is */ |
@@ -2892,7 +2892,7 @@ again: | |||
2892 | tx->stop_queue++; | 2892 | tx->stop_queue++; |
2893 | netif_tx_stop_queue(netdev_queue); | 2893 | netif_tx_stop_queue(netdev_queue); |
2894 | } | 2894 | } |
2895 | return 0; | 2895 | return NETDEV_TX_OK; |
2896 | 2896 | ||
2897 | abort_linearize: | 2897 | abort_linearize: |
2898 | /* Free any DMA resources we've alloced and clear out the skb | 2898 | /* Free any DMA resources we've alloced and clear out the skb |
@@ -2936,7 +2936,7 @@ abort_linearize: | |||
2936 | drop: | 2936 | drop: |
2937 | dev_kfree_skb_any(skb); | 2937 | dev_kfree_skb_any(skb); |
2938 | ss->stats.tx_dropped += 1; | 2938 | ss->stats.tx_dropped += 1; |
2939 | return 0; | 2939 | return NETDEV_TX_OK; |
2940 | 2940 | ||
2941 | } | 2941 | } |
2942 | 2942 | ||
@@ -2968,13 +2968,13 @@ static int myri10ge_sw_tso(struct sk_buff *skb, struct net_device *dev) | |||
2968 | } | 2968 | } |
2969 | } | 2969 | } |
2970 | dev_kfree_skb_any(skb); | 2970 | dev_kfree_skb_any(skb); |
2971 | return 0; | 2971 | return NETDEV_TX_OK; |
2972 | 2972 | ||
2973 | drop: | 2973 | drop: |
2974 | ss = &mgp->ss[skb_get_queue_mapping(skb)]; | 2974 | ss = &mgp->ss[skb_get_queue_mapping(skb)]; |
2975 | dev_kfree_skb_any(skb); | 2975 | dev_kfree_skb_any(skb); |
2976 | ss->stats.tx_dropped += 1; | 2976 | ss->stats.tx_dropped += 1; |
2977 | return 0; | 2977 | return NETDEV_TX_OK; |
2978 | } | 2978 | } |
2979 | 2979 | ||
2980 | static struct net_device_stats *myri10ge_get_stats(struct net_device *dev) | 2980 | static struct net_device_stats *myri10ge_get_stats(struct net_device *dev) |
diff --git a/drivers/net/myri_sbus.c b/drivers/net/myri_sbus.c index 5f0758bda6b3..29ebebc6a95b 100644 --- a/drivers/net/myri_sbus.c +++ b/drivers/net/myri_sbus.c | |||
@@ -692,7 +692,7 @@ static int myri_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
692 | DTX(("tbusy=0, returning 0\n")); | 692 | DTX(("tbusy=0, returning 0\n")); |
693 | netif_start_queue(dev); | 693 | netif_start_queue(dev); |
694 | spin_unlock_irqrestore(&mp->irq_lock, flags); | 694 | spin_unlock_irqrestore(&mp->irq_lock, flags); |
695 | return 0; | 695 | return NETDEV_TX_OK; |
696 | } | 696 | } |
697 | 697 | ||
698 | /* Create the MyriNet MAC header for an arbitrary protocol layer | 698 | /* Create the MyriNet MAC header for an arbitrary protocol layer |
diff --git a/drivers/net/natsemi.c b/drivers/net/natsemi.c index c9bfe4eea189..481aa2d287a3 100644 --- a/drivers/net/natsemi.c +++ b/drivers/net/natsemi.c | |||
@@ -2125,7 +2125,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
2125 | printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n", | 2125 | printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n", |
2126 | dev->name, np->cur_tx, entry); | 2126 | dev->name, np->cur_tx, entry); |
2127 | } | 2127 | } |
2128 | return 0; | 2128 | return NETDEV_TX_OK; |
2129 | } | 2129 | } |
2130 | 2130 | ||
2131 | static void netdev_tx_done(struct net_device *dev) | 2131 | static void netdev_tx_done(struct net_device *dev) |
diff --git a/drivers/net/netx-eth.c b/drivers/net/netx-eth.c index 946366dcc992..9f4235466d59 100644 --- a/drivers/net/netx-eth.c +++ b/drivers/net/netx-eth.c | |||
@@ -134,7 +134,7 @@ netx_eth_hard_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
134 | spin_unlock_irq(&priv->lock); | 134 | spin_unlock_irq(&priv->lock); |
135 | dev_kfree_skb(skb); | 135 | dev_kfree_skb(skb); |
136 | 136 | ||
137 | return 0; | 137 | return NETDEV_TX_OK; |
138 | } | 138 | } |
139 | 139 | ||
140 | static void netx_eth_receive(struct net_device *ndev) | 140 | static void netx_eth_receive(struct net_device *ndev) |
diff --git a/drivers/net/ni5010.c b/drivers/net/ni5010.c index 2a8da476ab3d..462d20f26436 100644 --- a/drivers/net/ni5010.c +++ b/drivers/net/ni5010.c | |||
@@ -463,7 +463,7 @@ static int ni5010_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
463 | hardware_send_packet(dev, (unsigned char *)skb->data, skb->len, length-skb->len); | 463 | hardware_send_packet(dev, (unsigned char *)skb->data, skb->len, length-skb->len); |
464 | dev->trans_start = jiffies; | 464 | dev->trans_start = jiffies; |
465 | dev_kfree_skb (skb); | 465 | dev_kfree_skb (skb); |
466 | return 0; | 466 | return NETDEV_TX_OK; |
467 | } | 467 | } |
468 | 468 | ||
469 | /* | 469 | /* |
diff --git a/drivers/net/ni52.c b/drivers/net/ni52.c index 77d44a061703..a0ac5d4f27d3 100644 --- a/drivers/net/ni52.c +++ b/drivers/net/ni52.c | |||
@@ -1183,7 +1183,7 @@ static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1183 | 1183 | ||
1184 | if (skb->len > XMIT_BUFF_SIZE) { | 1184 | if (skb->len > XMIT_BUFF_SIZE) { |
1185 | printk(KERN_ERR "%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n", dev->name, XMIT_BUFF_SIZE, skb->len); | 1185 | printk(KERN_ERR "%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n", dev->name, XMIT_BUFF_SIZE, skb->len); |
1186 | return 0; | 1186 | return NETDEV_TX_OK; |
1187 | } | 1187 | } |
1188 | 1188 | ||
1189 | netif_stop_queue(dev); | 1189 | netif_stop_queue(dev); |
@@ -1267,7 +1267,7 @@ static int ni52_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1267 | } | 1267 | } |
1268 | dev_kfree_skb(skb); | 1268 | dev_kfree_skb(skb); |
1269 | #endif | 1269 | #endif |
1270 | return 0; | 1270 | return NETDEV_TX_OK; |
1271 | } | 1271 | } |
1272 | 1272 | ||
1273 | /******************************************* | 1273 | /******************************************* |
diff --git a/drivers/net/ni65.c b/drivers/net/ni65.c index 1f10ed603e20..81a061785898 100644 --- a/drivers/net/ni65.c +++ b/drivers/net/ni65.c | |||
@@ -1216,7 +1216,7 @@ static int ni65_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1216 | spin_unlock_irqrestore(&p->ring_lock, flags); | 1216 | spin_unlock_irqrestore(&p->ring_lock, flags); |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | return 0; | 1219 | return NETDEV_TX_OK; |
1220 | } | 1220 | } |
1221 | 1221 | ||
1222 | static void set_multicast_list(struct net_device *dev) | 1222 | static void set_multicast_list(struct net_device *dev) |
diff --git a/drivers/net/pci-skeleton.c b/drivers/net/pci-skeleton.c index 8c1f6988f398..e4a93b8ed485 100644 --- a/drivers/net/pci-skeleton.c +++ b/drivers/net/pci-skeleton.c | |||
@@ -1356,7 +1356,7 @@ static int netdrv_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
1356 | DPRINTK ("%s: Queued Tx packet at %p size %u to slot %d.\n", | 1356 | DPRINTK ("%s: Queued Tx packet at %p size %u to slot %d.\n", |
1357 | dev->name, skb->data, skb->len, entry); | 1357 | dev->name, skb->data, skb->len, entry); |
1358 | 1358 | ||
1359 | return 0; | 1359 | return NETDEV_TX_OK; |
1360 | } | 1360 | } |
1361 | 1361 | ||
1362 | 1362 | ||
diff --git a/drivers/net/pcmcia/3c574_cs.c b/drivers/net/pcmcia/3c574_cs.c index f35c609ba020..a23aa8724042 100644 --- a/drivers/net/pcmcia/3c574_cs.c +++ b/drivers/net/pcmcia/3c574_cs.c | |||
@@ -806,7 +806,7 @@ static int el3_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
806 | pop_tx_status(dev); | 806 | pop_tx_status(dev); |
807 | spin_unlock_irqrestore(&lp->window_lock, flags); | 807 | spin_unlock_irqrestore(&lp->window_lock, flags); |
808 | dev_kfree_skb(skb); | 808 | dev_kfree_skb(skb); |
809 | return 0; | 809 | return NETDEV_TX_OK; |
810 | } | 810 | } |
811 | 811 | ||
812 | /* The EL3 interrupt handler. */ | 812 | /* The EL3 interrupt handler. */ |
diff --git a/drivers/net/pcmcia/3c589_cs.c b/drivers/net/pcmcia/3c589_cs.c index ec7cf5ac4f05..a77417c51e44 100644 --- a/drivers/net/pcmcia/3c589_cs.c +++ b/drivers/net/pcmcia/3c589_cs.c | |||
@@ -635,7 +635,7 @@ static int el3_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
635 | spin_unlock_irqrestore(&priv->lock, flags); | 635 | spin_unlock_irqrestore(&priv->lock, flags); |
636 | dev_kfree_skb(skb); | 636 | dev_kfree_skb(skb); |
637 | 637 | ||
638 | return 0; | 638 | return NETDEV_TX_OK; |
639 | } | 639 | } |
640 | 640 | ||
641 | /* The EL3 interrupt handler. */ | 641 | /* The EL3 interrupt handler. */ |
diff --git a/drivers/net/pcmcia/axnet_cs.c b/drivers/net/pcmcia/axnet_cs.c index 0e38d80fd255..b5cfac7c5179 100644 --- a/drivers/net/pcmcia/axnet_cs.c +++ b/drivers/net/pcmcia/axnet_cs.c | |||
@@ -1179,7 +1179,7 @@ static int axnet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1179 | dev_kfree_skb (skb); | 1179 | dev_kfree_skb (skb); |
1180 | dev->stats.tx_bytes += send_length; | 1180 | dev->stats.tx_bytes += send_length; |
1181 | 1181 | ||
1182 | return 0; | 1182 | return NETDEV_TX_OK; |
1183 | } | 1183 | } |
1184 | 1184 | ||
1185 | /** | 1185 | /** |
diff --git a/drivers/net/pcmcia/fmvj18x_cs.c b/drivers/net/pcmcia/fmvj18x_cs.c index 479d5b494371..434d9407bfb3 100644 --- a/drivers/net/pcmcia/fmvj18x_cs.c +++ b/drivers/net/pcmcia/fmvj18x_cs.c | |||
@@ -865,7 +865,7 @@ static int fjn_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
865 | if (length < ETH_ZLEN) | 865 | if (length < ETH_ZLEN) |
866 | { | 866 | { |
867 | if (skb_padto(skb, ETH_ZLEN)) | 867 | if (skb_padto(skb, ETH_ZLEN)) |
868 | return 0; | 868 | return NETDEV_TX_OK; |
869 | length = ETH_ZLEN; | 869 | length = ETH_ZLEN; |
870 | } | 870 | } |
871 | 871 | ||
@@ -924,7 +924,7 @@ static int fjn_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
924 | } | 924 | } |
925 | dev_kfree_skb (skb); | 925 | dev_kfree_skb (skb); |
926 | 926 | ||
927 | return 0; | 927 | return NETDEV_TX_OK; |
928 | } /* fjn_start_xmit */ | 928 | } /* fjn_start_xmit */ |
929 | 929 | ||
930 | /*====================================================================*/ | 930 | /*====================================================================*/ |
diff --git a/drivers/net/pcmcia/nmclan_cs.c b/drivers/net/pcmcia/nmclan_cs.c index 02ef63ed1f99..0f8118a82579 100644 --- a/drivers/net/pcmcia/nmclan_cs.c +++ b/drivers/net/pcmcia/nmclan_cs.c | |||
@@ -990,7 +990,7 @@ static int mace_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
990 | 990 | ||
991 | dev_kfree_skb(skb); | 991 | dev_kfree_skb(skb); |
992 | 992 | ||
993 | return 0; | 993 | return NETDEV_TX_OK; |
994 | } /* mace_start_xmit */ | 994 | } /* mace_start_xmit */ |
995 | 995 | ||
996 | /* ---------------------------------------------------------------------------- | 996 | /* ---------------------------------------------------------------------------- |
diff --git a/drivers/net/pcmcia/smc91c92_cs.c b/drivers/net/pcmcia/smc91c92_cs.c index 37e05d3ab893..2f39244c17f2 100644 --- a/drivers/net/pcmcia/smc91c92_cs.c +++ b/drivers/net/pcmcia/smc91c92_cs.c | |||
@@ -1399,7 +1399,7 @@ static int smc_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1399 | dev_kfree_skb (skb); | 1399 | dev_kfree_skb (skb); |
1400 | smc->saved_skb = NULL; | 1400 | smc->saved_skb = NULL; |
1401 | dev->stats.tx_dropped++; | 1401 | dev->stats.tx_dropped++; |
1402 | return 0; /* Do not re-queue this packet. */ | 1402 | return NETDEV_TX_OK; /* Do not re-queue this packet. */ |
1403 | } | 1403 | } |
1404 | /* A packet is now waiting. */ | 1404 | /* A packet is now waiting. */ |
1405 | smc->packets_waiting++; | 1405 | smc->packets_waiting++; |
@@ -1422,7 +1422,7 @@ static int smc_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1422 | outw((ir&0xff00) | IM_ALLOC_INT, ioaddr + INTERRUPT); | 1422 | outw((ir&0xff00) | IM_ALLOC_INT, ioaddr + INTERRUPT); |
1423 | smc_hardware_send_packet(dev); /* Send the packet now.. */ | 1423 | smc_hardware_send_packet(dev); /* Send the packet now.. */ |
1424 | spin_unlock_irqrestore(&smc->lock, flags); | 1424 | spin_unlock_irqrestore(&smc->lock, flags); |
1425 | return 0; | 1425 | return NETDEV_TX_OK; |
1426 | } | 1426 | } |
1427 | } | 1427 | } |
1428 | 1428 | ||
@@ -1431,7 +1431,7 @@ static int smc_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1431 | outw((IM_ALLOC_INT << 8) | (ir & 0xff00), ioaddr + INTERRUPT); | 1431 | outw((IM_ALLOC_INT << 8) | (ir & 0xff00), ioaddr + INTERRUPT); |
1432 | spin_unlock_irqrestore(&smc->lock, flags); | 1432 | spin_unlock_irqrestore(&smc->lock, flags); |
1433 | 1433 | ||
1434 | return 0; | 1434 | return NETDEV_TX_OK; |
1435 | } | 1435 | } |
1436 | 1436 | ||
1437 | /*====================================================================== | 1437 | /*====================================================================== |
diff --git a/drivers/net/pcmcia/xirc2ps_cs.c b/drivers/net/pcmcia/xirc2ps_cs.c index ef37d22c7e1d..eda7bf6047cd 100644 --- a/drivers/net/pcmcia/xirc2ps_cs.c +++ b/drivers/net/pcmcia/xirc2ps_cs.c | |||
@@ -1384,7 +1384,7 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1384 | if (pktlen < ETH_ZLEN) | 1384 | if (pktlen < ETH_ZLEN) |
1385 | { | 1385 | { |
1386 | if (skb_padto(skb, ETH_ZLEN)) | 1386 | if (skb_padto(skb, ETH_ZLEN)) |
1387 | return 0; | 1387 | return NETDEV_TX_OK; |
1388 | pktlen = ETH_ZLEN; | 1388 | pktlen = ETH_ZLEN; |
1389 | } | 1389 | } |
1390 | 1390 | ||
@@ -1414,7 +1414,7 @@ do_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1414 | dev->trans_start = jiffies; | 1414 | dev->trans_start = jiffies; |
1415 | dev->stats.tx_bytes += pktlen; | 1415 | dev->stats.tx_bytes += pktlen; |
1416 | netif_start_queue(dev); | 1416 | netif_start_queue(dev); |
1417 | return 0; | 1417 | return NETDEV_TX_OK; |
1418 | } | 1418 | } |
1419 | 1419 | ||
1420 | /**************** | 1420 | /**************** |
diff --git a/drivers/net/pcnet32.c b/drivers/net/pcnet32.c index 1c35e1d637a0..955a87ac9afa 100644 --- a/drivers/net/pcnet32.c +++ b/drivers/net/pcnet32.c | |||
@@ -2536,7 +2536,7 @@ static int pcnet32_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2536 | netif_stop_queue(dev); | 2536 | netif_stop_queue(dev); |
2537 | } | 2537 | } |
2538 | spin_unlock_irqrestore(&lp->lock, flags); | 2538 | spin_unlock_irqrestore(&lp->lock, flags); |
2539 | return 0; | 2539 | return NETDEV_TX_OK; |
2540 | } | 2540 | } |
2541 | 2541 | ||
2542 | /* The PCNET32 interrupt handler. */ | 2542 | /* The PCNET32 interrupt handler. */ |
diff --git a/drivers/net/phy/Kconfig b/drivers/net/phy/Kconfig index de9cf5136fdc..d5d8e1c5bc91 100644 --- a/drivers/net/phy/Kconfig +++ b/drivers/net/phy/Kconfig | |||
@@ -56,6 +56,12 @@ config BROADCOM_PHY | |||
56 | Currently supports the BCM5411, BCM5421, BCM5461, BCM5464, BCM5481 | 56 | Currently supports the BCM5411, BCM5421, BCM5461, BCM5464, BCM5481 |
57 | and BCM5482 PHYs. | 57 | and BCM5482 PHYs. |
58 | 58 | ||
59 | config BCM63XX_PHY | ||
60 | tristate "Drivers for Broadcom 63xx SOCs internal PHY" | ||
61 | depends on BCM63XX | ||
62 | ---help--- | ||
63 | Currently supports the 6348 and 6358 PHYs. | ||
64 | |||
59 | config ICPLUS_PHY | 65 | config ICPLUS_PHY |
60 | tristate "Drivers for ICPlus PHYs" | 66 | tristate "Drivers for ICPlus PHYs" |
61 | ---help--- | 67 | ---help--- |
diff --git a/drivers/net/phy/Makefile b/drivers/net/phy/Makefile index 3a1bfefefbc3..edfaac48cbd5 100644 --- a/drivers/net/phy/Makefile +++ b/drivers/net/phy/Makefile | |||
@@ -11,6 +11,7 @@ obj-$(CONFIG_QSEMI_PHY) += qsemi.o | |||
11 | obj-$(CONFIG_SMSC_PHY) += smsc.o | 11 | obj-$(CONFIG_SMSC_PHY) += smsc.o |
12 | obj-$(CONFIG_VITESSE_PHY) += vitesse.o | 12 | obj-$(CONFIG_VITESSE_PHY) += vitesse.o |
13 | obj-$(CONFIG_BROADCOM_PHY) += broadcom.o | 13 | obj-$(CONFIG_BROADCOM_PHY) += broadcom.o |
14 | obj-$(CONFIG_BCM63XX_PHY) += bcm63xx.o | ||
14 | obj-$(CONFIG_ICPLUS_PHY) += icplus.o | 15 | obj-$(CONFIG_ICPLUS_PHY) += icplus.o |
15 | obj-$(CONFIG_REALTEK_PHY) += realtek.o | 16 | obj-$(CONFIG_REALTEK_PHY) += realtek.o |
16 | obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o | 17 | obj-$(CONFIG_LSI_ET1011C_PHY) += et1011c.o |
diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c new file mode 100644 index 000000000000..4fed95e8350e --- /dev/null +++ b/drivers/net/phy/bcm63xx.c | |||
@@ -0,0 +1,132 @@ | |||
1 | /* | ||
2 | * Driver for Broadcom 63xx SOCs integrated PHYs | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License | ||
6 | * as published by the Free Software Foundation; either version | ||
7 | * 2 of the License, or (at your option) any later version. | ||
8 | */ | ||
9 | #include <linux/module.h> | ||
10 | #include <linux/phy.h> | ||
11 | |||
12 | #define MII_BCM63XX_IR 0x1a /* interrupt register */ | ||
13 | #define MII_BCM63XX_IR_EN 0x4000 /* global interrupt enable */ | ||
14 | #define MII_BCM63XX_IR_DUPLEX 0x0800 /* duplex changed */ | ||
15 | #define MII_BCM63XX_IR_SPEED 0x0400 /* speed changed */ | ||
16 | #define MII_BCM63XX_IR_LINK 0x0200 /* link changed */ | ||
17 | #define MII_BCM63XX_IR_GMASK 0x0100 /* global interrupt mask */ | ||
18 | |||
19 | MODULE_DESCRIPTION("Broadcom 63xx internal PHY driver"); | ||
20 | MODULE_AUTHOR("Maxime Bizon <mbizon@freebox.fr>"); | ||
21 | MODULE_LICENSE("GPL"); | ||
22 | |||
23 | static int bcm63xx_config_init(struct phy_device *phydev) | ||
24 | { | ||
25 | int reg, err; | ||
26 | |||
27 | reg = phy_read(phydev, MII_BCM63XX_IR); | ||
28 | if (reg < 0) | ||
29 | return reg; | ||
30 | |||
31 | /* Mask interrupts globally. */ | ||
32 | reg |= MII_BCM63XX_IR_GMASK; | ||
33 | err = phy_write(phydev, MII_BCM63XX_IR, reg); | ||
34 | if (err < 0) | ||
35 | return err; | ||
36 | |||
37 | /* Unmask events we are interested in */ | ||
38 | reg = ~(MII_BCM63XX_IR_DUPLEX | | ||
39 | MII_BCM63XX_IR_SPEED | | ||
40 | MII_BCM63XX_IR_LINK) | | ||
41 | MII_BCM63XX_IR_EN; | ||
42 | err = phy_write(phydev, MII_BCM63XX_IR, reg); | ||
43 | if (err < 0) | ||
44 | return err; | ||
45 | return 0; | ||
46 | } | ||
47 | |||
48 | static int bcm63xx_ack_interrupt(struct phy_device *phydev) | ||
49 | { | ||
50 | int reg; | ||
51 | |||
52 | /* Clear pending interrupts. */ | ||
53 | reg = phy_read(phydev, MII_BCM63XX_IR); | ||
54 | if (reg < 0) | ||
55 | return reg; | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | static int bcm63xx_config_intr(struct phy_device *phydev) | ||
61 | { | ||
62 | int reg, err; | ||
63 | |||
64 | reg = phy_read(phydev, MII_BCM63XX_IR); | ||
65 | if (reg < 0) | ||
66 | return reg; | ||
67 | |||
68 | if (phydev->interrupts == PHY_INTERRUPT_ENABLED) | ||
69 | reg &= ~MII_BCM63XX_IR_GMASK; | ||
70 | else | ||
71 | reg |= MII_BCM63XX_IR_GMASK; | ||
72 | |||
73 | err = phy_write(phydev, MII_BCM63XX_IR, reg); | ||
74 | return err; | ||
75 | } | ||
76 | |||
77 | static struct phy_driver bcm63xx_1_driver = { | ||
78 | .phy_id = 0x00406000, | ||
79 | .phy_id_mask = 0xfffffc00, | ||
80 | .name = "Broadcom BCM63XX (1)", | ||
81 | /* ASYM_PAUSE bit is marked RO in datasheet, so don't cheat */ | ||
82 | .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), | ||
83 | .flags = PHY_HAS_INTERRUPT, | ||
84 | .config_init = bcm63xx_config_init, | ||
85 | .config_aneg = genphy_config_aneg, | ||
86 | .read_status = genphy_read_status, | ||
87 | .ack_interrupt = bcm63xx_ack_interrupt, | ||
88 | .config_intr = bcm63xx_config_intr, | ||
89 | .driver = { .owner = THIS_MODULE }, | ||
90 | }; | ||
91 | |||
92 | /* same phy as above, with just a different OUI */ | ||
93 | static struct phy_driver bcm63xx_2_driver = { | ||
94 | .phy_id = 0x002bdc00, | ||
95 | .phy_id_mask = 0xfffffc00, | ||
96 | .name = "Broadcom BCM63XX (2)", | ||
97 | .features = (PHY_BASIC_FEATURES | SUPPORTED_Pause), | ||
98 | .flags = PHY_HAS_INTERRUPT, | ||
99 | .config_init = bcm63xx_config_init, | ||
100 | .config_aneg = genphy_config_aneg, | ||
101 | .read_status = genphy_read_status, | ||
102 | .ack_interrupt = bcm63xx_ack_interrupt, | ||
103 | .config_intr = bcm63xx_config_intr, | ||
104 | .driver = { .owner = THIS_MODULE }, | ||
105 | }; | ||
106 | |||
107 | static int __init bcm63xx_phy_init(void) | ||
108 | { | ||
109 | int ret; | ||
110 | |||
111 | ret = phy_driver_register(&bcm63xx_1_driver); | ||
112 | if (ret) | ||
113 | goto out_63xx_1; | ||
114 | ret = phy_driver_register(&bcm63xx_2_driver); | ||
115 | if (ret) | ||
116 | goto out_63xx_2; | ||
117 | return ret; | ||
118 | |||
119 | out_63xx_2: | ||
120 | phy_driver_unregister(&bcm63xx_1_driver); | ||
121 | out_63xx_1: | ||
122 | return ret; | ||
123 | } | ||
124 | |||
125 | static void __exit bcm63xx_phy_exit(void) | ||
126 | { | ||
127 | phy_driver_unregister(&bcm63xx_1_driver); | ||
128 | phy_driver_unregister(&bcm63xx_2_driver); | ||
129 | } | ||
130 | |||
131 | module_init(bcm63xx_phy_init); | ||
132 | module_exit(bcm63xx_phy_exit); | ||
diff --git a/drivers/net/plip.c b/drivers/net/plip.c index 2ca8b0d84ee2..00487f569cfd 100644 --- a/drivers/net/plip.c +++ b/drivers/net/plip.c | |||
@@ -990,7 +990,7 @@ plip_tx_packet(struct sk_buff *skb, struct net_device *dev) | |||
990 | schedule_work(&nl->immediate); | 990 | schedule_work(&nl->immediate); |
991 | spin_unlock_irq(&nl->lock); | 991 | spin_unlock_irq(&nl->lock); |
992 | 992 | ||
993 | return 0; | 993 | return NETDEV_TX_OK; |
994 | } | 994 | } |
995 | 995 | ||
996 | static void | 996 | static void |
diff --git a/drivers/net/ppp_generic.c b/drivers/net/ppp_generic.c index 639d11bc444e..d0b965517b46 100644 --- a/drivers/net/ppp_generic.c +++ b/drivers/net/ppp_generic.c | |||
@@ -988,12 +988,12 @@ ppp_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
988 | netif_stop_queue(dev); | 988 | netif_stop_queue(dev); |
989 | skb_queue_tail(&ppp->file.xq, skb); | 989 | skb_queue_tail(&ppp->file.xq, skb); |
990 | ppp_xmit_process(ppp); | 990 | ppp_xmit_process(ppp); |
991 | return 0; | 991 | return NETDEV_TX_OK; |
992 | 992 | ||
993 | outf: | 993 | outf: |
994 | kfree_skb(skb); | 994 | kfree_skb(skb); |
995 | ++dev->stats.tx_dropped; | 995 | ++dev->stats.tx_dropped; |
996 | return 0; | 996 | return NETDEV_TX_OK; |
997 | } | 997 | } |
998 | 998 | ||
999 | static int | 999 | static int |
diff --git a/drivers/net/r6040.c b/drivers/net/r6040.c index 961b5397a531..840677f5ee82 100644 --- a/drivers/net/r6040.c +++ b/drivers/net/r6040.c | |||
@@ -1115,13 +1115,13 @@ static int __devinit r6040_init_one(struct pci_dev *pdev, | |||
1115 | } | 1115 | } |
1116 | 1116 | ||
1117 | /* IO Size check */ | 1117 | /* IO Size check */ |
1118 | if (pci_resource_len(pdev, 0) < io_size) { | 1118 | if (pci_resource_len(pdev, bar) < io_size) { |
1119 | printk(KERN_ERR DRV_NAME ": Insufficient PCI resources, aborting\n"); | 1119 | printk(KERN_ERR DRV_NAME ": Insufficient PCI resources, aborting\n"); |
1120 | err = -EIO; | 1120 | err = -EIO; |
1121 | goto err_out; | 1121 | goto err_out; |
1122 | } | 1122 | } |
1123 | 1123 | ||
1124 | pioaddr = pci_resource_start(pdev, 0); /* IO map base address */ | 1124 | pioaddr = pci_resource_start(pdev, bar); /* IO map base address */ |
1125 | pci_set_master(pdev); | 1125 | pci_set_master(pdev); |
1126 | 1126 | ||
1127 | dev = alloc_etherdev(sizeof(struct r6040_private)); | 1127 | dev = alloc_etherdev(sizeof(struct r6040_private)); |
diff --git a/drivers/net/rionet.c b/drivers/net/rionet.c index 8702e7acdee6..bc98e7f69ee9 100644 --- a/drivers/net/rionet.c +++ b/drivers/net/rionet.c | |||
@@ -114,11 +114,6 @@ static int rionet_rx_clean(struct net_device *ndev) | |||
114 | 114 | ||
115 | if (error == NET_RX_DROP) { | 115 | if (error == NET_RX_DROP) { |
116 | ndev->stats.rx_dropped++; | 116 | ndev->stats.rx_dropped++; |
117 | } else if (error == NET_RX_BAD) { | ||
118 | if (netif_msg_rx_err(rnet)) | ||
119 | printk(KERN_WARNING "%s: bad rx packet\n", | ||
120 | DRV_NAME); | ||
121 | ndev->stats.rx_errors++; | ||
122 | } else { | 117 | } else { |
123 | ndev->stats.rx_packets++; | 118 | ndev->stats.rx_packets++; |
124 | ndev->stats.rx_bytes += RIO_MAX_MSG_SIZE; | 119 | ndev->stats.rx_bytes += RIO_MAX_MSG_SIZE; |
@@ -208,7 +203,7 @@ static int rionet_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
208 | 203 | ||
209 | spin_unlock_irqrestore(&rnet->tx_lock, flags); | 204 | spin_unlock_irqrestore(&rnet->tx_lock, flags); |
210 | 205 | ||
211 | return 0; | 206 | return NETDEV_TX_OK; |
212 | } | 207 | } |
213 | 208 | ||
214 | static void rionet_dbell_event(struct rio_mport *mport, void *dev_id, u16 sid, u16 tid, | 209 | static void rionet_dbell_event(struct rio_mport *mport, void *dev_id, u16 sid, u16 tid, |
diff --git a/drivers/net/rrunner.c b/drivers/net/rrunner.c index 81dbcbb910f4..d95534655911 100644 --- a/drivers/net/rrunner.c +++ b/drivers/net/rrunner.c | |||
@@ -1466,7 +1466,7 @@ static int rr_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1466 | spin_unlock_irqrestore(&rrpriv->lock, flags); | 1466 | spin_unlock_irqrestore(&rrpriv->lock, flags); |
1467 | 1467 | ||
1468 | dev->trans_start = jiffies; | 1468 | dev->trans_start = jiffies; |
1469 | return 0; | 1469 | return NETDEV_TX_OK; |
1470 | } | 1470 | } |
1471 | 1471 | ||
1472 | 1472 | ||
diff --git a/drivers/net/s2io.c b/drivers/net/s2io.c index 458daa06ed41..d4df9330c447 100644 --- a/drivers/net/s2io.c +++ b/drivers/net/s2io.c | |||
@@ -4111,14 +4111,14 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4111 | if (unlikely(skb->len <= 0)) { | 4111 | if (unlikely(skb->len <= 0)) { |
4112 | DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); | 4112 | DBG_PRINT(TX_DBG, "%s:Buffer has no data..\n", dev->name); |
4113 | dev_kfree_skb_any(skb); | 4113 | dev_kfree_skb_any(skb); |
4114 | return 0; | 4114 | return NETDEV_TX_OK; |
4115 | } | 4115 | } |
4116 | 4116 | ||
4117 | if (!is_s2io_card_up(sp)) { | 4117 | if (!is_s2io_card_up(sp)) { |
4118 | DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", | 4118 | DBG_PRINT(TX_DBG, "%s: Card going down for reset\n", |
4119 | dev->name); | 4119 | dev->name); |
4120 | dev_kfree_skb(skb); | 4120 | dev_kfree_skb(skb); |
4121 | return 0; | 4121 | return NETDEV_TX_OK; |
4122 | } | 4122 | } |
4123 | 4123 | ||
4124 | queue = 0; | 4124 | queue = 0; |
@@ -4192,7 +4192,7 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4192 | s2io_stop_tx_queue(sp, fifo->fifo_no); | 4192 | s2io_stop_tx_queue(sp, fifo->fifo_no); |
4193 | dev_kfree_skb(skb); | 4193 | dev_kfree_skb(skb); |
4194 | spin_unlock_irqrestore(&fifo->tx_lock, flags); | 4194 | spin_unlock_irqrestore(&fifo->tx_lock, flags); |
4195 | return 0; | 4195 | return NETDEV_TX_OK; |
4196 | } | 4196 | } |
4197 | 4197 | ||
4198 | offload_type = s2io_offload_type(skb); | 4198 | offload_type = s2io_offload_type(skb); |
@@ -4304,14 +4304,14 @@ static int s2io_xmit(struct sk_buff *skb, struct net_device *dev) | |||
4304 | if (sp->config.intr_type == MSI_X) | 4304 | if (sp->config.intr_type == MSI_X) |
4305 | tx_intr_handler(fifo); | 4305 | tx_intr_handler(fifo); |
4306 | 4306 | ||
4307 | return 0; | 4307 | return NETDEV_TX_OK; |
4308 | pci_map_failed: | 4308 | pci_map_failed: |
4309 | stats->pci_map_fail_cnt++; | 4309 | stats->pci_map_fail_cnt++; |
4310 | s2io_stop_tx_queue(sp, fifo->fifo_no); | 4310 | s2io_stop_tx_queue(sp, fifo->fifo_no); |
4311 | stats->mem_freed += skb->truesize; | 4311 | stats->mem_freed += skb->truesize; |
4312 | dev_kfree_skb(skb); | 4312 | dev_kfree_skb(skb); |
4313 | spin_unlock_irqrestore(&fifo->tx_lock, flags); | 4313 | spin_unlock_irqrestore(&fifo->tx_lock, flags); |
4314 | return 0; | 4314 | return NETDEV_TX_OK; |
4315 | } | 4315 | } |
4316 | 4316 | ||
4317 | static void | 4317 | static void |
diff --git a/drivers/net/sb1000.c b/drivers/net/sb1000.c index fc0e38bddeeb..6a81aec645d9 100644 --- a/drivers/net/sb1000.c +++ b/drivers/net/sb1000.c | |||
@@ -1086,7 +1086,7 @@ sb1000_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1086 | printk(KERN_WARNING "%s: trying to transmit!!!\n", dev->name); | 1086 | printk(KERN_WARNING "%s: trying to transmit!!!\n", dev->name); |
1087 | /* sb1000 can't xmit datagrams */ | 1087 | /* sb1000 can't xmit datagrams */ |
1088 | dev_kfree_skb(skb); | 1088 | dev_kfree_skb(skb); |
1089 | return 0; | 1089 | return NETDEV_TX_OK; |
1090 | } | 1090 | } |
1091 | 1091 | ||
1092 | /* SB1000 interrupt handler. */ | 1092 | /* SB1000 interrupt handler. */ |
diff --git a/drivers/net/sb1250-mac.c b/drivers/net/sb1250-mac.c index d8c9cf1b901d..4c2450b6bd0c 100644 --- a/drivers/net/sb1250-mac.c +++ b/drivers/net/sb1250-mac.c | |||
@@ -2091,7 +2091,7 @@ static int sbmac_start_tx(struct sk_buff *skb, struct net_device *dev) | |||
2091 | 2091 | ||
2092 | spin_unlock_irqrestore(&sc->sbm_lock, flags); | 2092 | spin_unlock_irqrestore(&sc->sbm_lock, flags); |
2093 | 2093 | ||
2094 | return 0; | 2094 | return NETDEV_TX_OK; |
2095 | } | 2095 | } |
2096 | 2096 | ||
2097 | /********************************************************************** | 2097 | /********************************************************************** |
diff --git a/drivers/net/seeq8005.c b/drivers/net/seeq8005.c index ebbbe09725fe..7cc8bb814137 100644 --- a/drivers/net/seeq8005.c +++ b/drivers/net/seeq8005.c | |||
@@ -401,7 +401,7 @@ static int seeq8005_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
401 | 401 | ||
402 | if (length < ETH_ZLEN) { | 402 | if (length < ETH_ZLEN) { |
403 | if (skb_padto(skb, ETH_ZLEN)) | 403 | if (skb_padto(skb, ETH_ZLEN)) |
404 | return 0; | 404 | return NETDEV_TX_OK; |
405 | length = ETH_ZLEN; | 405 | length = ETH_ZLEN; |
406 | } | 406 | } |
407 | buf = skb->data; | 407 | buf = skb->data; |
@@ -415,7 +415,7 @@ static int seeq8005_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
415 | dev_kfree_skb (skb); | 415 | dev_kfree_skb (skb); |
416 | /* You might need to clean up and record Tx statistics here. */ | 416 | /* You might need to clean up and record Tx statistics here. */ |
417 | 417 | ||
418 | return 0; | 418 | return NETDEV_TX_OK; |
419 | } | 419 | } |
420 | 420 | ||
421 | /* | 421 | /* |
diff --git a/drivers/net/sgiseeq.c b/drivers/net/sgiseeq.c index 5fb88ca6dd7f..78f60089b552 100644 --- a/drivers/net/sgiseeq.c +++ b/drivers/net/sgiseeq.c | |||
@@ -594,7 +594,7 @@ static int sgiseeq_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
594 | len = skb->len; | 594 | len = skb->len; |
595 | if (len < ETH_ZLEN) { | 595 | if (len < ETH_ZLEN) { |
596 | if (skb_padto(skb, ETH_ZLEN)) | 596 | if (skb_padto(skb, ETH_ZLEN)) |
597 | return 0; | 597 | return NETDEV_TX_OK; |
598 | len = ETH_ZLEN; | 598 | len = ETH_ZLEN; |
599 | } | 599 | } |
600 | 600 | ||
@@ -642,7 +642,7 @@ static int sgiseeq_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
642 | netif_stop_queue(dev); | 642 | netif_stop_queue(dev); |
643 | spin_unlock_irqrestore(&sp->tx_lock, flags); | 643 | spin_unlock_irqrestore(&sp->tx_lock, flags); |
644 | 644 | ||
645 | return 0; | 645 | return NETDEV_TX_OK; |
646 | } | 646 | } |
647 | 647 | ||
648 | static void timeout(struct net_device *dev) | 648 | static void timeout(struct net_device *dev) |
diff --git a/drivers/net/sh_eth.c b/drivers/net/sh_eth.c index a2d82ddb3b4d..4c4dcbf19026 100644 --- a/drivers/net/sh_eth.c +++ b/drivers/net/sh_eth.c | |||
@@ -1133,7 +1133,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev) | |||
1133 | 1133 | ||
1134 | ndev->trans_start = jiffies; | 1134 | ndev->trans_start = jiffies; |
1135 | 1135 | ||
1136 | return 0; | 1136 | return NETDEV_TX_OK; |
1137 | } | 1137 | } |
1138 | 1138 | ||
1139 | /* device close function */ | 1139 | /* device close function */ |
diff --git a/drivers/net/sis900.c b/drivers/net/sis900.c index a9a897bb42d5..61ceeaaf104d 100644 --- a/drivers/net/sis900.c +++ b/drivers/net/sis900.c | |||
@@ -1628,7 +1628,7 @@ sis900_start_xmit(struct sk_buff *skb, struct net_device *net_dev) | |||
1628 | "to slot %d.\n", | 1628 | "to slot %d.\n", |
1629 | net_dev->name, skb->data, (int)skb->len, entry); | 1629 | net_dev->name, skb->data, (int)skb->len, entry); |
1630 | 1630 | ||
1631 | return 0; | 1631 | return NETDEV_TX_OK; |
1632 | } | 1632 | } |
1633 | 1633 | ||
1634 | /** | 1634 | /** |
diff --git a/drivers/net/skfp/skfddi.c b/drivers/net/skfp/skfddi.c index 088fe26484e7..888a14a045ef 100644 --- a/drivers/net/skfp/skfddi.c +++ b/drivers/net/skfp/skfddi.c | |||
@@ -1077,7 +1077,7 @@ static int skfp_send_pkt(struct sk_buff *skb, struct net_device *dev) | |||
1077 | // dequeue packets from xmt queue and send them | 1077 | // dequeue packets from xmt queue and send them |
1078 | netif_start_queue(dev); | 1078 | netif_start_queue(dev); |
1079 | dev_kfree_skb(skb); | 1079 | dev_kfree_skb(skb); |
1080 | return (0); /* return "success" */ | 1080 | return NETDEV_TX_OK; /* return "success" */ |
1081 | } | 1081 | } |
1082 | if (bp->QueueSkb == 0) { // return with tbusy set: queue full | 1082 | if (bp->QueueSkb == 0) { // return with tbusy set: queue full |
1083 | 1083 | ||
@@ -1091,7 +1091,7 @@ static int skfp_send_pkt(struct sk_buff *skb, struct net_device *dev) | |||
1091 | netif_stop_queue(dev); | 1091 | netif_stop_queue(dev); |
1092 | } | 1092 | } |
1093 | dev->trans_start = jiffies; | 1093 | dev->trans_start = jiffies; |
1094 | return 0; | 1094 | return NETDEV_TX_OK; |
1095 | 1095 | ||
1096 | } // skfp_send_pkt | 1096 | } // skfp_send_pkt |
1097 | 1097 | ||
diff --git a/drivers/net/slip.c b/drivers/net/slip.c index 5c61d5fad908..899c4a2112c9 100644 --- a/drivers/net/slip.c +++ b/drivers/net/slip.c | |||
@@ -484,12 +484,12 @@ sl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
484 | spin_unlock(&sl->lock); | 484 | spin_unlock(&sl->lock); |
485 | printk(KERN_WARNING "%s: xmit call when iface is down\n", dev->name); | 485 | printk(KERN_WARNING "%s: xmit call when iface is down\n", dev->name); |
486 | dev_kfree_skb(skb); | 486 | dev_kfree_skb(skb); |
487 | return 0; | 487 | return NETDEV_TX_OK; |
488 | } | 488 | } |
489 | if (sl->tty == NULL) { | 489 | if (sl->tty == NULL) { |
490 | spin_unlock(&sl->lock); | 490 | spin_unlock(&sl->lock); |
491 | dev_kfree_skb(skb); | 491 | dev_kfree_skb(skb); |
492 | return 0; | 492 | return NETDEV_TX_OK; |
493 | } | 493 | } |
494 | 494 | ||
495 | sl_lock(sl); | 495 | sl_lock(sl); |
@@ -498,7 +498,7 @@ sl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
498 | spin_unlock(&sl->lock); | 498 | spin_unlock(&sl->lock); |
499 | 499 | ||
500 | dev_kfree_skb(skb); | 500 | dev_kfree_skb(skb); |
501 | return 0; | 501 | return NETDEV_TX_OK; |
502 | } | 502 | } |
503 | 503 | ||
504 | 504 | ||
diff --git a/drivers/net/smc911x.c b/drivers/net/smc911x.c index bc4976ac8712..2a6b6de95339 100644 --- a/drivers/net/smc911x.c +++ b/drivers/net/smc911x.c | |||
@@ -553,7 +553,7 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
553 | dev->stats.tx_dropped++; | 553 | dev->stats.tx_dropped++; |
554 | spin_unlock_irqrestore(&lp->lock, flags); | 554 | spin_unlock_irqrestore(&lp->lock, flags); |
555 | dev_kfree_skb(skb); | 555 | dev_kfree_skb(skb); |
556 | return 0; | 556 | return NETDEV_TX_OK; |
557 | } | 557 | } |
558 | 558 | ||
559 | #ifdef SMC_USE_DMA | 559 | #ifdef SMC_USE_DMA |
@@ -566,7 +566,7 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
566 | lp->pending_tx_skb = skb; | 566 | lp->pending_tx_skb = skb; |
567 | netif_stop_queue(dev); | 567 | netif_stop_queue(dev); |
568 | spin_unlock_irqrestore(&lp->lock, flags); | 568 | spin_unlock_irqrestore(&lp->lock, flags); |
569 | return 0; | 569 | return NETDEV_TX_OK; |
570 | } else { | 570 | } else { |
571 | DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, "%s: Activating Tx DMA\n", dev->name); | 571 | DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, "%s: Activating Tx DMA\n", dev->name); |
572 | lp->txdma_active = 1; | 572 | lp->txdma_active = 1; |
@@ -577,7 +577,7 @@ static int smc911x_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
577 | smc911x_hardware_send_pkt(dev); | 577 | smc911x_hardware_send_pkt(dev); |
578 | spin_unlock_irqrestore(&lp->lock, flags); | 578 | spin_unlock_irqrestore(&lp->lock, flags); |
579 | 579 | ||
580 | return 0; | 580 | return NETDEV_TX_OK; |
581 | } | 581 | } |
582 | 582 | ||
583 | /* | 583 | /* |
diff --git a/drivers/net/smc9194.c b/drivers/net/smc9194.c index e02471b2f2b5..0a1b6f401087 100644 --- a/drivers/net/smc9194.c +++ b/drivers/net/smc9194.c | |||
@@ -512,7 +512,7 @@ static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * de | |||
512 | if (length < ETH_ZLEN) { | 512 | if (length < ETH_ZLEN) { |
513 | if (skb_padto(skb, ETH_ZLEN)) { | 513 | if (skb_padto(skb, ETH_ZLEN)) { |
514 | netif_wake_queue(dev); | 514 | netif_wake_queue(dev); |
515 | return 0; | 515 | return NETDEV_TX_OK; |
516 | } | 516 | } |
517 | length = ETH_ZLEN; | 517 | length = ETH_ZLEN; |
518 | } | 518 | } |
@@ -534,7 +534,7 @@ static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * de | |||
534 | lp->saved_skb = NULL; | 534 | lp->saved_skb = NULL; |
535 | /* this IS an error, but, i don't want the skb saved */ | 535 | /* this IS an error, but, i don't want the skb saved */ |
536 | netif_wake_queue(dev); | 536 | netif_wake_queue(dev); |
537 | return 0; | 537 | return NETDEV_TX_OK; |
538 | } | 538 | } |
539 | /* either way, a packet is waiting now */ | 539 | /* either way, a packet is waiting now */ |
540 | lp->packets_waiting++; | 540 | lp->packets_waiting++; |
@@ -571,12 +571,12 @@ static int smc_wait_to_send_packet( struct sk_buff * skb, struct net_device * de | |||
571 | SMC_ENABLE_INT( IM_ALLOC_INT ); | 571 | SMC_ENABLE_INT( IM_ALLOC_INT ); |
572 | PRINTK2((CARDNAME": memory allocation deferred. \n")); | 572 | PRINTK2((CARDNAME": memory allocation deferred. \n")); |
573 | /* it's deferred, but I'll handle it later */ | 573 | /* it's deferred, but I'll handle it later */ |
574 | return 0; | 574 | return NETDEV_TX_OK; |
575 | } | 575 | } |
576 | /* or YES! I can send the packet now.. */ | 576 | /* or YES! I can send the packet now.. */ |
577 | smc_hardware_send_packet(dev); | 577 | smc_hardware_send_packet(dev); |
578 | netif_wake_queue(dev); | 578 | netif_wake_queue(dev); |
579 | return 0; | 579 | return NETDEV_TX_OK; |
580 | } | 580 | } |
581 | 581 | ||
582 | /* | 582 | /* |
diff --git a/drivers/net/smc91x.c b/drivers/net/smc91x.c index 1c70e999cc50..0f2c52c2e044 100644 --- a/drivers/net/smc91x.c +++ b/drivers/net/smc91x.c | |||
@@ -655,7 +655,7 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
655 | dev->stats.tx_errors++; | 655 | dev->stats.tx_errors++; |
656 | dev->stats.tx_dropped++; | 656 | dev->stats.tx_dropped++; |
657 | dev_kfree_skb(skb); | 657 | dev_kfree_skb(skb); |
658 | return 0; | 658 | return NETDEV_TX_OK; |
659 | } | 659 | } |
660 | 660 | ||
661 | smc_special_lock(&lp->lock); | 661 | smc_special_lock(&lp->lock); |
@@ -692,7 +692,7 @@ static int smc_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
692 | smc_hardware_send_pkt((unsigned long)dev); | 692 | smc_hardware_send_pkt((unsigned long)dev); |
693 | } | 693 | } |
694 | 694 | ||
695 | return 0; | 695 | return NETDEV_TX_OK; |
696 | } | 696 | } |
697 | 697 | ||
698 | /* | 698 | /* |
diff --git a/drivers/net/sonic.c b/drivers/net/sonic.c index 753a1fba4609..9599ce77ef85 100644 --- a/drivers/net/sonic.c +++ b/drivers/net/sonic.c | |||
@@ -211,7 +211,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
211 | length = skb->len; | 211 | length = skb->len; |
212 | if (length < ETH_ZLEN) { | 212 | if (length < ETH_ZLEN) { |
213 | if (skb_padto(skb, ETH_ZLEN)) | 213 | if (skb_padto(skb, ETH_ZLEN)) |
214 | return 0; | 214 | return NETDEV_TX_OK; |
215 | length = ETH_ZLEN; | 215 | length = ETH_ZLEN; |
216 | } | 216 | } |
217 | 217 | ||
@@ -265,7 +265,7 @@ static int sonic_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
265 | 265 | ||
266 | dev->trans_start = jiffies; | 266 | dev->trans_start = jiffies; |
267 | 267 | ||
268 | return 0; | 268 | return NETDEV_TX_OK; |
269 | } | 269 | } |
270 | 270 | ||
271 | /* | 271 | /* |
diff --git a/drivers/net/starfire.c b/drivers/net/starfire.c index 838cce8b8fff..1018349a29dc 100644 --- a/drivers/net/starfire.c +++ b/drivers/net/starfire.c | |||
@@ -1311,7 +1311,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1311 | 1311 | ||
1312 | dev->trans_start = jiffies; | 1312 | dev->trans_start = jiffies; |
1313 | 1313 | ||
1314 | return 0; | 1314 | return NETDEV_TX_OK; |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | 1317 | ||
diff --git a/drivers/net/sun3_82586.c b/drivers/net/sun3_82586.c index 7bb27426dbd6..2f1eaaf7a727 100644 --- a/drivers/net/sun3_82586.c +++ b/drivers/net/sun3_82586.c | |||
@@ -1015,7 +1015,7 @@ static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1015 | if(skb->len > XMIT_BUFF_SIZE) | 1015 | if(skb->len > XMIT_BUFF_SIZE) |
1016 | { | 1016 | { |
1017 | printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len); | 1017 | printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len); |
1018 | return 0; | 1018 | return NETDEV_TX_OK; |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | netif_stop_queue(dev); | 1021 | netif_stop_queue(dev); |
@@ -1110,7 +1110,7 @@ static int sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1110 | dev_kfree_skb(skb); | 1110 | dev_kfree_skb(skb); |
1111 | #endif | 1111 | #endif |
1112 | } | 1112 | } |
1113 | return 0; | 1113 | return NETDEV_TX_OK; |
1114 | } | 1114 | } |
1115 | 1115 | ||
1116 | /******************************************* | 1116 | /******************************************* |
diff --git a/drivers/net/sun3lance.c b/drivers/net/sun3lance.c index 534dfe3eef6f..0ca4241b4f63 100644 --- a/drivers/net/sun3lance.c +++ b/drivers/net/sun3lance.c | |||
@@ -562,7 +562,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev ) | |||
562 | netif_start_queue(dev); | 562 | netif_start_queue(dev); |
563 | dev->trans_start = jiffies; | 563 | dev->trans_start = jiffies; |
564 | 564 | ||
565 | return 0; | 565 | return NETDEV_TX_OK; |
566 | } | 566 | } |
567 | 567 | ||
568 | 568 | ||
@@ -648,7 +648,7 @@ static int lance_start_xmit( struct sk_buff *skb, struct net_device *dev ) | |||
648 | 648 | ||
649 | local_irq_restore(flags); | 649 | local_irq_restore(flags); |
650 | 650 | ||
651 | return 0; | 651 | return NETDEV_TX_OK; |
652 | } | 652 | } |
653 | 653 | ||
654 | /* The LANCE interrupt handler. */ | 654 | /* The LANCE interrupt handler. */ |
diff --git a/drivers/net/sunbmac.c b/drivers/net/sunbmac.c index 5017d7fcb40c..536cf7e06bfd 100644 --- a/drivers/net/sunbmac.c +++ b/drivers/net/sunbmac.c | |||
@@ -984,7 +984,7 @@ static int bigmac_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
984 | 984 | ||
985 | dev->trans_start = jiffies; | 985 | dev->trans_start = jiffies; |
986 | 986 | ||
987 | return 0; | 987 | return NETDEV_TX_OK; |
988 | } | 988 | } |
989 | 989 | ||
990 | static struct net_device_stats *bigmac_get_stats(struct net_device *dev) | 990 | static struct net_device_stats *bigmac_get_stats(struct net_device *dev) |
diff --git a/drivers/net/sundance.c b/drivers/net/sundance.c index 545f81b34ad7..0df6332ed9ce 100644 --- a/drivers/net/sundance.c +++ b/drivers/net/sundance.c | |||
@@ -1091,7 +1091,7 @@ start_tx (struct sk_buff *skb, struct net_device *dev) | |||
1091 | "%s: Transmit frame #%d queued in slot %d.\n", | 1091 | "%s: Transmit frame #%d queued in slot %d.\n", |
1092 | dev->name, np->cur_tx, entry); | 1092 | dev->name, np->cur_tx, entry); |
1093 | } | 1093 | } |
1094 | return 0; | 1094 | return NETDEV_TX_OK; |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | /* Reset hardware tx and free all of tx buffers */ | 1097 | /* Reset hardware tx and free all of tx buffers */ |
diff --git a/drivers/net/sunhme.c b/drivers/net/sunhme.c index 4ef729198e10..008bd59fc64b 100644 --- a/drivers/net/sunhme.c +++ b/drivers/net/sunhme.c | |||
@@ -2338,7 +2338,7 @@ static int happy_meal_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2338 | dev->trans_start = jiffies; | 2338 | dev->trans_start = jiffies; |
2339 | 2339 | ||
2340 | tx_add_log(hp, TXLOG_ACTION_TXMIT, 0); | 2340 | tx_add_log(hp, TXLOG_ACTION_TXMIT, 0); |
2341 | return 0; | 2341 | return NETDEV_TX_OK; |
2342 | } | 2342 | } |
2343 | 2343 | ||
2344 | static struct net_device_stats *happy_meal_get_stats(struct net_device *dev) | 2344 | static struct net_device_stats *happy_meal_get_stats(struct net_device *dev) |
diff --git a/drivers/net/sunlance.c b/drivers/net/sunlance.c index afc7b351e5ec..9d6fd4760eab 100644 --- a/drivers/net/sunlance.c +++ b/drivers/net/sunlance.c | |||
@@ -1163,7 +1163,7 @@ static int lance_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1163 | dev->trans_start = jiffies; | 1163 | dev->trans_start = jiffies; |
1164 | dev_kfree_skb(skb); | 1164 | dev_kfree_skb(skb); |
1165 | 1165 | ||
1166 | return 0; | 1166 | return NETDEV_TX_OK; |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | /* taken from the depca driver */ | 1169 | /* taken from the depca driver */ |
diff --git a/drivers/net/sunqe.c b/drivers/net/sunqe.c index c6ec61e0accf..dcefb608a9f4 100644 --- a/drivers/net/sunqe.c +++ b/drivers/net/sunqe.c | |||
@@ -621,7 +621,7 @@ static int qe_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
621 | 621 | ||
622 | dev_kfree_skb(skb); | 622 | dev_kfree_skb(skb); |
623 | 623 | ||
624 | return 0; | 624 | return NETDEV_TX_OK; |
625 | } | 625 | } |
626 | 626 | ||
627 | static void qe_set_multicast(struct net_device *dev) | 627 | static void qe_set_multicast(struct net_device *dev) |
diff --git a/drivers/net/tc35815.c b/drivers/net/tc35815.c index d737f6b8f876..1ce2da172ca9 100644 --- a/drivers/net/tc35815.c +++ b/drivers/net/tc35815.c | |||
@@ -1509,7 +1509,7 @@ static int tc35815_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1509 | */ | 1509 | */ |
1510 | 1510 | ||
1511 | spin_unlock_irqrestore(&lp->lock, flags); | 1511 | spin_unlock_irqrestore(&lp->lock, flags); |
1512 | return 0; | 1512 | return NETDEV_TX_OK; |
1513 | } | 1513 | } |
1514 | 1514 | ||
1515 | #define FATAL_ERROR_INT \ | 1515 | #define FATAL_ERROR_INT \ |
diff --git a/drivers/net/tlan.c b/drivers/net/tlan.c index 384cb5e28397..70c9ec45d8fb 100644 --- a/drivers/net/tlan.c +++ b/drivers/net/tlan.c | |||
@@ -1095,11 +1095,11 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev ) | |||
1095 | TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n", | 1095 | TLAN_DBG( TLAN_DEBUG_TX, "TRANSMIT: %s PHY is not ready\n", |
1096 | dev->name ); | 1096 | dev->name ); |
1097 | dev_kfree_skb_any(skb); | 1097 | dev_kfree_skb_any(skb); |
1098 | return 0; | 1098 | return NETDEV_TX_OK; |
1099 | } | 1099 | } |
1100 | 1100 | ||
1101 | if (skb_padto(skb, TLAN_MIN_FRAME_SIZE)) | 1101 | if (skb_padto(skb, TLAN_MIN_FRAME_SIZE)) |
1102 | return 0; | 1102 | return NETDEV_TX_OK; |
1103 | txlen = max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE); | 1103 | txlen = max(skb->len, (unsigned int)TLAN_MIN_FRAME_SIZE); |
1104 | 1104 | ||
1105 | tail_list = priv->txList + priv->txTail; | 1105 | tail_list = priv->txList + priv->txTail; |
@@ -1150,7 +1150,7 @@ static int TLan_StartTx( struct sk_buff *skb, struct net_device *dev ) | |||
1150 | CIRC_INC( priv->txTail, TLAN_NUM_TX_LISTS ); | 1150 | CIRC_INC( priv->txTail, TLAN_NUM_TX_LISTS ); |
1151 | 1151 | ||
1152 | dev->trans_start = jiffies; | 1152 | dev->trans_start = jiffies; |
1153 | return 0; | 1153 | return NETDEV_TX_OK; |
1154 | 1154 | ||
1155 | } /* TLan_StartTx */ | 1155 | } /* TLan_StartTx */ |
1156 | 1156 | ||
diff --git a/drivers/net/tokenring/3c359.c b/drivers/net/tokenring/3c359.c index b40b6de2d086..1787d52941bc 100644 --- a/drivers/net/tokenring/3c359.c +++ b/drivers/net/tokenring/3c359.c | |||
@@ -1240,7 +1240,7 @@ static int xl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1240 | 1240 | ||
1241 | spin_unlock_irqrestore(&xl_priv->xl_lock,flags) ; | 1241 | spin_unlock_irqrestore(&xl_priv->xl_lock,flags) ; |
1242 | 1242 | ||
1243 | return 0; | 1243 | return NETDEV_TX_OK; |
1244 | } else { | 1244 | } else { |
1245 | spin_unlock_irqrestore(&xl_priv->xl_lock,flags) ; | 1245 | spin_unlock_irqrestore(&xl_priv->xl_lock,flags) ; |
1246 | return NETDEV_TX_BUSY; | 1246 | return NETDEV_TX_BUSY; |
diff --git a/drivers/net/tokenring/ibmtr.c b/drivers/net/tokenring/ibmtr.c index 9d896116cf76..6472ba5cfc5e 100644 --- a/drivers/net/tokenring/ibmtr.c +++ b/drivers/net/tokenring/ibmtr.c | |||
@@ -1041,7 +1041,7 @@ static int tok_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
1041 | writeb(CMD_IN_SRB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD); | 1041 | writeb(CMD_IN_SRB, ti->mmio + ACA_OFFSET + ACA_SET + ISRA_ODD); |
1042 | spin_unlock_irqrestore(&(ti->lock), flags); | 1042 | spin_unlock_irqrestore(&(ti->lock), flags); |
1043 | dev->trans_start = jiffies; | 1043 | dev->trans_start = jiffies; |
1044 | return 0; | 1044 | return NETDEV_TX_OK; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | /*****************************************************************************/ | 1047 | /*****************************************************************************/ |
diff --git a/drivers/net/tokenring/lanstreamer.c b/drivers/net/tokenring/lanstreamer.c index b3715efdce56..d07e61a9499e 100644 --- a/drivers/net/tokenring/lanstreamer.c +++ b/drivers/net/tokenring/lanstreamer.c | |||
@@ -1183,7 +1183,7 @@ static int streamer_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1183 | 1183 | ||
1184 | streamer_priv->tx_ring_free = (streamer_priv->tx_ring_free + 1) & (STREAMER_TX_RING_SIZE - 1); | 1184 | streamer_priv->tx_ring_free = (streamer_priv->tx_ring_free + 1) & (STREAMER_TX_RING_SIZE - 1); |
1185 | spin_unlock_irqrestore(&streamer_priv->streamer_lock,flags); | 1185 | spin_unlock_irqrestore(&streamer_priv->streamer_lock,flags); |
1186 | return 0; | 1186 | return NETDEV_TX_OK; |
1187 | } else { | 1187 | } else { |
1188 | netif_stop_queue(dev); | 1188 | netif_stop_queue(dev); |
1189 | spin_unlock_irqrestore(&streamer_priv->streamer_lock,flags); | 1189 | spin_unlock_irqrestore(&streamer_priv->streamer_lock,flags); |
diff --git a/drivers/net/tokenring/olympic.c b/drivers/net/tokenring/olympic.c index 451b54136ede..f73f4e684f33 100644 --- a/drivers/net/tokenring/olympic.c +++ b/drivers/net/tokenring/olympic.c | |||
@@ -1052,7 +1052,7 @@ static int olympic_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1052 | writew((((readw(olympic_mmio+TXENQ_1)) & 0x8000) ^ 0x8000) | 1,olympic_mmio+TXENQ_1); | 1052 | writew((((readw(olympic_mmio+TXENQ_1)) & 0x8000) ^ 0x8000) | 1,olympic_mmio+TXENQ_1); |
1053 | netif_wake_queue(dev); | 1053 | netif_wake_queue(dev); |
1054 | spin_unlock_irqrestore(&olympic_priv->olympic_lock,flags); | 1054 | spin_unlock_irqrestore(&olympic_priv->olympic_lock,flags); |
1055 | return 0; | 1055 | return NETDEV_TX_OK; |
1056 | } else { | 1056 | } else { |
1057 | spin_unlock_irqrestore(&olympic_priv->olympic_lock,flags); | 1057 | spin_unlock_irqrestore(&olympic_priv->olympic_lock,flags); |
1058 | return NETDEV_TX_BUSY; | 1058 | return NETDEV_TX_BUSY; |
diff --git a/drivers/net/tokenring/smctr.c b/drivers/net/tokenring/smctr.c index 54ad4ed03374..6515894c83f5 100644 --- a/drivers/net/tokenring/smctr.c +++ b/drivers/net/tokenring/smctr.c | |||
@@ -4609,7 +4609,7 @@ static int smctr_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
4609 | if(tp->QueueSkb > 0) | 4609 | if(tp->QueueSkb > 0) |
4610 | netif_wake_queue(dev); | 4610 | netif_wake_queue(dev); |
4611 | 4611 | ||
4612 | return (0); | 4612 | return NETDEV_TX_OK; |
4613 | } | 4613 | } |
4614 | 4614 | ||
4615 | static int smctr_send_lobe_media_test(struct net_device *dev) | 4615 | static int smctr_send_lobe_media_test(struct net_device *dev) |
diff --git a/drivers/net/tokenring/tms380tr.c b/drivers/net/tokenring/tms380tr.c index a2eab72b507a..07f6dfd3ba0c 100644 --- a/drivers/net/tokenring/tms380tr.c +++ b/drivers/net/tokenring/tms380tr.c | |||
@@ -682,7 +682,7 @@ static int tms380tr_hardware_send_packet(struct sk_buff *skb, struct net_device | |||
682 | tms380tr_exec_sifcmd(dev, CMD_TX_VALID); | 682 | tms380tr_exec_sifcmd(dev, CMD_TX_VALID); |
683 | spin_unlock_irqrestore(&tp->lock, flags); | 683 | spin_unlock_irqrestore(&tp->lock, flags); |
684 | 684 | ||
685 | return 0; | 685 | return NETDEV_TX_OK; |
686 | } | 686 | } |
687 | 687 | ||
688 | /* | 688 | /* |
diff --git a/drivers/net/tulip/de2104x.c b/drivers/net/tulip/de2104x.c index 81f054dbb88d..769af558a345 100644 --- a/drivers/net/tulip/de2104x.c +++ b/drivers/net/tulip/de2104x.c | |||
@@ -651,7 +651,7 @@ static int de_start_xmit (struct sk_buff *skb, struct net_device *dev) | |||
651 | dw32(TxPoll, NormalTxPoll); | 651 | dw32(TxPoll, NormalTxPoll); |
652 | dev->trans_start = jiffies; | 652 | dev->trans_start = jiffies; |
653 | 653 | ||
654 | return 0; | 654 | return NETDEV_TX_OK; |
655 | } | 655 | } |
656 | 656 | ||
657 | /* Set or clear the multicast filter for this adaptor. | 657 | /* Set or clear the multicast filter for this adaptor. |
diff --git a/drivers/net/tulip/dmfe.c b/drivers/net/tulip/dmfe.c index 8e78f003f08f..5e15fab58c17 100644 --- a/drivers/net/tulip/dmfe.c +++ b/drivers/net/tulip/dmfe.c | |||
@@ -676,7 +676,7 @@ static int dmfe_start_xmit(struct sk_buff *skb, struct DEVICE *dev) | |||
676 | if (skb->len > MAX_PACKET_SIZE) { | 676 | if (skb->len > MAX_PACKET_SIZE) { |
677 | printk(KERN_ERR DRV_NAME ": big packet = %d\n", (u16)skb->len); | 677 | printk(KERN_ERR DRV_NAME ": big packet = %d\n", (u16)skb->len); |
678 | dev_kfree_skb(skb); | 678 | dev_kfree_skb(skb); |
679 | return 0; | 679 | return NETDEV_TX_OK; |
680 | } | 680 | } |
681 | 681 | ||
682 | spin_lock_irqsave(&db->lock, flags); | 682 | spin_lock_irqsave(&db->lock, flags); |
@@ -722,7 +722,7 @@ static int dmfe_start_xmit(struct sk_buff *skb, struct DEVICE *dev) | |||
722 | /* free this SKB */ | 722 | /* free this SKB */ |
723 | dev_kfree_skb(skb); | 723 | dev_kfree_skb(skb); |
724 | 724 | ||
725 | return 0; | 725 | return NETDEV_TX_OK; |
726 | } | 726 | } |
727 | 727 | ||
728 | 728 | ||
diff --git a/drivers/net/tulip/tulip_core.c b/drivers/net/tulip/tulip_core.c index 2abb5d3becc6..9d46638d250e 100644 --- a/drivers/net/tulip/tulip_core.c +++ b/drivers/net/tulip/tulip_core.c | |||
@@ -690,7 +690,7 @@ tulip_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
690 | 690 | ||
691 | dev->trans_start = jiffies; | 691 | dev->trans_start = jiffies; |
692 | 692 | ||
693 | return 0; | 693 | return NETDEV_TX_OK; |
694 | } | 694 | } |
695 | 695 | ||
696 | static void tulip_clean_tx_ring(struct tulip_private *tp) | 696 | static void tulip_clean_tx_ring(struct tulip_private *tp) |
diff --git a/drivers/net/tulip/uli526x.c b/drivers/net/tulip/uli526x.c index 9277ce8febe4..9074a34eb814 100644 --- a/drivers/net/tulip/uli526x.c +++ b/drivers/net/tulip/uli526x.c | |||
@@ -582,7 +582,7 @@ static int uli526x_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
582 | if (skb->len > MAX_PACKET_SIZE) { | 582 | if (skb->len > MAX_PACKET_SIZE) { |
583 | printk(KERN_ERR DRV_NAME ": big packet = %d\n", (u16)skb->len); | 583 | printk(KERN_ERR DRV_NAME ": big packet = %d\n", (u16)skb->len); |
584 | dev_kfree_skb(skb); | 584 | dev_kfree_skb(skb); |
585 | return 0; | 585 | return NETDEV_TX_OK; |
586 | } | 586 | } |
587 | 587 | ||
588 | spin_lock_irqsave(&db->lock, flags); | 588 | spin_lock_irqsave(&db->lock, flags); |
@@ -624,7 +624,7 @@ static int uli526x_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
624 | /* free this SKB */ | 624 | /* free this SKB */ |
625 | dev_kfree_skb(skb); | 625 | dev_kfree_skb(skb); |
626 | 626 | ||
627 | return 0; | 627 | return NETDEV_TX_OK; |
628 | } | 628 | } |
629 | 629 | ||
630 | 630 | ||
diff --git a/drivers/net/tulip/winbond-840.c b/drivers/net/tulip/winbond-840.c index 842b1a2c40d4..6bc7540b216e 100644 --- a/drivers/net/tulip/winbond-840.c +++ b/drivers/net/tulip/winbond-840.c | |||
@@ -1058,7 +1058,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1058 | printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n", | 1058 | printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n", |
1059 | dev->name, np->cur_tx, entry); | 1059 | dev->name, np->cur_tx, entry); |
1060 | } | 1060 | } |
1061 | return 0; | 1061 | return NETDEV_TX_OK; |
1062 | } | 1062 | } |
1063 | 1063 | ||
1064 | static void netdev_tx_done(struct net_device *dev) | 1064 | static void netdev_tx_done(struct net_device *dev) |
diff --git a/drivers/net/tulip/xircom_cb.c b/drivers/net/tulip/xircom_cb.c index c2ca9f40e40e..22b6a239fb33 100644 --- a/drivers/net/tulip/xircom_cb.c +++ b/drivers/net/tulip/xircom_cb.c | |||
@@ -434,7 +434,7 @@ static int xircom_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
434 | card->transmit_used = nextdescriptor; | 434 | card->transmit_used = nextdescriptor; |
435 | leave("xircom-start_xmit - sent"); | 435 | leave("xircom-start_xmit - sent"); |
436 | spin_unlock_irqrestore(&card->lock,flags); | 436 | spin_unlock_irqrestore(&card->lock,flags); |
437 | return 0; | 437 | return NETDEV_TX_OK; |
438 | } | 438 | } |
439 | 439 | ||
440 | 440 | ||
diff --git a/drivers/net/tun.c b/drivers/net/tun.c index 027f7aba26af..dfc1054e4cbd 100644 --- a/drivers/net/tun.c +++ b/drivers/net/tun.c | |||
@@ -398,12 +398,12 @@ static int tun_net_xmit(struct sk_buff *skb, struct net_device *dev) | |||
398 | if (tun->flags & TUN_FASYNC) | 398 | if (tun->flags & TUN_FASYNC) |
399 | kill_fasync(&tun->fasync, SIGIO, POLL_IN); | 399 | kill_fasync(&tun->fasync, SIGIO, POLL_IN); |
400 | wake_up_interruptible(&tun->socket.wait); | 400 | wake_up_interruptible(&tun->socket.wait); |
401 | return 0; | 401 | return NETDEV_TX_OK; |
402 | 402 | ||
403 | drop: | 403 | drop: |
404 | dev->stats.tx_dropped++; | 404 | dev->stats.tx_dropped++; |
405 | kfree_skb(skb); | 405 | kfree_skb(skb); |
406 | return 0; | 406 | return NETDEV_TX_OK; |
407 | } | 407 | } |
408 | 408 | ||
409 | static void tun_net_mclist(struct net_device *dev) | 409 | static void tun_net_mclist(struct net_device *dev) |
@@ -997,7 +997,6 @@ static int tun_set_iff(struct net *net, struct file *file, struct ifreq *ifr) | |||
997 | goto err_free_sk; | 997 | goto err_free_sk; |
998 | } | 998 | } |
999 | 999 | ||
1000 | err = -EINVAL; | ||
1001 | err = register_netdevice(tun->dev); | 1000 | err = register_netdevice(tun->dev); |
1002 | if (err < 0) | 1001 | if (err < 0) |
1003 | goto err_free_sk; | 1002 | goto err_free_sk; |
diff --git a/drivers/net/typhoon.c b/drivers/net/typhoon.c index cf25eb41b1ce..2c26b4577e8a 100644 --- a/drivers/net/typhoon.c +++ b/drivers/net/typhoon.c | |||
@@ -909,7 +909,7 @@ typhoon_start_tx(struct sk_buff *skb, struct net_device *dev) | |||
909 | netif_wake_queue(dev); | 909 | netif_wake_queue(dev); |
910 | } | 910 | } |
911 | 911 | ||
912 | return 0; | 912 | return NETDEV_TX_OK; |
913 | } | 913 | } |
914 | 914 | ||
915 | static void | 915 | static void |
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 40c6eba775ce..ca476a58087c 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -209,9 +209,10 @@ static struct sk_buff *get_new_skb(struct ucc_geth_private *ugeth, | |||
209 | { | 209 | { |
210 | struct sk_buff *skb = NULL; | 210 | struct sk_buff *skb = NULL; |
211 | 211 | ||
212 | skb = dev_alloc_skb(ugeth->ug_info->uf_info.max_rx_buf_length + | 212 | skb = __skb_dequeue(&ugeth->rx_recycle); |
213 | UCC_GETH_RX_DATA_BUF_ALIGNMENT); | 213 | if (!skb) |
214 | 214 | skb = dev_alloc_skb(ugeth->ug_info->uf_info.max_rx_buf_length + | |
215 | UCC_GETH_RX_DATA_BUF_ALIGNMENT); | ||
215 | if (skb == NULL) | 216 | if (skb == NULL) |
216 | return NULL; | 217 | return NULL; |
217 | 218 | ||
@@ -1986,6 +1987,8 @@ static void ucc_geth_memclean(struct ucc_geth_private *ugeth) | |||
1986 | iounmap(ugeth->ug_regs); | 1987 | iounmap(ugeth->ug_regs); |
1987 | ugeth->ug_regs = NULL; | 1988 | ugeth->ug_regs = NULL; |
1988 | } | 1989 | } |
1990 | |||
1991 | skb_queue_purge(&ugeth->rx_recycle); | ||
1989 | } | 1992 | } |
1990 | 1993 | ||
1991 | static void ucc_geth_set_multi(struct net_device *dev) | 1994 | static void ucc_geth_set_multi(struct net_device *dev) |
@@ -2202,6 +2205,8 @@ static int ucc_struct_init(struct ucc_geth_private *ugeth) | |||
2202 | return -ENOMEM; | 2205 | return -ENOMEM; |
2203 | } | 2206 | } |
2204 | 2207 | ||
2208 | skb_queue_head_init(&ugeth->rx_recycle); | ||
2209 | |||
2205 | return 0; | 2210 | return 0; |
2206 | } | 2211 | } |
2207 | 2212 | ||
@@ -3173,7 +3178,7 @@ static int ucc_geth_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
3173 | #endif | 3178 | #endif |
3174 | spin_unlock_irq(&ugeth->lock); | 3179 | spin_unlock_irq(&ugeth->lock); |
3175 | 3180 | ||
3176 | return 0; | 3181 | return NETDEV_TX_OK; |
3177 | } | 3182 | } |
3178 | 3183 | ||
3179 | static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit) | 3184 | static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit) |
@@ -3208,8 +3213,10 @@ static int ucc_geth_rx(struct ucc_geth_private *ugeth, u8 rxQ, int rx_work_limit | |||
3208 | if (netif_msg_rx_err(ugeth)) | 3213 | if (netif_msg_rx_err(ugeth)) |
3209 | ugeth_err("%s, %d: ERROR!!! skb - 0x%08x", | 3214 | ugeth_err("%s, %d: ERROR!!! skb - 0x%08x", |
3210 | __func__, __LINE__, (u32) skb); | 3215 | __func__, __LINE__, (u32) skb); |
3211 | if (skb) | 3216 | if (skb) { |
3212 | dev_kfree_skb_any(skb); | 3217 | skb->data = skb->head + NET_SKB_PAD; |
3218 | __skb_queue_head(&ugeth->rx_recycle, skb); | ||
3219 | } | ||
3213 | 3220 | ||
3214 | ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]] = NULL; | 3221 | ugeth->rx_skbuff[rxQ][ugeth->skb_currx[rxQ]] = NULL; |
3215 | dev->stats.rx_dropped++; | 3222 | dev->stats.rx_dropped++; |
@@ -3267,6 +3274,8 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ) | |||
3267 | 3274 | ||
3268 | /* Normal processing. */ | 3275 | /* Normal processing. */ |
3269 | while ((bd_status & T_R) == 0) { | 3276 | while ((bd_status & T_R) == 0) { |
3277 | struct sk_buff *skb; | ||
3278 | |||
3270 | /* BD contains already transmitted buffer. */ | 3279 | /* BD contains already transmitted buffer. */ |
3271 | /* Handle the transmitted buffer and release */ | 3280 | /* Handle the transmitted buffer and release */ |
3272 | /* the BD to be used with the current frame */ | 3281 | /* the BD to be used with the current frame */ |
@@ -3276,9 +3285,16 @@ static int ucc_geth_tx(struct net_device *dev, u8 txQ) | |||
3276 | 3285 | ||
3277 | dev->stats.tx_packets++; | 3286 | dev->stats.tx_packets++; |
3278 | 3287 | ||
3279 | /* Free the sk buffer associated with this TxBD */ | 3288 | skb = ugeth->tx_skbuff[txQ][ugeth->skb_dirtytx[txQ]]; |
3280 | dev_kfree_skb(ugeth-> | 3289 | |
3281 | tx_skbuff[txQ][ugeth->skb_dirtytx[txQ]]); | 3290 | if (skb_queue_len(&ugeth->rx_recycle) < RX_BD_RING_LEN && |
3291 | skb_recycle_check(skb, | ||
3292 | ugeth->ug_info->uf_info.max_rx_buf_length + | ||
3293 | UCC_GETH_RX_DATA_BUF_ALIGNMENT)) | ||
3294 | __skb_queue_head(&ugeth->rx_recycle, skb); | ||
3295 | else | ||
3296 | dev_kfree_skb(skb); | ||
3297 | |||
3282 | ugeth->tx_skbuff[txQ][ugeth->skb_dirtytx[txQ]] = NULL; | 3298 | ugeth->tx_skbuff[txQ][ugeth->skb_dirtytx[txQ]] = NULL; |
3283 | ugeth->skb_dirtytx[txQ] = | 3299 | ugeth->skb_dirtytx[txQ] = |
3284 | (ugeth->skb_dirtytx[txQ] + | 3300 | (ugeth->skb_dirtytx[txQ] + |
@@ -3307,16 +3323,16 @@ static int ucc_geth_poll(struct napi_struct *napi, int budget) | |||
3307 | 3323 | ||
3308 | ug_info = ugeth->ug_info; | 3324 | ug_info = ugeth->ug_info; |
3309 | 3325 | ||
3310 | howmany = 0; | ||
3311 | for (i = 0; i < ug_info->numQueuesRx; i++) | ||
3312 | howmany += ucc_geth_rx(ugeth, i, budget - howmany); | ||
3313 | |||
3314 | /* Tx event processing */ | 3326 | /* Tx event processing */ |
3315 | spin_lock(&ugeth->lock); | 3327 | spin_lock(&ugeth->lock); |
3316 | for (i = 0; i < ug_info->numQueuesTx; i++) | 3328 | for (i = 0; i < ug_info->numQueuesTx; i++) |
3317 | ucc_geth_tx(ugeth->ndev, i); | 3329 | ucc_geth_tx(ugeth->ndev, i); |
3318 | spin_unlock(&ugeth->lock); | 3330 | spin_unlock(&ugeth->lock); |
3319 | 3331 | ||
3332 | howmany = 0; | ||
3333 | for (i = 0; i < ug_info->numQueuesRx; i++) | ||
3334 | howmany += ucc_geth_rx(ugeth, i, budget - howmany); | ||
3335 | |||
3320 | if (howmany < budget) { | 3336 | if (howmany < budget) { |
3321 | napi_complete(napi); | 3337 | napi_complete(napi); |
3322 | setbits32(ugeth->uccf->p_uccm, UCCE_RX_EVENTS | UCCE_TX_EVENTS); | 3338 | setbits32(ugeth->uccf->p_uccm, UCCE_RX_EVENTS | UCCE_TX_EVENTS); |
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h index 195ab267ead7..cfb31afc08a9 100644 --- a/drivers/net/ucc_geth.h +++ b/drivers/net/ucc_geth.h | |||
@@ -1212,6 +1212,8 @@ struct ucc_geth_private { | |||
1212 | /* index of the first skb which hasn't been transmitted yet. */ | 1212 | /* index of the first skb which hasn't been transmitted yet. */ |
1213 | u16 skb_dirtytx[NUM_TX_QUEUES]; | 1213 | u16 skb_dirtytx[NUM_TX_QUEUES]; |
1214 | 1214 | ||
1215 | struct sk_buff_head rx_recycle; | ||
1216 | |||
1215 | struct ugeth_mii_info *mii_info; | 1217 | struct ugeth_mii_info *mii_info; |
1216 | struct phy_device *phydev; | 1218 | struct phy_device *phydev; |
1217 | phy_interface_t phy_interface; | 1219 | phy_interface_t phy_interface; |
diff --git a/drivers/net/usb/catc.c b/drivers/net/usb/catc.c index b9dd42574288..7abdc4abbe07 100644 --- a/drivers/net/usb/catc.c +++ b/drivers/net/usb/catc.c | |||
@@ -448,7 +448,7 @@ static int catc_start_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
448 | 448 | ||
449 | dev_kfree_skb(skb); | 449 | dev_kfree_skb(skb); |
450 | 450 | ||
451 | return 0; | 451 | return NETDEV_TX_OK; |
452 | } | 452 | } |
453 | 453 | ||
454 | static void catc_tx_timeout(struct net_device *netdev) | 454 | static void catc_tx_timeout(struct net_device *netdev) |
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c index f8c6d7ea7264..ffe410635735 100644 --- a/drivers/net/usb/hso.c +++ b/drivers/net/usb/hso.c | |||
@@ -780,7 +780,7 @@ static int hso_net_start_xmit(struct sk_buff *skb, struct net_device *net) | |||
780 | netif_stop_queue(net); | 780 | netif_stop_queue(net); |
781 | if (hso_get_activity(odev->parent) == -EAGAIN) { | 781 | if (hso_get_activity(odev->parent) == -EAGAIN) { |
782 | odev->skb_tx_buf = skb; | 782 | odev->skb_tx_buf = skb; |
783 | return 0; | 783 | return NETDEV_TX_OK; |
784 | } | 784 | } |
785 | 785 | ||
786 | /* log if asked */ | 786 | /* log if asked */ |
diff --git a/drivers/net/usb/kaweth.c b/drivers/net/usb/kaweth.c index 1f9ec29fce50..200fe3d525ca 100644 --- a/drivers/net/usb/kaweth.c +++ b/drivers/net/usb/kaweth.c | |||
@@ -829,7 +829,7 @@ static int kaweth_start_xmit(struct sk_buff *skb, struct net_device *net) | |||
829 | kaweth->stats.tx_errors++; | 829 | kaweth->stats.tx_errors++; |
830 | netif_start_queue(net); | 830 | netif_start_queue(net); |
831 | spin_unlock_irq(&kaweth->device_lock); | 831 | spin_unlock_irq(&kaweth->device_lock); |
832 | return 0; | 832 | return NETDEV_TX_OK; |
833 | } | 833 | } |
834 | } | 834 | } |
835 | 835 | ||
@@ -864,7 +864,7 @@ skip: | |||
864 | 864 | ||
865 | spin_unlock_irq(&kaweth->device_lock); | 865 | spin_unlock_irq(&kaweth->device_lock); |
866 | 866 | ||
867 | return 0; | 867 | return NETDEV_TX_OK; |
868 | } | 868 | } |
869 | 869 | ||
870 | /**************************************************************** | 870 | /**************************************************************** |
diff --git a/drivers/net/usb/pegasus.c b/drivers/net/usb/pegasus.c index 631d269ac980..69d2df95ac86 100644 --- a/drivers/net/usb/pegasus.c +++ b/drivers/net/usb/pegasus.c | |||
@@ -914,7 +914,7 @@ static int pegasus_start_xmit(struct sk_buff *skb, struct net_device *net) | |||
914 | } | 914 | } |
915 | dev_kfree_skb(skb); | 915 | dev_kfree_skb(skb); |
916 | 916 | ||
917 | return 0; | 917 | return NETDEV_TX_OK; |
918 | } | 918 | } |
919 | 919 | ||
920 | static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev) | 920 | static struct net_device_stats *pegasus_netdev_stats(struct net_device *dev) |
diff --git a/drivers/net/usb/rtl8150.c b/drivers/net/usb/rtl8150.c index fcc6fa0905d1..bac8b77fb25e 100644 --- a/drivers/net/usb/rtl8150.c +++ b/drivers/net/usb/rtl8150.c | |||
@@ -753,7 +753,7 @@ static int rtl8150_start_xmit(struct sk_buff *skb, struct net_device *netdev) | |||
753 | netdev->trans_start = jiffies; | 753 | netdev->trans_start = jiffies; |
754 | } | 754 | } |
755 | 755 | ||
756 | return 0; | 756 | return NETDEV_TX_OK; |
757 | } | 757 | } |
758 | 758 | ||
759 | 759 | ||
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index edfd9e10ceba..25e435c49040 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
@@ -575,7 +575,9 @@ EXPORT_SYMBOL_GPL(usbnet_unlink_rx_urbs); | |||
575 | int usbnet_stop (struct net_device *net) | 575 | int usbnet_stop (struct net_device *net) |
576 | { | 576 | { |
577 | struct usbnet *dev = netdev_priv(net); | 577 | struct usbnet *dev = netdev_priv(net); |
578 | struct driver_info *info = dev->driver_info; | ||
578 | int temp; | 579 | int temp; |
580 | int retval; | ||
579 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup); | 581 | DECLARE_WAIT_QUEUE_HEAD_ONSTACK (unlink_wakeup); |
580 | DECLARE_WAITQUEUE (wait, current); | 582 | DECLARE_WAITQUEUE (wait, current); |
581 | 583 | ||
@@ -587,6 +589,18 @@ int usbnet_stop (struct net_device *net) | |||
587 | net->stats.rx_errors, net->stats.tx_errors | 589 | net->stats.rx_errors, net->stats.tx_errors |
588 | ); | 590 | ); |
589 | 591 | ||
592 | /* allow minidriver to stop correctly (wireless devices to turn off | ||
593 | * radio etc) */ | ||
594 | if (info->stop) { | ||
595 | retval = info->stop(dev); | ||
596 | if (retval < 0 && netif_msg_ifdown(dev)) | ||
597 | devinfo(dev, | ||
598 | "stop fail (%d) usbnet usb-%s-%s, %s", | ||
599 | retval, | ||
600 | dev->udev->bus->bus_name, dev->udev->devpath, | ||
601 | info->description); | ||
602 | } | ||
603 | |||
590 | // ensure there are no more active urbs | 604 | // ensure there are no more active urbs |
591 | add_wait_queue (&unlink_wakeup, &wait); | 605 | add_wait_queue (&unlink_wakeup, &wait); |
592 | dev->wait = &unlink_wakeup; | 606 | dev->wait = &unlink_wakeup; |
diff --git a/drivers/net/veth.c b/drivers/net/veth.c index 1097c72e44d5..f1d753daa5bd 100644 --- a/drivers/net/veth.c +++ b/drivers/net/veth.c | |||
@@ -189,17 +189,17 @@ static int veth_xmit(struct sk_buff *skb, struct net_device *dev) | |||
189 | rcv_stats->rx_packets++; | 189 | rcv_stats->rx_packets++; |
190 | 190 | ||
191 | netif_rx(skb); | 191 | netif_rx(skb); |
192 | return 0; | 192 | return NETDEV_TX_OK; |
193 | 193 | ||
194 | tx_drop: | 194 | tx_drop: |
195 | kfree_skb(skb); | 195 | kfree_skb(skb); |
196 | stats->tx_dropped++; | 196 | stats->tx_dropped++; |
197 | return 0; | 197 | return NETDEV_TX_OK; |
198 | 198 | ||
199 | rx_drop: | 199 | rx_drop: |
200 | kfree_skb(skb); | 200 | kfree_skb(skb); |
201 | rcv_stats->rx_dropped++; | 201 | rcv_stats->rx_dropped++; |
202 | return 0; | 202 | return NETDEV_TX_OK; |
203 | } | 203 | } |
204 | 204 | ||
205 | /* | 205 | /* |
diff --git a/drivers/net/via-rhine.c b/drivers/net/via-rhine.c index 88c30a58b4bd..46eb618bbc90 100644 --- a/drivers/net/via-rhine.c +++ b/drivers/net/via-rhine.c | |||
@@ -1226,7 +1226,7 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1226 | entry = rp->cur_tx % TX_RING_SIZE; | 1226 | entry = rp->cur_tx % TX_RING_SIZE; |
1227 | 1227 | ||
1228 | if (skb_padto(skb, ETH_ZLEN)) | 1228 | if (skb_padto(skb, ETH_ZLEN)) |
1229 | return 0; | 1229 | return NETDEV_TX_OK; |
1230 | 1230 | ||
1231 | rp->tx_skbuff[entry] = skb; | 1231 | rp->tx_skbuff[entry] = skb; |
1232 | 1232 | ||
@@ -1238,7 +1238,7 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1238 | dev_kfree_skb(skb); | 1238 | dev_kfree_skb(skb); |
1239 | rp->tx_skbuff[entry] = NULL; | 1239 | rp->tx_skbuff[entry] = NULL; |
1240 | dev->stats.tx_dropped++; | 1240 | dev->stats.tx_dropped++; |
1241 | return 0; | 1241 | return NETDEV_TX_OK; |
1242 | } | 1242 | } |
1243 | 1243 | ||
1244 | /* Padding is not copied and so must be redone. */ | 1244 | /* Padding is not copied and so must be redone. */ |
@@ -1286,7 +1286,7 @@ static int rhine_start_tx(struct sk_buff *skb, struct net_device *dev) | |||
1286 | printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n", | 1286 | printk(KERN_DEBUG "%s: Transmit frame #%d queued in slot %d.\n", |
1287 | dev->name, rp->cur_tx-1, entry); | 1287 | dev->name, rp->cur_tx-1, entry); |
1288 | } | 1288 | } |
1289 | return 0; | 1289 | return NETDEV_TX_OK; |
1290 | } | 1290 | } |
1291 | 1291 | ||
1292 | /* The interrupt handler does all of the Rx thread work and cleans up | 1292 | /* The interrupt handler does all of the Rx thread work and cleans up |
diff --git a/drivers/net/via-velocity.c b/drivers/net/via-velocity.c index 3ba35956327a..42365e5f931b 100644 --- a/drivers/net/via-velocity.c +++ b/drivers/net/via-velocity.c | |||
@@ -2098,7 +2098,7 @@ static int velocity_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2098 | #ifdef VELOCITY_ZERO_COPY_SUPPORT | 2098 | #ifdef VELOCITY_ZERO_COPY_SUPPORT |
2099 | if (skb_shinfo(skb)->nr_frags > 6 && __skb_linearize(skb)) { | 2099 | if (skb_shinfo(skb)->nr_frags > 6 && __skb_linearize(skb)) { |
2100 | kfree_skb(skb); | 2100 | kfree_skb(skb); |
2101 | return 0; | 2101 | return NETDEV_TX_OK; |
2102 | } | 2102 | } |
2103 | #endif | 2103 | #endif |
2104 | 2104 | ||
diff --git a/drivers/net/vxge/vxge-config.c b/drivers/net/vxge/vxge-config.c index 58d2551c78ed..9e94c4b0fb18 100644 --- a/drivers/net/vxge/vxge-config.c +++ b/drivers/net/vxge/vxge-config.c | |||
@@ -313,14 +313,6 @@ __vxge_hw_device_reg_addr_get(struct __vxge_hw_device *hldev) | |||
313 | hldev->kdfc = (u8 __iomem *)(hldev->bar0 + | 313 | hldev->kdfc = (u8 __iomem *)(hldev->bar0 + |
314 | VXGE_HW_TOC_GET_KDFC_INITIAL_OFFSET(val64)); | 314 | VXGE_HW_TOC_GET_KDFC_INITIAL_OFFSET(val64)); |
315 | break; | 315 | break; |
316 | case 2: | ||
317 | hldev->kdfc = (u8 __iomem *)(hldev->bar1 + | ||
318 | VXGE_HW_TOC_GET_KDFC_INITIAL_OFFSET(val64)); | ||
319 | break; | ||
320 | case 4: | ||
321 | hldev->kdfc = (u8 __iomem *)(hldev->bar2 + | ||
322 | VXGE_HW_TOC_GET_KDFC_INITIAL_OFFSET(val64)); | ||
323 | break; | ||
324 | default: | 316 | default: |
325 | break; | 317 | break; |
326 | } | 318 | } |
@@ -831,8 +823,6 @@ vxge_hw_device_initialize( | |||
831 | sizeof(struct vxge_hw_device_config)); | 823 | sizeof(struct vxge_hw_device_config)); |
832 | 824 | ||
833 | hldev->bar0 = attr->bar0; | 825 | hldev->bar0 = attr->bar0; |
834 | hldev->bar1 = attr->bar1; | ||
835 | hldev->bar2 = attr->bar2; | ||
836 | hldev->pdev = attr->pdev; | 826 | hldev->pdev = attr->pdev; |
837 | 827 | ||
838 | hldev->uld_callbacks.link_up = attr->uld_callbacks.link_up; | 828 | hldev->uld_callbacks.link_up = attr->uld_callbacks.link_up; |
diff --git a/drivers/net/vxge/vxge-config.h b/drivers/net/vxge/vxge-config.h index afbdf6f4d224..224acea771ed 100644 --- a/drivers/net/vxge/vxge-config.h +++ b/drivers/net/vxge/vxge-config.h | |||
@@ -682,8 +682,6 @@ struct __vxge_hw_vpath_handle{ | |||
682 | * @major_revision: PCI Device major revision | 682 | * @major_revision: PCI Device major revision |
683 | * @minor_revision: PCI Device minor revision | 683 | * @minor_revision: PCI Device minor revision |
684 | * @bar0: BAR0 virtual address. | 684 | * @bar0: BAR0 virtual address. |
685 | * @bar1: BAR1 virtual address. | ||
686 | * @bar2: BAR2 virtual address. | ||
687 | * @pdev: Physical device handle | 685 | * @pdev: Physical device handle |
688 | * @config: Confguration passed by the LL driver at initialization | 686 | * @config: Confguration passed by the LL driver at initialization |
689 | * @link_state: Link state | 687 | * @link_state: Link state |
@@ -698,8 +696,6 @@ struct __vxge_hw_device { | |||
698 | u8 major_revision; | 696 | u8 major_revision; |
699 | u8 minor_revision; | 697 | u8 minor_revision; |
700 | void __iomem *bar0; | 698 | void __iomem *bar0; |
701 | void __iomem *bar1; | ||
702 | void __iomem *bar2; | ||
703 | struct pci_dev *pdev; | 699 | struct pci_dev *pdev; |
704 | struct net_device *ndev; | 700 | struct net_device *ndev; |
705 | struct vxge_hw_device_config config; | 701 | struct vxge_hw_device_config config; |
@@ -788,17 +784,13 @@ struct vxge_hw_device_hw_info { | |||
788 | /** | 784 | /** |
789 | * struct vxge_hw_device_attr - Device memory spaces. | 785 | * struct vxge_hw_device_attr - Device memory spaces. |
790 | * @bar0: BAR0 virtual address. | 786 | * @bar0: BAR0 virtual address. |
791 | * @bar1: BAR1 virtual address. | ||
792 | * @bar2: BAR2 virtual address. | ||
793 | * @pdev: PCI device object. | 787 | * @pdev: PCI device object. |
794 | * | 788 | * |
795 | * Device memory spaces. Includes configuration, BAR0, BAR1, etc. per device | 789 | * Device memory spaces. Includes configuration, BAR0 etc. per device |
796 | * mapped memories. Also, includes a pointer to OS-specific PCI device object. | 790 | * mapped memories. Also, includes a pointer to OS-specific PCI device object. |
797 | */ | 791 | */ |
798 | struct vxge_hw_device_attr { | 792 | struct vxge_hw_device_attr { |
799 | void __iomem *bar0; | 793 | void __iomem *bar0; |
800 | void __iomem *bar1; | ||
801 | void __iomem *bar2; | ||
802 | struct pci_dev *pdev; | 794 | struct pci_dev *pdev; |
803 | struct vxge_hw_uld_cbs uld_callbacks; | 795 | struct vxge_hw_uld_cbs uld_callbacks; |
804 | }; | 796 | }; |
diff --git a/drivers/net/vxge/vxge-main.c b/drivers/net/vxge/vxge-main.c index 6034497536a4..7b5402b50d0a 100644 --- a/drivers/net/vxge/vxge-main.c +++ b/drivers/net/vxge/vxge-main.c | |||
@@ -374,10 +374,10 @@ vxge_rx_complete(struct vxge_ring *ring, struct sk_buff *skb, u16 vlan, | |||
374 | if (ring->vlgrp && ext_info->vlan && | 374 | if (ring->vlgrp && ext_info->vlan && |
375 | (ring->vlan_tag_strip == | 375 | (ring->vlan_tag_strip == |
376 | VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_ENABLE)) | 376 | VXGE_HW_VPATH_RPA_STRIP_VLAN_TAG_ENABLE)) |
377 | vlan_gro_receive(&ring->napi, ring->vlgrp, | 377 | vlan_gro_receive(ring->napi_p, ring->vlgrp, |
378 | ext_info->vlan, skb); | 378 | ext_info->vlan, skb); |
379 | else | 379 | else |
380 | napi_gro_receive(&ring->napi, skb); | 380 | napi_gro_receive(ring->napi_p, skb); |
381 | } else { | 381 | } else { |
382 | if (ring->vlgrp && vlan && | 382 | if (ring->vlgrp && vlan && |
383 | (ring->vlan_tag_strip == | 383 | (ring->vlan_tag_strip == |
@@ -454,6 +454,8 @@ vxge_rx_1b_compl(struct __vxge_hw_ring *ringh, void *dtr, | |||
454 | vxge_hw_ring_rxd_1b_get(ringh, dtr, &dma_sizes); | 454 | vxge_hw_ring_rxd_1b_get(ringh, dtr, &dma_sizes); |
455 | pkt_length = dma_sizes; | 455 | pkt_length = dma_sizes; |
456 | 456 | ||
457 | pkt_length -= ETH_FCS_LEN; | ||
458 | |||
457 | vxge_debug_rx(VXGE_TRACE, | 459 | vxge_debug_rx(VXGE_TRACE, |
458 | "%s: %s:%d Packet Length = %d", | 460 | "%s: %s:%d Packet Length = %d", |
459 | ring->ndev->name, __func__, __LINE__, pkt_length); | 461 | ring->ndev->name, __func__, __LINE__, pkt_length); |
@@ -817,7 +819,6 @@ vxge_xmit(struct sk_buff *skb, struct net_device *dev) | |||
817 | u64 dma_pointer; | 819 | u64 dma_pointer; |
818 | struct vxge_tx_priv *txdl_priv = NULL; | 820 | struct vxge_tx_priv *txdl_priv = NULL; |
819 | struct __vxge_hw_fifo *fifo_hw; | 821 | struct __vxge_hw_fifo *fifo_hw; |
820 | u32 max_mss = 0x0; | ||
821 | int offload_type; | 822 | int offload_type; |
822 | unsigned long flags = 0; | 823 | unsigned long flags = 0; |
823 | int vpath_no = 0; | 824 | int vpath_no = 0; |
@@ -969,10 +970,6 @@ vxge_xmit(struct sk_buff *skb, struct net_device *dev) | |||
969 | 970 | ||
970 | int mss = vxge_tcp_mss(skb); | 971 | int mss = vxge_tcp_mss(skb); |
971 | if (mss) { | 972 | if (mss) { |
972 | max_mss = dev->mtu + ETH_HLEN - | ||
973 | VXGE_HW_TCPIP_HEADER_MAX_SIZE; | ||
974 | if (mss > max_mss) | ||
975 | mss = max_mss; | ||
976 | vxge_debug_tx(VXGE_TRACE, | 973 | vxge_debug_tx(VXGE_TRACE, |
977 | "%s: %s:%d mss = %d", | 974 | "%s: %s:%d mss = %d", |
978 | dev->name, __func__, __LINE__, mss); | 975 | dev->name, __func__, __LINE__, mss); |
@@ -1000,7 +997,7 @@ vxge_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1000 | VXGE_COMPLETE_VPATH_TX(fifo); | 997 | VXGE_COMPLETE_VPATH_TX(fifo); |
1001 | vxge_debug_entryexit(VXGE_TRACE, "%s: %s:%d Exiting...", | 998 | vxge_debug_entryexit(VXGE_TRACE, "%s: %s:%d Exiting...", |
1002 | dev->name, __func__, __LINE__); | 999 | dev->name, __func__, __LINE__); |
1003 | return 0; | 1000 | return NETDEV_TX_OK; |
1004 | 1001 | ||
1005 | _exit0: | 1002 | _exit0: |
1006 | vxge_debug_tx(VXGE_TRACE, "%s: pci_map_page failed", dev->name); | 1003 | vxge_debug_tx(VXGE_TRACE, "%s: pci_map_page failed", dev->name); |
@@ -1024,7 +1021,7 @@ _exit2: | |||
1024 | spin_unlock_irqrestore(&fifo->tx_lock, flags); | 1021 | spin_unlock_irqrestore(&fifo->tx_lock, flags); |
1025 | VXGE_COMPLETE_VPATH_TX(fifo); | 1022 | VXGE_COMPLETE_VPATH_TX(fifo); |
1026 | 1023 | ||
1027 | return 0; | 1024 | return NETDEV_TX_OK; |
1028 | } | 1025 | } |
1029 | 1026 | ||
1030 | /* | 1027 | /* |
@@ -2137,16 +2134,16 @@ int vxge_open_vpaths(struct vxgedev *vdev) | |||
2137 | */ | 2134 | */ |
2138 | static irqreturn_t vxge_isr_napi(int irq, void *dev_id) | 2135 | static irqreturn_t vxge_isr_napi(int irq, void *dev_id) |
2139 | { | 2136 | { |
2140 | struct __vxge_hw_device *hldev = (struct __vxge_hw_device *)dev_id; | ||
2141 | struct vxgedev *vdev; | ||
2142 | struct net_device *dev; | 2137 | struct net_device *dev; |
2138 | struct __vxge_hw_device *hldev; | ||
2143 | u64 reason; | 2139 | u64 reason; |
2144 | enum vxge_hw_status status; | 2140 | enum vxge_hw_status status; |
2141 | struct vxgedev *vdev = (struct vxgedev *) dev_id;; | ||
2145 | 2142 | ||
2146 | vxge_debug_intr(VXGE_TRACE, "%s:%d", __func__, __LINE__); | 2143 | vxge_debug_intr(VXGE_TRACE, "%s:%d", __func__, __LINE__); |
2147 | 2144 | ||
2148 | dev = hldev->ndev; | 2145 | dev = vdev->ndev; |
2149 | vdev = netdev_priv(dev); | 2146 | hldev = (struct __vxge_hw_device *)pci_get_drvdata(vdev->pdev); |
2150 | 2147 | ||
2151 | if (pci_channel_offline(vdev->pdev)) | 2148 | if (pci_channel_offline(vdev->pdev)) |
2152 | return IRQ_NONE; | 2149 | return IRQ_NONE; |
@@ -2417,15 +2414,13 @@ static void vxge_rem_isr(struct vxgedev *vdev) | |||
2417 | #endif | 2414 | #endif |
2418 | if (vdev->config.intr_type == INTA) { | 2415 | if (vdev->config.intr_type == INTA) { |
2419 | synchronize_irq(vdev->pdev->irq); | 2416 | synchronize_irq(vdev->pdev->irq); |
2420 | free_irq(vdev->pdev->irq, hldev); | 2417 | free_irq(vdev->pdev->irq, vdev); |
2421 | } | 2418 | } |
2422 | } | 2419 | } |
2423 | 2420 | ||
2424 | static int vxge_add_isr(struct vxgedev *vdev) | 2421 | static int vxge_add_isr(struct vxgedev *vdev) |
2425 | { | 2422 | { |
2426 | int ret = 0; | 2423 | int ret = 0; |
2427 | struct __vxge_hw_device *hldev = | ||
2428 | (struct __vxge_hw_device *) pci_get_drvdata(vdev->pdev); | ||
2429 | #ifdef CONFIG_PCI_MSI | 2424 | #ifdef CONFIG_PCI_MSI |
2430 | int vp_idx = 0, intr_idx = 0, intr_cnt = 0, msix_idx = 0, irq_req = 0; | 2425 | int vp_idx = 0, intr_idx = 0, intr_cnt = 0, msix_idx = 0, irq_req = 0; |
2431 | u64 function_mode = vdev->config.device_hw_info.function_mode; | 2426 | u64 function_mode = vdev->config.device_hw_info.function_mode; |
@@ -2579,7 +2574,7 @@ INTA_MODE: | |||
2579 | if (vdev->config.intr_type == INTA) { | 2574 | if (vdev->config.intr_type == INTA) { |
2580 | ret = request_irq((int) vdev->pdev->irq, | 2575 | ret = request_irq((int) vdev->pdev->irq, |
2581 | vxge_isr_napi, | 2576 | vxge_isr_napi, |
2582 | IRQF_SHARED, vdev->desc[0], hldev); | 2577 | IRQF_SHARED, vdev->desc[0], vdev); |
2583 | if (ret) { | 2578 | if (ret) { |
2584 | vxge_debug_init(VXGE_ERR, | 2579 | vxge_debug_init(VXGE_ERR, |
2585 | "%s %s-%d: ISR registration failed", | 2580 | "%s %s-%d: ISR registration failed", |
@@ -2712,11 +2707,15 @@ vxge_open(struct net_device *dev) | |||
2712 | netif_napi_add(dev, &vdev->napi, vxge_poll_inta, | 2707 | netif_napi_add(dev, &vdev->napi, vxge_poll_inta, |
2713 | vdev->config.napi_weight); | 2708 | vdev->config.napi_weight); |
2714 | napi_enable(&vdev->napi); | 2709 | napi_enable(&vdev->napi); |
2710 | for (i = 0; i < vdev->no_of_vpath; i++) | ||
2711 | vdev->vpaths[i].ring.napi_p = &vdev->napi; | ||
2715 | } else { | 2712 | } else { |
2716 | for (i = 0; i < vdev->no_of_vpath; i++) { | 2713 | for (i = 0; i < vdev->no_of_vpath; i++) { |
2717 | netif_napi_add(dev, &vdev->vpaths[i].ring.napi, | 2714 | netif_napi_add(dev, &vdev->vpaths[i].ring.napi, |
2718 | vxge_poll_msix, vdev->config.napi_weight); | 2715 | vxge_poll_msix, vdev->config.napi_weight); |
2719 | napi_enable(&vdev->vpaths[i].ring.napi); | 2716 | napi_enable(&vdev->vpaths[i].ring.napi); |
2717 | vdev->vpaths[i].ring.napi_p = | ||
2718 | &vdev->vpaths[i].ring.napi; | ||
2720 | } | 2719 | } |
2721 | } | 2720 | } |
2722 | 2721 | ||
@@ -2890,6 +2889,9 @@ int do_vxge_close(struct net_device *dev, int do_io) | |||
2890 | vdev = (struct vxgedev *)netdev_priv(dev); | 2889 | vdev = (struct vxgedev *)netdev_priv(dev); |
2891 | hldev = (struct __vxge_hw_device *) pci_get_drvdata(vdev->pdev); | 2890 | hldev = (struct __vxge_hw_device *) pci_get_drvdata(vdev->pdev); |
2892 | 2891 | ||
2892 | if (unlikely(!is_vxge_card_up(vdev))) | ||
2893 | return 0; | ||
2894 | |||
2893 | /* If vxge_handle_crit_err task is executing, | 2895 | /* If vxge_handle_crit_err task is executing, |
2894 | * wait till it completes. */ | 2896 | * wait till it completes. */ |
2895 | while (test_and_set_bit(__VXGE_STATE_RESET_CARD, &vdev->state)) | 2897 | while (test_and_set_bit(__VXGE_STATE_RESET_CARD, &vdev->state)) |
@@ -4152,18 +4154,6 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4152 | attr.bar0, | 4154 | attr.bar0, |
4153 | (unsigned long long)pci_resource_start(pdev, 0)); | 4155 | (unsigned long long)pci_resource_start(pdev, 0)); |
4154 | 4156 | ||
4155 | attr.bar1 = pci_ioremap_bar(pdev, 2); | ||
4156 | if (!attr.bar1) { | ||
4157 | vxge_debug_init(VXGE_ERR, | ||
4158 | "%s : cannot remap io memory bar2", __func__); | ||
4159 | ret = -ENODEV; | ||
4160 | goto _exit3; | ||
4161 | } | ||
4162 | vxge_debug_ll_config(VXGE_TRACE, | ||
4163 | "pci ioremap bar1: %p:0x%llx", | ||
4164 | attr.bar1, | ||
4165 | (unsigned long long)pci_resource_start(pdev, 2)); | ||
4166 | |||
4167 | status = vxge_hw_device_hw_info_get(attr.bar0, | 4157 | status = vxge_hw_device_hw_info_get(attr.bar0, |
4168 | &ll_config.device_hw_info); | 4158 | &ll_config.device_hw_info); |
4169 | if (status != VXGE_HW_OK) { | 4159 | if (status != VXGE_HW_OK) { |
@@ -4171,17 +4161,17 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4171 | "%s: Reading of hardware info failed." | 4161 | "%s: Reading of hardware info failed." |
4172 | "Please try upgrading the firmware.", VXGE_DRIVER_NAME); | 4162 | "Please try upgrading the firmware.", VXGE_DRIVER_NAME); |
4173 | ret = -EINVAL; | 4163 | ret = -EINVAL; |
4174 | goto _exit4; | 4164 | goto _exit3; |
4175 | } | 4165 | } |
4176 | 4166 | ||
4177 | if (ll_config.device_hw_info.fw_version.major != | 4167 | if (ll_config.device_hw_info.fw_version.major != |
4178 | VXGE_DRIVER_VERSION_MAJOR) { | 4168 | VXGE_DRIVER_FW_VERSION_MAJOR) { |
4179 | vxge_debug_init(VXGE_ERR, | 4169 | vxge_debug_init(VXGE_ERR, |
4180 | "FW Ver.(maj): %d not driver's expected version: %d", | 4170 | "%s: Incorrect firmware version." |
4181 | ll_config.device_hw_info.fw_version.major, | 4171 | "Please upgrade the firmware to version 1.x.x", |
4182 | VXGE_DRIVER_VERSION_MAJOR); | 4172 | VXGE_DRIVER_NAME); |
4183 | ret = -EINVAL; | 4173 | ret = -EINVAL; |
4184 | goto _exit4; | 4174 | goto _exit3; |
4185 | } | 4175 | } |
4186 | 4176 | ||
4187 | vpath_mask = ll_config.device_hw_info.vpath_mask; | 4177 | vpath_mask = ll_config.device_hw_info.vpath_mask; |
@@ -4189,7 +4179,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4189 | vxge_debug_ll_config(VXGE_TRACE, | 4179 | vxge_debug_ll_config(VXGE_TRACE, |
4190 | "%s: No vpaths available in device", VXGE_DRIVER_NAME); | 4180 | "%s: No vpaths available in device", VXGE_DRIVER_NAME); |
4191 | ret = -EINVAL; | 4181 | ret = -EINVAL; |
4192 | goto _exit4; | 4182 | goto _exit3; |
4193 | } | 4183 | } |
4194 | 4184 | ||
4195 | vxge_debug_ll_config(VXGE_TRACE, | 4185 | vxge_debug_ll_config(VXGE_TRACE, |
@@ -4222,7 +4212,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4222 | vxge_debug_ll_config(VXGE_ERR, | 4212 | vxge_debug_ll_config(VXGE_ERR, |
4223 | "%s: No more vpaths to configure", VXGE_DRIVER_NAME); | 4213 | "%s: No more vpaths to configure", VXGE_DRIVER_NAME); |
4224 | ret = 0; | 4214 | ret = 0; |
4225 | goto _exit4; | 4215 | goto _exit3; |
4226 | } | 4216 | } |
4227 | 4217 | ||
4228 | /* Setting driver callbacks */ | 4218 | /* Setting driver callbacks */ |
@@ -4235,7 +4225,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4235 | vxge_debug_init(VXGE_ERR, | 4225 | vxge_debug_init(VXGE_ERR, |
4236 | "Failed to initialize device (%d)", status); | 4226 | "Failed to initialize device (%d)", status); |
4237 | ret = -EINVAL; | 4227 | ret = -EINVAL; |
4238 | goto _exit4; | 4228 | goto _exit3; |
4239 | } | 4229 | } |
4240 | 4230 | ||
4241 | vxge_hw_device_debug_set(hldev, VXGE_ERR, VXGE_COMPONENT_LL); | 4231 | vxge_hw_device_debug_set(hldev, VXGE_ERR, VXGE_COMPONENT_LL); |
@@ -4260,7 +4250,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4260 | if (vxge_device_register(hldev, &ll_config, high_dma, no_of_vpath, | 4250 | if (vxge_device_register(hldev, &ll_config, high_dma, no_of_vpath, |
4261 | &vdev)) { | 4251 | &vdev)) { |
4262 | ret = -EINVAL; | 4252 | ret = -EINVAL; |
4263 | goto _exit5; | 4253 | goto _exit4; |
4264 | } | 4254 | } |
4265 | 4255 | ||
4266 | vxge_hw_device_debug_set(hldev, VXGE_TRACE, VXGE_COMPONENT_LL); | 4256 | vxge_hw_device_debug_set(hldev, VXGE_TRACE, VXGE_COMPONENT_LL); |
@@ -4271,7 +4261,6 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4271 | hldev->ndev = vdev->ndev; | 4261 | hldev->ndev = vdev->ndev; |
4272 | vdev->mtu = VXGE_HW_DEFAULT_MTU; | 4262 | vdev->mtu = VXGE_HW_DEFAULT_MTU; |
4273 | vdev->bar0 = attr.bar0; | 4263 | vdev->bar0 = attr.bar0; |
4274 | vdev->bar1 = attr.bar1; | ||
4275 | vdev->max_vpath_supported = max_vpath_supported; | 4264 | vdev->max_vpath_supported = max_vpath_supported; |
4276 | vdev->no_of_vpath = no_of_vpath; | 4265 | vdev->no_of_vpath = no_of_vpath; |
4277 | 4266 | ||
@@ -4336,6 +4325,27 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4336 | ll_config.device_hw_info.fw_version.version, | 4325 | ll_config.device_hw_info.fw_version.version, |
4337 | ll_config.device_hw_info.fw_date.date); | 4326 | ll_config.device_hw_info.fw_date.date); |
4338 | 4327 | ||
4328 | if (new_device) { | ||
4329 | switch (ll_config.device_hw_info.function_mode) { | ||
4330 | case VXGE_HW_FUNCTION_MODE_SINGLE_FUNCTION: | ||
4331 | vxge_debug_init(VXGE_TRACE, | ||
4332 | "%s: Single Function Mode Enabled", vdev->ndev->name); | ||
4333 | break; | ||
4334 | case VXGE_HW_FUNCTION_MODE_MULTI_FUNCTION: | ||
4335 | vxge_debug_init(VXGE_TRACE, | ||
4336 | "%s: Multi Function Mode Enabled", vdev->ndev->name); | ||
4337 | break; | ||
4338 | case VXGE_HW_FUNCTION_MODE_SRIOV: | ||
4339 | vxge_debug_init(VXGE_TRACE, | ||
4340 | "%s: Single Root IOV Mode Enabled", vdev->ndev->name); | ||
4341 | break; | ||
4342 | case VXGE_HW_FUNCTION_MODE_MRIOV: | ||
4343 | vxge_debug_init(VXGE_TRACE, | ||
4344 | "%s: Multi Root IOV Mode Enabled", vdev->ndev->name); | ||
4345 | break; | ||
4346 | } | ||
4347 | } | ||
4348 | |||
4339 | vxge_print_parm(vdev, vpath_mask); | 4349 | vxge_print_parm(vdev, vpath_mask); |
4340 | 4350 | ||
4341 | /* Store the fw version for ethttool option */ | 4351 | /* Store the fw version for ethttool option */ |
@@ -4353,7 +4363,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4353 | "%s: mac_addr_list : memory allocation failed", | 4363 | "%s: mac_addr_list : memory allocation failed", |
4354 | vdev->ndev->name); | 4364 | vdev->ndev->name); |
4355 | ret = -EPERM; | 4365 | ret = -EPERM; |
4356 | goto _exit6; | 4366 | goto _exit5; |
4357 | } | 4367 | } |
4358 | macaddr = (u8 *)&entry->macaddr; | 4368 | macaddr = (u8 *)&entry->macaddr; |
4359 | memcpy(macaddr, vdev->ndev->dev_addr, ETH_ALEN); | 4369 | memcpy(macaddr, vdev->ndev->dev_addr, ETH_ALEN); |
@@ -4361,6 +4371,7 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4361 | vdev->vpaths[i].mac_addr_cnt = 1; | 4371 | vdev->vpaths[i].mac_addr_cnt = 1; |
4362 | } | 4372 | } |
4363 | 4373 | ||
4374 | kfree(device_config); | ||
4364 | vxge_debug_entryexit(VXGE_TRACE, "%s: %s:%d Exiting...", | 4375 | vxge_debug_entryexit(VXGE_TRACE, "%s: %s:%d Exiting...", |
4365 | vdev->ndev->name, __func__, __LINE__); | 4376 | vdev->ndev->name, __func__, __LINE__); |
4366 | 4377 | ||
@@ -4370,16 +4381,14 @@ vxge_probe(struct pci_dev *pdev, const struct pci_device_id *pre) | |||
4370 | 4381 | ||
4371 | return 0; | 4382 | return 0; |
4372 | 4383 | ||
4373 | _exit6: | 4384 | _exit5: |
4374 | for (i = 0; i < vdev->no_of_vpath; i++) | 4385 | for (i = 0; i < vdev->no_of_vpath; i++) |
4375 | vxge_free_mac_add_list(&vdev->vpaths[i]); | 4386 | vxge_free_mac_add_list(&vdev->vpaths[i]); |
4376 | 4387 | ||
4377 | vxge_device_unregister(hldev); | 4388 | vxge_device_unregister(hldev); |
4378 | _exit5: | 4389 | _exit4: |
4379 | pci_disable_sriov(pdev); | 4390 | pci_disable_sriov(pdev); |
4380 | vxge_hw_device_terminate(hldev); | 4391 | vxge_hw_device_terminate(hldev); |
4381 | _exit4: | ||
4382 | iounmap(attr.bar1); | ||
4383 | _exit3: | 4392 | _exit3: |
4384 | iounmap(attr.bar0); | 4393 | iounmap(attr.bar0); |
4385 | _exit2: | 4394 | _exit2: |
@@ -4438,7 +4447,6 @@ vxge_remove(struct pci_dev *pdev) | |||
4438 | kfree(vdev->vpaths); | 4447 | kfree(vdev->vpaths); |
4439 | 4448 | ||
4440 | iounmap(vdev->bar0); | 4449 | iounmap(vdev->bar0); |
4441 | iounmap(vdev->bar1); | ||
4442 | 4450 | ||
4443 | pci_disable_sriov(pdev); | 4451 | pci_disable_sriov(pdev); |
4444 | 4452 | ||
diff --git a/drivers/net/vxge/vxge-main.h b/drivers/net/vxge/vxge-main.h index 9704b2bd4320..18d824c3ab93 100644 --- a/drivers/net/vxge/vxge-main.h +++ b/drivers/net/vxge/vxge-main.h | |||
@@ -21,7 +21,7 @@ | |||
21 | 21 | ||
22 | #define VXGE_DRIVER_NAME "vxge" | 22 | #define VXGE_DRIVER_NAME "vxge" |
23 | #define VXGE_DRIVER_VENDOR "Neterion, Inc" | 23 | #define VXGE_DRIVER_VENDOR "Neterion, Inc" |
24 | #define VXGE_DRIVER_VERSION_MAJOR 0 | 24 | #define VXGE_DRIVER_FW_VERSION_MAJOR 1 |
25 | 25 | ||
26 | #define DRV_VERSION VXGE_VERSION_MAJOR"."VXGE_VERSION_MINOR"."\ | 26 | #define DRV_VERSION VXGE_VERSION_MAJOR"."VXGE_VERSION_MINOR"."\ |
27 | VXGE_VERSION_FIX"."VXGE_VERSION_BUILD"-"\ | 27 | VXGE_VERSION_FIX"."VXGE_VERSION_BUILD"-"\ |
@@ -260,6 +260,7 @@ struct vxge_ring { | |||
260 | int gro_enable; | 260 | int gro_enable; |
261 | 261 | ||
262 | struct napi_struct napi; | 262 | struct napi_struct napi; |
263 | struct napi_struct *napi_p; | ||
263 | 264 | ||
264 | #define VXGE_MAX_MAC_ADDR_COUNT 30 | 265 | #define VXGE_MAX_MAC_ADDR_COUNT 30 |
265 | 266 | ||
@@ -363,7 +364,6 @@ struct vxgedev { | |||
363 | 364 | ||
364 | struct __vxge_hw_vpath_handle *vp_handles[VXGE_HW_MAX_VIRTUAL_PATHS]; | 365 | struct __vxge_hw_vpath_handle *vp_handles[VXGE_HW_MAX_VIRTUAL_PATHS]; |
365 | void __iomem *bar0; | 366 | void __iomem *bar0; |
366 | void __iomem *bar1; | ||
367 | struct vxge_sw_stats stats; | 367 | struct vxge_sw_stats stats; |
368 | int mtu; | 368 | int mtu; |
369 | /* Below variables are used for vpath selection to transmit a packet */ | 369 | /* Below variables are used for vpath selection to transmit a packet */ |
diff --git a/drivers/net/vxge/vxge-reg.h b/drivers/net/vxge/vxge-reg.h index 10f4da32929f..9a3b823e08d4 100644 --- a/drivers/net/vxge/vxge-reg.h +++ b/drivers/net/vxge/vxge-reg.h | |||
@@ -1784,7 +1784,7 @@ struct vxge_hw_mrpcim_reg { | |||
1784 | #define VXGE_HW_XMAC_GEN_ERR_REG_XMACJ_XMAC_FSM_ERR vxge_mBIT(63) | 1784 | #define VXGE_HW_XMAC_GEN_ERR_REG_XMACJ_XMAC_FSM_ERR vxge_mBIT(63) |
1785 | /*0x01e18*/ u64 xmac_gen_err_mask; | 1785 | /*0x01e18*/ u64 xmac_gen_err_mask; |
1786 | /*0x01e20*/ u64 xmac_gen_err_alarm; | 1786 | /*0x01e20*/ u64 xmac_gen_err_alarm; |
1787 | /*0x01e28*/ u64 xmac_link_err_port_reg[2]; | 1787 | /*0x01e28*/ u64 xmac_link_err_port0_reg; |
1788 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_XMACJ_PORT_DOWN vxge_mBIT(3) | 1788 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_XMACJ_PORT_DOWN vxge_mBIT(3) |
1789 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_XMACJ_PORT_UP vxge_mBIT(7) | 1789 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_XMACJ_PORT_UP vxge_mBIT(7) |
1790 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_XMACJ_PORT_WENT_DOWN vxge_mBIT(11) | 1790 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_XMACJ_PORT_WENT_DOWN vxge_mBIT(11) |
@@ -1798,8 +1798,11 @@ struct vxge_hw_mrpcim_reg { | |||
1798 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_RATEMGMT_LASI_INV vxge_mBIT(39) | 1798 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_RATEMGMT_LASI_INV vxge_mBIT(39) |
1799 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_XMDIO_MDIO_MGR_ACCESS_COMPLETE \ | 1799 | #define VXGE_HW_XMAC_LINK_ERR_PORT_REG_XMDIO_MDIO_MGR_ACCESS_COMPLETE \ |
1800 | vxge_mBIT(47) | 1800 | vxge_mBIT(47) |
1801 | /*0x01e30*/ u64 xmac_link_err_port_mask[2]; | 1801 | /*0x01e30*/ u64 xmac_link_err_port0_mask; |
1802 | /*0x01e38*/ u64 xmac_link_err_port_alarm[2]; | 1802 | /*0x01e38*/ u64 xmac_link_err_port0_alarm; |
1803 | /*0x01e40*/ u64 xmac_link_err_port1_reg; | ||
1804 | /*0x01e48*/ u64 xmac_link_err_port1_mask; | ||
1805 | /*0x01e50*/ u64 xmac_link_err_port1_alarm; | ||
1803 | /*0x01e58*/ u64 xgxs_gen_err_reg; | 1806 | /*0x01e58*/ u64 xgxs_gen_err_reg; |
1804 | #define VXGE_HW_XGXS_GEN_ERR_REG_XGXS_XGXS_FSM_ERR vxge_mBIT(63) | 1807 | #define VXGE_HW_XGXS_GEN_ERR_REG_XGXS_XGXS_FSM_ERR vxge_mBIT(63) |
1805 | /*0x01e60*/ u64 xgxs_gen_err_mask; | 1808 | /*0x01e60*/ u64 xgxs_gen_err_mask; |
diff --git a/drivers/net/vxge/vxge-traffic.h b/drivers/net/vxge/vxge-traffic.h index 7567a1140d07..8260b91fd795 100644 --- a/drivers/net/vxge/vxge-traffic.h +++ b/drivers/net/vxge/vxge-traffic.h | |||
@@ -35,8 +35,6 @@ | |||
35 | VXGE_HW_HEADER_VLAN_SIZE + \ | 35 | VXGE_HW_HEADER_VLAN_SIZE + \ |
36 | VXGE_HW_HEADER_SNAP_SIZE) | 36 | VXGE_HW_HEADER_SNAP_SIZE) |
37 | 37 | ||
38 | #define VXGE_HW_TCPIP_HEADER_MAX_SIZE (64 + 64) | ||
39 | |||
40 | /* 32bit alignments */ | 38 | /* 32bit alignments */ |
41 | #define VXGE_HW_HEADER_ETHERNET_II_802_3_ALIGN 2 | 39 | #define VXGE_HW_HEADER_ETHERNET_II_802_3_ALIGN 2 |
42 | #define VXGE_HW_HEADER_802_2_SNAP_ALIGN 2 | 40 | #define VXGE_HW_HEADER_802_2_SNAP_ALIGN 2 |
diff --git a/drivers/net/vxge/vxge-version.h b/drivers/net/vxge/vxge-version.h index 82786ffb7dd9..580c6eb077b9 100644 --- a/drivers/net/vxge/vxge-version.h +++ b/drivers/net/vxge/vxge-version.h | |||
@@ -18,6 +18,6 @@ | |||
18 | #define VXGE_VERSION_MAJOR "2" | 18 | #define VXGE_VERSION_MAJOR "2" |
19 | #define VXGE_VERSION_MINOR "0" | 19 | #define VXGE_VERSION_MINOR "0" |
20 | #define VXGE_VERSION_FIX "4" | 20 | #define VXGE_VERSION_FIX "4" |
21 | #define VXGE_VERSION_BUILD "17795" | 21 | #define VXGE_VERSION_BUILD "17899" |
22 | #define VXGE_VERSION_FOR "k" | 22 | #define VXGE_VERSION_FOR "k" |
23 | #endif | 23 | #endif |
diff --git a/drivers/net/wan/cycx_x25.c b/drivers/net/wan/cycx_x25.c index f525f9fe74db..4ae9bd297cc2 100644 --- a/drivers/net/wan/cycx_x25.c +++ b/drivers/net/wan/cycx_x25.c | |||
@@ -663,7 +663,7 @@ static int cycx_netdevice_hard_start_xmit(struct sk_buff *skb, | |||
663 | free_packet: | 663 | free_packet: |
664 | dev_kfree_skb(skb); | 664 | dev_kfree_skb(skb); |
665 | 665 | ||
666 | return 0; | 666 | return NETDEV_TX_OK; |
667 | } | 667 | } |
668 | 668 | ||
669 | /* Get Ethernet-style interface statistics. | 669 | /* Get Ethernet-style interface statistics. |
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c index 2fa275a58f9d..8526b6d1ee4d 100644 --- a/drivers/net/wan/dlci.c +++ b/drivers/net/wan/dlci.c | |||
@@ -194,7 +194,7 @@ static int dlci_transmit(struct sk_buff *skb, struct net_device *dev) | |||
194 | ret = 0; | 194 | ret = 0; |
195 | 195 | ||
196 | if (!skb || !dev) | 196 | if (!skb || !dev) |
197 | return(0); | 197 | return NETDEV_TX_OK; |
198 | 198 | ||
199 | dlp = netdev_priv(dev); | 199 | dlp = netdev_priv(dev); |
200 | 200 | ||
@@ -219,7 +219,7 @@ static int dlci_transmit(struct sk_buff *skb, struct net_device *dev) | |||
219 | /* Alan Cox recommends always returning 0, and always freeing the packet */ | 219 | /* Alan Cox recommends always returning 0, and always freeing the packet */ |
220 | /* experience suggest a slightly more conservative approach */ | 220 | /* experience suggest a slightly more conservative approach */ |
221 | 221 | ||
222 | if (!ret) | 222 | if (ret == NETDEV_TX_OK) |
223 | { | 223 | { |
224 | dev_kfree_skb(skb); | 224 | dev_kfree_skb(skb); |
225 | netif_wake_queue(dev); | 225 | netif_wake_queue(dev); |
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c index 8face5db8f32..e81946d98543 100644 --- a/drivers/net/wan/dscc4.c +++ b/drivers/net/wan/dscc4.c | |||
@@ -1182,7 +1182,7 @@ static int dscc4_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1182 | if (dscc4_tx_quiescent(dpriv, dev)) | 1182 | if (dscc4_tx_quiescent(dpriv, dev)) |
1183 | dscc4_do_tx(dpriv, dev); | 1183 | dscc4_do_tx(dpriv, dev); |
1184 | 1184 | ||
1185 | return 0; | 1185 | return NETDEV_TX_OK; |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | static int dscc4_close(struct net_device *dev) | 1188 | static int dscc4_close(struct net_device *dev) |
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c index 25c9ef6a1815..20a1237a3d74 100644 --- a/drivers/net/wan/farsync.c +++ b/drivers/net/wan/farsync.c | |||
@@ -792,25 +792,6 @@ fst_process_rx_status(int rx_status, char *name) | |||
792 | */ | 792 | */ |
793 | break; | 793 | break; |
794 | } | 794 | } |
795 | |||
796 | case NET_RX_CN_LOW: | ||
797 | { | ||
798 | dbg(DBG_ASS, "%s: Receive Low Congestion\n", name); | ||
799 | break; | ||
800 | } | ||
801 | |||
802 | case NET_RX_CN_MOD: | ||
803 | { | ||
804 | dbg(DBG_ASS, "%s: Receive Moderate Congestion\n", name); | ||
805 | break; | ||
806 | } | ||
807 | |||
808 | case NET_RX_CN_HIGH: | ||
809 | { | ||
810 | dbg(DBG_ASS, "%s: Receive High Congestion\n", name); | ||
811 | break; | ||
812 | } | ||
813 | |||
814 | case NET_RX_DROP: | 795 | case NET_RX_DROP: |
815 | { | 796 | { |
816 | dbg(DBG_ASS, "%s: Received packet dropped\n", name); | 797 | dbg(DBG_ASS, "%s: Received packet dropped\n", name); |
@@ -2313,7 +2294,7 @@ fst_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2313 | dbg(DBG_ASS, | 2294 | dbg(DBG_ASS, |
2314 | "Tried to transmit but no carrier on card %d port %d\n", | 2295 | "Tried to transmit but no carrier on card %d port %d\n", |
2315 | card->card_no, port->index); | 2296 | card->card_no, port->index); |
2316 | return 0; | 2297 | return NETDEV_TX_OK; |
2317 | } | 2298 | } |
2318 | 2299 | ||
2319 | /* Drop it if it's too big! MTU failure ? */ | 2300 | /* Drop it if it's too big! MTU failure ? */ |
@@ -2322,7 +2303,7 @@ fst_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2322 | LEN_TX_BUFFER); | 2303 | LEN_TX_BUFFER); |
2323 | dev_kfree_skb(skb); | 2304 | dev_kfree_skb(skb); |
2324 | dev->stats.tx_errors++; | 2305 | dev->stats.tx_errors++; |
2325 | return 0; | 2306 | return NETDEV_TX_OK; |
2326 | } | 2307 | } |
2327 | 2308 | ||
2328 | /* | 2309 | /* |
@@ -2356,7 +2337,7 @@ fst_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2356 | dev->stats.tx_errors++; | 2337 | dev->stats.tx_errors++; |
2357 | dbg(DBG_ASS, "Tx queue overflow card %d port %d\n", | 2338 | dbg(DBG_ASS, "Tx queue overflow card %d port %d\n", |
2358 | card->card_no, port->index); | 2339 | card->card_no, port->index); |
2359 | return 0; | 2340 | return NETDEV_TX_OK; |
2360 | } | 2341 | } |
2361 | 2342 | ||
2362 | /* | 2343 | /* |
@@ -2373,7 +2354,7 @@ fst_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
2373 | fst_q_work_item(&fst_work_txq, card->card_no); | 2354 | fst_q_work_item(&fst_work_txq, card->card_no); |
2374 | tasklet_schedule(&fst_tx_task); | 2355 | tasklet_schedule(&fst_tx_task); |
2375 | 2356 | ||
2376 | return 0; | 2357 | return NETDEV_TX_OK; |
2377 | } | 2358 | } |
2378 | 2359 | ||
2379 | /* | 2360 | /* |
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c index bfa0161a02d3..52438c76bf8a 100644 --- a/drivers/net/wan/hdlc_fr.c +++ b/drivers/net/wan/hdlc_fr.c | |||
@@ -421,7 +421,7 @@ static int pvc_xmit(struct sk_buff *skb, struct net_device *dev) | |||
421 | GFP_ATOMIC)) { | 421 | GFP_ATOMIC)) { |
422 | dev->stats.tx_dropped++; | 422 | dev->stats.tx_dropped++; |
423 | dev_kfree_skb(skb); | 423 | dev_kfree_skb(skb); |
424 | return 0; | 424 | return NETDEV_TX_OK; |
425 | } | 425 | } |
426 | skb_put(skb, pad); | 426 | skb_put(skb, pad); |
427 | memset(skb->data + len, 0, pad); | 427 | memset(skb->data + len, 0, pad); |
@@ -435,13 +435,13 @@ static int pvc_xmit(struct sk_buff *skb, struct net_device *dev) | |||
435 | dev->stats.tx_compressed++; | 435 | dev->stats.tx_compressed++; |
436 | skb->dev = pvc->frad; | 436 | skb->dev = pvc->frad; |
437 | dev_queue_xmit(skb); | 437 | dev_queue_xmit(skb); |
438 | return 0; | 438 | return NETDEV_TX_OK; |
439 | } | 439 | } |
440 | } | 440 | } |
441 | 441 | ||
442 | dev->stats.tx_dropped++; | 442 | dev->stats.tx_dropped++; |
443 | dev_kfree_skb(skb); | 443 | dev_kfree_skb(skb); |
444 | return 0; | 444 | return NETDEV_TX_OK; |
445 | } | 445 | } |
446 | 446 | ||
447 | static inline void fr_log_dlci_active(pvc_device *pvc) | 447 | static inline void fr_log_dlci_active(pvc_device *pvc) |
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c index 45b1822c962d..d1492ae5d30a 100644 --- a/drivers/net/wan/lmc/lmc_main.c +++ b/drivers/net/wan/lmc/lmc_main.c | |||
@@ -1428,7 +1428,7 @@ static int lmc_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1428 | lmc_softc_t *sc = dev_to_sc(dev); | 1428 | lmc_softc_t *sc = dev_to_sc(dev); |
1429 | u32 flag; | 1429 | u32 flag; |
1430 | int entry; | 1430 | int entry; |
1431 | int ret = 0; | 1431 | int ret = NETDEV_TX_OK; |
1432 | unsigned long flags; | 1432 | unsigned long flags; |
1433 | 1433 | ||
1434 | lmc_trace(dev, "lmc_start_xmit in"); | 1434 | lmc_trace(dev, "lmc_start_xmit in"); |
diff --git a/drivers/net/wan/sbni.c b/drivers/net/wan/sbni.c index 3fb9dbc88a1a..545178e6765d 100644 --- a/drivers/net/wan/sbni.c +++ b/drivers/net/wan/sbni.c | |||
@@ -465,7 +465,7 @@ sbni_start_xmit( struct sk_buff *skb, struct net_device *dev ) | |||
465 | prepare_to_send( skb, p ); | 465 | prepare_to_send( skb, p ); |
466 | spin_unlock( &nl->lock ); | 466 | spin_unlock( &nl->lock ); |
467 | netif_start_queue( dev ); | 467 | netif_start_queue( dev ); |
468 | return 0; | 468 | return NETDEV_TX_OK; |
469 | } | 469 | } |
470 | } | 470 | } |
471 | 471 | ||
@@ -485,7 +485,7 @@ sbni_start_xmit( struct sk_buff *skb, struct net_device *dev ) | |||
485 | prepare_to_send( skb, dev ); | 485 | prepare_to_send( skb, dev ); |
486 | 486 | ||
487 | spin_unlock( &nl->lock ); | 487 | spin_unlock( &nl->lock ); |
488 | return 0; | 488 | return NETDEV_TX_OK; |
489 | } | 489 | } |
490 | 490 | ||
491 | #endif /* CONFIG_SBNI_MULTILINE */ | 491 | #endif /* CONFIG_SBNI_MULTILINE */ |
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c index e4ad7b6b52eb..03b76adbe5f0 100644 --- a/drivers/net/wan/wanxl.c +++ b/drivers/net/wan/wanxl.c | |||
@@ -310,7 +310,7 @@ static int wanxl_xmit(struct sk_buff *skb, struct net_device *dev) | |||
310 | } | 310 | } |
311 | 311 | ||
312 | spin_unlock(&port->lock); | 312 | spin_unlock(&port->lock); |
313 | return 0; | 313 | return NETDEV_TX_OK; |
314 | } | 314 | } |
315 | 315 | ||
316 | 316 | ||
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c index d67e208ab375..1047920e742c 100644 --- a/drivers/net/wan/x25_asy.c +++ b/drivers/net/wan/x25_asy.c | |||
@@ -308,7 +308,7 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) | |||
308 | printk(KERN_ERR "%s: xmit call when iface is down\n", | 308 | printk(KERN_ERR "%s: xmit call when iface is down\n", |
309 | dev->name); | 309 | dev->name); |
310 | kfree_skb(skb); | 310 | kfree_skb(skb); |
311 | return 0; | 311 | return NETDEV_TX_OK; |
312 | } | 312 | } |
313 | 313 | ||
314 | switch (skb->data[0]) { | 314 | switch (skb->data[0]) { |
@@ -319,14 +319,14 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) | |||
319 | if (err != LAPB_OK) | 319 | if (err != LAPB_OK) |
320 | printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err); | 320 | printk(KERN_ERR "x25_asy: lapb_connect_request error - %d\n", err); |
321 | kfree_skb(skb); | 321 | kfree_skb(skb); |
322 | return 0; | 322 | return NETDEV_TX_OK; |
323 | case 0x02: /* Disconnect request .. do nothing - hang up ?? */ | 323 | case 0x02: /* Disconnect request .. do nothing - hang up ?? */ |
324 | err = lapb_disconnect_request(dev); | 324 | err = lapb_disconnect_request(dev); |
325 | if (err != LAPB_OK) | 325 | if (err != LAPB_OK) |
326 | printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err); | 326 | printk(KERN_ERR "x25_asy: lapb_disconnect_request error - %d\n", err); |
327 | default: | 327 | default: |
328 | kfree_skb(skb); | 328 | kfree_skb(skb); |
329 | return 0; | 329 | return NETDEV_TX_OK; |
330 | } | 330 | } |
331 | skb_pull(skb, 1); /* Remove control byte */ | 331 | skb_pull(skb, 1); /* Remove control byte */ |
332 | /* | 332 | /* |
@@ -344,9 +344,9 @@ static int x25_asy_xmit(struct sk_buff *skb, struct net_device *dev) | |||
344 | if (err != LAPB_OK) { | 344 | if (err != LAPB_OK) { |
345 | printk(KERN_ERR "x25_asy: lapb_data_request error - %d\n", err); | 345 | printk(KERN_ERR "x25_asy: lapb_data_request error - %d\n", err); |
346 | kfree_skb(skb); | 346 | kfree_skb(skb); |
347 | return 0; | 347 | return NETDEV_TX_OK; |
348 | } | 348 | } |
349 | return 0; | 349 | return NETDEV_TX_OK; |
350 | } | 350 | } |
351 | 351 | ||
352 | 352 | ||
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c index 2b9e379994a1..ecc93834533f 100644 --- a/drivers/net/wireless/adm8211.c +++ b/drivers/net/wireless/adm8211.c | |||
@@ -452,7 +452,8 @@ static void adm8211_interrupt_rci(struct ieee80211_hw *dev) | |||
452 | rx_status.freq = adm8211_channels[priv->channel - 1].center_freq; | 452 | rx_status.freq = adm8211_channels[priv->channel - 1].center_freq; |
453 | rx_status.band = IEEE80211_BAND_2GHZ; | 453 | rx_status.band = IEEE80211_BAND_2GHZ; |
454 | 454 | ||
455 | ieee80211_rx_irqsafe(dev, skb, &rx_status); | 455 | memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); |
456 | ieee80211_rx_irqsafe(dev, skb); | ||
456 | } | 457 | } |
457 | 458 | ||
458 | entry = (++priv->cur_rx) % priv->rx_ring_size; | 459 | entry = (++priv->cur_rx) % priv->rx_ring_size; |
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c index c70604f0329e..49f3139a3fe7 100644 --- a/drivers/net/wireless/airo.c +++ b/drivers/net/wireless/airo.c | |||
@@ -1927,7 +1927,7 @@ static int mpi_start_xmit(struct sk_buff *skb, struct net_device *dev) { | |||
1927 | 1927 | ||
1928 | if (!skb) { | 1928 | if (!skb) { |
1929 | airo_print_err(dev->name, "%s: skb == NULL!",__func__); | 1929 | airo_print_err(dev->name, "%s: skb == NULL!",__func__); |
1930 | return 0; | 1930 | return NETDEV_TX_OK; |
1931 | } | 1931 | } |
1932 | npacks = skb_queue_len (&ai->txq); | 1932 | npacks = skb_queue_len (&ai->txq); |
1933 | 1933 | ||
@@ -1938,7 +1938,7 @@ static int mpi_start_xmit(struct sk_buff *skb, struct net_device *dev) { | |||
1938 | return NETDEV_TX_BUSY; | 1938 | return NETDEV_TX_BUSY; |
1939 | } | 1939 | } |
1940 | skb_queue_tail (&ai->txq, skb); | 1940 | skb_queue_tail (&ai->txq, skb); |
1941 | return 0; | 1941 | return NETDEV_TX_OK; |
1942 | } | 1942 | } |
1943 | 1943 | ||
1944 | spin_lock_irqsave(&ai->aux_lock, flags); | 1944 | spin_lock_irqsave(&ai->aux_lock, flags); |
@@ -1951,7 +1951,7 @@ static int mpi_start_xmit(struct sk_buff *skb, struct net_device *dev) { | |||
1951 | set_bit(FLAG_PENDING_XMIT, &ai->flags); | 1951 | set_bit(FLAG_PENDING_XMIT, &ai->flags); |
1952 | mpi_send_packet (dev); | 1952 | mpi_send_packet (dev); |
1953 | } | 1953 | } |
1954 | return 0; | 1954 | return NETDEV_TX_OK; |
1955 | } | 1955 | } |
1956 | 1956 | ||
1957 | /* | 1957 | /* |
@@ -2127,7 +2127,7 @@ static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) { | |||
2127 | 2127 | ||
2128 | if ( skb == NULL ) { | 2128 | if ( skb == NULL ) { |
2129 | airo_print_err(dev->name, "%s: skb == NULL!", __func__); | 2129 | airo_print_err(dev->name, "%s: skb == NULL!", __func__); |
2130 | return 0; | 2130 | return NETDEV_TX_OK; |
2131 | } | 2131 | } |
2132 | 2132 | ||
2133 | /* Find a vacant FID */ | 2133 | /* Find a vacant FID */ |
@@ -2155,7 +2155,7 @@ static int airo_start_xmit(struct sk_buff *skb, struct net_device *dev) { | |||
2155 | wake_up_interruptible(&priv->thr_wait); | 2155 | wake_up_interruptible(&priv->thr_wait); |
2156 | } else | 2156 | } else |
2157 | airo_end_xmit(dev); | 2157 | airo_end_xmit(dev); |
2158 | return 0; | 2158 | return NETDEV_TX_OK; |
2159 | } | 2159 | } |
2160 | 2160 | ||
2161 | static void airo_end_xmit11(struct net_device *dev) { | 2161 | static void airo_end_xmit11(struct net_device *dev) { |
@@ -2199,7 +2199,7 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) { | |||
2199 | 2199 | ||
2200 | if ( skb == NULL ) { | 2200 | if ( skb == NULL ) { |
2201 | airo_print_err(dev->name, "%s: skb == NULL!", __func__); | 2201 | airo_print_err(dev->name, "%s: skb == NULL!", __func__); |
2202 | return 0; | 2202 | return NETDEV_TX_OK; |
2203 | } | 2203 | } |
2204 | 2204 | ||
2205 | /* Find a vacant FID */ | 2205 | /* Find a vacant FID */ |
@@ -2227,7 +2227,7 @@ static int airo_start_xmit11(struct sk_buff *skb, struct net_device *dev) { | |||
2227 | wake_up_interruptible(&priv->thr_wait); | 2227 | wake_up_interruptible(&priv->thr_wait); |
2228 | } else | 2228 | } else |
2229 | airo_end_xmit11(dev); | 2229 | airo_end_xmit11(dev); |
2230 | return 0; | 2230 | return NETDEV_TX_OK; |
2231 | } | 2231 | } |
2232 | 2232 | ||
2233 | static void airo_read_stats(struct net_device *dev) | 2233 | static void airo_read_stats(struct net_device *dev) |
diff --git a/drivers/net/wireless/arlan-main.c b/drivers/net/wireless/arlan-main.c index d84caf198a23..d479f4735aaa 100644 --- a/drivers/net/wireless/arlan-main.c +++ b/drivers/net/wireless/arlan-main.c | |||
@@ -1193,7 +1193,7 @@ static int arlan_tx(struct sk_buff *skb, struct net_device *dev) | |||
1193 | 1193 | ||
1194 | arlan_process_interrupt(dev); | 1194 | arlan_process_interrupt(dev); |
1195 | ARLAN_DEBUG_EXIT("arlan_tx"); | 1195 | ARLAN_DEBUG_EXIT("arlan_tx"); |
1196 | return 0; | 1196 | return NETDEV_TX_OK; |
1197 | 1197 | ||
1198 | bad_end: | 1198 | bad_end: |
1199 | arlan_process_interrupt(dev); | 1199 | arlan_process_interrupt(dev); |
diff --git a/drivers/net/wireless/at76c50x-usb.c b/drivers/net/wireless/at76c50x-usb.c index 4efbdbe6d6bf..13303fa34734 100644 --- a/drivers/net/wireless/at76c50x-usb.c +++ b/drivers/net/wireless/at76c50x-usb.c | |||
@@ -1568,7 +1568,8 @@ static void at76_rx_tasklet(unsigned long param) | |||
1568 | 1568 | ||
1569 | at76_dbg(DBG_MAC80211, "calling ieee80211_rx_irqsafe(): %d/%d", | 1569 | at76_dbg(DBG_MAC80211, "calling ieee80211_rx_irqsafe(): %d/%d", |
1570 | priv->rx_skb->len, priv->rx_skb->data_len); | 1570 | priv->rx_skb->len, priv->rx_skb->data_len); |
1571 | ieee80211_rx_irqsafe(priv->hw, priv->rx_skb, &rx_status); | 1571 | memcpy(IEEE80211_SKB_RXCB(priv->rx_skb), &rx_status, sizeof(rx_status)); |
1572 | ieee80211_rx_irqsafe(priv->hw, priv->rx_skb); | ||
1572 | 1573 | ||
1573 | /* Use a new skb for the next receive */ | 1574 | /* Use a new skb for the next receive */ |
1574 | priv->rx_skb = NULL; | 1575 | priv->rx_skb = NULL; |
diff --git a/drivers/net/wireless/ath/ar9170/main.c b/drivers/net/wireless/ath/ar9170/main.c index 9d38cf60a0db..51753ed1b8ba 100644 --- a/drivers/net/wireless/ath/ar9170/main.c +++ b/drivers/net/wireless/ath/ar9170/main.c | |||
@@ -917,8 +917,10 @@ static void ar9170_handle_mpdu(struct ar9170 *ar, u8 *buf, int len) | |||
917 | ar9170_rx_phy_status(ar, phy, &status); | 917 | ar9170_rx_phy_status(ar, phy, &status); |
918 | 918 | ||
919 | skb = ar9170_rx_copy_data(buf, mpdu_len); | 919 | skb = ar9170_rx_copy_data(buf, mpdu_len); |
920 | if (likely(skb)) | 920 | if (likely(skb)) { |
921 | ieee80211_rx_irqsafe(ar->hw, skb, &status); | 921 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); |
922 | ieee80211_rx_irqsafe(ar->hw, skb); | ||
923 | } | ||
922 | } | 924 | } |
923 | 925 | ||
924 | void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb) | 926 | void ar9170_rx(struct ar9170 *ar, struct sk_buff *skb) |
diff --git a/drivers/net/wireless/ath/ar9170/usb.c b/drivers/net/wireless/ath/ar9170/usb.c index 754b1f8d8da9..1aec7afdffa7 100644 --- a/drivers/net/wireless/ath/ar9170/usb.c +++ b/drivers/net/wireless/ath/ar9170/usb.c | |||
@@ -779,7 +779,7 @@ static int ar9170_usb_probe(struct usb_interface *intf, | |||
779 | aru->req_one_stage_fw = ar9170_requires_one_stage(id); | 779 | aru->req_one_stage_fw = ar9170_requires_one_stage(id); |
780 | 780 | ||
781 | usb_set_intfdata(intf, aru); | 781 | usb_set_intfdata(intf, aru); |
782 | SET_IEEE80211_DEV(ar->hw, &udev->dev); | 782 | SET_IEEE80211_DEV(ar->hw, &intf->dev); |
783 | 783 | ||
784 | init_usb_anchor(&aru->rx_submitted); | 784 | init_usb_anchor(&aru->rx_submitted); |
785 | init_usb_anchor(&aru->tx_pending); | 785 | init_usb_anchor(&aru->tx_pending); |
diff --git a/drivers/net/wireless/ath/ath5k/ath5k.h b/drivers/net/wireless/ath/ath5k/ath5k.h index 6358233bac99..91375113916b 100644 --- a/drivers/net/wireless/ath/ath5k/ath5k.h +++ b/drivers/net/wireless/ath/ath5k/ath5k.h | |||
@@ -713,8 +713,8 @@ struct ath5k_gain { | |||
713 | * Used internaly for reset_tx_queue). | 713 | * Used internaly for reset_tx_queue). |
714 | * Also see struct struct ieee80211_channel. | 714 | * Also see struct struct ieee80211_channel. |
715 | */ | 715 | */ |
716 | #define IS_CHAN_XR(_c) ((_c.hw_value & CHANNEL_XR) != 0) | 716 | #define IS_CHAN_XR(_c) ((_c->hw_value & CHANNEL_XR) != 0) |
717 | #define IS_CHAN_B(_c) ((_c.hw_value & CHANNEL_B) != 0) | 717 | #define IS_CHAN_B(_c) ((_c->hw_value & CHANNEL_B) != 0) |
718 | 718 | ||
719 | /* | 719 | /* |
720 | * The following structure is used to map 2GHz channels to | 720 | * The following structure is used to map 2GHz channels to |
@@ -1029,14 +1029,15 @@ struct ath5k_hw { | |||
1029 | enum ath5k_int ah_imr; | 1029 | enum ath5k_int ah_imr; |
1030 | 1030 | ||
1031 | enum nl80211_iftype ah_op_mode; | 1031 | enum nl80211_iftype ah_op_mode; |
1032 | enum ath5k_power_mode ah_power_mode; | 1032 | struct ieee80211_channel *ah_current_channel; |
1033 | struct ieee80211_channel ah_current_channel; | ||
1034 | bool ah_turbo; | 1033 | bool ah_turbo; |
1035 | bool ah_calibration; | 1034 | bool ah_calibration; |
1036 | bool ah_running; | ||
1037 | bool ah_single_chip; | 1035 | bool ah_single_chip; |
1038 | bool ah_combined_mic; | 1036 | bool ah_combined_mic; |
1039 | 1037 | ||
1038 | enum ath5k_version ah_version; | ||
1039 | enum ath5k_radio ah_radio; | ||
1040 | u32 ah_phy; | ||
1040 | u32 ah_mac_srev; | 1041 | u32 ah_mac_srev; |
1041 | u16 ah_mac_version; | 1042 | u16 ah_mac_version; |
1042 | u16 ah_mac_revision; | 1043 | u16 ah_mac_revision; |
@@ -1044,13 +1045,6 @@ struct ath5k_hw { | |||
1044 | u16 ah_radio_5ghz_revision; | 1045 | u16 ah_radio_5ghz_revision; |
1045 | u16 ah_radio_2ghz_revision; | 1046 | u16 ah_radio_2ghz_revision; |
1046 | 1047 | ||
1047 | enum ath5k_version ah_version; | ||
1048 | enum ath5k_radio ah_radio; | ||
1049 | u32 ah_phy; | ||
1050 | |||
1051 | bool ah_5ghz; | ||
1052 | bool ah_2ghz; | ||
1053 | |||
1054 | #define ah_modes ah_capabilities.cap_mode | 1048 | #define ah_modes ah_capabilities.cap_mode |
1055 | #define ah_ee_version ah_capabilities.cap_eeprom.ee_version | 1049 | #define ah_ee_version ah_capabilities.cap_eeprom.ee_version |
1056 | 1050 | ||
@@ -1058,7 +1052,6 @@ struct ath5k_hw { | |||
1058 | u32 ah_aifs; | 1052 | u32 ah_aifs; |
1059 | u32 ah_cw_min; | 1053 | u32 ah_cw_min; |
1060 | u32 ah_cw_max; | 1054 | u32 ah_cw_max; |
1061 | bool ah_software_retry; | ||
1062 | u32 ah_limit_tx_retries; | 1055 | u32 ah_limit_tx_retries; |
1063 | 1056 | ||
1064 | /* Antenna Control */ | 1057 | /* Antenna Control */ |
@@ -1066,6 +1059,7 @@ struct ath5k_hw { | |||
1066 | u8 ah_ant_mode; | 1059 | u8 ah_ant_mode; |
1067 | u8 ah_tx_ant; | 1060 | u8 ah_tx_ant; |
1068 | u8 ah_def_ant; | 1061 | u8 ah_def_ant; |
1062 | bool ah_software_retry; | ||
1069 | 1063 | ||
1070 | u8 ah_sta_id[ETH_ALEN]; | 1064 | u8 ah_sta_id[ETH_ALEN]; |
1071 | 1065 | ||
@@ -1075,7 +1069,6 @@ struct ath5k_hw { | |||
1075 | u8 ah_bssid[ETH_ALEN]; | 1069 | u8 ah_bssid[ETH_ALEN]; |
1076 | u8 ah_bssid_mask[ETH_ALEN]; | 1070 | u8 ah_bssid_mask[ETH_ALEN]; |
1077 | 1071 | ||
1078 | u32 ah_gpio[AR5K_MAX_GPIO]; | ||
1079 | int ah_gpio_npins; | 1072 | int ah_gpio_npins; |
1080 | 1073 | ||
1081 | struct ath_regulatory ah_regulatory; | 1074 | struct ath_regulatory ah_regulatory; |
diff --git a/drivers/net/wireless/ath/ath5k/attach.c b/drivers/net/wireless/ath/ath5k/attach.c index c41ef58393e7..9a84d9410b27 100644 --- a/drivers/net/wireless/ath/ath5k/attach.c +++ b/drivers/net/wireless/ath/ath5k/attach.c | |||
@@ -319,6 +319,9 @@ struct ath5k_hw *ath5k_hw_attach(struct ath5k_softc *sc, u8 mac_version) | |||
319 | 319 | ||
320 | ath5k_hw_rfgain_opt_init(ah); | 320 | ath5k_hw_rfgain_opt_init(ah); |
321 | 321 | ||
322 | /* turn on HW LEDs */ | ||
323 | ath5k_hw_set_ledstate(ah, AR5K_LED_INIT); | ||
324 | |||
322 | return ah; | 325 | return ah; |
323 | err_free: | 326 | err_free: |
324 | kfree(ah); | 327 | kfree(ah); |
diff --git a/drivers/net/wireless/ath/ath5k/base.c b/drivers/net/wireless/ath/ath5k/base.c index ea045151f953..20ba6fa5f1f1 100644 --- a/drivers/net/wireless/ath/ath5k/base.c +++ b/drivers/net/wireless/ath/ath5k/base.c | |||
@@ -218,6 +218,8 @@ static struct pci_driver ath5k_pci_driver = { | |||
218 | * Prototypes - MAC 802.11 stack related functions | 218 | * Prototypes - MAC 802.11 stack related functions |
219 | */ | 219 | */ |
220 | static int ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb); | 220 | static int ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb); |
221 | static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, | ||
222 | struct ath5k_txq *txq); | ||
221 | static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan); | 223 | static int ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan); |
222 | static int ath5k_reset_wake(struct ath5k_softc *sc); | 224 | static int ath5k_reset_wake(struct ath5k_softc *sc); |
223 | static int ath5k_start(struct ieee80211_hw *hw); | 225 | static int ath5k_start(struct ieee80211_hw *hw); |
@@ -248,6 +250,8 @@ static void ath5k_bss_info_changed(struct ieee80211_hw *hw, | |||
248 | struct ieee80211_vif *vif, | 250 | struct ieee80211_vif *vif, |
249 | struct ieee80211_bss_conf *bss_conf, | 251 | struct ieee80211_bss_conf *bss_conf, |
250 | u32 changes); | 252 | u32 changes); |
253 | static void ath5k_sw_scan_start(struct ieee80211_hw *hw); | ||
254 | static void ath5k_sw_scan_complete(struct ieee80211_hw *hw); | ||
251 | 255 | ||
252 | static const struct ieee80211_ops ath5k_hw_ops = { | 256 | static const struct ieee80211_ops ath5k_hw_ops = { |
253 | .tx = ath5k_tx, | 257 | .tx = ath5k_tx, |
@@ -265,6 +269,8 @@ static const struct ieee80211_ops ath5k_hw_ops = { | |||
265 | .set_tsf = ath5k_set_tsf, | 269 | .set_tsf = ath5k_set_tsf, |
266 | .reset_tsf = ath5k_reset_tsf, | 270 | .reset_tsf = ath5k_reset_tsf, |
267 | .bss_info_changed = ath5k_bss_info_changed, | 271 | .bss_info_changed = ath5k_bss_info_changed, |
272 | .sw_scan_start = ath5k_sw_scan_start, | ||
273 | .sw_scan_complete = ath5k_sw_scan_complete, | ||
268 | }; | 274 | }; |
269 | 275 | ||
270 | /* | 276 | /* |
@@ -297,7 +303,8 @@ static void ath5k_desc_free(struct ath5k_softc *sc, | |||
297 | static int ath5k_rxbuf_setup(struct ath5k_softc *sc, | 303 | static int ath5k_rxbuf_setup(struct ath5k_softc *sc, |
298 | struct ath5k_buf *bf); | 304 | struct ath5k_buf *bf); |
299 | static int ath5k_txbuf_setup(struct ath5k_softc *sc, | 305 | static int ath5k_txbuf_setup(struct ath5k_softc *sc, |
300 | struct ath5k_buf *bf); | 306 | struct ath5k_buf *bf, |
307 | struct ath5k_txq *txq); | ||
301 | static inline void ath5k_txbuf_free(struct ath5k_softc *sc, | 308 | static inline void ath5k_txbuf_free(struct ath5k_softc *sc, |
302 | struct ath5k_buf *bf) | 309 | struct ath5k_buf *bf) |
303 | { | 310 | { |
@@ -512,6 +519,7 @@ ath5k_pci_probe(struct pci_dev *pdev, | |||
512 | /* Initialize driver private data */ | 519 | /* Initialize driver private data */ |
513 | SET_IEEE80211_DEV(hw, &pdev->dev); | 520 | SET_IEEE80211_DEV(hw, &pdev->dev); |
514 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | | 521 | hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | |
522 | IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | | ||
515 | IEEE80211_HW_SIGNAL_DBM | | 523 | IEEE80211_HW_SIGNAL_DBM | |
516 | IEEE80211_HW_NOISE_DBM; | 524 | IEEE80211_HW_NOISE_DBM; |
517 | 525 | ||
@@ -666,7 +674,6 @@ ath5k_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
666 | 674 | ||
667 | ath5k_led_off(sc); | 675 | ath5k_led_off(sc); |
668 | 676 | ||
669 | free_irq(pdev->irq, sc); | ||
670 | pci_save_state(pdev); | 677 | pci_save_state(pdev); |
671 | pci_disable_device(pdev); | 678 | pci_disable_device(pdev); |
672 | pci_set_power_state(pdev, PCI_D3hot); | 679 | pci_set_power_state(pdev, PCI_D3hot); |
@@ -694,18 +701,8 @@ ath5k_pci_resume(struct pci_dev *pdev) | |||
694 | */ | 701 | */ |
695 | pci_write_config_byte(pdev, 0x41, 0); | 702 | pci_write_config_byte(pdev, 0x41, 0); |
696 | 703 | ||
697 | err = request_irq(pdev->irq, ath5k_intr, IRQF_SHARED, "ath", sc); | ||
698 | if (err) { | ||
699 | ATH5K_ERR(sc, "request_irq failed\n"); | ||
700 | goto err_no_irq; | ||
701 | } | ||
702 | |||
703 | ath5k_led_enable(sc); | 704 | ath5k_led_enable(sc); |
704 | return 0; | 705 | return 0; |
705 | |||
706 | err_no_irq: | ||
707 | pci_disable_device(pdev); | ||
708 | return err; | ||
709 | } | 706 | } |
710 | #endif /* CONFIG_PM */ | 707 | #endif /* CONFIG_PM */ |
711 | 708 | ||
@@ -785,12 +782,18 @@ ath5k_attach(struct pci_dev *pdev, struct ieee80211_hw *hw) | |||
785 | goto err_desc; | 782 | goto err_desc; |
786 | } | 783 | } |
787 | sc->bhalq = ret; | 784 | sc->bhalq = ret; |
785 | sc->cabq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_CAB, 0); | ||
786 | if (IS_ERR(sc->cabq)) { | ||
787 | ATH5K_ERR(sc, "can't setup cab queue\n"); | ||
788 | ret = PTR_ERR(sc->cabq); | ||
789 | goto err_bhal; | ||
790 | } | ||
788 | 791 | ||
789 | sc->txq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BK); | 792 | sc->txq = ath5k_txq_setup(sc, AR5K_TX_QUEUE_DATA, AR5K_WME_AC_BK); |
790 | if (IS_ERR(sc->txq)) { | 793 | if (IS_ERR(sc->txq)) { |
791 | ATH5K_ERR(sc, "can't setup xmit queue\n"); | 794 | ATH5K_ERR(sc, "can't setup xmit queue\n"); |
792 | ret = PTR_ERR(sc->txq); | 795 | ret = PTR_ERR(sc->txq); |
793 | goto err_bhal; | 796 | goto err_queues; |
794 | } | 797 | } |
795 | 798 | ||
796 | tasklet_init(&sc->rxtq, ath5k_tasklet_rx, (unsigned long)sc); | 799 | tasklet_init(&sc->rxtq, ath5k_tasklet_rx, (unsigned long)sc); |
@@ -1228,10 +1231,10 @@ ath5k_rxbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) | |||
1228 | } | 1231 | } |
1229 | 1232 | ||
1230 | static int | 1233 | static int |
1231 | ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf) | 1234 | ath5k_txbuf_setup(struct ath5k_softc *sc, struct ath5k_buf *bf, |
1235 | struct ath5k_txq *txq) | ||
1232 | { | 1236 | { |
1233 | struct ath5k_hw *ah = sc->ah; | 1237 | struct ath5k_hw *ah = sc->ah; |
1234 | struct ath5k_txq *txq = sc->txq; | ||
1235 | struct ath5k_desc *ds = bf->desc; | 1238 | struct ath5k_desc *ds = bf->desc; |
1236 | struct sk_buff *skb = bf->skb; | 1239 | struct sk_buff *skb = bf->skb; |
1237 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | 1240 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); |
@@ -1901,7 +1904,8 @@ accept: | |||
1901 | if (sc->opmode == NL80211_IFTYPE_ADHOC) | 1904 | if (sc->opmode == NL80211_IFTYPE_ADHOC) |
1902 | ath5k_check_ibss_tsf(sc, skb, &rxs); | 1905 | ath5k_check_ibss_tsf(sc, skb, &rxs); |
1903 | 1906 | ||
1904 | __ieee80211_rx(sc->hw, skb, &rxs); | 1907 | memcpy(IEEE80211_SKB_RXCB(skb), &rxs, sizeof(rxs)); |
1908 | ieee80211_rx(sc->hw, skb); | ||
1905 | 1909 | ||
1906 | bf->skb = next_skb; | 1910 | bf->skb = next_skb; |
1907 | bf->skbaddr = next_skb_addr; | 1911 | bf->skbaddr = next_skb_addr; |
@@ -2078,13 +2082,6 @@ err_unmap: | |||
2078 | return ret; | 2082 | return ret; |
2079 | } | 2083 | } |
2080 | 2084 | ||
2081 | static void ath5k_beacon_disable(struct ath5k_softc *sc) | ||
2082 | { | ||
2083 | sc->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA); | ||
2084 | ath5k_hw_set_imr(sc->ah, sc->imask); | ||
2085 | ath5k_hw_stop_tx_dma(sc->ah, sc->bhalq); | ||
2086 | } | ||
2087 | |||
2088 | /* | 2085 | /* |
2089 | * Transmit a beacon frame at SWBA. Dynamic updates to the | 2086 | * Transmit a beacon frame at SWBA. Dynamic updates to the |
2090 | * frame contents are done as needed and the slot time is | 2087 | * frame contents are done as needed and the slot time is |
@@ -2098,6 +2095,7 @@ ath5k_beacon_send(struct ath5k_softc *sc) | |||
2098 | { | 2095 | { |
2099 | struct ath5k_buf *bf = sc->bbuf; | 2096 | struct ath5k_buf *bf = sc->bbuf; |
2100 | struct ath5k_hw *ah = sc->ah; | 2097 | struct ath5k_hw *ah = sc->ah; |
2098 | struct sk_buff *skb; | ||
2101 | 2099 | ||
2102 | ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "in beacon_send\n"); | 2100 | ATH5K_DBG_UNLIMIT(sc, ATH5K_DEBUG_BEACON, "in beacon_send\n"); |
2103 | 2101 | ||
@@ -2151,6 +2149,12 @@ ath5k_beacon_send(struct ath5k_softc *sc) | |||
2151 | ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "TXDP[%u] = %llx (%p)\n", | 2149 | ATH5K_DBG(sc, ATH5K_DEBUG_BEACON, "TXDP[%u] = %llx (%p)\n", |
2152 | sc->bhalq, (unsigned long long)bf->daddr, bf->desc); | 2150 | sc->bhalq, (unsigned long long)bf->daddr, bf->desc); |
2153 | 2151 | ||
2152 | skb = ieee80211_get_buffered_bc(sc->hw, sc->vif); | ||
2153 | while (skb) { | ||
2154 | ath5k_tx_queue(sc->hw, skb, sc->cabq); | ||
2155 | skb = ieee80211_get_buffered_bc(sc->hw, sc->vif); | ||
2156 | } | ||
2157 | |||
2154 | sc->bsent++; | 2158 | sc->bsent++; |
2155 | } | 2159 | } |
2156 | 2160 | ||
@@ -2271,13 +2275,11 @@ ath5k_beacon_config(struct ath5k_softc *sc) | |||
2271 | struct ath5k_hw *ah = sc->ah; | 2275 | struct ath5k_hw *ah = sc->ah; |
2272 | unsigned long flags; | 2276 | unsigned long flags; |
2273 | 2277 | ||
2274 | ath5k_hw_set_imr(ah, 0); | 2278 | spin_lock_irqsave(&sc->block, flags); |
2275 | sc->bmisscount = 0; | 2279 | sc->bmisscount = 0; |
2276 | sc->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA); | 2280 | sc->imask &= ~(AR5K_INT_BMISS | AR5K_INT_SWBA); |
2277 | 2281 | ||
2278 | if (sc->opmode == NL80211_IFTYPE_ADHOC || | 2282 | if (sc->enable_beacon) { |
2279 | sc->opmode == NL80211_IFTYPE_MESH_POINT || | ||
2280 | sc->opmode == NL80211_IFTYPE_AP) { | ||
2281 | /* | 2283 | /* |
2282 | * In IBSS mode we use a self-linked tx descriptor and let the | 2284 | * In IBSS mode we use a self-linked tx descriptor and let the |
2283 | * hardware send the beacons automatically. We have to load it | 2285 | * hardware send the beacons automatically. We have to load it |
@@ -2290,16 +2292,17 @@ ath5k_beacon_config(struct ath5k_softc *sc) | |||
2290 | sc->imask |= AR5K_INT_SWBA; | 2292 | sc->imask |= AR5K_INT_SWBA; |
2291 | 2293 | ||
2292 | if (sc->opmode == NL80211_IFTYPE_ADHOC) { | 2294 | if (sc->opmode == NL80211_IFTYPE_ADHOC) { |
2293 | if (ath5k_hw_hasveol(ah)) { | 2295 | if (ath5k_hw_hasveol(ah)) |
2294 | spin_lock_irqsave(&sc->block, flags); | ||
2295 | ath5k_beacon_send(sc); | 2296 | ath5k_beacon_send(sc); |
2296 | spin_unlock_irqrestore(&sc->block, flags); | ||
2297 | } | ||
2298 | } else | 2297 | } else |
2299 | ath5k_beacon_update_timers(sc, -1); | 2298 | ath5k_beacon_update_timers(sc, -1); |
2299 | } else { | ||
2300 | ath5k_hw_stop_tx_dma(sc->ah, sc->bhalq); | ||
2300 | } | 2301 | } |
2301 | 2302 | ||
2302 | ath5k_hw_set_imr(ah, sc->imask); | 2303 | ath5k_hw_set_imr(ah, sc->imask); |
2304 | mmiowb(); | ||
2305 | spin_unlock_irqrestore(&sc->block, flags); | ||
2303 | } | 2306 | } |
2304 | 2307 | ||
2305 | static void ath5k_tasklet_beacon(unsigned long data) | 2308 | static void ath5k_tasklet_beacon(unsigned long data) |
@@ -2598,6 +2601,14 @@ static int | |||
2598 | ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | 2601 | ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
2599 | { | 2602 | { |
2600 | struct ath5k_softc *sc = hw->priv; | 2603 | struct ath5k_softc *sc = hw->priv; |
2604 | |||
2605 | return ath5k_tx_queue(hw, skb, sc->txq); | ||
2606 | } | ||
2607 | |||
2608 | static int ath5k_tx_queue(struct ieee80211_hw *hw, struct sk_buff *skb, | ||
2609 | struct ath5k_txq *txq) | ||
2610 | { | ||
2611 | struct ath5k_softc *sc = hw->priv; | ||
2601 | struct ath5k_buf *bf; | 2612 | struct ath5k_buf *bf; |
2602 | unsigned long flags; | 2613 | unsigned long flags; |
2603 | int hdrlen; | 2614 | int hdrlen; |
@@ -2641,7 +2652,7 @@ ath5k_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
2641 | 2652 | ||
2642 | bf->skb = skb; | 2653 | bf->skb = skb; |
2643 | 2654 | ||
2644 | if (ath5k_txbuf_setup(sc, bf)) { | 2655 | if (ath5k_txbuf_setup(sc, bf, txq)) { |
2645 | bf->skb = NULL; | 2656 | bf->skb = NULL; |
2646 | spin_lock_irqsave(&sc->txbuflock, flags); | 2657 | spin_lock_irqsave(&sc->txbuflock, flags); |
2647 | list_add_tail(&bf->list, &sc->txbuf); | 2658 | list_add_tail(&bf->list, &sc->txbuf); |
@@ -2676,7 +2687,7 @@ ath5k_reset(struct ath5k_softc *sc, struct ieee80211_channel *chan) | |||
2676 | sc->curchan = chan; | 2687 | sc->curchan = chan; |
2677 | sc->curband = &sc->sbands[chan->band]; | 2688 | sc->curband = &sc->sbands[chan->band]; |
2678 | } | 2689 | } |
2679 | ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, true); | 2690 | ret = ath5k_hw_reset(ah, sc->opmode, sc->curchan, chan != NULL); |
2680 | if (ret) { | 2691 | if (ret) { |
2681 | ATH5K_ERR(sc, "can't reset hardware (%d)\n", ret); | 2692 | ATH5K_ERR(sc, "can't reset hardware (%d)\n", ret); |
2682 | goto err; | 2693 | goto err; |
@@ -2776,7 +2787,6 @@ ath5k_remove_interface(struct ieee80211_hw *hw, | |||
2776 | goto end; | 2787 | goto end; |
2777 | 2788 | ||
2778 | ath5k_hw_set_lladdr(sc->ah, mac); | 2789 | ath5k_hw_set_lladdr(sc->ah, mac); |
2779 | ath5k_beacon_disable(sc); | ||
2780 | sc->vif = NULL; | 2790 | sc->vif = NULL; |
2781 | end: | 2791 | end: |
2782 | mutex_unlock(&sc->lock); | 2792 | mutex_unlock(&sc->lock); |
@@ -3105,25 +3115,6 @@ out: | |||
3105 | return ret; | 3115 | return ret; |
3106 | } | 3116 | } |
3107 | 3117 | ||
3108 | /* | ||
3109 | * Update the beacon and reconfigure the beacon queues. | ||
3110 | */ | ||
3111 | static void | ||
3112 | ath5k_beacon_reconfig(struct ieee80211_hw *hw, struct ieee80211_vif *vif) | ||
3113 | { | ||
3114 | int ret; | ||
3115 | unsigned long flags; | ||
3116 | struct ath5k_softc *sc = hw->priv; | ||
3117 | |||
3118 | spin_lock_irqsave(&sc->block, flags); | ||
3119 | ret = ath5k_beacon_update(hw, vif); | ||
3120 | spin_unlock_irqrestore(&sc->block, flags); | ||
3121 | if (ret == 0) { | ||
3122 | ath5k_beacon_config(sc); | ||
3123 | mmiowb(); | ||
3124 | } | ||
3125 | } | ||
3126 | |||
3127 | static void | 3118 | static void |
3128 | set_beacon_filter(struct ieee80211_hw *hw, bool enable) | 3119 | set_beacon_filter(struct ieee80211_hw *hw, bool enable) |
3129 | { | 3120 | { |
@@ -3146,6 +3137,7 @@ static void ath5k_bss_info_changed(struct ieee80211_hw *hw, | |||
3146 | { | 3137 | { |
3147 | struct ath5k_softc *sc = hw->priv; | 3138 | struct ath5k_softc *sc = hw->priv; |
3148 | struct ath5k_hw *ah = sc->ah; | 3139 | struct ath5k_hw *ah = sc->ah; |
3140 | unsigned long flags; | ||
3149 | 3141 | ||
3150 | mutex_lock(&sc->lock); | 3142 | mutex_lock(&sc->lock); |
3151 | if (WARN_ON(sc->vif != vif)) | 3143 | if (WARN_ON(sc->vif != vif)) |
@@ -3167,15 +3159,37 @@ static void ath5k_bss_info_changed(struct ieee80211_hw *hw, | |||
3167 | sc->assoc = bss_conf->assoc; | 3159 | sc->assoc = bss_conf->assoc; |
3168 | if (sc->opmode == NL80211_IFTYPE_STATION) | 3160 | if (sc->opmode == NL80211_IFTYPE_STATION) |
3169 | set_beacon_filter(hw, sc->assoc); | 3161 | set_beacon_filter(hw, sc->assoc); |
3162 | ath5k_hw_set_ledstate(sc->ah, sc->assoc ? | ||
3163 | AR5K_LED_ASSOC : AR5K_LED_INIT); | ||
3170 | } | 3164 | } |
3171 | 3165 | ||
3172 | if (changes & BSS_CHANGED_BEACON && | 3166 | if (changes & BSS_CHANGED_BEACON) { |
3173 | (vif->type == NL80211_IFTYPE_ADHOC || | 3167 | spin_lock_irqsave(&sc->block, flags); |
3174 | vif->type == NL80211_IFTYPE_MESH_POINT || | 3168 | ath5k_beacon_update(hw, vif); |
3175 | vif->type == NL80211_IFTYPE_AP)) { | 3169 | spin_unlock_irqrestore(&sc->block, flags); |
3176 | ath5k_beacon_reconfig(hw, vif); | ||
3177 | } | 3170 | } |
3178 | 3171 | ||
3172 | if (changes & BSS_CHANGED_BEACON_ENABLED) | ||
3173 | sc->enable_beacon = bss_conf->enable_beacon; | ||
3174 | |||
3175 | if (changes & (BSS_CHANGED_BEACON | BSS_CHANGED_BEACON_ENABLED | | ||
3176 | BSS_CHANGED_BEACON_INT)) | ||
3177 | ath5k_beacon_config(sc); | ||
3178 | |||
3179 | unlock: | 3179 | unlock: |
3180 | mutex_unlock(&sc->lock); | 3180 | mutex_unlock(&sc->lock); |
3181 | } | 3181 | } |
3182 | |||
3183 | static void ath5k_sw_scan_start(struct ieee80211_hw *hw) | ||
3184 | { | ||
3185 | struct ath5k_softc *sc = hw->priv; | ||
3186 | if (!sc->assoc) | ||
3187 | ath5k_hw_set_ledstate(sc->ah, AR5K_LED_SCAN); | ||
3188 | } | ||
3189 | |||
3190 | static void ath5k_sw_scan_complete(struct ieee80211_hw *hw) | ||
3191 | { | ||
3192 | struct ath5k_softc *sc = hw->priv; | ||
3193 | ath5k_hw_set_ledstate(sc->ah, sc->assoc ? | ||
3194 | AR5K_LED_ASSOC : AR5K_LED_INIT); | ||
3195 | } | ||
diff --git a/drivers/net/wireless/ath/ath5k/base.h b/drivers/net/wireless/ath/ath5k/base.h index f9b7f2f819b7..778e422946ab 100644 --- a/drivers/net/wireless/ath/ath5k/base.h +++ b/drivers/net/wireless/ath/ath5k/base.h | |||
@@ -114,8 +114,7 @@ struct ath5k_softc { | |||
114 | struct pci_dev *pdev; /* for dma mapping */ | 114 | struct pci_dev *pdev; /* for dma mapping */ |
115 | void __iomem *iobase; /* address of the device */ | 115 | void __iomem *iobase; /* address of the device */ |
116 | struct mutex lock; /* dev-level lock */ | 116 | struct mutex lock; /* dev-level lock */ |
117 | /* FIXME: how many does it really need? */ | 117 | struct ieee80211_tx_queue_stats tx_stats[AR5K_NUM_TX_QUEUES]; |
118 | struct ieee80211_tx_queue_stats tx_stats[16]; | ||
119 | struct ieee80211_low_level_stats ll_stats; | 118 | struct ieee80211_low_level_stats ll_stats; |
120 | struct ieee80211_hw *hw; /* IEEE 802.11 common */ | 119 | struct ieee80211_hw *hw; /* IEEE 802.11 common */ |
121 | struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; | 120 | struct ieee80211_supported_band sbands[IEEE80211_NUM_BANDS]; |
@@ -171,9 +170,8 @@ struct ath5k_softc { | |||
171 | struct list_head txbuf; /* transmit buffer */ | 170 | struct list_head txbuf; /* transmit buffer */ |
172 | spinlock_t txbuflock; | 171 | spinlock_t txbuflock; |
173 | unsigned int txbuf_len; /* buf count in txbuf list */ | 172 | unsigned int txbuf_len; /* buf count in txbuf list */ |
174 | struct ath5k_txq txqs[2]; /* beacon and tx */ | 173 | struct ath5k_txq txqs[AR5K_NUM_TX_QUEUES]; /* tx queues */ |
175 | 174 | struct ath5k_txq *txq; /* main tx queue */ | |
176 | struct ath5k_txq *txq; /* beacon and tx*/ | ||
177 | struct tasklet_struct txtq; /* tx intr tasklet */ | 175 | struct tasklet_struct txtq; /* tx intr tasklet */ |
178 | struct ath5k_led tx_led; /* tx led */ | 176 | struct ath5k_led tx_led; /* tx led */ |
179 | 177 | ||
@@ -187,10 +185,12 @@ struct ath5k_softc { | |||
187 | bintval, /* beacon interval in TU */ | 185 | bintval, /* beacon interval in TU */ |
188 | bsent; | 186 | bsent; |
189 | unsigned int nexttbtt; /* next beacon time in TU */ | 187 | unsigned int nexttbtt; /* next beacon time in TU */ |
188 | struct ath5k_txq *cabq; /* content after beacon */ | ||
190 | 189 | ||
191 | struct timer_list calib_tim; /* calibration timer */ | 190 | struct timer_list calib_tim; /* calibration timer */ |
192 | int power_level; /* Requested tx power in dbm */ | 191 | int power_level; /* Requested tx power in dbm */ |
193 | bool assoc; /* assocate state */ | 192 | bool assoc; /* assocate state */ |
193 | bool enable_beacon; /* true if beacons are on */ | ||
194 | }; | 194 | }; |
195 | 195 | ||
196 | #define ath5k_hw_hasbssidmask(_ah) \ | 196 | #define ath5k_hw_hasbssidmask(_ah) \ |
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c index 4904a07e4b59..747508c15d34 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c | |||
@@ -380,13 +380,15 @@ ath5k_debug_init_device(struct ath5k_softc *sc) | |||
380 | sc->debug.debugfs_phydir = debugfs_create_dir(wiphy_name(sc->hw->wiphy), | 380 | sc->debug.debugfs_phydir = debugfs_create_dir(wiphy_name(sc->hw->wiphy), |
381 | ath5k_global_debugfs); | 381 | ath5k_global_debugfs); |
382 | 382 | ||
383 | sc->debug.debugfs_debug = debugfs_create_file("debug", S_IWUSR | S_IRUGO, | 383 | sc->debug.debugfs_debug = debugfs_create_file("debug", |
384 | S_IWUSR | S_IRUSR, | ||
384 | sc->debug.debugfs_phydir, sc, &fops_debug); | 385 | sc->debug.debugfs_phydir, sc, &fops_debug); |
385 | 386 | ||
386 | sc->debug.debugfs_registers = debugfs_create_file("registers", S_IRUGO, | 387 | sc->debug.debugfs_registers = debugfs_create_file("registers", S_IRUSR, |
387 | sc->debug.debugfs_phydir, sc, &fops_registers); | 388 | sc->debug.debugfs_phydir, sc, &fops_registers); |
388 | 389 | ||
389 | sc->debug.debugfs_beacon = debugfs_create_file("beacon", S_IWUSR | S_IRUGO, | 390 | sc->debug.debugfs_beacon = debugfs_create_file("beacon", |
391 | S_IWUSR | S_IRUSR, | ||
390 | sc->debug.debugfs_phydir, sc, &fops_beacon); | 392 | sc->debug.debugfs_phydir, sc, &fops_beacon); |
391 | 393 | ||
392 | sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR, | 394 | sc->debug.debugfs_reset = debugfs_create_file("reset", S_IWUSR, |
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index a876ca8d69ef..2075ba993966 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c | |||
@@ -1085,8 +1085,7 @@ int ath5k_hw_channel(struct ath5k_hw *ah, struct ieee80211_channel *channel) | |||
1085 | AR5K_PHY_CCKTXCTL_WORLD); | 1085 | AR5K_PHY_CCKTXCTL_WORLD); |
1086 | } | 1086 | } |
1087 | 1087 | ||
1088 | ah->ah_current_channel.center_freq = channel->center_freq; | 1088 | ah->ah_current_channel = channel; |
1089 | ah->ah_current_channel.hw_value = channel->hw_value; | ||
1090 | ah->ah_turbo = channel->hw_value == CHANNEL_T ? true : false; | 1089 | ah->ah_turbo = channel->hw_value == CHANNEL_T ? true : false; |
1091 | 1090 | ||
1092 | return 0; | 1091 | return 0; |
@@ -1731,7 +1730,7 @@ ath5k_hw_set_fast_div(struct ath5k_hw *ah, u8 ee_mode, bool enable) | |||
1731 | void | 1730 | void |
1732 | ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode) | 1731 | ath5k_hw_set_antenna_mode(struct ath5k_hw *ah, u8 ant_mode) |
1733 | { | 1732 | { |
1734 | struct ieee80211_channel *channel = &ah->ah_current_channel; | 1733 | struct ieee80211_channel *channel = ah->ah_current_channel; |
1735 | bool use_def_for_tx, update_def_on_tx, use_def_for_rts, fast_div; | 1734 | bool use_def_for_tx, update_def_on_tx, use_def_for_rts, fast_div; |
1736 | bool use_def_for_sg; | 1735 | bool use_def_for_sg; |
1737 | u8 def_ant, tx_ant, ee_mode; | 1736 | u8 def_ant, tx_ant, ee_mode; |
@@ -3011,7 +3010,7 @@ ath5k_hw_txpower(struct ath5k_hw *ah, struct ieee80211_channel *channel, | |||
3011 | int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) | 3010 | int ath5k_hw_set_txpower_limit(struct ath5k_hw *ah, u8 txpower) |
3012 | { | 3011 | { |
3013 | /*Just a try M.F.*/ | 3012 | /*Just a try M.F.*/ |
3014 | struct ieee80211_channel *channel = &ah->ah_current_channel; | 3013 | struct ieee80211_channel *channel = ah->ah_current_channel; |
3015 | u8 ee_mode; | 3014 | u8 ee_mode; |
3016 | 3015 | ||
3017 | ATH5K_TRACE(ah->ah_sc); | 3016 | ATH5K_TRACE(ah->ah_sc); |
diff --git a/drivers/net/wireless/ath/ath5k/qcu.c b/drivers/net/wireless/ath/ath5k/qcu.c index 73407b3f53ef..6d5aaf00d8bb 100644 --- a/drivers/net/wireless/ath/ath5k/qcu.c +++ b/drivers/net/wireless/ath/ath5k/qcu.c | |||
@@ -411,7 +411,6 @@ int ath5k_hw_reset_tx_queue(struct ath5k_hw *ah, unsigned int queue) | |||
411 | AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_MISC(queue), | 411 | AR5K_REG_ENABLE_BITS(ah, AR5K_QUEUE_MISC(queue), |
412 | AR5K_QCU_MISC_FRSHED_BCN_SENT_GT | | 412 | AR5K_QCU_MISC_FRSHED_BCN_SENT_GT | |
413 | AR5K_QCU_MISC_CBREXP_DIS | | 413 | AR5K_QCU_MISC_CBREXP_DIS | |
414 | AR5K_QCU_MISC_RDY_VEOL_POLICY | | ||
415 | AR5K_QCU_MISC_CBREXP_BCN_DIS); | 414 | AR5K_QCU_MISC_CBREXP_BCN_DIS); |
416 | 415 | ||
417 | ath5k_hw_reg_write(ah, ((AR5K_TUNE_BEACON_INTERVAL - | 416 | ath5k_hw_reg_write(ah, ((AR5K_TUNE_BEACON_INTERVAL - |
diff --git a/drivers/net/wireless/ath/ath5k/reset.c b/drivers/net/wireless/ath/ath5k/reset.c index bd0a97a38d34..86733fdb4774 100644 --- a/drivers/net/wireless/ath/ath5k/reset.c +++ b/drivers/net/wireless/ath/ath5k/reset.c | |||
@@ -290,7 +290,6 @@ int ath5k_hw_set_power(struct ath5k_hw *ah, enum ath5k_power_mode mode, | |||
290 | } | 290 | } |
291 | 291 | ||
292 | commit: | 292 | commit: |
293 | ah->ah_power_mode = mode; | ||
294 | ath5k_hw_reg_write(ah, staid, AR5K_STA_ID1); | 293 | ath5k_hw_reg_write(ah, staid, AR5K_STA_ID1); |
295 | 294 | ||
296 | return 0; | 295 | return 0; |
diff --git a/drivers/net/wireless/ath/ath9k/ath9k.h b/drivers/net/wireless/ath/ath9k/ath9k.h index 5efc9345ca0d..eb9d5228cb6c 100644 --- a/drivers/net/wireless/ath/ath9k/ath9k.h +++ b/drivers/net/wireless/ath/ath9k/ath9k.h | |||
@@ -272,7 +272,6 @@ struct ath_atx_tid { | |||
272 | int sched; | 272 | int sched; |
273 | int paused; | 273 | int paused; |
274 | u8 state; | 274 | u8 state; |
275 | int addba_exchangeattempts; | ||
276 | }; | 275 | }; |
277 | 276 | ||
278 | struct ath_atx_ac { | 277 | struct ath_atx_ac { |
@@ -541,6 +540,7 @@ struct ath_softc { | |||
541 | int irq; | 540 | int irq; |
542 | spinlock_t sc_resetlock; | 541 | spinlock_t sc_resetlock; |
543 | spinlock_t sc_serial_rw; | 542 | spinlock_t sc_serial_rw; |
543 | spinlock_t ani_lock; | ||
544 | struct mutex mutex; | 544 | struct mutex mutex; |
545 | 545 | ||
546 | u8 curbssid[ETH_ALEN]; | 546 | u8 curbssid[ETH_ALEN]; |
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c index 3639a2e6987d..45c4ea57616b 100644 --- a/drivers/net/wireless/ath/ath9k/beacon.c +++ b/drivers/net/wireless/ath/ath9k/beacon.c | |||
@@ -674,13 +674,6 @@ static void ath_beacon_config_adhoc(struct ath_softc *sc, | |||
674 | 674 | ||
675 | intval = conf->beacon_interval & ATH9K_BEACON_PERIOD; | 675 | intval = conf->beacon_interval & ATH9K_BEACON_PERIOD; |
676 | 676 | ||
677 | /* | ||
678 | * It looks like mac80211 may end up using beacon interval of zero in | ||
679 | * some cases (at least for mesh point). Avoid getting into an | ||
680 | * infinite loop by using a bit safer value instead.. | ||
681 | */ | ||
682 | if (intval == 0) | ||
683 | intval = 100; | ||
684 | 677 | ||
685 | /* Pull nexttbtt forward to reflect the current TSF */ | 678 | /* Pull nexttbtt forward to reflect the current TSF */ |
686 | 679 | ||
@@ -745,6 +738,14 @@ void ath_beacon_config(struct ath_softc *sc, struct ieee80211_vif *vif) | |||
745 | iftype = sc->sc_ah->opmode; | 738 | iftype = sc->sc_ah->opmode; |
746 | } | 739 | } |
747 | 740 | ||
741 | /* | ||
742 | * It looks like mac80211 may end up using beacon interval of zero in | ||
743 | * some cases (at least for mesh point). Avoid getting into an | ||
744 | * infinite loop by using a bit safer value instead. To be safe, | ||
745 | * do sanity check on beacon interval for all operating modes. | ||
746 | */ | ||
747 | if (cur_conf->beacon_interval == 0) | ||
748 | cur_conf->beacon_interval = 100; | ||
748 | 749 | ||
749 | switch (iftype) { | 750 | switch (iftype) { |
750 | case NL80211_IFTYPE_AP: | 751 | case NL80211_IFTYPE_AP: |
diff --git a/drivers/net/wireless/ath/ath9k/debug.c b/drivers/net/wireless/ath/ath9k/debug.c index 6d20725d6451..9f99f00c1447 100644 --- a/drivers/net/wireless/ath/ath9k/debug.c +++ b/drivers/net/wireless/ath/ath9k/debug.c | |||
@@ -500,31 +500,31 @@ int ath9k_init_debug(struct ath_softc *sc) | |||
500 | goto err; | 500 | goto err; |
501 | 501 | ||
502 | sc->debug.debugfs_debug = debugfs_create_file("debug", | 502 | sc->debug.debugfs_debug = debugfs_create_file("debug", |
503 | S_IRUGO | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug); | 503 | S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, &fops_debug); |
504 | if (!sc->debug.debugfs_debug) | 504 | if (!sc->debug.debugfs_debug) |
505 | goto err; | 505 | goto err; |
506 | 506 | ||
507 | sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUGO, | 507 | sc->debug.debugfs_dma = debugfs_create_file("dma", S_IRUSR, |
508 | sc->debug.debugfs_phy, sc, &fops_dma); | 508 | sc->debug.debugfs_phy, sc, &fops_dma); |
509 | if (!sc->debug.debugfs_dma) | 509 | if (!sc->debug.debugfs_dma) |
510 | goto err; | 510 | goto err; |
511 | 511 | ||
512 | sc->debug.debugfs_interrupt = debugfs_create_file("interrupt", | 512 | sc->debug.debugfs_interrupt = debugfs_create_file("interrupt", |
513 | S_IRUGO, | 513 | S_IRUSR, |
514 | sc->debug.debugfs_phy, | 514 | sc->debug.debugfs_phy, |
515 | sc, &fops_interrupt); | 515 | sc, &fops_interrupt); |
516 | if (!sc->debug.debugfs_interrupt) | 516 | if (!sc->debug.debugfs_interrupt) |
517 | goto err; | 517 | goto err; |
518 | 518 | ||
519 | sc->debug.debugfs_rcstat = debugfs_create_file("rcstat", | 519 | sc->debug.debugfs_rcstat = debugfs_create_file("rcstat", |
520 | S_IRUGO, | 520 | S_IRUSR, |
521 | sc->debug.debugfs_phy, | 521 | sc->debug.debugfs_phy, |
522 | sc, &fops_rcstat); | 522 | sc, &fops_rcstat); |
523 | if (!sc->debug.debugfs_rcstat) | 523 | if (!sc->debug.debugfs_rcstat) |
524 | goto err; | 524 | goto err; |
525 | 525 | ||
526 | sc->debug.debugfs_wiphy = debugfs_create_file( | 526 | sc->debug.debugfs_wiphy = debugfs_create_file( |
527 | "wiphy", S_IRUGO | S_IWUSR, sc->debug.debugfs_phy, sc, | 527 | "wiphy", S_IRUSR | S_IWUSR, sc->debug.debugfs_phy, sc, |
528 | &fops_wiphy); | 528 | &fops_wiphy); |
529 | if (!sc->debug.debugfs_wiphy) | 529 | if (!sc->debug.debugfs_wiphy) |
530 | goto err; | 530 | goto err; |
diff --git a/drivers/net/wireless/ath/ath9k/eeprom.c b/drivers/net/wireless/ath/ath9k/eeprom.c index a2fda702b620..d82a0f97e6f5 100644 --- a/drivers/net/wireless/ath/ath9k/eeprom.c +++ b/drivers/net/wireless/ath/ath9k/eeprom.c | |||
@@ -2516,10 +2516,8 @@ static void ath9k_hw_set_def_power_per_rate_table(struct ath_hw *ah, | |||
2516 | targetPowerCck.tPow2x[1]; | 2516 | targetPowerCck.tPow2x[1]; |
2517 | ratesArray[rate5_5s] = ratesArray[rate5_5l] = | 2517 | ratesArray[rate5_5s] = ratesArray[rate5_5l] = |
2518 | targetPowerCck.tPow2x[2]; | 2518 | targetPowerCck.tPow2x[2]; |
2519 | ; | ||
2520 | ratesArray[rate11s] = ratesArray[rate11l] = | 2519 | ratesArray[rate11s] = ratesArray[rate11l] = |
2521 | targetPowerCck.tPow2x[3]; | 2520 | targetPowerCck.tPow2x[3]; |
2522 | ; | ||
2523 | } | 2521 | } |
2524 | if (IS_CHAN_HT40(chan)) { | 2522 | if (IS_CHAN_HT40(chan)) { |
2525 | for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) { | 2523 | for (i = 0; i < ARRAY_SIZE(targetPowerHt40.tPow2x); i++) { |
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 34935a8ee59d..cffb0789f669 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
@@ -2345,7 +2345,7 @@ int ath9k_hw_reset(struct ath_hw *ah, struct ath9k_channel *chan, | |||
2345 | ath9k_hw_init_bb(ah, chan); | 2345 | ath9k_hw_init_bb(ah, chan); |
2346 | 2346 | ||
2347 | if (!ath9k_hw_init_cal(ah, chan)) | 2347 | if (!ath9k_hw_init_cal(ah, chan)) |
2348 | return -EIO;; | 2348 | return -EIO; |
2349 | 2349 | ||
2350 | rx_chainmask = ah->rxchainmask; | 2350 | rx_chainmask = ah->rxchainmask; |
2351 | if ((rx_chainmask == 0x5) || (rx_chainmask == 0x3)) { | 2351 | if ((rx_chainmask == 0x5) || (rx_chainmask == 0x3)) { |
diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c index 66a6c1f5022a..961b0ce6ef3e 100644 --- a/drivers/net/wireless/ath/ath9k/main.c +++ b/drivers/net/wireless/ath/ath9k/main.c | |||
@@ -342,6 +342,7 @@ static void ath_ani_calibrate(unsigned long data) | |||
342 | * don't calibrate when we're scanning. | 342 | * don't calibrate when we're scanning. |
343 | * we are most likely not on our home channel. | 343 | * we are most likely not on our home channel. |
344 | */ | 344 | */ |
345 | spin_lock(&sc->ani_lock); | ||
345 | if (sc->sc_flags & SC_OP_SCANNING) | 346 | if (sc->sc_flags & SC_OP_SCANNING) |
346 | goto set_timer; | 347 | goto set_timer; |
347 | 348 | ||
@@ -405,6 +406,7 @@ static void ath_ani_calibrate(unsigned long data) | |||
405 | ath9k_ps_restore(sc); | 406 | ath9k_ps_restore(sc); |
406 | 407 | ||
407 | set_timer: | 408 | set_timer: |
409 | spin_unlock(&sc->ani_lock); | ||
408 | /* | 410 | /* |
409 | * Set timer interval based on previous results. | 411 | * Set timer interval based on previous results. |
410 | * The interval must be the shortest necessary to satisfy ANI, | 412 | * The interval must be the shortest necessary to satisfy ANI, |
@@ -887,6 +889,7 @@ static void setup_ht_cap(struct ath_softc *sc, | |||
887 | { | 889 | { |
888 | #define ATH9K_HT_CAP_MAXRXAMPDU_65536 0x3 /* 2 ^ 16 */ | 890 | #define ATH9K_HT_CAP_MAXRXAMPDU_65536 0x3 /* 2 ^ 16 */ |
889 | #define ATH9K_HT_CAP_MPDUDENSITY_8 0x6 /* 8 usec */ | 891 | #define ATH9K_HT_CAP_MPDUDENSITY_8 0x6 /* 8 usec */ |
892 | u8 tx_streams, rx_streams; | ||
890 | 893 | ||
891 | ht_info->ht_supported = true; | 894 | ht_info->ht_supported = true; |
892 | ht_info->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | | 895 | ht_info->cap = IEEE80211_HT_CAP_SUP_WIDTH_20_40 | |
@@ -899,45 +902,43 @@ static void setup_ht_cap(struct ath_softc *sc, | |||
899 | 902 | ||
900 | /* set up supported mcs set */ | 903 | /* set up supported mcs set */ |
901 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); | 904 | memset(&ht_info->mcs, 0, sizeof(ht_info->mcs)); |
905 | tx_streams = !(sc->tx_chainmask & (sc->tx_chainmask - 1)) ? 1 : 2; | ||
906 | rx_streams = !(sc->rx_chainmask & (sc->rx_chainmask - 1)) ? 1 : 2; | ||
902 | 907 | ||
903 | switch(sc->rx_chainmask) { | 908 | if (tx_streams != rx_streams) { |
904 | case 1: | 909 | DPRINTF(sc, ATH_DBG_CONFIG, "TX streams %d, RX streams: %d\n", |
905 | ht_info->mcs.rx_mask[0] = 0xff; | 910 | tx_streams, rx_streams); |
906 | break; | 911 | ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_RX_DIFF; |
907 | case 3: | 912 | ht_info->mcs.tx_params |= ((tx_streams - 1) << |
908 | case 5: | 913 | IEEE80211_HT_MCS_TX_MAX_STREAMS_SHIFT); |
909 | case 7: | ||
910 | default: | ||
911 | ht_info->mcs.rx_mask[0] = 0xff; | ||
912 | ht_info->mcs.rx_mask[1] = 0xff; | ||
913 | break; | ||
914 | } | 914 | } |
915 | 915 | ||
916 | ht_info->mcs.tx_params = IEEE80211_HT_MCS_TX_DEFINED; | 916 | ht_info->mcs.rx_mask[0] = 0xff; |
917 | if (rx_streams >= 2) | ||
918 | ht_info->mcs.rx_mask[1] = 0xff; | ||
919 | |||
920 | ht_info->mcs.tx_params |= IEEE80211_HT_MCS_TX_DEFINED; | ||
917 | } | 921 | } |
918 | 922 | ||
919 | static void ath9k_bss_assoc_info(struct ath_softc *sc, | 923 | static void ath9k_bss_assoc_info(struct ath_softc *sc, |
920 | struct ieee80211_vif *vif, | 924 | struct ieee80211_vif *vif, |
921 | struct ieee80211_bss_conf *bss_conf) | 925 | struct ieee80211_bss_conf *bss_conf) |
922 | { | 926 | { |
923 | struct ath_vif *avp = (void *)vif->drv_priv; | ||
924 | 927 | ||
925 | if (bss_conf->assoc) { | 928 | if (bss_conf->assoc) { |
926 | DPRINTF(sc, ATH_DBG_CONFIG, "Bss Info ASSOC %d, bssid: %pM\n", | 929 | DPRINTF(sc, ATH_DBG_CONFIG, "Bss Info ASSOC %d, bssid: %pM\n", |
927 | bss_conf->aid, sc->curbssid); | 930 | bss_conf->aid, sc->curbssid); |
928 | 931 | ||
929 | /* New association, store aid */ | 932 | /* New association, store aid */ |
930 | if (avp->av_opmode == NL80211_IFTYPE_STATION) { | 933 | sc->curaid = bss_conf->aid; |
931 | sc->curaid = bss_conf->aid; | 934 | ath9k_hw_write_associd(sc); |
932 | ath9k_hw_write_associd(sc); | ||
933 | 935 | ||
934 | /* | 936 | /* |
935 | * Request a re-configuration of Beacon related timers | 937 | * Request a re-configuration of Beacon related timers |
936 | * on the receipt of the first Beacon frame (i.e., | 938 | * on the receipt of the first Beacon frame (i.e., |
937 | * after time sync with the AP). | 939 | * after time sync with the AP). |
938 | */ | 940 | */ |
939 | sc->sc_flags |= SC_OP_BEACON_SYNC; | 941 | sc->sc_flags |= SC_OP_BEACON_SYNC; |
940 | } | ||
941 | 942 | ||
942 | /* Configure the beacon */ | 943 | /* Configure the beacon */ |
943 | ath_beacon_config(sc, vif); | 944 | ath_beacon_config(sc, vif); |
@@ -952,6 +953,8 @@ static void ath9k_bss_assoc_info(struct ath_softc *sc, | |||
952 | } else { | 953 | } else { |
953 | DPRINTF(sc, ATH_DBG_CONFIG, "Bss Info DISASSOC\n"); | 954 | DPRINTF(sc, ATH_DBG_CONFIG, "Bss Info DISASSOC\n"); |
954 | sc->curaid = 0; | 955 | sc->curaid = 0; |
956 | /* Stop ANI */ | ||
957 | del_timer_sync(&sc->ani.timer); | ||
955 | } | 958 | } |
956 | } | 959 | } |
957 | 960 | ||
@@ -1311,6 +1314,7 @@ static int ath_init(u16 devid, struct ath_softc *sc) | |||
1311 | spin_lock_init(&sc->wiphy_lock); | 1314 | spin_lock_init(&sc->wiphy_lock); |
1312 | spin_lock_init(&sc->sc_resetlock); | 1315 | spin_lock_init(&sc->sc_resetlock); |
1313 | spin_lock_init(&sc->sc_serial_rw); | 1316 | spin_lock_init(&sc->sc_serial_rw); |
1317 | spin_lock_init(&sc->ani_lock); | ||
1314 | mutex_init(&sc->mutex); | 1318 | mutex_init(&sc->mutex); |
1315 | tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); | 1319 | tasklet_init(&sc->intr_tq, ath9k_tasklet, (unsigned long)sc); |
1316 | tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet, | 1320 | tasklet_init(&sc->bcon_tasklet, ath_beacon_tasklet, |
@@ -2196,7 +2200,9 @@ static int ath9k_add_interface(struct ieee80211_hw *hw, | |||
2196 | 2200 | ||
2197 | ath9k_hw_set_interrupts(sc->sc_ah, sc->imask); | 2201 | ath9k_hw_set_interrupts(sc->sc_ah, sc->imask); |
2198 | 2202 | ||
2199 | if (conf->type == NL80211_IFTYPE_AP) | 2203 | if (conf->type == NL80211_IFTYPE_AP || |
2204 | conf->type == NL80211_IFTYPE_ADHOC || | ||
2205 | conf->type == NL80211_IFTYPE_MONITOR) | ||
2200 | ath_start_ani(sc); | 2206 | ath_start_ani(sc); |
2201 | 2207 | ||
2202 | out: | 2208 | out: |
@@ -2681,9 +2687,9 @@ static void ath9k_sw_scan_start(struct ieee80211_hw *hw) | |||
2681 | aphy->state = ATH_WIPHY_SCAN; | 2687 | aphy->state = ATH_WIPHY_SCAN; |
2682 | ath9k_wiphy_pause_all_forced(sc, aphy); | 2688 | ath9k_wiphy_pause_all_forced(sc, aphy); |
2683 | 2689 | ||
2684 | mutex_lock(&sc->mutex); | 2690 | spin_lock_bh(&sc->ani_lock); |
2685 | sc->sc_flags |= SC_OP_SCANNING; | 2691 | sc->sc_flags |= SC_OP_SCANNING; |
2686 | mutex_unlock(&sc->mutex); | 2692 | spin_unlock_bh(&sc->ani_lock); |
2687 | } | 2693 | } |
2688 | 2694 | ||
2689 | static void ath9k_sw_scan_complete(struct ieee80211_hw *hw) | 2695 | static void ath9k_sw_scan_complete(struct ieee80211_hw *hw) |
@@ -2691,11 +2697,11 @@ static void ath9k_sw_scan_complete(struct ieee80211_hw *hw) | |||
2691 | struct ath_wiphy *aphy = hw->priv; | 2697 | struct ath_wiphy *aphy = hw->priv; |
2692 | struct ath_softc *sc = aphy->sc; | 2698 | struct ath_softc *sc = aphy->sc; |
2693 | 2699 | ||
2694 | mutex_lock(&sc->mutex); | 2700 | spin_lock_bh(&sc->ani_lock); |
2695 | aphy->state = ATH_WIPHY_ACTIVE; | 2701 | aphy->state = ATH_WIPHY_ACTIVE; |
2696 | sc->sc_flags &= ~SC_OP_SCANNING; | 2702 | sc->sc_flags &= ~SC_OP_SCANNING; |
2697 | sc->sc_flags |= SC_OP_FULL_RESET; | 2703 | sc->sc_flags |= SC_OP_FULL_RESET; |
2698 | mutex_unlock(&sc->mutex); | 2704 | spin_unlock_bh(&sc->ani_lock); |
2699 | } | 2705 | } |
2700 | 2706 | ||
2701 | struct ieee80211_ops ath9k_ops = { | 2707 | struct ieee80211_ops ath9k_ops = { |
diff --git a/drivers/net/wireless/ath/ath9k/recv.c b/drivers/net/wireless/ath/ath9k/recv.c index cece1c4c6bda..b3da81db453b 100644 --- a/drivers/net/wireless/ath/ath9k/recv.c +++ b/drivers/net/wireless/ath/ath9k/recv.c | |||
@@ -236,10 +236,31 @@ static int ath_rx_prepare(struct sk_buff *skb, struct ath_desc *ds, | |||
236 | rx_status->signal = rx_status->noise + ds->ds_rxstat.rs_rssi; | 236 | rx_status->signal = rx_status->noise + ds->ds_rxstat.rs_rssi; |
237 | rx_status->antenna = ds->ds_rxstat.rs_antenna; | 237 | rx_status->antenna = ds->ds_rxstat.rs_antenna; |
238 | 238 | ||
239 | /* at 45 you will be able to use MCS 15 reliably. A more elaborate | 239 | /* |
240 | * scheme can be used here but it requires tables of SNR/throughput for | 240 | * Theory for reporting quality: |
241 | * each possible mode used. */ | 241 | * |
242 | rx_status->qual = ds->ds_rxstat.rs_rssi * 100 / 45; | 242 | * At a hardware RSSI of 45 you will be able to use MCS 7 reliably. |
243 | * At a hardware RSSI of 45 you will be able to use MCS 15 reliably. | ||
244 | * At a hardware RSSI of 35 you should be able use 54 Mbps reliably. | ||
245 | * | ||
246 | * MCS 7 is the highets MCS index usable by a 1-stream device. | ||
247 | * MCS 15 is the highest MCS index usable by a 2-stream device. | ||
248 | * | ||
249 | * All ath9k devices are either 1-stream or 2-stream. | ||
250 | * | ||
251 | * How many bars you see is derived from the qual reporting. | ||
252 | * | ||
253 | * A more elaborate scheme can be used here but it requires tables | ||
254 | * of SNR/throughput for each possible mode used. For the MCS table | ||
255 | * you can refer to the wireless wiki: | ||
256 | * | ||
257 | * http://wireless.kernel.org/en/developers/Documentation/ieee80211/802.11n | ||
258 | * | ||
259 | */ | ||
260 | if (conf_is_ht(&hw->conf)) | ||
261 | rx_status->qual = ds->ds_rxstat.rs_rssi * 100 / 45; | ||
262 | else | ||
263 | rx_status->qual = ds->ds_rxstat.rs_rssi * 100 / 35; | ||
243 | 264 | ||
244 | /* rssi can be more than 45 though, anything above that | 265 | /* rssi can be more than 45 though, anything above that |
245 | * should be considered at 100% */ | 266 | * should be considered at 100% */ |
@@ -505,11 +526,6 @@ static bool ath_beacon_dtim_pending_cab(struct sk_buff *skb) | |||
505 | return false; | 526 | return false; |
506 | } | 527 | } |
507 | 528 | ||
508 | static void ath_rx_ps_back_to_sleep(struct ath_softc *sc) | ||
509 | { | ||
510 | sc->sc_flags &= ~(SC_OP_WAIT_FOR_BEACON | SC_OP_WAIT_FOR_CAB); | ||
511 | } | ||
512 | |||
513 | static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb) | 529 | static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb) |
514 | { | 530 | { |
515 | struct ieee80211_mgmt *mgmt; | 531 | struct ieee80211_mgmt *mgmt; |
@@ -521,6 +537,8 @@ static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb) | |||
521 | if (memcmp(sc->curbssid, mgmt->bssid, ETH_ALEN) != 0) | 537 | if (memcmp(sc->curbssid, mgmt->bssid, ETH_ALEN) != 0) |
522 | return; /* not from our current AP */ | 538 | return; /* not from our current AP */ |
523 | 539 | ||
540 | sc->sc_flags &= ~SC_OP_WAIT_FOR_BEACON; | ||
541 | |||
524 | if (sc->sc_flags & SC_OP_BEACON_SYNC) { | 542 | if (sc->sc_flags & SC_OP_BEACON_SYNC) { |
525 | sc->sc_flags &= ~SC_OP_BEACON_SYNC; | 543 | sc->sc_flags &= ~SC_OP_BEACON_SYNC; |
526 | DPRINTF(sc, ATH_DBG_PS, "Reconfigure Beacon timers based on " | 544 | DPRINTF(sc, ATH_DBG_PS, "Reconfigure Beacon timers based on " |
@@ -528,14 +546,6 @@ static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb) | |||
528 | ath_beacon_config(sc, NULL); | 546 | ath_beacon_config(sc, NULL); |
529 | } | 547 | } |
530 | 548 | ||
531 | if (!(sc->hw->conf.flags & IEEE80211_CONF_PS)) { | ||
532 | /* We are not in PS mode anymore; remain awake */ | ||
533 | DPRINTF(sc, ATH_DBG_PS, "Not in PS mode anymore, remain " | ||
534 | "awake\n"); | ||
535 | sc->sc_flags &= ~(SC_OP_WAIT_FOR_BEACON | SC_OP_WAIT_FOR_CAB); | ||
536 | return; | ||
537 | } | ||
538 | |||
539 | if (ath_beacon_dtim_pending_cab(skb)) { | 549 | if (ath_beacon_dtim_pending_cab(skb)) { |
540 | /* | 550 | /* |
541 | * Remain awake waiting for buffered broadcast/multicast | 551 | * Remain awake waiting for buffered broadcast/multicast |
@@ -556,11 +566,9 @@ static void ath_rx_ps_beacon(struct ath_softc *sc, struct sk_buff *skb) | |||
556 | * fails to send a frame indicating that all CAB frames have | 566 | * fails to send a frame indicating that all CAB frames have |
557 | * been delivered. | 567 | * been delivered. |
558 | */ | 568 | */ |
569 | sc->sc_flags &= ~SC_OP_WAIT_FOR_CAB; | ||
559 | DPRINTF(sc, ATH_DBG_PS, "PS wait for CAB frames timed out\n"); | 570 | DPRINTF(sc, ATH_DBG_PS, "PS wait for CAB frames timed out\n"); |
560 | } | 571 | } |
561 | |||
562 | /* No more broadcast/multicast frames to be received at this point. */ | ||
563 | ath_rx_ps_back_to_sleep(sc); | ||
564 | } | 572 | } |
565 | 573 | ||
566 | static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb) | 574 | static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb) |
@@ -578,13 +586,13 @@ static void ath_rx_ps(struct ath_softc *sc, struct sk_buff *skb) | |||
578 | ieee80211_is_action(hdr->frame_control)) && | 586 | ieee80211_is_action(hdr->frame_control)) && |
579 | is_multicast_ether_addr(hdr->addr1) && | 587 | is_multicast_ether_addr(hdr->addr1) && |
580 | !ieee80211_has_moredata(hdr->frame_control)) { | 588 | !ieee80211_has_moredata(hdr->frame_control)) { |
581 | DPRINTF(sc, ATH_DBG_PS, "All PS CAB frames received, back to " | ||
582 | "sleep\n"); | ||
583 | /* | 589 | /* |
584 | * No more broadcast/multicast frames to be received at this | 590 | * No more broadcast/multicast frames to be received at this |
585 | * point. | 591 | * point. |
586 | */ | 592 | */ |
587 | ath_rx_ps_back_to_sleep(sc); | 593 | sc->sc_flags &= ~SC_OP_WAIT_FOR_CAB; |
594 | DPRINTF(sc, ATH_DBG_PS, "All PS CAB frames received, back to " | ||
595 | "sleep\n"); | ||
588 | } else if ((sc->sc_flags & SC_OP_WAIT_FOR_PSPOLL_DATA) && | 596 | } else if ((sc->sc_flags & SC_OP_WAIT_FOR_PSPOLL_DATA) && |
589 | !is_multicast_ether_addr(hdr->addr1) && | 597 | !is_multicast_ether_addr(hdr->addr1) && |
590 | !ieee80211_has_morefrags(hdr->frame_control)) { | 598 | !ieee80211_has_morefrags(hdr->frame_control)) { |
@@ -619,13 +627,18 @@ static void ath_rx_send_to_mac80211(struct ath_softc *sc, struct sk_buff *skb, | |||
619 | if (aphy == NULL) | 627 | if (aphy == NULL) |
620 | continue; | 628 | continue; |
621 | nskb = skb_copy(skb, GFP_ATOMIC); | 629 | nskb = skb_copy(skb, GFP_ATOMIC); |
622 | if (nskb) | 630 | if (nskb) { |
623 | __ieee80211_rx(aphy->hw, nskb, rx_status); | 631 | memcpy(IEEE80211_SKB_RXCB(nskb), rx_status, |
632 | sizeof(*rx_status)); | ||
633 | ieee80211_rx(aphy->hw, nskb); | ||
634 | } | ||
624 | } | 635 | } |
625 | __ieee80211_rx(sc->hw, skb, rx_status); | 636 | memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status)); |
637 | ieee80211_rx(sc->hw, skb); | ||
626 | } else { | 638 | } else { |
627 | /* Deliver unicast frames based on receiver address */ | 639 | /* Deliver unicast frames based on receiver address */ |
628 | __ieee80211_rx(ath_get_virt_hw(sc, hdr), skb, rx_status); | 640 | memcpy(IEEE80211_SKB_RXCB(skb), rx_status, sizeof(*rx_status)); |
641 | ieee80211_rx(ath_get_virt_hw(sc, hdr), skb); | ||
629 | } | 642 | } |
630 | } | 643 | } |
631 | 644 | ||
diff --git a/drivers/net/wireless/ath/ath9k/xmit.c b/drivers/net/wireless/ath/ath9k/xmit.c index 4ccf48e396df..5de9878d2c12 100644 --- a/drivers/net/wireless/ath/ath9k/xmit.c +++ b/drivers/net/wireless/ath/ath9k/xmit.c | |||
@@ -73,18 +73,6 @@ static void ath_tx_rc_status(struct ath_buf *bf, struct ath_desc *ds, | |||
73 | /* Aggregation logic */ | 73 | /* Aggregation logic */ |
74 | /*********************/ | 74 | /*********************/ |
75 | 75 | ||
76 | static int ath_aggr_query(struct ath_softc *sc, struct ath_node *an, u8 tidno) | ||
77 | { | ||
78 | struct ath_atx_tid *tid; | ||
79 | tid = ATH_AN_2_TID(an, tidno); | ||
80 | |||
81 | if (tid->state & AGGR_ADDBA_COMPLETE || | ||
82 | tid->state & AGGR_ADDBA_PROGRESS) | ||
83 | return 1; | ||
84 | else | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | static void ath_tx_queue_tid(struct ath_txq *txq, struct ath_atx_tid *tid) | 76 | static void ath_tx_queue_tid(struct ath_txq *txq, struct ath_atx_tid *tid) |
89 | { | 77 | { |
90 | struct ath_atx_ac *ac = tid->ac; | 78 | struct ath_atx_ac *ac = tid->ac; |
@@ -250,6 +238,10 @@ static struct ath_buf* ath_clone_txbuf(struct ath_softc *sc, struct ath_buf *bf) | |||
250 | struct ath_buf *tbf; | 238 | struct ath_buf *tbf; |
251 | 239 | ||
252 | spin_lock_bh(&sc->tx.txbuflock); | 240 | spin_lock_bh(&sc->tx.txbuflock); |
241 | if (WARN_ON(list_empty(&sc->tx.txbuf))) { | ||
242 | spin_unlock_bh(&sc->tx.txbuflock); | ||
243 | return NULL; | ||
244 | } | ||
253 | ASSERT(!list_empty((&sc->tx.txbuf))); | 245 | ASSERT(!list_empty((&sc->tx.txbuf))); |
254 | tbf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list); | 246 | tbf = list_first_entry(&sc->tx.txbuf, struct ath_buf, list); |
255 | list_del(&tbf->list); | 247 | list_del(&tbf->list); |
@@ -391,6 +383,8 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
391 | struct ath_buf *tbf; | 383 | struct ath_buf *tbf; |
392 | 384 | ||
393 | tbf = ath_clone_txbuf(sc, bf_last); | 385 | tbf = ath_clone_txbuf(sc, bf_last); |
386 | if (!tbf) | ||
387 | break; | ||
394 | ath9k_hw_cleartxdesc(sc->sc_ah, tbf->bf_desc); | 388 | ath9k_hw_cleartxdesc(sc->sc_ah, tbf->bf_desc); |
395 | list_add_tail(&tbf->list, &bf_head); | 389 | list_add_tail(&tbf->list, &bf_head); |
396 | } else { | 390 | } else { |
@@ -414,7 +408,6 @@ static void ath_tx_complete_aggr(struct ath_softc *sc, struct ath_txq *txq, | |||
414 | if (tid->state & AGGR_CLEANUP) { | 408 | if (tid->state & AGGR_CLEANUP) { |
415 | if (tid->baw_head == tid->baw_tail) { | 409 | if (tid->baw_head == tid->baw_tail) { |
416 | tid->state &= ~AGGR_ADDBA_COMPLETE; | 410 | tid->state &= ~AGGR_ADDBA_COMPLETE; |
417 | tid->addba_exchangeattempts = 0; | ||
418 | tid->state &= ~AGGR_CLEANUP; | 411 | tid->state &= ~AGGR_CLEANUP; |
419 | 412 | ||
420 | /* send buffered frames as singles */ | 413 | /* send buffered frames as singles */ |
@@ -719,7 +712,6 @@ int ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid) | |||
719 | 712 | ||
720 | if (!(txtid->state & AGGR_ADDBA_COMPLETE)) { | 713 | if (!(txtid->state & AGGR_ADDBA_COMPLETE)) { |
721 | txtid->state &= ~AGGR_ADDBA_PROGRESS; | 714 | txtid->state &= ~AGGR_ADDBA_PROGRESS; |
722 | txtid->addba_exchangeattempts = 0; | ||
723 | return 0; | 715 | return 0; |
724 | } | 716 | } |
725 | 717 | ||
@@ -747,7 +739,6 @@ int ath_tx_aggr_stop(struct ath_softc *sc, struct ieee80211_sta *sta, u16 tid) | |||
747 | txtid->state |= AGGR_CLEANUP; | 739 | txtid->state |= AGGR_CLEANUP; |
748 | } else { | 740 | } else { |
749 | txtid->state &= ~AGGR_ADDBA_COMPLETE; | 741 | txtid->state &= ~AGGR_ADDBA_COMPLETE; |
750 | txtid->addba_exchangeattempts = 0; | ||
751 | ath_tx_flush_tid(sc, txtid); | 742 | ath_tx_flush_tid(sc, txtid); |
752 | } | 743 | } |
753 | 744 | ||
@@ -780,14 +771,8 @@ bool ath_tx_aggr_check(struct ath_softc *sc, struct ath_node *an, u8 tidno) | |||
780 | 771 | ||
781 | txtid = ATH_AN_2_TID(an, tidno); | 772 | txtid = ATH_AN_2_TID(an, tidno); |
782 | 773 | ||
783 | if (!(txtid->state & AGGR_ADDBA_COMPLETE)) { | 774 | if (!(txtid->state & (AGGR_ADDBA_COMPLETE | AGGR_ADDBA_PROGRESS))) |
784 | if (!(txtid->state & AGGR_ADDBA_PROGRESS) && | ||
785 | (txtid->addba_exchangeattempts < ADDBA_EXCHANGE_ATTEMPTS)) { | ||
786 | txtid->addba_exchangeattempts++; | ||
787 | return true; | 775 | return true; |
788 | } | ||
789 | } | ||
790 | |||
791 | return false; | 776 | return false; |
792 | } | 777 | } |
793 | 778 | ||
@@ -1636,7 +1621,7 @@ static void ath_tx_start_dma(struct ath_softc *sc, struct ath_buf *bf, | |||
1636 | goto tx_done; | 1621 | goto tx_done; |
1637 | } | 1622 | } |
1638 | 1623 | ||
1639 | if (ath_aggr_query(sc, an, bf->bf_tidno)) { | 1624 | if (tx_info->flags & IEEE80211_TX_CTL_AMPDU) { |
1640 | /* | 1625 | /* |
1641 | * Try aggregation if it's a unicast data frame | 1626 | * Try aggregation if it's a unicast data frame |
1642 | * and the destination is HT capable. | 1627 | * and the destination is HT capable. |
@@ -2122,7 +2107,6 @@ void ath_tx_node_init(struct ath_softc *sc, struct ath_node *an) | |||
2122 | tid->ac = &an->ac[acno]; | 2107 | tid->ac = &an->ac[acno]; |
2123 | tid->state &= ~AGGR_ADDBA_COMPLETE; | 2108 | tid->state &= ~AGGR_ADDBA_COMPLETE; |
2124 | tid->state &= ~AGGR_ADDBA_PROGRESS; | 2109 | tid->state &= ~AGGR_ADDBA_PROGRESS; |
2125 | tid->addba_exchangeattempts = 0; | ||
2126 | } | 2110 | } |
2127 | 2111 | ||
2128 | for (acno = 0, ac = &an->ac[acno]; | 2112 | for (acno = 0, ac = &an->ac[acno]; |
@@ -2179,7 +2163,6 @@ void ath_tx_node_cleanup(struct ath_softc *sc, struct ath_node *an) | |||
2179 | tid->sched = false; | 2163 | tid->sched = false; |
2180 | ath_tid_drain(sc, txq, tid); | 2164 | ath_tid_drain(sc, txq, tid); |
2181 | tid->state &= ~AGGR_ADDBA_COMPLETE; | 2165 | tid->state &= ~AGGR_ADDBA_COMPLETE; |
2182 | tid->addba_exchangeattempts = 0; | ||
2183 | tid->state &= ~AGGR_CLEANUP; | 2166 | tid->state &= ~AGGR_CLEANUP; |
2184 | } | 2167 | } |
2185 | } | 2168 | } |
diff --git a/drivers/net/wireless/ath/regd.c b/drivers/net/wireless/ath/regd.c index eef370bd1211..f37c83275793 100644 --- a/drivers/net/wireless/ath/regd.c +++ b/drivers/net/wireless/ath/regd.c | |||
@@ -569,7 +569,5 @@ u32 ath_regd_get_band_ctl(struct ath_regulatory *reg, | |||
569 | default: | 569 | default: |
570 | return NO_CTL; | 570 | return NO_CTL; |
571 | } | 571 | } |
572 | |||
573 | return NO_CTL; | ||
574 | } | 572 | } |
575 | EXPORT_SYMBOL(ath_regd_get_band_ctl); | 573 | EXPORT_SYMBOL(ath_regd_get_band_ctl); |
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c index 291a94bd46fd..05813bc3e308 100644 --- a/drivers/net/wireless/atmel.c +++ b/drivers/net/wireless/atmel.c | |||
@@ -793,13 +793,13 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
793 | !(*priv->present_callback)(priv->card)) { | 793 | !(*priv->present_callback)(priv->card)) { |
794 | dev->stats.tx_errors++; | 794 | dev->stats.tx_errors++; |
795 | dev_kfree_skb(skb); | 795 | dev_kfree_skb(skb); |
796 | return 0; | 796 | return NETDEV_TX_OK; |
797 | } | 797 | } |
798 | 798 | ||
799 | if (priv->station_state != STATION_STATE_READY) { | 799 | if (priv->station_state != STATION_STATE_READY) { |
800 | dev->stats.tx_errors++; | 800 | dev->stats.tx_errors++; |
801 | dev_kfree_skb(skb); | 801 | dev_kfree_skb(skb); |
802 | return 0; | 802 | return NETDEV_TX_OK; |
803 | } | 803 | } |
804 | 804 | ||
805 | /* first ensure the timer func cannot run */ | 805 | /* first ensure the timer func cannot run */ |
@@ -856,7 +856,7 @@ static int start_tx(struct sk_buff *skb, struct net_device *dev) | |||
856 | spin_unlock_bh(&priv->timerlock); | 856 | spin_unlock_bh(&priv->timerlock); |
857 | dev_kfree_skb(skb); | 857 | dev_kfree_skb(skb); |
858 | 858 | ||
859 | return 0; | 859 | return NETDEV_TX_OK; |
860 | } | 860 | } |
861 | 861 | ||
862 | static void atmel_transmit_management_frame(struct atmel_private *priv, | 862 | static void atmel_transmit_management_frame(struct atmel_private *priv, |
diff --git a/drivers/net/wireless/b43/xmit.c b/drivers/net/wireless/b43/xmit.c index 55f36a7254d9..5b85e7d73592 100644 --- a/drivers/net/wireless/b43/xmit.c +++ b/drivers/net/wireless/b43/xmit.c | |||
@@ -670,7 +670,8 @@ void b43_rx(struct b43_wldev *dev, struct sk_buff *skb, const void *_rxhdr) | |||
670 | goto drop; | 670 | goto drop; |
671 | } | 671 | } |
672 | 672 | ||
673 | ieee80211_rx_irqsafe(dev->wl->hw, skb, &status); | 673 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); |
674 | ieee80211_rx_irqsafe(dev->wl->hw, skb); | ||
674 | 675 | ||
675 | return; | 676 | return; |
676 | drop: | 677 | drop: |
diff --git a/drivers/net/wireless/b43legacy/xmit.c b/drivers/net/wireless/b43legacy/xmit.c index b8e39dd06e99..f79cee82601b 100644 --- a/drivers/net/wireless/b43legacy/xmit.c +++ b/drivers/net/wireless/b43legacy/xmit.c | |||
@@ -591,7 +591,8 @@ void b43legacy_rx(struct b43legacy_wldev *dev, | |||
591 | } | 591 | } |
592 | 592 | ||
593 | dev->stats.last_rx = jiffies; | 593 | dev->stats.last_rx = jiffies; |
594 | ieee80211_rx_irqsafe(dev->wl->hw, skb, &status); | 594 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); |
595 | ieee80211_rx_irqsafe(dev->wl->hw, skb); | ||
595 | 596 | ||
596 | return; | 597 | return; |
597 | drop: | 598 | drop: |
diff --git a/drivers/net/wireless/hostap/hostap_80211_tx.c b/drivers/net/wireless/hostap/hostap_80211_tx.c index d313b005114e..1fe1bbabb907 100644 --- a/drivers/net/wireless/hostap/hostap_80211_tx.c +++ b/drivers/net/wireless/hostap/hostap_80211_tx.c | |||
@@ -75,7 +75,7 @@ int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
75 | printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb " | 75 | printk(KERN_DEBUG "%s: hostap_data_start_xmit: short skb " |
76 | "(len=%d)\n", dev->name, skb->len); | 76 | "(len=%d)\n", dev->name, skb->len); |
77 | kfree_skb(skb); | 77 | kfree_skb(skb); |
78 | return 0; | 78 | return NETDEV_TX_OK; |
79 | } | 79 | } |
80 | 80 | ||
81 | if (local->ddev != dev) { | 81 | if (local->ddev != dev) { |
@@ -89,14 +89,14 @@ int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
89 | printk(KERN_DEBUG "%s: prism2_tx: trying to use " | 89 | printk(KERN_DEBUG "%s: prism2_tx: trying to use " |
90 | "AP device with Ethernet net dev\n", dev->name); | 90 | "AP device with Ethernet net dev\n", dev->name); |
91 | kfree_skb(skb); | 91 | kfree_skb(skb); |
92 | return 0; | 92 | return NETDEV_TX_OK; |
93 | } | 93 | } |
94 | } else { | 94 | } else { |
95 | if (local->iw_mode == IW_MODE_REPEAT) { | 95 | if (local->iw_mode == IW_MODE_REPEAT) { |
96 | printk(KERN_DEBUG "%s: prism2_tx: trying to use " | 96 | printk(KERN_DEBUG "%s: prism2_tx: trying to use " |
97 | "non-WDS link in Repeater mode\n", dev->name); | 97 | "non-WDS link in Repeater mode\n", dev->name); |
98 | kfree_skb(skb); | 98 | kfree_skb(skb); |
99 | return 0; | 99 | return NETDEV_TX_OK; |
100 | } else if (local->iw_mode == IW_MODE_INFRA && | 100 | } else if (local->iw_mode == IW_MODE_INFRA && |
101 | (local->wds_type & HOSTAP_WDS_AP_CLIENT) && | 101 | (local->wds_type & HOSTAP_WDS_AP_CLIENT) && |
102 | memcmp(skb->data + ETH_ALEN, dev->dev_addr, | 102 | memcmp(skb->data + ETH_ALEN, dev->dev_addr, |
@@ -210,13 +210,13 @@ int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
210 | skb = skb_unshare(skb, GFP_ATOMIC); | 210 | skb = skb_unshare(skb, GFP_ATOMIC); |
211 | if (skb == NULL) { | 211 | if (skb == NULL) { |
212 | iface->stats.tx_dropped++; | 212 | iface->stats.tx_dropped++; |
213 | return 0; | 213 | return NETDEV_TX_OK; |
214 | } | 214 | } |
215 | if (pskb_expand_head(skb, need_headroom, need_tailroom, | 215 | if (pskb_expand_head(skb, need_headroom, need_tailroom, |
216 | GFP_ATOMIC)) { | 216 | GFP_ATOMIC)) { |
217 | kfree_skb(skb); | 217 | kfree_skb(skb); |
218 | iface->stats.tx_dropped++; | 218 | iface->stats.tx_dropped++; |
219 | return 0; | 219 | return NETDEV_TX_OK; |
220 | } | 220 | } |
221 | } else if (skb_headroom(skb) < need_headroom) { | 221 | } else if (skb_headroom(skb) < need_headroom) { |
222 | struct sk_buff *tmp = skb; | 222 | struct sk_buff *tmp = skb; |
@@ -224,13 +224,13 @@ int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
224 | kfree_skb(tmp); | 224 | kfree_skb(tmp); |
225 | if (skb == NULL) { | 225 | if (skb == NULL) { |
226 | iface->stats.tx_dropped++; | 226 | iface->stats.tx_dropped++; |
227 | return 0; | 227 | return NETDEV_TX_OK; |
228 | } | 228 | } |
229 | } else { | 229 | } else { |
230 | skb = skb_unshare(skb, GFP_ATOMIC); | 230 | skb = skb_unshare(skb, GFP_ATOMIC); |
231 | if (skb == NULL) { | 231 | if (skb == NULL) { |
232 | iface->stats.tx_dropped++; | 232 | iface->stats.tx_dropped++; |
233 | return 0; | 233 | return NETDEV_TX_OK; |
234 | } | 234 | } |
235 | } | 235 | } |
236 | 236 | ||
@@ -256,7 +256,7 @@ int hostap_data_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
256 | /* Send IEEE 802.11 encapsulated frame using the master radio device */ | 256 | /* Send IEEE 802.11 encapsulated frame using the master radio device */ |
257 | skb->dev = local->dev; | 257 | skb->dev = local->dev; |
258 | dev_queue_xmit(skb); | 258 | dev_queue_xmit(skb); |
259 | return 0; | 259 | return NETDEV_TX_OK; |
260 | } | 260 | } |
261 | 261 | ||
262 | 262 | ||
@@ -276,7 +276,7 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
276 | printk(KERN_DEBUG "%s: hostap_mgmt_start_xmit: short skb " | 276 | printk(KERN_DEBUG "%s: hostap_mgmt_start_xmit: short skb " |
277 | "(len=%d)\n", dev->name, skb->len); | 277 | "(len=%d)\n", dev->name, skb->len); |
278 | kfree_skb(skb); | 278 | kfree_skb(skb); |
279 | return 0; | 279 | return NETDEV_TX_OK; |
280 | } | 280 | } |
281 | 281 | ||
282 | iface->stats.tx_packets++; | 282 | iface->stats.tx_packets++; |
@@ -301,7 +301,7 @@ int hostap_mgmt_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
301 | /* Send IEEE 802.11 encapsulated frame using the master radio device */ | 301 | /* Send IEEE 802.11 encapsulated frame using the master radio device */ |
302 | skb->dev = local->dev; | 302 | skb->dev = local->dev; |
303 | dev_queue_xmit(skb); | 303 | dev_queue_xmit(skb); |
304 | return 0; | 304 | return NETDEV_TX_OK; |
305 | } | 305 | } |
306 | 306 | ||
307 | 307 | ||
@@ -396,7 +396,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
396 | printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, " | 396 | printk(KERN_DEBUG "%s: invalid skb->cb magic (0x%08x, " |
397 | "expected 0x%08x)\n", | 397 | "expected 0x%08x)\n", |
398 | dev->name, meta->magic, HOSTAP_SKB_TX_DATA_MAGIC); | 398 | dev->name, meta->magic, HOSTAP_SKB_TX_DATA_MAGIC); |
399 | ret = 0; | 399 | ret = NETDEV_TX_OK; |
400 | iface->stats.tx_dropped++; | 400 | iface->stats.tx_dropped++; |
401 | goto fail; | 401 | goto fail; |
402 | } | 402 | } |
@@ -414,7 +414,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
414 | if (skb->len < 24) { | 414 | if (skb->len < 24) { |
415 | printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb " | 415 | printk(KERN_DEBUG "%s: hostap_master_start_xmit: short skb " |
416 | "(len=%d)\n", dev->name, skb->len); | 416 | "(len=%d)\n", dev->name, skb->len); |
417 | ret = 0; | 417 | ret = NETDEV_TX_OK; |
418 | iface->stats.tx_dropped++; | 418 | iface->stats.tx_dropped++; |
419 | goto fail; | 419 | goto fail; |
420 | } | 420 | } |
@@ -441,13 +441,13 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
441 | dev->name, meta->ethertype); | 441 | dev->name, meta->ethertype); |
442 | hostap_dump_tx_80211(dev->name, skb); | 442 | hostap_dump_tx_80211(dev->name, skb); |
443 | 443 | ||
444 | ret = 0; /* drop packet */ | 444 | ret = NETDEV_TX_OK; /* drop packet */ |
445 | iface->stats.tx_dropped++; | 445 | iface->stats.tx_dropped++; |
446 | goto fail; | 446 | goto fail; |
447 | } | 447 | } |
448 | break; | 448 | break; |
449 | case AP_TX_DROP: | 449 | case AP_TX_DROP: |
450 | ret = 0; /* drop packet */ | 450 | ret = NETDEV_TX_OK; /* drop packet */ |
451 | iface->stats.tx_dropped++; | 451 | iface->stats.tx_dropped++; |
452 | goto fail; | 452 | goto fail; |
453 | case AP_TX_RETRY: | 453 | case AP_TX_RETRY: |
@@ -455,7 +455,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
455 | case AP_TX_BUFFERED: | 455 | case AP_TX_BUFFERED: |
456 | /* do not free skb here, it will be freed when the | 456 | /* do not free skb here, it will be freed when the |
457 | * buffered frame is sent/timed out */ | 457 | * buffered frame is sent/timed out */ |
458 | ret = 0; | 458 | ret = NETDEV_TX_OK; |
459 | goto tx_exit; | 459 | goto tx_exit; |
460 | } | 460 | } |
461 | 461 | ||
@@ -501,7 +501,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
501 | "frame (drop_unencrypted=1)\n", dev->name); | 501 | "frame (drop_unencrypted=1)\n", dev->name); |
502 | } | 502 | } |
503 | iface->stats.tx_dropped++; | 503 | iface->stats.tx_dropped++; |
504 | ret = 0; | 504 | ret = NETDEV_TX_OK; |
505 | goto fail; | 505 | goto fail; |
506 | } | 506 | } |
507 | 507 | ||
@@ -510,7 +510,7 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
510 | if (skb == NULL) { | 510 | if (skb == NULL) { |
511 | printk(KERN_DEBUG "%s: TX - encryption failed\n", | 511 | printk(KERN_DEBUG "%s: TX - encryption failed\n", |
512 | dev->name); | 512 | dev->name); |
513 | ret = 0; | 513 | ret = NETDEV_TX_OK; |
514 | goto fail; | 514 | goto fail; |
515 | } | 515 | } |
516 | meta = (struct hostap_skb_tx_data *) skb->cb; | 516 | meta = (struct hostap_skb_tx_data *) skb->cb; |
@@ -519,23 +519,23 @@ int hostap_master_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
519 | "expected 0x%08x) after hostap_tx_encrypt\n", | 519 | "expected 0x%08x) after hostap_tx_encrypt\n", |
520 | dev->name, meta->magic, | 520 | dev->name, meta->magic, |
521 | HOSTAP_SKB_TX_DATA_MAGIC); | 521 | HOSTAP_SKB_TX_DATA_MAGIC); |
522 | ret = 0; | 522 | ret = NETDEV_TX_OK; |
523 | iface->stats.tx_dropped++; | 523 | iface->stats.tx_dropped++; |
524 | goto fail; | 524 | goto fail; |
525 | } | 525 | } |
526 | } | 526 | } |
527 | 527 | ||
528 | if (local->func->tx == NULL || local->func->tx(skb, dev)) { | 528 | if (local->func->tx == NULL || local->func->tx(skb, dev)) { |
529 | ret = 0; | 529 | ret = NETDEV_TX_OK; |
530 | iface->stats.tx_dropped++; | 530 | iface->stats.tx_dropped++; |
531 | } else { | 531 | } else { |
532 | ret = 0; | 532 | ret = NETDEV_TX_OK; |
533 | iface->stats.tx_packets++; | 533 | iface->stats.tx_packets++; |
534 | iface->stats.tx_bytes += skb->len; | 534 | iface->stats.tx_bytes += skb->len; |
535 | } | 535 | } |
536 | 536 | ||
537 | fail: | 537 | fail: |
538 | if (!ret && skb) | 538 | if (ret == NETDEV_TX_OK && skb) |
539 | dev_kfree_skb(skb); | 539 | dev_kfree_skb(skb); |
540 | tx_exit: | 540 | tx_exit: |
541 | if (tx.sta_ptr) | 541 | if (tx.sta_ptr) |
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c index 44c29b3f6728..d726b3c6077a 100644 --- a/drivers/net/wireless/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/ipw2x00/ipw2200.c | |||
@@ -11436,11 +11436,11 @@ static struct pci_device_id card_ids[] = { | |||
11436 | {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2754, 0, 0, 0}, | 11436 | {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2754, 0, 0, 0}, |
11437 | {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2761, 0, 0, 0}, | 11437 | {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2761, 0, 0, 0}, |
11438 | {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2762, 0, 0, 0}, | 11438 | {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2762, 0, 0, 0}, |
11439 | {PCI_VENDOR_ID_INTEL, 0x104f, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, | 11439 | {PCI_VDEVICE(INTEL, 0x104f), 0}, |
11440 | {PCI_VENDOR_ID_INTEL, 0x4220, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */ | 11440 | {PCI_VDEVICE(INTEL, 0x4220), 0}, /* BG */ |
11441 | {PCI_VENDOR_ID_INTEL, 0x4221, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* BG */ | 11441 | {PCI_VDEVICE(INTEL, 0x4221), 0}, /* BG */ |
11442 | {PCI_VENDOR_ID_INTEL, 0x4223, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ | 11442 | {PCI_VDEVICE(INTEL, 0x4223), 0}, /* ABG */ |
11443 | {PCI_VENDOR_ID_INTEL, 0x4224, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, /* ABG */ | 11443 | {PCI_VDEVICE(INTEL, 0x4224), 0}, /* ABG */ |
11444 | 11444 | ||
11445 | /* required last entry */ | 11445 | /* required last entry */ |
11446 | {0,} | 11446 | {0,} |
diff --git a/drivers/net/wireless/ipw2x00/libipw_tx.c b/drivers/net/wireless/ipw2x00/libipw_tx.c index da2ad5437ce5..2e8f84fb29fa 100644 --- a/drivers/net/wireless/ipw2x00/libipw_tx.c +++ b/drivers/net/wireless/ipw2x00/libipw_tx.c | |||
@@ -527,13 +527,13 @@ int ieee80211_xmit(struct sk_buff *skb, struct net_device *dev) | |||
527 | if (ret == 0) { | 527 | if (ret == 0) { |
528 | dev->stats.tx_packets++; | 528 | dev->stats.tx_packets++; |
529 | dev->stats.tx_bytes += txb->payload_size; | 529 | dev->stats.tx_bytes += txb->payload_size; |
530 | return 0; | 530 | return NETDEV_TX_OK; |
531 | } | 531 | } |
532 | 532 | ||
533 | ieee80211_txb_free(txb); | 533 | ieee80211_txb_free(txb); |
534 | } | 534 | } |
535 | 535 | ||
536 | return 0; | 536 | return NETDEV_TX_OK; |
537 | 537 | ||
538 | failed: | 538 | failed: |
539 | spin_unlock_irqrestore(&ieee->lock, flags); | 539 | spin_unlock_irqrestore(&ieee->lock, flags); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-3945.c b/drivers/net/wireless/iwlwifi/iwl-3945.c index 46288e724889..b0246dbda99a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-3945.c +++ b/drivers/net/wireless/iwlwifi/iwl-3945.c | |||
@@ -577,7 +577,8 @@ static void iwl3945_pass_packet_to_mac80211(struct iwl_priv *priv, | |||
577 | if (ieee80211_is_data(hdr->frame_control)) | 577 | if (ieee80211_is_data(hdr->frame_control)) |
578 | priv->rxtxpackets += len; | 578 | priv->rxtxpackets += len; |
579 | #endif | 579 | #endif |
580 | ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats); | 580 | memcpy(IEEE80211_SKB_RXCB(rxb->skb), stats, sizeof(*stats)); |
581 | ieee80211_rx_irqsafe(priv->hw, rxb->skb); | ||
581 | rxb->skb = NULL; | 582 | rxb->skb = NULL; |
582 | } | 583 | } |
583 | 584 | ||
@@ -1986,7 +1987,7 @@ static int iwl3945_commit_rxon(struct iwl_priv *priv) | |||
1986 | staging_rxon->reserved4 = 0; | 1987 | staging_rxon->reserved4 = 0; |
1987 | staging_rxon->reserved5 = 0; | 1988 | staging_rxon->reserved5 = 0; |
1988 | 1989 | ||
1989 | iwl_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto); | 1990 | iwl_set_rxon_hwcrypto(priv, !iwl3945_mod_params.sw_crypto); |
1990 | 1991 | ||
1991 | /* Apply the new configuration */ | 1992 | /* Apply the new configuration */ |
1992 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, | 1993 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON, |
@@ -2562,6 +2563,7 @@ int iwl3945_hw_set_hw_params(struct iwl_priv *priv) | |||
2562 | priv->hw_params.bcast_sta_id = IWL3945_BROADCAST_ID; | 2563 | priv->hw_params.bcast_sta_id = IWL3945_BROADCAST_ID; |
2563 | 2564 | ||
2564 | priv->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; | 2565 | priv->hw_params.rx_wrt_ptr_reg = FH39_RSCSR_CHNL0_WPTR; |
2566 | priv->hw_params.max_beacon_itrvl = IWL39_MAX_UCODE_BEACON_INTERVAL; | ||
2565 | 2567 | ||
2566 | return 0; | 2568 | return 0; |
2567 | } | 2569 | } |
diff --git a/drivers/net/wireless/iwlwifi/iwl-4965.c b/drivers/net/wireless/iwlwifi/iwl-4965.c index 8f3d4bc6a03f..edbb0bfd8cb7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-4965.c +++ b/drivers/net/wireless/iwlwifi/iwl-4965.c | |||
@@ -728,7 +728,7 @@ static int iwl4965_alive_notify(struct iwl_priv *priv) | |||
728 | 728 | ||
729 | static struct iwl_sensitivity_ranges iwl4965_sensitivity = { | 729 | static struct iwl_sensitivity_ranges iwl4965_sensitivity = { |
730 | .min_nrg_cck = 97, | 730 | .min_nrg_cck = 97, |
731 | .max_nrg_cck = 0, | 731 | .max_nrg_cck = 0, /* not used, set to 0 */ |
732 | 732 | ||
733 | .auto_corr_min_ofdm = 85, | 733 | .auto_corr_min_ofdm = 85, |
734 | .auto_corr_min_ofdm_mrc = 170, | 734 | .auto_corr_min_ofdm_mrc = 170, |
diff --git a/drivers/net/wireless/iwlwifi/iwl-5000.c b/drivers/net/wireless/iwlwifi/iwl-5000.c index b3c648ce8c7b..85e8bac499a7 100644 --- a/drivers/net/wireless/iwlwifi/iwl-5000.c +++ b/drivers/net/wireless/iwlwifi/iwl-5000.c | |||
@@ -388,7 +388,7 @@ void iwl5000_rts_tx_cmd_flag(struct ieee80211_tx_info *info, | |||
388 | 388 | ||
389 | static struct iwl_sensitivity_ranges iwl5000_sensitivity = { | 389 | static struct iwl_sensitivity_ranges iwl5000_sensitivity = { |
390 | .min_nrg_cck = 95, | 390 | .min_nrg_cck = 95, |
391 | .max_nrg_cck = 0, | 391 | .max_nrg_cck = 0, /* not used, set to 0 */ |
392 | .auto_corr_min_ofdm = 90, | 392 | .auto_corr_min_ofdm = 90, |
393 | .auto_corr_min_ofdm_mrc = 170, | 393 | .auto_corr_min_ofdm_mrc = 170, |
394 | .auto_corr_min_ofdm_x1 = 120, | 394 | .auto_corr_min_ofdm_x1 = 120, |
@@ -407,6 +407,28 @@ static struct iwl_sensitivity_ranges iwl5000_sensitivity = { | |||
407 | .nrg_th_ofdm = 95, | 407 | .nrg_th_ofdm = 95, |
408 | }; | 408 | }; |
409 | 409 | ||
410 | static struct iwl_sensitivity_ranges iwl5150_sensitivity = { | ||
411 | .min_nrg_cck = 95, | ||
412 | .max_nrg_cck = 0, /* not used, set to 0 */ | ||
413 | .auto_corr_min_ofdm = 90, | ||
414 | .auto_corr_min_ofdm_mrc = 170, | ||
415 | .auto_corr_min_ofdm_x1 = 105, | ||
416 | .auto_corr_min_ofdm_mrc_x1 = 220, | ||
417 | |||
418 | .auto_corr_max_ofdm = 120, | ||
419 | .auto_corr_max_ofdm_mrc = 210, | ||
420 | /* max = min for performance bug in 5150 DSP */ | ||
421 | .auto_corr_max_ofdm_x1 = 105, | ||
422 | .auto_corr_max_ofdm_mrc_x1 = 220, | ||
423 | |||
424 | .auto_corr_min_cck = 125, | ||
425 | .auto_corr_max_cck = 200, | ||
426 | .auto_corr_min_cck_mrc = 170, | ||
427 | .auto_corr_max_cck_mrc = 400, | ||
428 | .nrg_th_cck = 95, | ||
429 | .nrg_th_ofdm = 95, | ||
430 | }; | ||
431 | |||
410 | static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv, | 432 | static const u8 *iwl5000_eeprom_query_addr(const struct iwl_priv *priv, |
411 | size_t offset) | 433 | size_t offset) |
412 | { | 434 | { |
@@ -826,8 +848,6 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) | |||
826 | BIT(IEEE80211_BAND_5GHZ); | 848 | BIT(IEEE80211_BAND_5GHZ); |
827 | priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; | 849 | priv->hw_params.rx_wrt_ptr_reg = FH_RSCSR_CHNL0_WPTR; |
828 | 850 | ||
829 | priv->hw_params.sens = &iwl5000_sensitivity; | ||
830 | |||
831 | priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant); | 851 | priv->hw_params.tx_chains_num = num_of_ant(priv->cfg->valid_tx_ant); |
832 | priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant); | 852 | priv->hw_params.rx_chains_num = num_of_ant(priv->cfg->valid_rx_ant); |
833 | priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant; | 853 | priv->hw_params.valid_tx_ant = priv->cfg->valid_tx_ant; |
@@ -836,9 +856,11 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) | |||
836 | if (priv->cfg->ops->lib->temp_ops.set_ct_kill) | 856 | if (priv->cfg->ops->lib->temp_ops.set_ct_kill) |
837 | priv->cfg->ops->lib->temp_ops.set_ct_kill(priv); | 857 | priv->cfg->ops->lib->temp_ops.set_ct_kill(priv); |
838 | 858 | ||
859 | /* Set initial sensitivity parameters */ | ||
839 | /* Set initial calibration set */ | 860 | /* Set initial calibration set */ |
840 | switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { | 861 | switch (priv->hw_rev & CSR_HW_REV_TYPE_MSK) { |
841 | case CSR_HW_REV_TYPE_5150: | 862 | case CSR_HW_REV_TYPE_5150: |
863 | priv->hw_params.sens = &iwl5150_sensitivity; | ||
842 | priv->hw_params.calib_init_cfg = | 864 | priv->hw_params.calib_init_cfg = |
843 | BIT(IWL_CALIB_DC) | | 865 | BIT(IWL_CALIB_DC) | |
844 | BIT(IWL_CALIB_LO) | | 866 | BIT(IWL_CALIB_LO) | |
@@ -847,6 +869,7 @@ static int iwl5000_hw_set_hw_params(struct iwl_priv *priv) | |||
847 | 869 | ||
848 | break; | 870 | break; |
849 | default: | 871 | default: |
872 | priv->hw_params.sens = &iwl5000_sensitivity; | ||
850 | priv->hw_params.calib_init_cfg = | 873 | priv->hw_params.calib_init_cfg = |
851 | BIT(IWL_CALIB_XTAL) | | 874 | BIT(IWL_CALIB_XTAL) | |
852 | BIT(IWL_CALIB_LO) | | 875 | BIT(IWL_CALIB_LO) | |
diff --git a/drivers/net/wireless/iwlwifi/iwl-agn.c b/drivers/net/wireless/iwlwifi/iwl-agn.c index 6d1519e1f011..1d4e9cadb088 100644 --- a/drivers/net/wireless/iwlwifi/iwl-agn.c +++ b/drivers/net/wireless/iwlwifi/iwl-agn.c | |||
@@ -171,7 +171,7 @@ int iwl_commit_rxon(struct iwl_priv *priv) | |||
171 | le16_to_cpu(priv->staging_rxon.channel), | 171 | le16_to_cpu(priv->staging_rxon.channel), |
172 | priv->staging_rxon.bssid_addr); | 172 | priv->staging_rxon.bssid_addr); |
173 | 173 | ||
174 | iwl_set_rxon_hwcrypto(priv, !priv->hw_params.sw_crypto); | 174 | iwl_set_rxon_hwcrypto(priv, !priv->cfg->mod_params->sw_crypto); |
175 | 175 | ||
176 | /* Apply the new configuration | 176 | /* Apply the new configuration |
177 | * RXON unassoc clears the station table in uCode, send it before | 177 | * RXON unassoc clears the station table in uCode, send it before |
@@ -512,70 +512,6 @@ int iwl_hw_tx_queue_init(struct iwl_priv *priv, | |||
512 | return 0; | 512 | return 0; |
513 | } | 513 | } |
514 | 514 | ||
515 | |||
516 | /****************************************************************************** | ||
517 | * | ||
518 | * Misc. internal state and helper functions | ||
519 | * | ||
520 | ******************************************************************************/ | ||
521 | |||
522 | #define MAX_UCODE_BEACON_INTERVAL 4096 | ||
523 | |||
524 | static u16 iwl_adjust_beacon_interval(u16 beacon_val) | ||
525 | { | ||
526 | u16 new_val = 0; | ||
527 | u16 beacon_factor = 0; | ||
528 | |||
529 | beacon_factor = (beacon_val + MAX_UCODE_BEACON_INTERVAL) | ||
530 | / MAX_UCODE_BEACON_INTERVAL; | ||
531 | new_val = beacon_val / beacon_factor; | ||
532 | |||
533 | if (!new_val) | ||
534 | new_val = MAX_UCODE_BEACON_INTERVAL; | ||
535 | |||
536 | return new_val; | ||
537 | } | ||
538 | |||
539 | static void iwl_setup_rxon_timing(struct iwl_priv *priv) | ||
540 | { | ||
541 | u64 tsf; | ||
542 | s32 interval_tm, rem; | ||
543 | unsigned long flags; | ||
544 | struct ieee80211_conf *conf = NULL; | ||
545 | u16 beacon_int = 0; | ||
546 | |||
547 | conf = ieee80211_get_hw_conf(priv->hw); | ||
548 | |||
549 | spin_lock_irqsave(&priv->lock, flags); | ||
550 | priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp); | ||
551 | priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval); | ||
552 | |||
553 | if (priv->iw_mode == NL80211_IFTYPE_STATION) { | ||
554 | beacon_int = iwl_adjust_beacon_interval(priv->beacon_int); | ||
555 | priv->rxon_timing.atim_window = 0; | ||
556 | } else { | ||
557 | beacon_int = iwl_adjust_beacon_interval( | ||
558 | priv->vif->bss_conf.beacon_int); | ||
559 | |||
560 | /* TODO: we need to get atim_window from upper stack | ||
561 | * for now we set to 0 */ | ||
562 | priv->rxon_timing.atim_window = 0; | ||
563 | } | ||
564 | |||
565 | priv->rxon_timing.beacon_interval = cpu_to_le16(beacon_int); | ||
566 | |||
567 | tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ | ||
568 | interval_tm = beacon_int * 1024; | ||
569 | rem = do_div(tsf, interval_tm); | ||
570 | priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem); | ||
571 | |||
572 | spin_unlock_irqrestore(&priv->lock, flags); | ||
573 | IWL_DEBUG_ASSOC(priv, "beacon interval %d beacon timer %d beacon tim %d\n", | ||
574 | le16_to_cpu(priv->rxon_timing.beacon_interval), | ||
575 | le32_to_cpu(priv->rxon_timing.beacon_init_val), | ||
576 | le16_to_cpu(priv->rxon_timing.atim_window)); | ||
577 | } | ||
578 | |||
579 | /****************************************************************************** | 515 | /****************************************************************************** |
580 | * | 516 | * |
581 | * Generic RX handler implementations | 517 | * Generic RX handler implementations |
@@ -1812,6 +1748,11 @@ static int iwl_prepare_card_hw(struct iwl_priv *priv) | |||
1812 | 1748 | ||
1813 | IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter \n"); | 1749 | IWL_DEBUG_INFO(priv, "iwl_prepare_card_hw enter \n"); |
1814 | 1750 | ||
1751 | ret = iwl_set_hw_ready(priv); | ||
1752 | if (priv->hw_ready) | ||
1753 | return ret; | ||
1754 | |||
1755 | /* If HW is not ready, prepare the conditions to check again */ | ||
1815 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, | 1756 | iwl_set_bit(priv, CSR_HW_IF_CONFIG_REG, |
1816 | CSR_HW_IF_CONFIG_REG_PREPARE); | 1757 | CSR_HW_IF_CONFIG_REG_PREPARE); |
1817 | 1758 | ||
@@ -1819,6 +1760,7 @@ static int iwl_prepare_card_hw(struct iwl_priv *priv) | |||
1819 | ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, | 1760 | ~CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, |
1820 | CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); | 1761 | CSR_HW_IF_CONFIG_REG_BIT_NIC_PREPARE_DONE, 150000); |
1821 | 1762 | ||
1763 | /* HW should be ready by now, check again. */ | ||
1822 | if (ret != -ETIMEDOUT) | 1764 | if (ret != -ETIMEDOUT) |
1823 | iwl_set_hw_ready(priv); | 1765 | iwl_set_hw_ready(priv); |
1824 | 1766 | ||
@@ -2331,7 +2273,7 @@ static int iwl_mac_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | |||
2331 | 2273 | ||
2332 | IWL_DEBUG_MAC80211(priv, "enter\n"); | 2274 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
2333 | 2275 | ||
2334 | if (priv->hw_params.sw_crypto) { | 2276 | if (priv->cfg->mod_params->sw_crypto) { |
2335 | IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); | 2277 | IWL_DEBUG_MAC80211(priv, "leave - hwcrypto disabled\n"); |
2336 | return -EOPNOTSUPP; | 2278 | return -EOPNOTSUPP; |
2337 | } | 2279 | } |
diff --git a/drivers/net/wireless/iwlwifi/iwl-calib.c b/drivers/net/wireless/iwlwifi/iwl-calib.c index a5d63672ad39..f8bf592e939c 100644 --- a/drivers/net/wireless/iwlwifi/iwl-calib.c +++ b/drivers/net/wireless/iwlwifi/iwl-calib.c | |||
@@ -251,12 +251,7 @@ static int iwl_sens_energy_cck(struct iwl_priv *priv, | |||
251 | 251 | ||
252 | /* increase energy threshold (reduce nrg value) | 252 | /* increase energy threshold (reduce nrg value) |
253 | * to decrease sensitivity */ | 253 | * to decrease sensitivity */ |
254 | if (data->nrg_th_cck > | 254 | data->nrg_th_cck = data->nrg_th_cck - NRG_STEP_CCK; |
255 | (ranges->max_nrg_cck + NRG_STEP_CCK)) | ||
256 | data->nrg_th_cck = data->nrg_th_cck | ||
257 | - NRG_STEP_CCK; | ||
258 | else | ||
259 | data->nrg_th_cck = ranges->max_nrg_cck; | ||
260 | /* Else if we got fewer than desired, increase sensitivity */ | 255 | /* Else if we got fewer than desired, increase sensitivity */ |
261 | } else if (false_alarms < min_false_alarms) { | 256 | } else if (false_alarms < min_false_alarms) { |
262 | data->nrg_curr_state = IWL_FA_TOO_FEW; | 257 | data->nrg_curr_state = IWL_FA_TOO_FEW; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-commands.h b/drivers/net/wireless/iwlwifi/iwl-commands.h index c87033bf3ad2..ebb2fbce5365 100644 --- a/drivers/net/wireless/iwlwifi/iwl-commands.h +++ b/drivers/net/wireless/iwlwifi/iwl-commands.h | |||
@@ -765,6 +765,8 @@ struct iwl5000_rxon_assoc_cmd { | |||
765 | } __attribute__ ((packed)); | 765 | } __attribute__ ((packed)); |
766 | 766 | ||
767 | #define IWL_CONN_MAX_LISTEN_INTERVAL 10 | 767 | #define IWL_CONN_MAX_LISTEN_INTERVAL 10 |
768 | #define IWL_MAX_UCODE_BEACON_INTERVAL 4 /* 4096 */ | ||
769 | #define IWL39_MAX_UCODE_BEACON_INTERVAL 1 /* 1024 */ | ||
768 | 770 | ||
769 | /* | 771 | /* |
770 | * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) | 772 | * REPLY_RXON_TIMING = 0x14 (command, has simple generic response) |
@@ -1922,7 +1924,7 @@ struct iwl_link_qual_general_params { | |||
1922 | #define LINK_QUAL_AGG_DISABLE_START_MIN (0) | 1924 | #define LINK_QUAL_AGG_DISABLE_START_MIN (0) |
1923 | 1925 | ||
1924 | #define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31) | 1926 | #define LINK_QUAL_AGG_FRAME_LIMIT_DEF (31) |
1925 | #define LINK_QUAL_AGG_FRAME_LIMIT_MAX (64) | 1927 | #define LINK_QUAL_AGG_FRAME_LIMIT_MAX (63) |
1926 | #define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0) | 1928 | #define LINK_QUAL_AGG_FRAME_LIMIT_MIN (0) |
1927 | 1929 | ||
1928 | /** | 1930 | /** |
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.c b/drivers/net/wireless/iwlwifi/iwl-core.c index 6ab07165ea28..d5cd9a20edca 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.c +++ b/drivers/net/wireless/iwlwifi/iwl-core.c | |||
@@ -635,6 +635,63 @@ u8 iwl_is_fat_tx_allowed(struct iwl_priv *priv, | |||
635 | } | 635 | } |
636 | EXPORT_SYMBOL(iwl_is_fat_tx_allowed); | 636 | EXPORT_SYMBOL(iwl_is_fat_tx_allowed); |
637 | 637 | ||
638 | static u16 iwl_adjust_beacon_interval(u16 beacon_val, u16 max_beacon_val) | ||
639 | { | ||
640 | u16 new_val = 0; | ||
641 | u16 beacon_factor = 0; | ||
642 | |||
643 | beacon_factor = (beacon_val + max_beacon_val) / max_beacon_val; | ||
644 | new_val = beacon_val / beacon_factor; | ||
645 | |||
646 | if (!new_val) | ||
647 | new_val = max_beacon_val; | ||
648 | |||
649 | return new_val; | ||
650 | } | ||
651 | |||
652 | void iwl_setup_rxon_timing(struct iwl_priv *priv) | ||
653 | { | ||
654 | u64 tsf; | ||
655 | s32 interval_tm, rem; | ||
656 | unsigned long flags; | ||
657 | struct ieee80211_conf *conf = NULL; | ||
658 | u16 beacon_int; | ||
659 | |||
660 | conf = ieee80211_get_hw_conf(priv->hw); | ||
661 | |||
662 | spin_lock_irqsave(&priv->lock, flags); | ||
663 | priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp); | ||
664 | priv->rxon_timing.listen_interval = cpu_to_le16(conf->listen_interval); | ||
665 | |||
666 | if (priv->iw_mode == NL80211_IFTYPE_STATION) { | ||
667 | beacon_int = priv->beacon_int; | ||
668 | priv->rxon_timing.atim_window = 0; | ||
669 | } else { | ||
670 | beacon_int = priv->vif->bss_conf.beacon_int; | ||
671 | |||
672 | /* TODO: we need to get atim_window from upper stack | ||
673 | * for now we set to 0 */ | ||
674 | priv->rxon_timing.atim_window = 0; | ||
675 | } | ||
676 | |||
677 | beacon_int = iwl_adjust_beacon_interval(beacon_int, | ||
678 | priv->hw_params.max_beacon_itrvl * 1024); | ||
679 | priv->rxon_timing.beacon_interval = cpu_to_le16(beacon_int); | ||
680 | |||
681 | tsf = priv->timestamp; /* tsf is modifed by do_div: copy it */ | ||
682 | interval_tm = beacon_int * 1024; | ||
683 | rem = do_div(tsf, interval_tm); | ||
684 | priv->rxon_timing.beacon_init_val = cpu_to_le32(interval_tm - rem); | ||
685 | |||
686 | spin_unlock_irqrestore(&priv->lock, flags); | ||
687 | IWL_DEBUG_ASSOC(priv, | ||
688 | "beacon interval %d beacon timer %d beacon tim %d\n", | ||
689 | le16_to_cpu(priv->rxon_timing.beacon_interval), | ||
690 | le32_to_cpu(priv->rxon_timing.beacon_init_val), | ||
691 | le16_to_cpu(priv->rxon_timing.atim_window)); | ||
692 | } | ||
693 | EXPORT_SYMBOL(iwl_setup_rxon_timing); | ||
694 | |||
638 | void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) | 695 | void iwl_set_rxon_hwcrypto(struct iwl_priv *priv, int hw_decrypt) |
639 | { | 696 | { |
640 | struct iwl_rxon_cmd *rxon = &priv->staging_rxon; | 697 | struct iwl_rxon_cmd *rxon = &priv->staging_rxon; |
@@ -1325,7 +1382,8 @@ int iwl_setup_mac(struct iwl_priv *priv) | |||
1325 | hw->flags = IEEE80211_HW_SIGNAL_DBM | | 1382 | hw->flags = IEEE80211_HW_SIGNAL_DBM | |
1326 | IEEE80211_HW_NOISE_DBM | | 1383 | IEEE80211_HW_NOISE_DBM | |
1327 | IEEE80211_HW_AMPDU_AGGREGATION | | 1384 | IEEE80211_HW_AMPDU_AGGREGATION | |
1328 | IEEE80211_HW_SPECTRUM_MGMT; | 1385 | IEEE80211_HW_SPECTRUM_MGMT | |
1386 | IEEE80211_HW_SUPPORTS_PS; | ||
1329 | hw->wiphy->interface_modes = | 1387 | hw->wiphy->interface_modes = |
1330 | BIT(NL80211_IFTYPE_STATION) | | 1388 | BIT(NL80211_IFTYPE_STATION) | |
1331 | BIT(NL80211_IFTYPE_ADHOC); | 1389 | BIT(NL80211_IFTYPE_ADHOC); |
@@ -1361,7 +1419,6 @@ EXPORT_SYMBOL(iwl_setup_mac); | |||
1361 | 1419 | ||
1362 | int iwl_set_hw_params(struct iwl_priv *priv) | 1420 | int iwl_set_hw_params(struct iwl_priv *priv) |
1363 | { | 1421 | { |
1364 | priv->hw_params.sw_crypto = priv->cfg->mod_params->sw_crypto; | ||
1365 | priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; | 1422 | priv->hw_params.max_rxq_size = RX_QUEUE_SIZE; |
1366 | priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; | 1423 | priv->hw_params.max_rxq_log = RX_QUEUE_SIZE_LOG; |
1367 | if (priv->cfg->mod_params->amsdu_size_8K) | 1424 | if (priv->cfg->mod_params->amsdu_size_8K) |
@@ -1370,6 +1427,8 @@ int iwl_set_hw_params(struct iwl_priv *priv) | |||
1370 | priv->hw_params.rx_buf_size = IWL_RX_BUF_SIZE_4K; | 1427 | priv->hw_params.rx_buf_size = IWL_RX_BUF_SIZE_4K; |
1371 | priv->hw_params.max_pkt_size = priv->hw_params.rx_buf_size - 256; | 1428 | priv->hw_params.max_pkt_size = priv->hw_params.rx_buf_size - 256; |
1372 | 1429 | ||
1430 | priv->hw_params.max_beacon_itrvl = IWL_MAX_UCODE_BEACON_INTERVAL; | ||
1431 | |||
1373 | if (priv->cfg->mod_params->disable_11n) | 1432 | if (priv->cfg->mod_params->disable_11n) |
1374 | priv->cfg->sku &= ~IWL_SKU_N; | 1433 | priv->cfg->sku &= ~IWL_SKU_N; |
1375 | 1434 | ||
diff --git a/drivers/net/wireless/iwlwifi/iwl-core.h b/drivers/net/wireless/iwlwifi/iwl-core.h index dabf663e36e5..a658410e66a4 100644 --- a/drivers/net/wireless/iwlwifi/iwl-core.h +++ b/drivers/net/wireless/iwlwifi/iwl-core.h | |||
@@ -384,7 +384,6 @@ static inline __le32 iwl_hw_set_rate_n_flags(u8 rate, u32 flags) | |||
384 | void iwl_init_scan_params(struct iwl_priv *priv); | 384 | void iwl_init_scan_params(struct iwl_priv *priv); |
385 | int iwl_scan_cancel(struct iwl_priv *priv); | 385 | int iwl_scan_cancel(struct iwl_priv *priv); |
386 | int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); | 386 | int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms); |
387 | int iwl_scan_initiate(struct iwl_priv *priv); | ||
388 | int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); | 387 | int iwl_mac_hw_scan(struct ieee80211_hw *hw, struct cfg80211_scan_request *req); |
389 | u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, | 388 | u16 iwl_fill_probe_req(struct iwl_priv *priv, struct ieee80211_mgmt *frame, |
390 | const u8 *ie, int ie_len, int left); | 389 | const u8 *ie, int ie_len, int left); |
@@ -398,7 +397,6 @@ void iwl_bg_scan_check(struct work_struct *data); | |||
398 | void iwl_bg_abort_scan(struct work_struct *work); | 397 | void iwl_bg_abort_scan(struct work_struct *work); |
399 | void iwl_bg_scan_completed(struct work_struct *work); | 398 | void iwl_bg_scan_completed(struct work_struct *work); |
400 | void iwl_setup_scan_deferred_work(struct iwl_priv *priv); | 399 | void iwl_setup_scan_deferred_work(struct iwl_priv *priv); |
401 | int iwl_send_scan_abort(struct iwl_priv *priv); | ||
402 | 400 | ||
403 | /* For faster active scanning, scan will move to the next channel if fewer than | 401 | /* For faster active scanning, scan will move to the next channel if fewer than |
404 | * PLCP_QUIET_THRESH packets are heard on this channel within | 402 | * PLCP_QUIET_THRESH packets are heard on this channel within |
@@ -556,6 +554,7 @@ extern void iwl_rx_reply_rx_phy(struct iwl_priv *priv, | |||
556 | void iwl_rx_reply_compressed_ba(struct iwl_priv *priv, | 554 | void iwl_rx_reply_compressed_ba(struct iwl_priv *priv, |
557 | struct iwl_rx_mem_buffer *rxb); | 555 | struct iwl_rx_mem_buffer *rxb); |
558 | 556 | ||
557 | void iwl_setup_rxon_timing(struct iwl_priv *priv); | ||
559 | static inline int iwl_send_rxon_assoc(struct iwl_priv *priv) | 558 | static inline int iwl_send_rxon_assoc(struct iwl_priv *priv) |
560 | { | 559 | { |
561 | return priv->cfg->ops->hcmd->rxon_assoc(priv); | 560 | return priv->cfg->ops->hcmd->rxon_assoc(priv); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-debug.h b/drivers/net/wireless/iwlwifi/iwl-debug.h index 2cf014f523be..65bbce0f1717 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debug.h +++ b/drivers/net/wireless/iwlwifi/iwl-debug.h | |||
@@ -36,6 +36,12 @@ struct iwl_priv; | |||
36 | #define IWL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) | 36 | #define IWL_INFO(p, f, a...) dev_info(&((p)->pci_dev->dev), f, ## a) |
37 | #define IWL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) | 37 | #define IWL_CRIT(p, f, a...) dev_crit(&((p)->pci_dev->dev), f, ## a) |
38 | 38 | ||
39 | #define iwl_print_hex_error(priv, p, len) \ | ||
40 | do { \ | ||
41 | print_hex_dump(KERN_ERR, "iwl data: ", \ | ||
42 | DUMP_PREFIX_OFFSET, 16, 1, p, len, 1); \ | ||
43 | } while (0) | ||
44 | |||
39 | #ifdef CONFIG_IWLWIFI_DEBUG | 45 | #ifdef CONFIG_IWLWIFI_DEBUG |
40 | #define IWL_DEBUG(__priv, level, fmt, args...) \ | 46 | #define IWL_DEBUG(__priv, level, fmt, args...) \ |
41 | do { \ | 47 | do { \ |
diff --git a/drivers/net/wireless/iwlwifi/iwl-debugfs.c b/drivers/net/wireless/iwlwifi/iwl-debugfs.c index 11e08c068917..f32ac74b69ac 100644 --- a/drivers/net/wireless/iwlwifi/iwl-debugfs.c +++ b/drivers/net/wireless/iwlwifi/iwl-debugfs.c | |||
@@ -615,7 +615,10 @@ int iwl_dbgfs_register(struct iwl_priv *priv, const char *name) | |||
615 | DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); | 615 | DEBUGFS_ADD_BOOL(disable_sensitivity, rf, &priv->disable_sens_cal); |
616 | DEBUGFS_ADD_BOOL(disable_chain_noise, rf, | 616 | DEBUGFS_ADD_BOOL(disable_chain_noise, rf, |
617 | &priv->disable_chain_noise_cal); | 617 | &priv->disable_chain_noise_cal); |
618 | DEBUGFS_ADD_BOOL(disable_tx_power, rf, &priv->disable_tx_power_cal); | 618 | if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) || |
619 | ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945)) | ||
620 | DEBUGFS_ADD_BOOL(disable_tx_power, rf, | ||
621 | &priv->disable_tx_power_cal); | ||
619 | return 0; | 622 | return 0; |
620 | 623 | ||
621 | err: | 624 | err: |
@@ -646,7 +649,9 @@ void iwl_dbgfs_unregister(struct iwl_priv *priv) | |||
646 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); | 649 | DEBUGFS_REMOVE(priv->dbgfs->dir_data); |
647 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); | 650 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_sensitivity); |
648 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); | 651 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_chain_noise); |
649 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power); | 652 | if (((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_4965) || |
653 | ((priv->hw_rev & CSR_HW_REV_TYPE_MSK) == CSR_HW_REV_TYPE_3945)) | ||
654 | DEBUGFS_REMOVE(priv->dbgfs->dbgfs_rf_files.file_disable_tx_power); | ||
650 | DEBUGFS_REMOVE(priv->dbgfs->dir_rf); | 655 | DEBUGFS_REMOVE(priv->dbgfs->dir_rf); |
651 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); | 656 | DEBUGFS_REMOVE(priv->dbgfs->dir_drv); |
652 | kfree(priv->dbgfs); | 657 | kfree(priv->dbgfs); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-dev.h b/drivers/net/wireless/iwlwifi/iwl-dev.h index e2d620f0b6e8..1a2fe37d4735 100644 --- a/drivers/net/wireless/iwlwifi/iwl-dev.h +++ b/drivers/net/wireless/iwlwifi/iwl-dev.h | |||
@@ -608,7 +608,7 @@ struct iwl_hw_params { | |||
608 | u8 max_stations; | 608 | u8 max_stations; |
609 | u8 bcast_sta_id; | 609 | u8 bcast_sta_id; |
610 | u8 fat_channel; | 610 | u8 fat_channel; |
611 | u8 sw_crypto; | 611 | u8 max_beacon_itrvl; /* in 1024 ms */ |
612 | u32 max_inst_size; | 612 | u32 max_inst_size; |
613 | u32 max_data_size; | 613 | u32 max_data_size; |
614 | u32 max_bsm_size; | 614 | u32 max_bsm_size; |
diff --git a/drivers/net/wireless/iwlwifi/iwl-rx.c b/drivers/net/wireless/iwlwifi/iwl-rx.c index 2b8d40b37a1c..66fe365dd08a 100644 --- a/drivers/net/wireless/iwlwifi/iwl-rx.c +++ b/drivers/net/wireless/iwlwifi/iwl-rx.c | |||
@@ -927,12 +927,13 @@ static void iwl_pass_packet_to_mac80211(struct iwl_priv *priv, | |||
927 | hdr = (struct ieee80211_hdr *)rxb->skb->data; | 927 | hdr = (struct ieee80211_hdr *)rxb->skb->data; |
928 | 928 | ||
929 | /* in case of HW accelerated crypto and bad decryption, drop */ | 929 | /* in case of HW accelerated crypto and bad decryption, drop */ |
930 | if (!priv->hw_params.sw_crypto && | 930 | if (!priv->cfg->mod_params->sw_crypto && |
931 | iwl_set_decrypted_flag(priv, hdr, ampdu_status, stats)) | 931 | iwl_set_decrypted_flag(priv, hdr, ampdu_status, stats)) |
932 | return; | 932 | return; |
933 | 933 | ||
934 | iwl_update_rx_stats(priv, le16_to_cpu(hdr->frame_control), len); | 934 | iwl_update_rx_stats(priv, le16_to_cpu(hdr->frame_control), len); |
935 | ieee80211_rx_irqsafe(priv->hw, rxb->skb, stats); | 935 | memcpy(IEEE80211_SKB_RXCB(rxb->skb), stats, sizeof(*stats)); |
936 | ieee80211_rx_irqsafe(priv->hw, rxb->skb); | ||
936 | priv->alloc_rxb_skb--; | 937 | priv->alloc_rxb_skb--; |
937 | rxb->skb = NULL; | 938 | rxb->skb = NULL; |
938 | } | 939 | } |
diff --git a/drivers/net/wireless/iwlwifi/iwl-scan.c b/drivers/net/wireless/iwlwifi/iwl-scan.c index e26875dbe859..00398d973a07 100644 --- a/drivers/net/wireless/iwlwifi/iwl-scan.c +++ b/drivers/net/wireless/iwlwifi/iwl-scan.c | |||
@@ -109,7 +109,7 @@ int iwl_scan_cancel_timeout(struct iwl_priv *priv, unsigned long ms) | |||
109 | } | 109 | } |
110 | EXPORT_SYMBOL(iwl_scan_cancel_timeout); | 110 | EXPORT_SYMBOL(iwl_scan_cancel_timeout); |
111 | 111 | ||
112 | int iwl_send_scan_abort(struct iwl_priv *priv) | 112 | static int iwl_send_scan_abort(struct iwl_priv *priv) |
113 | { | 113 | { |
114 | int ret = 0; | 114 | int ret = 0; |
115 | struct iwl_rx_packet *res; | 115 | struct iwl_rx_packet *res; |
@@ -150,7 +150,6 @@ int iwl_send_scan_abort(struct iwl_priv *priv) | |||
150 | 150 | ||
151 | return ret; | 151 | return ret; |
152 | } | 152 | } |
153 | EXPORT_SYMBOL(iwl_send_scan_abort); | ||
154 | 153 | ||
155 | /* Service response to REPLY_SCAN_CMD (0x80) */ | 154 | /* Service response to REPLY_SCAN_CMD (0x80) */ |
156 | static void iwl_rx_reply_scan(struct iwl_priv *priv, | 155 | static void iwl_rx_reply_scan(struct iwl_priv *priv, |
@@ -322,7 +321,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv, | |||
322 | u8 is_active, u8 n_probes, | 321 | u8 is_active, u8 n_probes, |
323 | struct iwl_scan_channel *scan_ch) | 322 | struct iwl_scan_channel *scan_ch) |
324 | { | 323 | { |
325 | const struct ieee80211_channel *channels = NULL; | 324 | struct ieee80211_channel *chan; |
326 | const struct ieee80211_supported_band *sband; | 325 | const struct ieee80211_supported_band *sband; |
327 | const struct iwl_channel_info *ch_info; | 326 | const struct iwl_channel_info *ch_info; |
328 | u16 passive_dwell = 0; | 327 | u16 passive_dwell = 0; |
@@ -334,20 +333,19 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv, | |||
334 | if (!sband) | 333 | if (!sband) |
335 | return 0; | 334 | return 0; |
336 | 335 | ||
337 | channels = sband->channels; | ||
338 | |||
339 | active_dwell = iwl_get_active_dwell_time(priv, band, n_probes); | 336 | active_dwell = iwl_get_active_dwell_time(priv, band, n_probes); |
340 | passive_dwell = iwl_get_passive_dwell_time(priv, band); | 337 | passive_dwell = iwl_get_passive_dwell_time(priv, band); |
341 | 338 | ||
342 | if (passive_dwell <= active_dwell) | 339 | if (passive_dwell <= active_dwell) |
343 | passive_dwell = active_dwell + 1; | 340 | passive_dwell = active_dwell + 1; |
344 | 341 | ||
345 | for (i = 0, added = 0; i < sband->n_channels; i++) { | 342 | for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) { |
346 | if (channels[i].flags & IEEE80211_CHAN_DISABLED) | 343 | chan = priv->scan_request->channels[i]; |
344 | |||
345 | if (chan->band != band) | ||
347 | continue; | 346 | continue; |
348 | 347 | ||
349 | channel = | 348 | channel = ieee80211_frequency_to_channel(chan->center_freq); |
350 | ieee80211_frequency_to_channel(channels[i].center_freq); | ||
351 | scan_ch->channel = cpu_to_le16(channel); | 349 | scan_ch->channel = cpu_to_le16(channel); |
352 | 350 | ||
353 | ch_info = iwl_get_channel_info(priv, band, channel); | 351 | ch_info = iwl_get_channel_info(priv, band, channel); |
@@ -358,7 +356,7 @@ static int iwl_get_channels_for_scan(struct iwl_priv *priv, | |||
358 | } | 356 | } |
359 | 357 | ||
360 | if (!is_active || is_channel_passive(ch_info) || | 358 | if (!is_active || is_channel_passive(ch_info) || |
361 | (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) | 359 | (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) |
362 | scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; | 360 | scan_ch->type = SCAN_CHANNEL_TYPE_PASSIVE; |
363 | else | 361 | else |
364 | scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; | 362 | scan_ch->type = SCAN_CHANNEL_TYPE_ACTIVE; |
@@ -405,7 +403,7 @@ void iwl_init_scan_params(struct iwl_priv *priv) | |||
405 | priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; | 403 | priv->scan_tx_ant[IEEE80211_BAND_2GHZ] = ant_idx; |
406 | } | 404 | } |
407 | 405 | ||
408 | int iwl_scan_initiate(struct iwl_priv *priv) | 406 | static int iwl_scan_initiate(struct iwl_priv *priv) |
409 | { | 407 | { |
410 | if (!iwl_is_ready_rf(priv)) { | 408 | if (!iwl_is_ready_rf(priv)) { |
411 | IWL_DEBUG_SCAN(priv, "Aborting scan due to not ready.\n"); | 409 | IWL_DEBUG_SCAN(priv, "Aborting scan due to not ready.\n"); |
@@ -423,10 +421,6 @@ int iwl_scan_initiate(struct iwl_priv *priv) | |||
423 | } | 421 | } |
424 | 422 | ||
425 | IWL_DEBUG_INFO(priv, "Starting scan...\n"); | 423 | IWL_DEBUG_INFO(priv, "Starting scan...\n"); |
426 | if (priv->cfg->sku & IWL_SKU_G) | ||
427 | priv->scan_bands |= BIT(IEEE80211_BAND_2GHZ); | ||
428 | if (priv->cfg->sku & IWL_SKU_A) | ||
429 | priv->scan_bands |= BIT(IEEE80211_BAND_5GHZ); | ||
430 | set_bit(STATUS_SCANNING, &priv->status); | 424 | set_bit(STATUS_SCANNING, &priv->status); |
431 | priv->scan_start = jiffies; | 425 | priv->scan_start = jiffies; |
432 | priv->scan_pass_start = priv->scan_start; | 426 | priv->scan_pass_start = priv->scan_start; |
@@ -435,7 +429,6 @@ int iwl_scan_initiate(struct iwl_priv *priv) | |||
435 | 429 | ||
436 | return 0; | 430 | return 0; |
437 | } | 431 | } |
438 | EXPORT_SYMBOL(iwl_scan_initiate); | ||
439 | 432 | ||
440 | #define IWL_DELAY_NEXT_SCAN (HZ*2) | 433 | #define IWL_DELAY_NEXT_SCAN (HZ*2) |
441 | 434 | ||
@@ -444,7 +437,7 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw, | |||
444 | { | 437 | { |
445 | unsigned long flags; | 438 | unsigned long flags; |
446 | struct iwl_priv *priv = hw->priv; | 439 | struct iwl_priv *priv = hw->priv; |
447 | int ret; | 440 | int ret, i; |
448 | 441 | ||
449 | IWL_DEBUG_MAC80211(priv, "enter\n"); | 442 | IWL_DEBUG_MAC80211(priv, "enter\n"); |
450 | 443 | ||
@@ -478,6 +471,10 @@ int iwl_mac_hw_scan(struct ieee80211_hw *hw, | |||
478 | goto out_unlock; | 471 | goto out_unlock; |
479 | } | 472 | } |
480 | 473 | ||
474 | priv->scan_bands = 0; | ||
475 | for (i = 0; i < req->n_channels; i++) | ||
476 | priv->scan_bands |= BIT(req->channels[i]->band); | ||
477 | |||
481 | priv->scan_request = req; | 478 | priv->scan_request = req; |
482 | 479 | ||
483 | ret = iwl_scan_initiate(priv); | 480 | ret = iwl_scan_initiate(priv); |
diff --git a/drivers/net/wireless/iwlwifi/iwl-tx.c b/drivers/net/wireless/iwlwifi/iwl-tx.c index 85ae7a62109c..753fca32d9df 100644 --- a/drivers/net/wireless/iwlwifi/iwl-tx.c +++ b/drivers/net/wireless/iwlwifi/iwl-tx.c | |||
@@ -348,6 +348,10 @@ int iwl_tx_queue_init(struct iwl_priv *priv, struct iwl_tx_queue *txq, | |||
348 | 348 | ||
349 | txq->need_update = 0; | 349 | txq->need_update = 0; |
350 | 350 | ||
351 | /* aggregation TX queues will get their ID when aggregation begins */ | ||
352 | if (txq_id <= IWL_TX_FIFO_AC3) | ||
353 | txq->swq_id = txq_id; | ||
354 | |||
351 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise | 355 | /* TFD_QUEUE_SIZE_MAX must be power-of-two size, otherwise |
352 | * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */ | 356 | * iwl_queue_inc_wrap and iwl_queue_dec_wrap are broken. */ |
353 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); | 357 | BUILD_BUG_ON(TFD_QUEUE_SIZE_MAX & (TFD_QUEUE_SIZE_MAX - 1)); |
@@ -734,8 +738,7 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
734 | 738 | ||
735 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); | 739 | IWL_DEBUG_TX(priv, "station Id %d\n", sta_id); |
736 | 740 | ||
737 | swq_id = skb_get_queue_mapping(skb); | 741 | txq_id = skb_get_queue_mapping(skb); |
738 | txq_id = swq_id; | ||
739 | if (ieee80211_is_data_qos(fc)) { | 742 | if (ieee80211_is_data_qos(fc)) { |
740 | qc = ieee80211_get_qos_ctl(hdr); | 743 | qc = ieee80211_get_qos_ctl(hdr); |
741 | tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; | 744 | tid = qc[0] & IEEE80211_QOS_CTL_TID_MASK; |
@@ -746,16 +749,14 @@ int iwl_tx_skb(struct iwl_priv *priv, struct sk_buff *skb) | |||
746 | hdr->seq_ctrl |= cpu_to_le16(seq_number); | 749 | hdr->seq_ctrl |= cpu_to_le16(seq_number); |
747 | seq_number += 0x10; | 750 | seq_number += 0x10; |
748 | /* aggregation is on for this <sta,tid> */ | 751 | /* aggregation is on for this <sta,tid> */ |
749 | if (info->flags & IEEE80211_TX_CTL_AMPDU) { | 752 | if (info->flags & IEEE80211_TX_CTL_AMPDU) |
750 | txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; | 753 | txq_id = priv->stations[sta_id].tid[tid].agg.txq_id; |
751 | swq_id = iwl_virtual_agg_queue_num(swq_id, txq_id); | ||
752 | } | ||
753 | priv->stations[sta_id].tid[tid].tfds_in_queue++; | 754 | priv->stations[sta_id].tid[tid].tfds_in_queue++; |
754 | } | 755 | } |
755 | 756 | ||
756 | txq = &priv->txq[txq_id]; | 757 | txq = &priv->txq[txq_id]; |
758 | swq_id = txq->swq_id; | ||
757 | q = &txq->q; | 759 | q = &txq->q; |
758 | txq->swq_id = swq_id; | ||
759 | 760 | ||
760 | spin_lock_irqsave(&priv->lock, flags); | 761 | spin_lock_irqsave(&priv->lock, flags); |
761 | 762 | ||
@@ -1108,7 +1109,7 @@ void iwl_tx_cmd_complete(struct iwl_priv *priv, struct iwl_rx_mem_buffer *rxb) | |||
1108 | txq_id, sequence, | 1109 | txq_id, sequence, |
1109 | priv->txq[IWL_CMD_QUEUE_NUM].q.read_ptr, | 1110 | priv->txq[IWL_CMD_QUEUE_NUM].q.read_ptr, |
1110 | priv->txq[IWL_CMD_QUEUE_NUM].q.write_ptr)) { | 1111 | priv->txq[IWL_CMD_QUEUE_NUM].q.write_ptr)) { |
1111 | iwl_print_hex_dump(priv, IWL_DL_INFO , rxb, 32); | 1112 | iwl_print_hex_error(priv, rxb, 32); |
1112 | return; | 1113 | return; |
1113 | } | 1114 | } |
1114 | 1115 | ||
@@ -1186,6 +1187,7 @@ int iwl_tx_agg_start(struct iwl_priv *priv, const u8 *ra, u16 tid, u16 *ssn) | |||
1186 | tid_data = &priv->stations[sta_id].tid[tid]; | 1187 | tid_data = &priv->stations[sta_id].tid[tid]; |
1187 | *ssn = SEQ_TO_SN(tid_data->seq_number); | 1188 | *ssn = SEQ_TO_SN(tid_data->seq_number); |
1188 | tid_data->agg.txq_id = txq_id; | 1189 | tid_data->agg.txq_id = txq_id; |
1190 | priv->txq[txq_id].swq_id = iwl_virtual_agg_queue_num(tx_fifo, txq_id); | ||
1189 | spin_unlock_irqrestore(&priv->sta_lock, flags); | 1191 | spin_unlock_irqrestore(&priv->sta_lock, flags); |
1190 | 1192 | ||
1191 | ret = priv->cfg->ops->lib->txq_agg_enable(priv, txq_id, tx_fifo, | 1193 | ret = priv->cfg->ops->lib->txq_agg_enable(priv, txq_id, tx_fifo, |
diff --git a/drivers/net/wireless/iwlwifi/iwl3945-base.c b/drivers/net/wireless/iwlwifi/iwl3945-base.c index cb9bd4c8f25e..303c4b483f5b 100644 --- a/drivers/net/wireless/iwlwifi/iwl3945-base.c +++ b/drivers/net/wireless/iwlwifi/iwl3945-base.c | |||
@@ -361,76 +361,6 @@ static void iwl3945_unset_hw_params(struct iwl_priv *priv) | |||
361 | priv->shared_phys); | 361 | priv->shared_phys); |
362 | } | 362 | } |
363 | 363 | ||
364 | #define MAX_UCODE_BEACON_INTERVAL 1024 | ||
365 | #define INTEL_CONN_LISTEN_INTERVAL cpu_to_le16(0xA) | ||
366 | |||
367 | static __le16 iwl3945_adjust_beacon_interval(u16 beacon_val) | ||
368 | { | ||
369 | u16 new_val = 0; | ||
370 | u16 beacon_factor = 0; | ||
371 | |||
372 | beacon_factor = | ||
373 | (beacon_val + MAX_UCODE_BEACON_INTERVAL) | ||
374 | / MAX_UCODE_BEACON_INTERVAL; | ||
375 | new_val = beacon_val / beacon_factor; | ||
376 | |||
377 | return cpu_to_le16(new_val); | ||
378 | } | ||
379 | |||
380 | static void iwl3945_setup_rxon_timing(struct iwl_priv *priv) | ||
381 | { | ||
382 | u64 interval_tm_unit; | ||
383 | u64 tsf, result; | ||
384 | unsigned long flags; | ||
385 | struct ieee80211_conf *conf = NULL; | ||
386 | u16 beacon_int = 0; | ||
387 | |||
388 | conf = ieee80211_get_hw_conf(priv->hw); | ||
389 | |||
390 | spin_lock_irqsave(&priv->lock, flags); | ||
391 | priv->rxon_timing.timestamp = cpu_to_le64(priv->timestamp); | ||
392 | priv->rxon_timing.listen_interval = INTEL_CONN_LISTEN_INTERVAL; | ||
393 | |||
394 | tsf = priv->timestamp; | ||
395 | |||
396 | beacon_int = priv->beacon_int; | ||
397 | spin_unlock_irqrestore(&priv->lock, flags); | ||
398 | |||
399 | if (priv->iw_mode == NL80211_IFTYPE_STATION) { | ||
400 | if (beacon_int == 0) { | ||
401 | priv->rxon_timing.beacon_interval = cpu_to_le16(100); | ||
402 | priv->rxon_timing.beacon_init_val = cpu_to_le32(102400); | ||
403 | } else { | ||
404 | priv->rxon_timing.beacon_interval = | ||
405 | cpu_to_le16(beacon_int); | ||
406 | priv->rxon_timing.beacon_interval = | ||
407 | iwl3945_adjust_beacon_interval( | ||
408 | le16_to_cpu(priv->rxon_timing.beacon_interval)); | ||
409 | } | ||
410 | |||
411 | priv->rxon_timing.atim_window = 0; | ||
412 | } else { | ||
413 | priv->rxon_timing.beacon_interval = | ||
414 | iwl3945_adjust_beacon_interval( | ||
415 | priv->vif->bss_conf.beacon_int); | ||
416 | /* TODO: we need to get atim_window from upper stack | ||
417 | * for now we set to 0 */ | ||
418 | priv->rxon_timing.atim_window = 0; | ||
419 | } | ||
420 | |||
421 | interval_tm_unit = | ||
422 | (le16_to_cpu(priv->rxon_timing.beacon_interval) * 1024); | ||
423 | result = do_div(tsf, interval_tm_unit); | ||
424 | priv->rxon_timing.beacon_init_val = | ||
425 | cpu_to_le32((u32) ((u64) interval_tm_unit - result)); | ||
426 | |||
427 | IWL_DEBUG_ASSOC(priv, | ||
428 | "beacon interval %d beacon timer %d beacon tim %d\n", | ||
429 | le16_to_cpu(priv->rxon_timing.beacon_interval), | ||
430 | le32_to_cpu(priv->rxon_timing.beacon_init_val), | ||
431 | le16_to_cpu(priv->rxon_timing.atim_window)); | ||
432 | } | ||
433 | |||
434 | static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, | 364 | static void iwl3945_build_tx_cmd_hwcrypto(struct iwl_priv *priv, |
435 | struct ieee80211_tx_info *info, | 365 | struct ieee80211_tx_info *info, |
436 | struct iwl_cmd *cmd, | 366 | struct iwl_cmd *cmd, |
@@ -1844,7 +1774,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, | |||
1844 | u8 is_active, u8 n_probes, | 1774 | u8 is_active, u8 n_probes, |
1845 | struct iwl3945_scan_channel *scan_ch) | 1775 | struct iwl3945_scan_channel *scan_ch) |
1846 | { | 1776 | { |
1847 | const struct ieee80211_channel *channels = NULL; | 1777 | struct ieee80211_channel *chan; |
1848 | const struct ieee80211_supported_band *sband; | 1778 | const struct ieee80211_supported_band *sband; |
1849 | const struct iwl_channel_info *ch_info; | 1779 | const struct iwl_channel_info *ch_info; |
1850 | u16 passive_dwell = 0; | 1780 | u16 passive_dwell = 0; |
@@ -1855,19 +1785,19 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, | |||
1855 | if (!sband) | 1785 | if (!sband) |
1856 | return 0; | 1786 | return 0; |
1857 | 1787 | ||
1858 | channels = sband->channels; | ||
1859 | |||
1860 | active_dwell = iwl_get_active_dwell_time(priv, band, n_probes); | 1788 | active_dwell = iwl_get_active_dwell_time(priv, band, n_probes); |
1861 | passive_dwell = iwl_get_passive_dwell_time(priv, band); | 1789 | passive_dwell = iwl_get_passive_dwell_time(priv, band); |
1862 | 1790 | ||
1863 | if (passive_dwell <= active_dwell) | 1791 | if (passive_dwell <= active_dwell) |
1864 | passive_dwell = active_dwell + 1; | 1792 | passive_dwell = active_dwell + 1; |
1865 | 1793 | ||
1866 | for (i = 0, added = 0; i < sband->n_channels; i++) { | 1794 | for (i = 0, added = 0; i < priv->scan_request->n_channels; i++) { |
1867 | if (channels[i].flags & IEEE80211_CHAN_DISABLED) | 1795 | chan = priv->scan_request->channels[i]; |
1796 | |||
1797 | if (chan->band != band) | ||
1868 | continue; | 1798 | continue; |
1869 | 1799 | ||
1870 | scan_ch->channel = channels[i].hw_value; | 1800 | scan_ch->channel = chan->hw_value; |
1871 | 1801 | ||
1872 | ch_info = iwl_get_channel_info(priv, band, scan_ch->channel); | 1802 | ch_info = iwl_get_channel_info(priv, band, scan_ch->channel); |
1873 | if (!is_channel_valid(ch_info)) { | 1803 | if (!is_channel_valid(ch_info)) { |
@@ -1882,7 +1812,7 @@ static int iwl3945_get_channels_for_scan(struct iwl_priv *priv, | |||
1882 | * and use long active_dwell time. | 1812 | * and use long active_dwell time. |
1883 | */ | 1813 | */ |
1884 | if (!is_active || is_channel_passive(ch_info) || | 1814 | if (!is_active || is_channel_passive(ch_info) || |
1885 | (channels[i].flags & IEEE80211_CHAN_PASSIVE_SCAN)) { | 1815 | (chan->flags & IEEE80211_CHAN_PASSIVE_SCAN)) { |
1886 | scan_ch->type = 0; /* passive */ | 1816 | scan_ch->type = 0; /* passive */ |
1887 | if (IWL_UCODE_API(priv->ucode_ver) == 1) | 1817 | if (IWL_UCODE_API(priv->ucode_ver) == 1) |
1888 | scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); | 1818 | scan_ch->active_dwell = cpu_to_le16(passive_dwell - 1); |
@@ -3066,7 +2996,7 @@ void iwl3945_post_associate(struct iwl_priv *priv) | |||
3066 | iwlcore_commit_rxon(priv); | 2996 | iwlcore_commit_rxon(priv); |
3067 | 2997 | ||
3068 | memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); | 2998 | memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); |
3069 | iwl3945_setup_rxon_timing(priv); | 2999 | iwl_setup_rxon_timing(priv); |
3070 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, | 3000 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, |
3071 | sizeof(priv->rxon_timing), &priv->rxon_timing); | 3001 | sizeof(priv->rxon_timing), &priv->rxon_timing); |
3072 | if (rc) | 3002 | if (rc) |
@@ -3261,7 +3191,7 @@ void iwl3945_config_ap(struct iwl_priv *priv) | |||
3261 | 3191 | ||
3262 | /* RXON Timing */ | 3192 | /* RXON Timing */ |
3263 | memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); | 3193 | memset(&priv->rxon_timing, 0, sizeof(struct iwl_rxon_time_cmd)); |
3264 | iwl3945_setup_rxon_timing(priv); | 3194 | iwl_setup_rxon_timing(priv); |
3265 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, | 3195 | rc = iwl_send_cmd_pdu(priv, REPLY_RXON_TIMING, |
3266 | sizeof(priv->rxon_timing), | 3196 | sizeof(priv->rxon_timing), |
3267 | &priv->rxon_timing); | 3197 | &priv->rxon_timing); |
diff --git a/drivers/net/wireless/iwmc3200wifi/cfg80211.c b/drivers/net/wireless/iwmc3200wifi/cfg80211.c index 96f714e6e12b..54bebba8e27e 100644 --- a/drivers/net/wireless/iwmc3200wifi/cfg80211.c +++ b/drivers/net/wireless/iwmc3200wifi/cfg80211.c | |||
@@ -23,6 +23,7 @@ | |||
23 | 23 | ||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/netdevice.h> | 25 | #include <linux/netdevice.h> |
26 | #include <linux/etherdevice.h> | ||
26 | #include <linux/wireless.h> | 27 | #include <linux/wireless.h> |
27 | #include <linux/ieee80211.h> | 28 | #include <linux/ieee80211.h> |
28 | #include <net/cfg80211.h> | 29 | #include <net/cfg80211.h> |
@@ -130,6 +131,181 @@ static struct ieee80211_supported_band iwm_band_5ghz = { | |||
130 | .n_bitrates = iwm_a_rates_size, | 131 | .n_bitrates = iwm_a_rates_size, |
131 | }; | 132 | }; |
132 | 133 | ||
134 | static int iwm_key_init(struct iwm_key *key, u8 key_index, | ||
135 | const u8 *mac_addr, struct key_params *params) | ||
136 | { | ||
137 | key->hdr.key_idx = key_index; | ||
138 | if (!mac_addr || is_broadcast_ether_addr(mac_addr)) { | ||
139 | key->hdr.multicast = 1; | ||
140 | memset(key->hdr.mac, 0xff, ETH_ALEN); | ||
141 | } else { | ||
142 | key->hdr.multicast = 0; | ||
143 | memcpy(key->hdr.mac, mac_addr, ETH_ALEN); | ||
144 | } | ||
145 | |||
146 | if (params) { | ||
147 | if (params->key_len > WLAN_MAX_KEY_LEN || | ||
148 | params->seq_len > IW_ENCODE_SEQ_MAX_SIZE) | ||
149 | return -EINVAL; | ||
150 | |||
151 | key->cipher = params->cipher; | ||
152 | key->key_len = params->key_len; | ||
153 | key->seq_len = params->seq_len; | ||
154 | memcpy(key->key, params->key, key->key_len); | ||
155 | memcpy(key->seq, params->seq, key->seq_len); | ||
156 | } | ||
157 | |||
158 | return 0; | ||
159 | } | ||
160 | |||
161 | static int iwm_reset_profile(struct iwm_priv *iwm) | ||
162 | { | ||
163 | int ret; | ||
164 | |||
165 | if (!iwm->umac_profile_active) | ||
166 | return 0; | ||
167 | |||
168 | /* | ||
169 | * If there is a current active profile, but no | ||
170 | * default key, it's not worth trying to associate again. | ||
171 | */ | ||
172 | if (iwm->default_key < 0) | ||
173 | return 0; | ||
174 | |||
175 | /* | ||
176 | * Here we have an active profile, but a key setting changed. | ||
177 | * We thus have to invalidate the current profile, and push the | ||
178 | * new one. Keys will be pushed when association takes place. | ||
179 | */ | ||
180 | ret = iwm_invalidate_mlme_profile(iwm); | ||
181 | if (ret < 0) { | ||
182 | IWM_ERR(iwm, "Couldn't invalidate profile\n"); | ||
183 | return ret; | ||
184 | } | ||
185 | |||
186 | return iwm_send_mlme_profile(iwm); | ||
187 | } | ||
188 | |||
189 | static int iwm_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev, | ||
190 | u8 key_index, const u8 *mac_addr, | ||
191 | struct key_params *params) | ||
192 | { | ||
193 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | ||
194 | struct iwm_key *key = &iwm->keys[key_index]; | ||
195 | int ret; | ||
196 | |||
197 | IWM_DBG_WEXT(iwm, DBG, "Adding key for %pM\n", mac_addr); | ||
198 | |||
199 | memset(key, 0, sizeof(struct iwm_key)); | ||
200 | ret = iwm_key_init(key, key_index, mac_addr, params); | ||
201 | if (ret < 0) { | ||
202 | IWM_ERR(iwm, "Invalid key_params\n"); | ||
203 | return ret; | ||
204 | } | ||
205 | |||
206 | /* | ||
207 | * The WEP keys can be set before or after setting the essid. | ||
208 | * We need to handle both cases by simply pushing the keys after | ||
209 | * we send the profile. | ||
210 | * If the profile is not set yet (i.e. we're pushing keys before | ||
211 | * the essid), we set the cipher appropriately. | ||
212 | * If the profile is set, we havent associated yet because our | ||
213 | * cipher was incorrectly set. So we invalidate and send the | ||
214 | * profile again. | ||
215 | */ | ||
216 | if (key->cipher == WLAN_CIPHER_SUITE_WEP40 || | ||
217 | key->cipher == WLAN_CIPHER_SUITE_WEP104) { | ||
218 | u8 *ucast_cipher = &iwm->umac_profile->sec.ucast_cipher; | ||
219 | u8 *mcast_cipher = &iwm->umac_profile->sec.mcast_cipher; | ||
220 | |||
221 | IWM_DBG_WEXT(iwm, DBG, "WEP key\n"); | ||
222 | |||
223 | if (key->cipher == WLAN_CIPHER_SUITE_WEP40) | ||
224 | *ucast_cipher = *mcast_cipher = UMAC_CIPHER_TYPE_WEP_40; | ||
225 | if (key->cipher == WLAN_CIPHER_SUITE_WEP104) | ||
226 | *ucast_cipher = *mcast_cipher = | ||
227 | UMAC_CIPHER_TYPE_WEP_104; | ||
228 | |||
229 | return iwm_reset_profile(iwm); | ||
230 | } | ||
231 | |||
232 | return iwm_set_key(iwm, 0, key); | ||
233 | } | ||
234 | |||
235 | static int iwm_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev, | ||
236 | u8 key_index, const u8 *mac_addr, void *cookie, | ||
237 | void (*callback)(void *cookie, | ||
238 | struct key_params*)) | ||
239 | { | ||
240 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | ||
241 | struct iwm_key *key = &iwm->keys[key_index]; | ||
242 | struct key_params params; | ||
243 | |||
244 | IWM_DBG_WEXT(iwm, DBG, "Getting key %d\n", key_index); | ||
245 | |||
246 | memset(¶ms, 0, sizeof(params)); | ||
247 | |||
248 | params.cipher = key->cipher; | ||
249 | params.key_len = key->key_len; | ||
250 | params.seq_len = key->seq_len; | ||
251 | params.seq = key->seq; | ||
252 | params.key = key->key; | ||
253 | |||
254 | callback(cookie, ¶ms); | ||
255 | |||
256 | return key->key_len ? 0 : -ENOENT; | ||
257 | } | ||
258 | |||
259 | |||
260 | static int iwm_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev, | ||
261 | u8 key_index, const u8 *mac_addr) | ||
262 | { | ||
263 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | ||
264 | struct iwm_key *key = &iwm->keys[key_index]; | ||
265 | |||
266 | if (!iwm->keys[key_index].key_len) { | ||
267 | IWM_DBG_WEXT(iwm, DBG, "Key %d not used\n", key_index); | ||
268 | return 0; | ||
269 | } | ||
270 | |||
271 | if (key_index == iwm->default_key) | ||
272 | iwm->default_key = -1; | ||
273 | |||
274 | /* If the interface is down, we just cache this */ | ||
275 | if (!test_bit(IWM_STATUS_READY, &iwm->status)) | ||
276 | return 0; | ||
277 | |||
278 | return iwm_set_key(iwm, 1, key); | ||
279 | } | ||
280 | |||
281 | static int iwm_cfg80211_set_default_key(struct wiphy *wiphy, | ||
282 | struct net_device *ndev, | ||
283 | u8 key_index) | ||
284 | { | ||
285 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | ||
286 | int ret; | ||
287 | |||
288 | IWM_DBG_WEXT(iwm, DBG, "Default key index is: %d\n", key_index); | ||
289 | |||
290 | if (!iwm->keys[key_index].key_len) { | ||
291 | IWM_ERR(iwm, "Key %d not used\n", key_index); | ||
292 | return -EINVAL; | ||
293 | } | ||
294 | |||
295 | iwm->default_key = key_index; | ||
296 | |||
297 | /* If the interface is down, we just cache this */ | ||
298 | if (!test_bit(IWM_STATUS_READY, &iwm->status)) | ||
299 | return 0; | ||
300 | |||
301 | ret = iwm_set_tx_key(iwm, key_index); | ||
302 | if (ret < 0) | ||
303 | return ret; | ||
304 | |||
305 | return iwm_reset_profile(iwm); | ||
306 | } | ||
307 | |||
308 | |||
133 | int iwm_cfg80211_inform_bss(struct iwm_priv *iwm) | 309 | int iwm_cfg80211_inform_bss(struct iwm_priv *iwm) |
134 | { | 310 | { |
135 | struct wiphy *wiphy = iwm_to_wiphy(iwm); | 311 | struct wiphy *wiphy = iwm_to_wiphy(iwm); |
@@ -167,20 +343,15 @@ int iwm_cfg80211_inform_bss(struct iwm_priv *iwm) | |||
167 | return 0; | 343 | return 0; |
168 | } | 344 | } |
169 | 345 | ||
170 | static int iwm_cfg80211_change_iface(struct wiphy *wiphy, int ifindex, | 346 | static int iwm_cfg80211_change_iface(struct wiphy *wiphy, |
347 | struct net_device *ndev, | ||
171 | enum nl80211_iftype type, u32 *flags, | 348 | enum nl80211_iftype type, u32 *flags, |
172 | struct vif_params *params) | 349 | struct vif_params *params) |
173 | { | 350 | { |
174 | struct net_device *ndev; | ||
175 | struct wireless_dev *wdev; | 351 | struct wireless_dev *wdev; |
176 | struct iwm_priv *iwm; | 352 | struct iwm_priv *iwm; |
177 | u32 old_mode; | 353 | u32 old_mode; |
178 | 354 | ||
179 | /* we're under RTNL */ | ||
180 | ndev = __dev_get_by_index(&init_net, ifindex); | ||
181 | if (!ndev) | ||
182 | return -ENODEV; | ||
183 | |||
184 | wdev = ndev->ieee80211_ptr; | 355 | wdev = ndev->ieee80211_ptr; |
185 | iwm = ndev_to_iwm(ndev); | 356 | iwm = ndev_to_iwm(ndev); |
186 | old_mode = iwm->conf.mode; | 357 | old_mode = iwm->conf.mode; |
@@ -329,12 +500,62 @@ static int iwm_cfg80211_leave_ibss(struct wiphy *wiphy, struct net_device *dev) | |||
329 | return 0; | 500 | return 0; |
330 | } | 501 | } |
331 | 502 | ||
503 | static int iwm_cfg80211_set_txpower(struct wiphy *wiphy, | ||
504 | enum tx_power_setting type, int dbm) | ||
505 | { | ||
506 | switch (type) { | ||
507 | case TX_POWER_AUTOMATIC: | ||
508 | return 0; | ||
509 | default: | ||
510 | return -EOPNOTSUPP; | ||
511 | } | ||
512 | |||
513 | return 0; | ||
514 | } | ||
515 | |||
516 | static int iwm_cfg80211_get_txpower(struct wiphy *wiphy, int *dbm) | ||
517 | { | ||
518 | struct iwm_priv *iwm = wiphy_to_iwm(wiphy); | ||
519 | |||
520 | *dbm = iwm->txpower; | ||
521 | |||
522 | return 0; | ||
523 | } | ||
524 | |||
525 | static int iwm_cfg80211_set_power_mgmt(struct wiphy *wiphy, | ||
526 | struct net_device *dev, | ||
527 | bool enabled, int timeout) | ||
528 | { | ||
529 | struct iwm_priv *iwm = wiphy_to_iwm(wiphy); | ||
530 | u32 power_index; | ||
531 | |||
532 | if (enabled) | ||
533 | power_index = IWM_POWER_INDEX_DEFAULT; | ||
534 | else | ||
535 | power_index = IWM_POWER_INDEX_MIN; | ||
536 | |||
537 | if (power_index == iwm->conf.power_index) | ||
538 | return 0; | ||
539 | |||
540 | iwm->conf.power_index = power_index; | ||
541 | |||
542 | return iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, | ||
543 | CFG_POWER_INDEX, iwm->conf.power_index); | ||
544 | } | ||
545 | |||
332 | static struct cfg80211_ops iwm_cfg80211_ops = { | 546 | static struct cfg80211_ops iwm_cfg80211_ops = { |
333 | .change_virtual_intf = iwm_cfg80211_change_iface, | 547 | .change_virtual_intf = iwm_cfg80211_change_iface, |
548 | .add_key = iwm_cfg80211_add_key, | ||
549 | .get_key = iwm_cfg80211_get_key, | ||
550 | .del_key = iwm_cfg80211_del_key, | ||
551 | .set_default_key = iwm_cfg80211_set_default_key, | ||
334 | .scan = iwm_cfg80211_scan, | 552 | .scan = iwm_cfg80211_scan, |
335 | .set_wiphy_params = iwm_cfg80211_set_wiphy_params, | 553 | .set_wiphy_params = iwm_cfg80211_set_wiphy_params, |
336 | .join_ibss = iwm_cfg80211_join_ibss, | 554 | .join_ibss = iwm_cfg80211_join_ibss, |
337 | .leave_ibss = iwm_cfg80211_leave_ibss, | 555 | .leave_ibss = iwm_cfg80211_leave_ibss, |
556 | .set_tx_power = iwm_cfg80211_set_txpower, | ||
557 | .get_tx_power = iwm_cfg80211_get_txpower, | ||
558 | .set_power_mgmt = iwm_cfg80211_set_power_mgmt, | ||
338 | }; | 559 | }; |
339 | 560 | ||
340 | struct wireless_dev *iwm_wdev_alloc(int sizeof_bus, struct device *dev) | 561 | struct wireless_dev *iwm_wdev_alloc(int sizeof_bus, struct device *dev) |
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.c b/drivers/net/wireless/iwmc3200wifi/commands.c index 834a7f544e5d..0d35afefb61c 100644 --- a/drivers/net/wireless/iwmc3200wifi/commands.c +++ b/drivers/net/wireless/iwmc3200wifi/commands.c | |||
@@ -70,14 +70,28 @@ static int iwm_send_lmac_ptrough_cmd(struct iwm_priv *iwm, | |||
70 | int iwm_send_wifi_if_cmd(struct iwm_priv *iwm, void *payload, u16 payload_size, | 70 | int iwm_send_wifi_if_cmd(struct iwm_priv *iwm, void *payload, u16 payload_size, |
71 | bool resp) | 71 | bool resp) |
72 | { | 72 | { |
73 | struct iwm_umac_wifi_if *hdr = (struct iwm_umac_wifi_if *)payload; | ||
73 | struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT; | 74 | struct iwm_udma_wifi_cmd udma_cmd = UDMA_UMAC_INIT; |
74 | struct iwm_umac_cmd umac_cmd; | 75 | struct iwm_umac_cmd umac_cmd; |
76 | int ret; | ||
77 | u8 oid = hdr->oid; | ||
75 | 78 | ||
76 | umac_cmd.id = UMAC_CMD_OPCODE_WIFI_IF_WRAPPER; | 79 | umac_cmd.id = UMAC_CMD_OPCODE_WIFI_IF_WRAPPER; |
77 | umac_cmd.resp = resp; | 80 | umac_cmd.resp = resp; |
78 | 81 | ||
79 | return iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, | 82 | ret = iwm_hal_send_umac_cmd(iwm, &udma_cmd, &umac_cmd, |
80 | payload, payload_size); | 83 | payload, payload_size); |
84 | |||
85 | if (resp) { | ||
86 | ret = wait_event_interruptible_timeout(iwm->wifi_ntfy_queue, | ||
87 | test_and_clear_bit(oid, &iwm->wifi_ntfy[0]), | ||
88 | 3 * HZ); | ||
89 | |||
90 | if (!ret) | ||
91 | ret = -EBUSY; | ||
92 | } | ||
93 | |||
94 | return ret; | ||
81 | } | 95 | } |
82 | 96 | ||
83 | static struct coex_event iwm_sta_xor_prio_tbl[COEX_EVENTS_NUM] = | 97 | static struct coex_event iwm_sta_xor_prio_tbl[COEX_EVENTS_NUM] = |
@@ -106,7 +120,7 @@ static struct coex_event iwm_sta_cm_prio_tbl[COEX_EVENTS_NUM] = | |||
106 | {4, 3, 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS}, | 120 | {4, 3, 0, COEX_UNASSOC_MANUAL_SCAN_FLAGS}, |
107 | {3, 3, 0, COEX_UNASSOC_AUTO_SCAN_FLAGS}, | 121 | {3, 3, 0, COEX_UNASSOC_AUTO_SCAN_FLAGS}, |
108 | {5, 5, 0, COEX_CALIBRATION_FLAGS}, | 122 | {5, 5, 0, COEX_CALIBRATION_FLAGS}, |
109 | {4, 4, 0, COEX_PERIODIC_CALIBRATION_FLAGS}, | 123 | {3, 3, 0, COEX_PERIODIC_CALIBRATION_FLAGS}, |
110 | {5, 4, 0, COEX_CONNECTION_ESTAB_FLAGS}, | 124 | {5, 4, 0, COEX_CONNECTION_ESTAB_FLAGS}, |
111 | {4, 4, 0, COEX_ASSOCIATED_IDLE_FLAGS}, | 125 | {4, 4, 0, COEX_ASSOCIATED_IDLE_FLAGS}, |
112 | {4, 4, 0, COEX_ASSOC_MANUAL_SCAN_FLAGS}, | 126 | {4, 4, 0, COEX_ASSOC_MANUAL_SCAN_FLAGS}, |
@@ -331,8 +345,7 @@ int iwm_umac_set_config_var(struct iwm_priv *iwm, u16 key, | |||
331 | return ret; | 345 | return ret; |
332 | } | 346 | } |
333 | 347 | ||
334 | int iwm_send_umac_config(struct iwm_priv *iwm, | 348 | int iwm_send_umac_config(struct iwm_priv *iwm, __le32 reset_flags) |
335 | __le32 reset_flags) | ||
336 | { | 349 | { |
337 | int ret; | 350 | int ret; |
338 | 351 | ||
@@ -360,6 +373,12 @@ int iwm_send_umac_config(struct iwm_priv *iwm, | |||
360 | return ret; | 373 | return ret; |
361 | 374 | ||
362 | ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, | 375 | ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, |
376 | CFG_WIRELESS_MODE, | ||
377 | iwm->conf.wireless_mode); | ||
378 | if (ret < 0) | ||
379 | return ret; | ||
380 | |||
381 | ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, | ||
363 | CFG_COEX_MODE, iwm->conf.coexist_mode); | 382 | CFG_COEX_MODE, iwm->conf.coexist_mode); |
364 | if (ret < 0) | 383 | if (ret < 0) |
365 | return ret; | 384 | return ret; |
@@ -401,7 +420,7 @@ int iwm_send_umac_config(struct iwm_priv *iwm, | |||
401 | return ret; | 420 | return ret; |
402 | 421 | ||
403 | ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, | 422 | ret = iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, |
404 | CFG_PM_CTRL_FLAGS, 0x30001); | 423 | CFG_PM_CTRL_FLAGS, 0x1); |
405 | if (ret < 0) | 424 | if (ret < 0) |
406 | return ret; | 425 | return ret; |
407 | 426 | ||
@@ -510,9 +529,6 @@ int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx) | |||
510 | { | 529 | { |
511 | struct iwm_umac_tx_key_id tx_key_id; | 530 | struct iwm_umac_tx_key_id tx_key_id; |
512 | 531 | ||
513 | if (!iwm->default_key || !iwm->default_key->in_use) | ||
514 | return -EINVAL; | ||
515 | |||
516 | tx_key_id.hdr.oid = UMAC_WIFI_IF_CMD_GLOBAL_TX_KEY_ID; | 532 | tx_key_id.hdr.oid = UMAC_WIFI_IF_CMD_GLOBAL_TX_KEY_ID; |
517 | tx_key_id.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_tx_key_id) - | 533 | tx_key_id.hdr.buf_size = cpu_to_le16(sizeof(struct iwm_umac_tx_key_id) - |
518 | sizeof(struct iwm_umac_wifi_if)); | 534 | sizeof(struct iwm_umac_wifi_if)); |
@@ -555,10 +571,9 @@ static int iwm_check_profile(struct iwm_priv *iwm) | |||
555 | return 0; | 571 | return 0; |
556 | } | 572 | } |
557 | 573 | ||
558 | int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | 574 | int iwm_set_key(struct iwm_priv *iwm, bool remove, struct iwm_key *key) |
559 | struct iwm_key *key) | ||
560 | { | 575 | { |
561 | int ret; | 576 | int ret = 0; |
562 | u8 cmd[64], *sta_addr, *key_data, key_len; | 577 | u8 cmd[64], *sta_addr, *key_data, key_len; |
563 | s8 key_idx; | 578 | s8 key_idx; |
564 | u16 cmd_size = 0; | 579 | u16 cmd_size = 0; |
@@ -568,9 +583,6 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
568 | struct iwm_umac_key_tkip *tkip = (struct iwm_umac_key_tkip *)cmd; | 583 | struct iwm_umac_key_tkip *tkip = (struct iwm_umac_key_tkip *)cmd; |
569 | struct iwm_umac_key_ccmp *ccmp = (struct iwm_umac_key_ccmp *)cmd; | 584 | struct iwm_umac_key_ccmp *ccmp = (struct iwm_umac_key_ccmp *)cmd; |
570 | 585 | ||
571 | if (set_tx_key) | ||
572 | iwm->default_key = key; | ||
573 | |||
574 | /* | 586 | /* |
575 | * We check if our current profile is valid. | 587 | * We check if our current profile is valid. |
576 | * If not, we dont push the key, we just cache them, | 588 | * If not, we dont push the key, we just cache them, |
@@ -589,8 +601,7 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
589 | key_idx = key->hdr.key_idx; | 601 | key_idx = key->hdr.key_idx; |
590 | 602 | ||
591 | if (!remove) { | 603 | if (!remove) { |
592 | IWM_DBG_WEXT(iwm, DBG, "key_idx:%d set tx key:%d\n", | 604 | IWM_DBG_WEXT(iwm, DBG, "key_idx:%d\n", key_idx); |
593 | key_idx, set_tx_key); | ||
594 | IWM_DBG_WEXT(iwm, DBG, "key_len:%d\n", key_len); | 605 | IWM_DBG_WEXT(iwm, DBG, "key_len:%d\n", key_len); |
595 | IWM_DBG_WEXT(iwm, DBG, "MAC:%pM, idx:%d, multicast:%d\n", | 606 | IWM_DBG_WEXT(iwm, DBG, "MAC:%pM, idx:%d, multicast:%d\n", |
596 | key_hdr->mac, key_hdr->key_idx, key_hdr->multicast); | 607 | key_hdr->mac, key_hdr->key_idx, key_hdr->multicast); |
@@ -602,8 +613,8 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
602 | iwm->umac_profile->sec.auth_type, | 613 | iwm->umac_profile->sec.auth_type, |
603 | iwm->umac_profile->sec.flags); | 614 | iwm->umac_profile->sec.flags); |
604 | 615 | ||
605 | switch (key->alg) { | 616 | switch (key->cipher) { |
606 | case UMAC_CIPHER_TYPE_WEP_40: | 617 | case WLAN_CIPHER_SUITE_WEP40: |
607 | wep40->hdr.oid = UMAC_WIFI_IF_CMD_ADD_WEP40_KEY; | 618 | wep40->hdr.oid = UMAC_WIFI_IF_CMD_ADD_WEP40_KEY; |
608 | wep40->hdr.buf_size = | 619 | wep40->hdr.buf_size = |
609 | cpu_to_le16(sizeof(struct iwm_umac_key_wep40) - | 620 | cpu_to_le16(sizeof(struct iwm_umac_key_wep40) - |
@@ -617,7 +628,7 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
617 | cmd_size = sizeof(struct iwm_umac_key_wep40); | 628 | cmd_size = sizeof(struct iwm_umac_key_wep40); |
618 | break; | 629 | break; |
619 | 630 | ||
620 | case UMAC_CIPHER_TYPE_WEP_104: | 631 | case WLAN_CIPHER_SUITE_WEP104: |
621 | wep104->hdr.oid = UMAC_WIFI_IF_CMD_ADD_WEP104_KEY; | 632 | wep104->hdr.oid = UMAC_WIFI_IF_CMD_ADD_WEP104_KEY; |
622 | wep104->hdr.buf_size = | 633 | wep104->hdr.buf_size = |
623 | cpu_to_le16(sizeof(struct iwm_umac_key_wep104) - | 634 | cpu_to_le16(sizeof(struct iwm_umac_key_wep104) - |
@@ -631,7 +642,7 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
631 | cmd_size = sizeof(struct iwm_umac_key_wep104); | 642 | cmd_size = sizeof(struct iwm_umac_key_wep104); |
632 | break; | 643 | break; |
633 | 644 | ||
634 | case UMAC_CIPHER_TYPE_CCMP: | 645 | case WLAN_CIPHER_SUITE_CCMP: |
635 | key_hdr->key_idx++; | 646 | key_hdr->key_idx++; |
636 | ccmp->hdr.oid = UMAC_WIFI_IF_CMD_ADD_CCMP_KEY; | 647 | ccmp->hdr.oid = UMAC_WIFI_IF_CMD_ADD_CCMP_KEY; |
637 | ccmp->hdr.buf_size = | 648 | ccmp->hdr.buf_size = |
@@ -643,13 +654,13 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
643 | 654 | ||
644 | memcpy(ccmp->key, key_data, key_len); | 655 | memcpy(ccmp->key, key_data, key_len); |
645 | 656 | ||
646 | if (key->flags & IW_ENCODE_EXT_RX_SEQ_VALID) | 657 | if (key->seq_len) |
647 | memcpy(ccmp->iv_count, key->rx_seq, 6); | 658 | memcpy(ccmp->iv_count, key->seq, key->seq_len); |
648 | 659 | ||
649 | cmd_size = sizeof(struct iwm_umac_key_ccmp); | 660 | cmd_size = sizeof(struct iwm_umac_key_ccmp); |
650 | break; | 661 | break; |
651 | 662 | ||
652 | case UMAC_CIPHER_TYPE_TKIP: | 663 | case WLAN_CIPHER_SUITE_TKIP: |
653 | key_hdr->key_idx++; | 664 | key_hdr->key_idx++; |
654 | tkip->hdr.oid = UMAC_WIFI_IF_CMD_ADD_TKIP_KEY; | 665 | tkip->hdr.oid = UMAC_WIFI_IF_CMD_ADD_TKIP_KEY; |
655 | tkip->hdr.buf_size = | 666 | tkip->hdr.buf_size = |
@@ -666,8 +677,8 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
666 | key_data + IWM_TKIP_KEY_SIZE + IWM_TKIP_MIC_SIZE, | 677 | key_data + IWM_TKIP_KEY_SIZE + IWM_TKIP_MIC_SIZE, |
667 | IWM_TKIP_MIC_SIZE); | 678 | IWM_TKIP_MIC_SIZE); |
668 | 679 | ||
669 | if (key->flags & IW_ENCODE_EXT_RX_SEQ_VALID) | 680 | if (key->seq_len) |
670 | memcpy(ccmp->iv_count, key->rx_seq, 6); | 681 | memcpy(ccmp->iv_count, key->seq, key->seq_len); |
671 | 682 | ||
672 | cmd_size = sizeof(struct iwm_umac_key_tkip); | 683 | cmd_size = sizeof(struct iwm_umac_key_tkip); |
673 | break; | 684 | break; |
@@ -676,8 +687,8 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
676 | return -ENOTSUPP; | 687 | return -ENOTSUPP; |
677 | } | 688 | } |
678 | 689 | ||
679 | if ((key->alg == UMAC_CIPHER_TYPE_CCMP) || | 690 | if ((key->cipher == WLAN_CIPHER_SUITE_TKIP) || |
680 | (key->alg == UMAC_CIPHER_TYPE_TKIP)) | 691 | (key->cipher == WLAN_CIPHER_SUITE_CCMP)) |
681 | /* | 692 | /* |
682 | * UGLY_UGLY_UGLY | 693 | * UGLY_UGLY_UGLY |
683 | * Copied HACK from the MWG driver. | 694 | * Copied HACK from the MWG driver. |
@@ -688,23 +699,11 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
688 | schedule_timeout_interruptible(usecs_to_jiffies(300)); | 699 | schedule_timeout_interruptible(usecs_to_jiffies(300)); |
689 | 700 | ||
690 | ret = iwm_send_wifi_if_cmd(iwm, cmd, cmd_size, 1); | 701 | ret = iwm_send_wifi_if_cmd(iwm, cmd, cmd_size, 1); |
691 | if (ret < 0) | ||
692 | goto err; | ||
693 | |||
694 | /* | ||
695 | * We need a default key only if it is set and | ||
696 | * if we're doing WEP. | ||
697 | */ | ||
698 | if (iwm->default_key == key && | ||
699 | ((key->alg == UMAC_CIPHER_TYPE_WEP_40) || | ||
700 | (key->alg == UMAC_CIPHER_TYPE_WEP_104))) { | ||
701 | ret = iwm_set_tx_key(iwm, key_idx); | ||
702 | if (ret < 0) | ||
703 | goto err; | ||
704 | } | ||
705 | } else { | 702 | } else { |
706 | struct iwm_umac_key_remove key_remove; | 703 | struct iwm_umac_key_remove key_remove; |
707 | 704 | ||
705 | IWM_DBG_WEXT(iwm, ERR, "Removing key_idx:%d\n", key_idx); | ||
706 | |||
708 | key_remove.hdr.oid = UMAC_WIFI_IF_CMD_REMOVE_KEY; | 707 | key_remove.hdr.oid = UMAC_WIFI_IF_CMD_REMOVE_KEY; |
709 | key_remove.hdr.buf_size = | 708 | key_remove.hdr.buf_size = |
710 | cpu_to_le16(sizeof(struct iwm_umac_key_remove) - | 709 | cpu_to_le16(sizeof(struct iwm_umac_key_remove) - |
@@ -718,13 +717,9 @@ int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | |||
718 | if (ret < 0) | 717 | if (ret < 0) |
719 | return ret; | 718 | return ret; |
720 | 719 | ||
721 | iwm->keys[key_idx].in_use = 0; | 720 | iwm->keys[key_idx].key_len = 0; |
722 | } | 721 | } |
723 | 722 | ||
724 | return 0; | ||
725 | |||
726 | err: | ||
727 | kfree(key); | ||
728 | return ret; | 723 | return ret; |
729 | } | 724 | } |
730 | 725 | ||
@@ -746,31 +741,25 @@ int iwm_send_mlme_profile(struct iwm_priv *iwm) | |||
746 | return ret; | 741 | return ret; |
747 | } | 742 | } |
748 | 743 | ||
749 | /* Wait for the profile to be active */ | ||
750 | ret = wait_event_interruptible_timeout(iwm->mlme_queue, | ||
751 | iwm->umac_profile_active == 1, | ||
752 | 3 * HZ); | ||
753 | if (!ret) | ||
754 | return -EBUSY; | ||
755 | |||
756 | |||
757 | for (i = 0; i < IWM_NUM_KEYS; i++) | 744 | for (i = 0; i < IWM_NUM_KEYS; i++) |
758 | if (iwm->keys[i].in_use) { | 745 | if (iwm->keys[i].key_len) { |
759 | int default_key = 0; | ||
760 | struct iwm_key *key = &iwm->keys[i]; | 746 | struct iwm_key *key = &iwm->keys[i]; |
761 | 747 | ||
762 | if (key == iwm->default_key) | ||
763 | default_key = 1; | ||
764 | |||
765 | /* Wait for the profile before sending the keys */ | 748 | /* Wait for the profile before sending the keys */ |
766 | wait_event_interruptible_timeout(iwm->mlme_queue, | 749 | wait_event_interruptible_timeout(iwm->mlme_queue, |
767 | (test_bit(IWM_STATUS_ASSOCIATING, &iwm->status) || | 750 | (test_bit(IWM_STATUS_ASSOCIATING, &iwm->status) || |
768 | test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)), | 751 | test_bit(IWM_STATUS_ASSOCIATED, &iwm->status)), |
769 | 3 * HZ); | 752 | 3 * HZ); |
770 | 753 | ||
771 | ret = iwm_set_key(iwm, 0, default_key, key); | 754 | ret = iwm_set_key(iwm, 0, key); |
772 | if (ret < 0) | 755 | if (ret < 0) |
773 | return ret; | 756 | return ret; |
757 | |||
758 | if (iwm->default_key == i) { | ||
759 | ret = iwm_set_tx_key(iwm, i); | ||
760 | if (ret < 0) | ||
761 | return ret; | ||
762 | } | ||
774 | } | 763 | } |
775 | 764 | ||
776 | return 0; | 765 | return 0; |
@@ -778,8 +767,8 @@ int iwm_send_mlme_profile(struct iwm_priv *iwm) | |||
778 | 767 | ||
779 | int iwm_invalidate_mlme_profile(struct iwm_priv *iwm) | 768 | int iwm_invalidate_mlme_profile(struct iwm_priv *iwm) |
780 | { | 769 | { |
781 | int ret; | ||
782 | struct iwm_umac_invalidate_profile invalid; | 770 | struct iwm_umac_invalidate_profile invalid; |
771 | int ret; | ||
783 | 772 | ||
784 | invalid.hdr.oid = UMAC_WIFI_IF_CMD_INVALIDATE_PROFILE; | 773 | invalid.hdr.oid = UMAC_WIFI_IF_CMD_INVALIDATE_PROFILE; |
785 | invalid.hdr.buf_size = | 774 | invalid.hdr.buf_size = |
@@ -793,8 +782,7 @@ int iwm_invalidate_mlme_profile(struct iwm_priv *iwm) | |||
793 | return ret; | 782 | return ret; |
794 | 783 | ||
795 | ret = wait_event_interruptible_timeout(iwm->mlme_queue, | 784 | ret = wait_event_interruptible_timeout(iwm->mlme_queue, |
796 | (iwm->umac_profile_active == 0), | 785 | (iwm->umac_profile_active == 0), 2 * HZ); |
797 | 2 * HZ); | ||
798 | if (!ret) | 786 | if (!ret) |
799 | return -EBUSY; | 787 | return -EBUSY; |
800 | 788 | ||
diff --git a/drivers/net/wireless/iwmc3200wifi/commands.h b/drivers/net/wireless/iwmc3200wifi/commands.h index 36b13a130595..e24d5b633997 100644 --- a/drivers/net/wireless/iwmc3200wifi/commands.h +++ b/drivers/net/wireless/iwmc3200wifi/commands.h | |||
@@ -106,8 +106,7 @@ enum { | |||
106 | CFG_TLC_SPATIAL_STREAM_SUPPORTED, | 106 | CFG_TLC_SPATIAL_STREAM_SUPPORTED, |
107 | CFG_TLC_RETRY_PER_RATE, | 107 | CFG_TLC_RETRY_PER_RATE, |
108 | CFG_TLC_RETRY_PER_HT_RATE, | 108 | CFG_TLC_RETRY_PER_HT_RATE, |
109 | CFG_TLC_FIXED_RATE, | 109 | CFG_TLC_FIXED_MCS, |
110 | CFG_TLC_FIXED_RATE_FLAGS, | ||
111 | CFG_TLC_CONTROL_FLAGS, | 110 | CFG_TLC_CONTROL_FLAGS, |
112 | CFG_TLC_SR_MIN_FAIL, | 111 | CFG_TLC_SR_MIN_FAIL, |
113 | CFG_TLC_SR_MIN_PASS, | 112 | CFG_TLC_SR_MIN_PASS, |
@@ -232,6 +231,7 @@ struct iwm_umac_cmd_get_channel_list { | |||
232 | /* Wireless mode */ | 231 | /* Wireless mode */ |
233 | #define WIRELESS_MODE_11A 0x1 | 232 | #define WIRELESS_MODE_11A 0x1 |
234 | #define WIRELESS_MODE_11G 0x2 | 233 | #define WIRELESS_MODE_11G 0x2 |
234 | #define WIRELESS_MODE_11N 0x4 | ||
235 | 235 | ||
236 | #define UMAC_PROFILE_EX_IE_REQUIRED 0x1 | 236 | #define UMAC_PROFILE_EX_IE_REQUIRED 0x1 |
237 | #define UMAC_PROFILE_QOS_ALLOWED 0x2 | 237 | #define UMAC_PROFILE_QOS_ALLOWED 0x2 |
@@ -406,8 +406,7 @@ int iwm_send_mlme_profile(struct iwm_priv *iwm); | |||
406 | int iwm_invalidate_mlme_profile(struct iwm_priv *iwm); | 406 | int iwm_invalidate_mlme_profile(struct iwm_priv *iwm); |
407 | int iwm_send_packet(struct iwm_priv *iwm, struct sk_buff *skb, int pool_id); | 407 | int iwm_send_packet(struct iwm_priv *iwm, struct sk_buff *skb, int pool_id); |
408 | int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx); | 408 | int iwm_set_tx_key(struct iwm_priv *iwm, u8 key_idx); |
409 | int iwm_set_key(struct iwm_priv *iwm, bool remove, bool set_tx_key, | 409 | int iwm_set_key(struct iwm_priv *iwm, bool remove, struct iwm_key *key); |
410 | struct iwm_key *key); | ||
411 | int iwm_send_umac_stats_req(struct iwm_priv *iwm, u32 flags); | 410 | int iwm_send_umac_stats_req(struct iwm_priv *iwm, u32 flags); |
412 | int iwm_send_umac_channel_list(struct iwm_priv *iwm); | 411 | int iwm_send_umac_channel_list(struct iwm_priv *iwm); |
413 | int iwm_scan_ssids(struct iwm_priv *iwm, struct cfg80211_ssid *ssids, | 412 | int iwm_scan_ssids(struct iwm_priv *iwm, struct cfg80211_ssid *ssids, |
diff --git a/drivers/net/wireless/iwmc3200wifi/eeprom.c b/drivers/net/wireless/iwmc3200wifi/eeprom.c index 0f34b84fd2eb..365910fbe01e 100644 --- a/drivers/net/wireless/iwmc3200wifi/eeprom.c +++ b/drivers/net/wireless/iwmc3200wifi/eeprom.c | |||
@@ -156,10 +156,6 @@ int iwm_eeprom_init(struct iwm_priv *iwm) | |||
156 | return -ENOMEM; | 156 | return -ENOMEM; |
157 | 157 | ||
158 | for (i = IWM_EEPROM_FIRST; i < IWM_EEPROM_LAST; i++) { | 158 | for (i = IWM_EEPROM_FIRST; i < IWM_EEPROM_LAST; i++) { |
159 | #ifdef CONFIG_IWM_B0_HW_SUPPORT | ||
160 | if (iwm->conf.hw_b0 && (i >= IWM_EEPROM_INDIRECT_OFFSET)) | ||
161 | break; | ||
162 | #endif | ||
163 | ret = iwm_eeprom_read(iwm, i); | 159 | ret = iwm_eeprom_read(iwm, i); |
164 | if (ret < 0) { | 160 | if (ret < 0) { |
165 | IWM_ERR(iwm, "Couldn't read eeprom entry #%d: %s\n", | 161 | IWM_ERR(iwm, "Couldn't read eeprom entry #%d: %s\n", |
diff --git a/drivers/net/wireless/iwmc3200wifi/fw.c b/drivers/net/wireless/iwmc3200wifi/fw.c index ec1a15a5a0e4..0f32cab9ced4 100644 --- a/drivers/net/wireless/iwmc3200wifi/fw.c +++ b/drivers/net/wireless/iwmc3200wifi/fw.c | |||
@@ -275,6 +275,7 @@ static int iwm_load_lmac(struct iwm_priv *iwm, const char *img_name) | |||
275 | */ | 275 | */ |
276 | int iwm_load_fw(struct iwm_priv *iwm) | 276 | int iwm_load_fw(struct iwm_priv *iwm) |
277 | { | 277 | { |
278 | unsigned long init_calib_map, periodic_calib_map; | ||
278 | int ret; | 279 | int ret; |
279 | 280 | ||
280 | /* We first start downloading the UMAC */ | 281 | /* We first start downloading the UMAC */ |
@@ -315,23 +316,19 @@ int iwm_load_fw(struct iwm_priv *iwm) | |||
315 | return ret; | 316 | return ret; |
316 | } | 317 | } |
317 | 318 | ||
318 | #ifdef CONFIG_IWM_B0_HW_SUPPORT | 319 | init_calib_map = iwm->conf.calib_map & IWM_CALIB_MAP_INIT_MSK; |
319 | if (iwm->conf.hw_b0) { | 320 | periodic_calib_map = IWM_CALIB_MAP_PER_LMAC(iwm->conf.calib_map); |
320 | clear_bit(PHY_CALIBRATE_RX_IQ_CMD, &iwm->conf.init_calib_map); | 321 | |
321 | clear_bit(PHY_CALIBRATE_RX_IQ_CMD, | ||
322 | &iwm->conf.periodic_calib_map); | ||
323 | } | ||
324 | #endif | ||
325 | /* Read RX IQ calibration result from EEPROM */ | 322 | /* Read RX IQ calibration result from EEPROM */ |
326 | if (test_bit(PHY_CALIBRATE_RX_IQ_CMD, &iwm->conf.init_calib_map)) { | 323 | if (test_bit(PHY_CALIBRATE_RX_IQ_CMD, &init_calib_map)) { |
327 | iwm_store_rxiq_calib_result(iwm); | 324 | iwm_store_rxiq_calib_result(iwm); |
328 | set_bit(PHY_CALIBRATE_RX_IQ_CMD, &iwm->calib_done_map); | 325 | set_bit(PHY_CALIBRATE_RX_IQ_CMD, &iwm->calib_done_map); |
329 | } | 326 | } |
330 | 327 | ||
331 | iwm_send_prio_table(iwm); | 328 | iwm_send_prio_table(iwm); |
332 | iwm_send_init_calib_cfg(iwm, iwm->conf.init_calib_map); | 329 | iwm_send_init_calib_cfg(iwm, init_calib_map); |
333 | 330 | ||
334 | while (iwm->calib_done_map != iwm->conf.init_calib_map) { | 331 | while (iwm->calib_done_map != init_calib_map) { |
335 | ret = iwm_notif_handle(iwm, CALIBRATION_RES_NOTIFICATION, | 332 | ret = iwm_notif_handle(iwm, CALIBRATION_RES_NOTIFICATION, |
336 | IWM_SRC_LMAC, WAIT_NOTIF_TIMEOUT); | 333 | IWM_SRC_LMAC, WAIT_NOTIF_TIMEOUT); |
337 | if (ret) { | 334 | if (ret) { |
@@ -340,7 +337,7 @@ int iwm_load_fw(struct iwm_priv *iwm) | |||
340 | } | 337 | } |
341 | IWM_DBG_FW(iwm, DBG, "Got calibration result. calib_done_map: " | 338 | IWM_DBG_FW(iwm, DBG, "Got calibration result. calib_done_map: " |
342 | "0x%lx, requested calibrations: 0x%lx\n", | 339 | "0x%lx, requested calibrations: 0x%lx\n", |
343 | iwm->calib_done_map, iwm->conf.init_calib_map); | 340 | iwm->calib_done_map, init_calib_map); |
344 | } | 341 | } |
345 | 342 | ||
346 | /* Handle LMAC CALIBRATION_COMPLETE notification */ | 343 | /* Handle LMAC CALIBRATION_COMPLETE notification */ |
@@ -378,7 +375,7 @@ int iwm_load_fw(struct iwm_priv *iwm) | |||
378 | 375 | ||
379 | iwm_send_prio_table(iwm); | 376 | iwm_send_prio_table(iwm); |
380 | iwm_send_calib_results(iwm); | 377 | iwm_send_calib_results(iwm); |
381 | iwm_send_periodic_calib_cfg(iwm, iwm->conf.periodic_calib_map); | 378 | iwm_send_periodic_calib_cfg(iwm, periodic_calib_map); |
382 | 379 | ||
383 | return 0; | 380 | return 0; |
384 | 381 | ||
diff --git a/drivers/net/wireless/iwmc3200wifi/iwm.h b/drivers/net/wireless/iwmc3200wifi/iwm.h index 77c339f8516c..79d9d89d47ae 100644 --- a/drivers/net/wireless/iwmc3200wifi/iwm.h +++ b/drivers/net/wireless/iwmc3200wifi/iwm.h | |||
@@ -52,8 +52,6 @@ | |||
52 | #define IWM_COPYRIGHT "Copyright(c) 2009 Intel Corporation" | 52 | #define IWM_COPYRIGHT "Copyright(c) 2009 Intel Corporation" |
53 | #define IWM_AUTHOR "<ilw@linux.intel.com>" | 53 | #define IWM_AUTHOR "<ilw@linux.intel.com>" |
54 | 54 | ||
55 | #define CONFIG_IWM_B0_HW_SUPPORT 1 | ||
56 | |||
57 | #define IWM_SRC_LMAC UMAC_HDI_IN_SOURCE_FHRX | 55 | #define IWM_SRC_LMAC UMAC_HDI_IN_SOURCE_FHRX |
58 | #define IWM_SRC_UDMA UMAC_HDI_IN_SOURCE_UDMA | 56 | #define IWM_SRC_UDMA UMAC_HDI_IN_SOURCE_UDMA |
59 | #define IWM_SRC_UMAC UMAC_HDI_IN_SOURCE_FW | 57 | #define IWM_SRC_UMAC UMAC_HDI_IN_SOURCE_FW |
@@ -65,8 +63,7 @@ | |||
65 | 63 | ||
66 | struct iwm_conf { | 64 | struct iwm_conf { |
67 | u32 sdio_ior_timeout; | 65 | u32 sdio_ior_timeout; |
68 | unsigned long init_calib_map; | 66 | unsigned long calib_map; |
69 | unsigned long periodic_calib_map; | ||
70 | bool reset_on_fatal_err; | 67 | bool reset_on_fatal_err; |
71 | bool auto_connect; | 68 | bool auto_connect; |
72 | bool wimax_not_present; | 69 | bool wimax_not_present; |
@@ -87,9 +84,6 @@ struct iwm_conf { | |||
87 | u8 ibss_channel; | 84 | u8 ibss_channel; |
88 | 85 | ||
89 | u8 mac_addr[ETH_ALEN]; | 86 | u8 mac_addr[ETH_ALEN]; |
90 | #ifdef CONFIG_IWM_B0_HW_SUPPORT | ||
91 | bool hw_b0; | ||
92 | #endif | ||
93 | }; | 87 | }; |
94 | 88 | ||
95 | enum { | 89 | enum { |
@@ -162,13 +156,11 @@ struct iwm_umac_key_hdr { | |||
162 | 156 | ||
163 | struct iwm_key { | 157 | struct iwm_key { |
164 | struct iwm_umac_key_hdr hdr; | 158 | struct iwm_umac_key_hdr hdr; |
165 | u8 in_use; | 159 | u32 cipher; |
166 | u8 alg; | 160 | u8 key[WLAN_MAX_KEY_LEN]; |
167 | u32 flags; | 161 | u8 seq[IW_ENCODE_SEQ_MAX_SIZE]; |
168 | u8 tx_seq[IW_ENCODE_SEQ_MAX_SIZE]; | 162 | int key_len; |
169 | u8 rx_seq[IW_ENCODE_SEQ_MAX_SIZE]; | 163 | int seq_len; |
170 | u8 key_len; | ||
171 | u8 key[32]; | ||
172 | }; | 164 | }; |
173 | 165 | ||
174 | #define IWM_RX_ID_HASH 0xff | 166 | #define IWM_RX_ID_HASH 0xff |
@@ -186,10 +178,6 @@ struct iwm_key { | |||
186 | #define IWM_STATUS_ASSOCIATING 3 | 178 | #define IWM_STATUS_ASSOCIATING 3 |
187 | #define IWM_STATUS_ASSOCIATED 4 | 179 | #define IWM_STATUS_ASSOCIATED 4 |
188 | 180 | ||
189 | #define IWM_RADIO_RFKILL_OFF 0 | ||
190 | #define IWM_RADIO_RFKILL_HW 1 | ||
191 | #define IWM_RADIO_RFKILL_SW 2 | ||
192 | |||
193 | struct iwm_tx_queue { | 181 | struct iwm_tx_queue { |
194 | int id; | 182 | int id; |
195 | struct sk_buff_head queue; | 183 | struct sk_buff_head queue; |
@@ -223,7 +211,6 @@ struct iwm_priv { | |||
223 | struct iwm_conf conf; | 211 | struct iwm_conf conf; |
224 | 212 | ||
225 | unsigned long status; | 213 | unsigned long status; |
226 | unsigned long radio; | ||
227 | 214 | ||
228 | struct list_head pending_notif; | 215 | struct list_head pending_notif; |
229 | wait_queue_head_t notif_queue; | 216 | wait_queue_head_t notif_queue; |
@@ -242,6 +229,7 @@ struct iwm_priv { | |||
242 | u8 bssid[ETH_ALEN]; | 229 | u8 bssid[ETH_ALEN]; |
243 | u8 channel; | 230 | u8 channel; |
244 | u16 rate; | 231 | u16 rate; |
232 | u32 txpower; | ||
245 | 233 | ||
246 | struct iwm_sta_info sta_table[IWM_STA_TABLE_NUM]; | 234 | struct iwm_sta_info sta_table[IWM_STA_TABLE_NUM]; |
247 | struct list_head bss_list; | 235 | struct list_head bss_list; |
@@ -276,7 +264,10 @@ struct iwm_priv { | |||
276 | struct iwm_tx_queue txq[IWM_TX_QUEUES]; | 264 | struct iwm_tx_queue txq[IWM_TX_QUEUES]; |
277 | 265 | ||
278 | struct iwm_key keys[IWM_NUM_KEYS]; | 266 | struct iwm_key keys[IWM_NUM_KEYS]; |
279 | struct iwm_key *default_key; | 267 | s8 default_key; |
268 | |||
269 | DECLARE_BITMAP(wifi_ntfy, WIFI_IF_NTFY_MAX); | ||
270 | wait_queue_head_t wifi_ntfy_queue; | ||
280 | 271 | ||
281 | wait_queue_head_t mlme_queue; | 272 | wait_queue_head_t mlme_queue; |
282 | 273 | ||
@@ -289,7 +280,6 @@ struct iwm_priv { | |||
289 | struct timer_list watchdog; | 280 | struct timer_list watchdog; |
290 | struct work_struct reset_worker; | 281 | struct work_struct reset_worker; |
291 | struct mutex mutex; | 282 | struct mutex mutex; |
292 | struct rfkill *rfkill; | ||
293 | 283 | ||
294 | char private[0] __attribute__((__aligned__(NETDEV_ALIGN))); | 284 | char private[0] __attribute__((__aligned__(NETDEV_ALIGN))); |
295 | }; | 285 | }; |
diff --git a/drivers/net/wireless/iwmc3200wifi/lmac.h b/drivers/net/wireless/iwmc3200wifi/lmac.h index db2e5eea1895..19213e165f5f 100644 --- a/drivers/net/wireless/iwmc3200wifi/lmac.h +++ b/drivers/net/wireless/iwmc3200wifi/lmac.h | |||
@@ -396,6 +396,10 @@ enum { | |||
396 | CALIBRATION_CMD_NUM, | 396 | CALIBRATION_CMD_NUM, |
397 | }; | 397 | }; |
398 | 398 | ||
399 | #define IWM_CALIB_MAP_INIT_MSK 0xFFFF | ||
400 | #define IWM_CALIB_MAP_PER_LMAC(m) ((m & 0xFF0000) >> 16) | ||
401 | #define IWM_CALIB_MAP_PER_UMAC(m) ((m & 0xFF000000) >> 24) | ||
402 | |||
399 | struct iwm_lmac_calib_hdr { | 403 | struct iwm_lmac_calib_hdr { |
400 | u8 opcode; | 404 | u8 opcode; |
401 | u8 first_grp; | 405 | u8 first_grp; |
diff --git a/drivers/net/wireless/iwmc3200wifi/main.c b/drivers/net/wireless/iwmc3200wifi/main.c index 8be206d58222..484f110151b7 100644 --- a/drivers/net/wireless/iwmc3200wifi/main.c +++ b/drivers/net/wireless/iwmc3200wifi/main.c | |||
@@ -53,11 +53,7 @@ | |||
53 | static struct iwm_conf def_iwm_conf = { | 53 | static struct iwm_conf def_iwm_conf = { |
54 | 54 | ||
55 | .sdio_ior_timeout = 5000, | 55 | .sdio_ior_timeout = 5000, |
56 | .init_calib_map = BIT(PHY_CALIBRATE_DC_CMD) | | 56 | .calib_map = BIT(PHY_CALIBRATE_DC_CMD) | |
57 | BIT(PHY_CALIBRATE_LO_CMD) | | ||
58 | BIT(PHY_CALIBRATE_TX_IQ_CMD) | | ||
59 | BIT(PHY_CALIBRATE_RX_IQ_CMD), | ||
60 | .periodic_calib_map = BIT(PHY_CALIBRATE_DC_CMD) | | ||
61 | BIT(PHY_CALIBRATE_LO_CMD) | | 57 | BIT(PHY_CALIBRATE_LO_CMD) | |
62 | BIT(PHY_CALIBRATE_TX_IQ_CMD) | | 58 | BIT(PHY_CALIBRATE_TX_IQ_CMD) | |
63 | BIT(PHY_CALIBRATE_RX_IQ_CMD) | | 59 | BIT(PHY_CALIBRATE_RX_IQ_CMD) | |
@@ -191,6 +187,7 @@ int iwm_priv_init(struct iwm_priv *iwm) | |||
191 | INIT_LIST_HEAD(&iwm->pending_notif); | 187 | INIT_LIST_HEAD(&iwm->pending_notif); |
192 | init_waitqueue_head(&iwm->notif_queue); | 188 | init_waitqueue_head(&iwm->notif_queue); |
193 | init_waitqueue_head(&iwm->nonwifi_queue); | 189 | init_waitqueue_head(&iwm->nonwifi_queue); |
190 | init_waitqueue_head(&iwm->wifi_ntfy_queue); | ||
194 | init_waitqueue_head(&iwm->mlme_queue); | 191 | init_waitqueue_head(&iwm->mlme_queue); |
195 | memcpy(&iwm->conf, &def_iwm_conf, sizeof(struct iwm_conf)); | 192 | memcpy(&iwm->conf, &def_iwm_conf, sizeof(struct iwm_conf)); |
196 | spin_lock_init(&iwm->tx_credit.lock); | 193 | spin_lock_init(&iwm->tx_credit.lock); |
@@ -229,7 +226,7 @@ int iwm_priv_init(struct iwm_priv *iwm) | |||
229 | for (i = 0; i < IWM_NUM_KEYS; i++) | 226 | for (i = 0; i < IWM_NUM_KEYS; i++) |
230 | memset(&iwm->keys[i], 0, sizeof(struct iwm_key)); | 227 | memset(&iwm->keys[i], 0, sizeof(struct iwm_key)); |
231 | 228 | ||
232 | iwm->default_key = NULL; | 229 | iwm->default_key = -1; |
233 | 230 | ||
234 | init_timer(&iwm->watchdog); | 231 | init_timer(&iwm->watchdog); |
235 | iwm->watchdog.function = iwm_watchdog; | 232 | iwm->watchdog.function = iwm_watchdog; |
@@ -518,13 +515,6 @@ static int iwm_channels_init(struct iwm_priv *iwm) | |||
518 | { | 515 | { |
519 | int ret; | 516 | int ret; |
520 | 517 | ||
521 | #ifdef CONFIG_IWM_B0_HW_SUPPORT | ||
522 | if (iwm->conf.hw_b0) { | ||
523 | IWM_INFO(iwm, "Workaround EEPROM channels for B0 hardware\n"); | ||
524 | return 0; | ||
525 | } | ||
526 | #endif | ||
527 | |||
528 | ret = iwm_send_umac_channel_list(iwm); | 518 | ret = iwm_send_umac_channel_list(iwm); |
529 | if (ret) { | 519 | if (ret) { |
530 | IWM_ERR(iwm, "Send channel list failed\n"); | 520 | IWM_ERR(iwm, "Send channel list failed\n"); |
@@ -642,19 +632,10 @@ int __iwm_up(struct iwm_priv *iwm) | |||
642 | } | 632 | } |
643 | } | 633 | } |
644 | 634 | ||
645 | iwm->umac_profile = kmalloc(sizeof(struct iwm_umac_profile), | ||
646 | GFP_KERNEL); | ||
647 | if (!iwm->umac_profile) { | ||
648 | IWM_ERR(iwm, "Couldn't alloc memory for profile\n"); | ||
649 | goto err_fw; | ||
650 | } | ||
651 | |||
652 | iwm_init_default_profile(iwm, iwm->umac_profile); | ||
653 | |||
654 | ret = iwm_channels_init(iwm); | 635 | ret = iwm_channels_init(iwm); |
655 | if (ret < 0) { | 636 | if (ret < 0) { |
656 | IWM_ERR(iwm, "Couldn't init channels\n"); | 637 | IWM_ERR(iwm, "Couldn't init channels\n"); |
657 | goto err_profile; | 638 | goto err_fw; |
658 | } | 639 | } |
659 | 640 | ||
660 | /* Set the READY bit to indicate interface is brought up successfully */ | 641 | /* Set the READY bit to indicate interface is brought up successfully */ |
@@ -662,10 +643,6 @@ int __iwm_up(struct iwm_priv *iwm) | |||
662 | 643 | ||
663 | return 0; | 644 | return 0; |
664 | 645 | ||
665 | err_profile: | ||
666 | kfree(iwm->umac_profile); | ||
667 | iwm->umac_profile = NULL; | ||
668 | |||
669 | err_fw: | 646 | err_fw: |
670 | iwm_eeprom_exit(iwm); | 647 | iwm_eeprom_exit(iwm); |
671 | 648 | ||
@@ -704,11 +681,10 @@ int __iwm_down(struct iwm_priv *iwm) | |||
704 | clear_bit(IWM_STATUS_READY, &iwm->status); | 681 | clear_bit(IWM_STATUS_READY, &iwm->status); |
705 | 682 | ||
706 | iwm_eeprom_exit(iwm); | 683 | iwm_eeprom_exit(iwm); |
707 | kfree(iwm->umac_profile); | ||
708 | iwm->umac_profile = NULL; | ||
709 | iwm_bss_list_clean(iwm); | 684 | iwm_bss_list_clean(iwm); |
710 | 685 | iwm_init_default_profile(iwm, iwm->umac_profile); | |
711 | iwm->default_key = NULL; | 686 | iwm->umac_profile_active = false; |
687 | iwm->default_key = -1; | ||
712 | iwm->core_enabled = 0; | 688 | iwm->core_enabled = 0; |
713 | 689 | ||
714 | ret = iwm_bus_disable(iwm); | 690 | ret = iwm_bus_disable(iwm); |
diff --git a/drivers/net/wireless/iwmc3200wifi/netdev.c b/drivers/net/wireless/iwmc3200wifi/netdev.c index aaa20c6885c8..e94e96955b99 100644 --- a/drivers/net/wireless/iwmc3200wifi/netdev.c +++ b/drivers/net/wireless/iwmc3200wifi/netdev.c | |||
@@ -48,29 +48,22 @@ | |||
48 | #include <linux/netdevice.h> | 48 | #include <linux/netdevice.h> |
49 | 49 | ||
50 | #include "iwm.h" | 50 | #include "iwm.h" |
51 | #include "commands.h" | ||
51 | #include "cfg80211.h" | 52 | #include "cfg80211.h" |
52 | #include "debug.h" | 53 | #include "debug.h" |
53 | 54 | ||
54 | static int iwm_open(struct net_device *ndev) | 55 | static int iwm_open(struct net_device *ndev) |
55 | { | 56 | { |
56 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | 57 | struct iwm_priv *iwm = ndev_to_iwm(ndev); |
57 | int ret = 0; | ||
58 | |||
59 | if (!test_bit(IWM_RADIO_RFKILL_SW, &iwm->radio)) | ||
60 | ret = iwm_up(iwm); | ||
61 | 58 | ||
62 | return ret; | 59 | return iwm_up(iwm); |
63 | } | 60 | } |
64 | 61 | ||
65 | static int iwm_stop(struct net_device *ndev) | 62 | static int iwm_stop(struct net_device *ndev) |
66 | { | 63 | { |
67 | struct iwm_priv *iwm = ndev_to_iwm(ndev); | 64 | struct iwm_priv *iwm = ndev_to_iwm(ndev); |
68 | int ret = 0; | ||
69 | |||
70 | if (!test_bit(IWM_RADIO_RFKILL_SW, &iwm->radio)) | ||
71 | ret = iwm_down(iwm); | ||
72 | 65 | ||
73 | return ret; | 66 | return iwm_down(iwm); |
74 | } | 67 | } |
75 | 68 | ||
76 | /* | 69 | /* |
@@ -135,8 +128,20 @@ void *iwm_if_alloc(int sizeof_bus, struct device *dev, | |||
135 | SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); | 128 | SET_NETDEV_DEV(ndev, wiphy_dev(wdev->wiphy)); |
136 | wdev->netdev = ndev; | 129 | wdev->netdev = ndev; |
137 | 130 | ||
131 | iwm->umac_profile = kmalloc(sizeof(struct iwm_umac_profile), | ||
132 | GFP_KERNEL); | ||
133 | if (!iwm->umac_profile) { | ||
134 | dev_err(dev, "Couldn't alloc memory for profile\n"); | ||
135 | goto out_profile; | ||
136 | } | ||
137 | |||
138 | iwm_init_default_profile(iwm, iwm->umac_profile); | ||
139 | |||
138 | return iwm; | 140 | return iwm; |
139 | 141 | ||
142 | out_profile: | ||
143 | free_netdev(ndev); | ||
144 | |||
140 | out_priv: | 145 | out_priv: |
141 | iwm_priv_deinit(iwm); | 146 | iwm_priv_deinit(iwm); |
142 | 147 | ||
@@ -153,6 +158,8 @@ void iwm_if_free(struct iwm_priv *iwm) | |||
153 | free_netdev(iwm_to_ndev(iwm)); | 158 | free_netdev(iwm_to_ndev(iwm)); |
154 | iwm_wdev_free(iwm); | 159 | iwm_wdev_free(iwm); |
155 | iwm_priv_deinit(iwm); | 160 | iwm_priv_deinit(iwm); |
161 | kfree(iwm->umac_profile); | ||
162 | iwm->umac_profile = NULL; | ||
156 | } | 163 | } |
157 | 164 | ||
158 | int iwm_if_add(struct iwm_priv *iwm) | 165 | int iwm_if_add(struct iwm_priv *iwm) |
diff --git a/drivers/net/wireless/iwmc3200wifi/rx.c b/drivers/net/wireless/iwmc3200wifi/rx.c index d73cf96c6dc6..3909477fb3bf 100644 --- a/drivers/net/wireless/iwmc3200wifi/rx.c +++ b/drivers/net/wireless/iwmc3200wifi/rx.c | |||
@@ -143,17 +143,18 @@ static int iwm_ntf_init_complete(struct iwm_priv *iwm, u8 *buf, | |||
143 | unsigned long buf_size, | 143 | unsigned long buf_size, |
144 | struct iwm_wifi_cmd *cmd) | 144 | struct iwm_wifi_cmd *cmd) |
145 | { | 145 | { |
146 | struct wiphy *wiphy = iwm_to_wiphy(iwm); | ||
146 | struct iwm_umac_notif_init_complete *init_complete = | 147 | struct iwm_umac_notif_init_complete *init_complete = |
147 | (struct iwm_umac_notif_init_complete *)(buf); | 148 | (struct iwm_umac_notif_init_complete *)(buf); |
148 | u16 status = le16_to_cpu(init_complete->status); | 149 | u16 status = le16_to_cpu(init_complete->status); |
150 | bool blocked = (status == UMAC_NTFY_INIT_COMPLETE_STATUS_ERR); | ||
149 | 151 | ||
150 | if (status == UMAC_NTFY_INIT_COMPLETE_STATUS_ERR) { | 152 | if (blocked) |
151 | IWM_DBG_NTF(iwm, DBG, "Hardware rf kill is on (radio off)\n"); | 153 | IWM_DBG_NTF(iwm, DBG, "Hardware rf kill is on (radio off)\n"); |
152 | set_bit(IWM_RADIO_RFKILL_HW, &iwm->radio); | 154 | else |
153 | } else { | ||
154 | IWM_DBG_NTF(iwm, DBG, "Hardware rf kill is off (radio on)\n"); | 155 | IWM_DBG_NTF(iwm, DBG, "Hardware rf kill is off (radio on)\n"); |
155 | clear_bit(IWM_RADIO_RFKILL_HW, &iwm->radio); | 156 | |
156 | } | 157 | wiphy_rfkill_set_hw_state(wiphy, blocked); |
157 | 158 | ||
158 | return 0; | 159 | return 0; |
159 | } | 160 | } |
@@ -875,6 +876,7 @@ static int iwm_ntf_statistics(struct iwm_priv *iwm, u8 *buf, | |||
875 | /* UMAC passes rate info multiplies by 2 */ | 876 | /* UMAC passes rate info multiplies by 2 */ |
876 | iwm->rate = max_rate >> 1; | 877 | iwm->rate = max_rate >> 1; |
877 | } | 878 | } |
879 | iwm->txpower = le32_to_cpu(stats->tx_power); | ||
878 | 880 | ||
879 | wstats->status = 0; | 881 | wstats->status = 0; |
880 | 882 | ||
@@ -922,13 +924,6 @@ static int iwm_ntf_eeprom_proxy(struct iwm_priv *iwm, u8 *buf, | |||
922 | if ((hdr_offset + hdr_len) > IWM_EEPROM_LEN) | 924 | if ((hdr_offset + hdr_len) > IWM_EEPROM_LEN) |
923 | return -EINVAL; | 925 | return -EINVAL; |
924 | 926 | ||
925 | #ifdef CONFIG_IWM_B0_HW_SUPPORT | ||
926 | if (hdr_offset == IWM_EEPROM_SKU_CAP_OFF) { | ||
927 | if (eeprom_proxy->buf[0] == 0xff) | ||
928 | iwm->conf.hw_b0 = 1; | ||
929 | } | ||
930 | #endif | ||
931 | |||
932 | switch (hdr_type) { | 927 | switch (hdr_type) { |
933 | case IWM_UMAC_CMD_EEPROM_TYPE_READ: | 928 | case IWM_UMAC_CMD_EEPROM_TYPE_READ: |
934 | memcpy(iwm->eeprom + hdr_offset, eeprom_proxy->buf, hdr_len); | 929 | memcpy(iwm->eeprom + hdr_offset, eeprom_proxy->buf, hdr_len); |
@@ -993,12 +988,17 @@ static int iwm_ntf_wifi_if_wrapper(struct iwm_priv *iwm, u8 *buf, | |||
993 | (struct iwm_umac_wifi_if *)cmd->buf.payload; | 988 | (struct iwm_umac_wifi_if *)cmd->buf.payload; |
994 | 989 | ||
995 | IWM_DBG_NTF(iwm, DBG, "WIFI_IF_WRAPPER cmd is delivered to UMAC: " | 990 | IWM_DBG_NTF(iwm, DBG, "WIFI_IF_WRAPPER cmd is delivered to UMAC: " |
996 | "oid is %d\n", hdr->oid); | 991 | "oid is 0x%x\n", hdr->oid); |
992 | |||
993 | if (hdr->oid <= WIFI_IF_NTFY_MAX) { | ||
994 | set_bit(hdr->oid, &iwm->wifi_ntfy[0]); | ||
995 | wake_up_interruptible(&iwm->wifi_ntfy_queue); | ||
996 | } else | ||
997 | return -EINVAL; | ||
997 | 998 | ||
998 | switch (hdr->oid) { | 999 | switch (hdr->oid) { |
999 | case UMAC_WIFI_IF_CMD_SET_PROFILE: | 1000 | case UMAC_WIFI_IF_CMD_SET_PROFILE: |
1000 | iwm->umac_profile_active = 1; | 1001 | iwm->umac_profile_active = 1; |
1001 | wake_up_interruptible(&iwm->mlme_queue); | ||
1002 | break; | 1002 | break; |
1003 | default: | 1003 | default: |
1004 | break; | 1004 | break; |
@@ -1010,6 +1010,7 @@ static int iwm_ntf_wifi_if_wrapper(struct iwm_priv *iwm, u8 *buf, | |||
1010 | static int iwm_ntf_card_state(struct iwm_priv *iwm, u8 *buf, | 1010 | static int iwm_ntf_card_state(struct iwm_priv *iwm, u8 *buf, |
1011 | unsigned long buf_size, struct iwm_wifi_cmd *cmd) | 1011 | unsigned long buf_size, struct iwm_wifi_cmd *cmd) |
1012 | { | 1012 | { |
1013 | struct wiphy *wiphy = iwm_to_wiphy(iwm); | ||
1013 | struct iwm_lmac_card_state *state = (struct iwm_lmac_card_state *) | 1014 | struct iwm_lmac_card_state *state = (struct iwm_lmac_card_state *) |
1014 | (buf + sizeof(struct iwm_umac_wifi_in_hdr)); | 1015 | (buf + sizeof(struct iwm_umac_wifi_in_hdr)); |
1015 | u32 flags = le32_to_cpu(state->flags); | 1016 | u32 flags = le32_to_cpu(state->flags); |
@@ -1018,10 +1019,7 @@ static int iwm_ntf_card_state(struct iwm_priv *iwm, u8 *buf, | |||
1018 | flags & IWM_CARD_STATE_HW_DISABLED ? "ON" : "OFF", | 1019 | flags & IWM_CARD_STATE_HW_DISABLED ? "ON" : "OFF", |
1019 | flags & IWM_CARD_STATE_CTKILL_DISABLED ? "ON" : "OFF"); | 1020 | flags & IWM_CARD_STATE_CTKILL_DISABLED ? "ON" : "OFF"); |
1020 | 1021 | ||
1021 | if (flags & IWM_CARD_STATE_HW_DISABLED) | 1022 | wiphy_rfkill_set_hw_state(wiphy, flags & IWM_CARD_STATE_HW_DISABLED); |
1022 | set_bit(IWM_RADIO_RFKILL_HW, &iwm->radio); | ||
1023 | else | ||
1024 | clear_bit(IWM_RADIO_RFKILL_HW, &iwm->radio); | ||
1025 | 1023 | ||
1026 | return 0; | 1024 | return 0; |
1027 | } | 1025 | } |
@@ -1368,7 +1366,7 @@ static void iwm_rx_process_packet(struct iwm_priv *iwm, | |||
1368 | ndev->stats.rx_packets++; | 1366 | ndev->stats.rx_packets++; |
1369 | ndev->stats.rx_bytes += skb->len; | 1367 | ndev->stats.rx_bytes += skb->len; |
1370 | 1368 | ||
1371 | if (netif_rx(skb) == NET_RX_DROP) { | 1369 | if (netif_rx_ni(skb) == NET_RX_DROP) { |
1372 | IWM_ERR(iwm, "Packet dropped\n"); | 1370 | IWM_ERR(iwm, "Packet dropped\n"); |
1373 | ndev->stats.rx_dropped++; | 1371 | ndev->stats.rx_dropped++; |
1374 | } | 1372 | } |
diff --git a/drivers/net/wireless/iwmc3200wifi/sdio.c b/drivers/net/wireless/iwmc3200wifi/sdio.c index 916681837fd2..b93f620ee4f1 100644 --- a/drivers/net/wireless/iwmc3200wifi/sdio.c +++ b/drivers/net/wireless/iwmc3200wifi/sdio.c | |||
@@ -506,11 +506,7 @@ static struct sdio_driver iwm_sdio_driver = { | |||
506 | 506 | ||
507 | static int __init iwm_sdio_init_module(void) | 507 | static int __init iwm_sdio_init_module(void) |
508 | { | 508 | { |
509 | int ret; | 509 | return sdio_register_driver(&iwm_sdio_driver); |
510 | |||
511 | ret = sdio_register_driver(&iwm_sdio_driver); | ||
512 | |||
513 | return ret; | ||
514 | } | 510 | } |
515 | 511 | ||
516 | static void __exit iwm_sdio_exit_module(void) | 512 | static void __exit iwm_sdio_exit_module(void) |
diff --git a/drivers/net/wireless/iwmc3200wifi/umac.h b/drivers/net/wireless/iwmc3200wifi/umac.h index 4a95cce1f0a6..0af2a3c76281 100644 --- a/drivers/net/wireless/iwmc3200wifi/umac.h +++ b/drivers/net/wireless/iwmc3200wifi/umac.h | |||
@@ -495,6 +495,8 @@ struct iwm_fw_alive_hdr { | |||
495 | #define WIFI_DBG_IF_NTFY_COEX_HANDLE_ENVELOP 0xE8 | 495 | #define WIFI_DBG_IF_NTFY_COEX_HANDLE_ENVELOP 0xE8 |
496 | #define WIFI_DBG_IF_NTFY_COEX_HANDLE_RELEASE_ENVELOP 0xE9 | 496 | #define WIFI_DBG_IF_NTFY_COEX_HANDLE_RELEASE_ENVELOP 0xE9 |
497 | 497 | ||
498 | #define WIFI_IF_NTFY_MAX 0xff | ||
499 | |||
498 | /* Notification structures */ | 500 | /* Notification structures */ |
499 | struct iwm_umac_notif_wifi_if { | 501 | struct iwm_umac_notif_wifi_if { |
500 | struct iwm_umac_wifi_in_hdr hdr; | 502 | struct iwm_umac_wifi_in_hdr hdr; |
diff --git a/drivers/net/wireless/iwmc3200wifi/wext.c b/drivers/net/wireless/iwmc3200wifi/wext.c index 584c94d0f399..2e7eaf96cf93 100644 --- a/drivers/net/wireless/iwmc3200wifi/wext.c +++ b/drivers/net/wireless/iwmc3200wifi/wext.c | |||
@@ -82,6 +82,9 @@ static int iwm_wext_siwap(struct net_device *dev, struct iw_request_info *info, | |||
82 | struct sockaddr *ap_addr, char *extra) | 82 | struct sockaddr *ap_addr, char *extra) |
83 | { | 83 | { |
84 | struct iwm_priv *iwm = ndev_to_iwm(dev); | 84 | struct iwm_priv *iwm = ndev_to_iwm(dev); |
85 | int ret; | ||
86 | |||
87 | IWM_DBG_WEXT(iwm, DBG, "Set BSSID: %pM\n", ap_addr->sa_data); | ||
85 | 88 | ||
86 | if (iwm->conf.mode == UMAC_MODE_IBSS) | 89 | if (iwm->conf.mode == UMAC_MODE_IBSS) |
87 | return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra); | 90 | return cfg80211_ibss_wext_siwap(dev, info, ap_addr, extra); |
@@ -104,10 +107,25 @@ static int iwm_wext_siwap(struct net_device *dev, struct iw_request_info *info, | |||
104 | } | 107 | } |
105 | 108 | ||
106 | if (iwm->umac_profile_active) { | 109 | if (iwm->umac_profile_active) { |
110 | int i; | ||
111 | |||
107 | if (!memcmp(&iwm->umac_profile->bssid[0], iwm->bssid, ETH_ALEN)) | 112 | if (!memcmp(&iwm->umac_profile->bssid[0], iwm->bssid, ETH_ALEN)) |
108 | return 0; | 113 | return 0; |
109 | 114 | ||
110 | iwm_invalidate_mlme_profile(iwm); | 115 | /* |
116 | * If we're clearing the BSSID, and we're associated, | ||
117 | * we have to clear the keys as they're no longer valid. | ||
118 | */ | ||
119 | if (is_zero_ether_addr(ap_addr->sa_data)) { | ||
120 | for (i = 0; i < IWM_NUM_KEYS; i++) | ||
121 | iwm->keys[i].key_len = 0; | ||
122 | } | ||
123 | |||
124 | ret = iwm_invalidate_mlme_profile(iwm); | ||
125 | if (ret < 0) { | ||
126 | IWM_ERR(iwm, "Couldn't invalidate profile\n"); | ||
127 | return ret; | ||
128 | } | ||
111 | } | 129 | } |
112 | 130 | ||
113 | if (iwm->umac_profile->ssid.ssid_len) | 131 | if (iwm->umac_profile->ssid.ssid_len) |
@@ -146,6 +164,8 @@ static int iwm_wext_siwessid(struct net_device *dev, | |||
146 | size_t len = data->length; | 164 | size_t len = data->length; |
147 | int ret; | 165 | int ret; |
148 | 166 | ||
167 | IWM_DBG_WEXT(iwm, DBG, "Set ESSID: >%s<\n", ssid); | ||
168 | |||
149 | if (iwm->conf.mode == UMAC_MODE_IBSS) | 169 | if (iwm->conf.mode == UMAC_MODE_IBSS) |
150 | return cfg80211_ibss_wext_siwessid(dev, info, data, ssid); | 170 | return cfg80211_ibss_wext_siwessid(dev, info, data, ssid); |
151 | 171 | ||
@@ -195,27 +215,6 @@ static int iwm_wext_giwessid(struct net_device *dev, | |||
195 | return 0; | 215 | return 0; |
196 | } | 216 | } |
197 | 217 | ||
198 | static struct iwm_key * | ||
199 | iwm_key_init(struct iwm_priv *iwm, u8 key_idx, bool in_use, | ||
200 | struct iw_encode_ext *ext, u8 alg) | ||
201 | { | ||
202 | struct iwm_key *key = &iwm->keys[key_idx]; | ||
203 | |||
204 | memset(key, 0, sizeof(struct iwm_key)); | ||
205 | memcpy(key->hdr.mac, ext->addr.sa_data, ETH_ALEN); | ||
206 | key->hdr.key_idx = key_idx; | ||
207 | if (is_broadcast_ether_addr(ext->addr.sa_data)) | ||
208 | key->hdr.multicast = 1; | ||
209 | |||
210 | key->in_use = in_use; | ||
211 | key->flags = ext->ext_flags; | ||
212 | key->alg = alg; | ||
213 | key->key_len = ext->key_len; | ||
214 | memcpy(key->key, ext->key, ext->key_len); | ||
215 | |||
216 | return key; | ||
217 | } | ||
218 | |||
219 | static int iwm_wext_giwrate(struct net_device *dev, | 218 | static int iwm_wext_giwrate(struct net_device *dev, |
220 | struct iw_request_info *info, | 219 | struct iw_request_info *info, |
221 | struct iw_param *rate, char *extra) | 220 | struct iw_param *rate, char *extra) |
@@ -227,184 +226,6 @@ static int iwm_wext_giwrate(struct net_device *dev, | |||
227 | return 0; | 226 | return 0; |
228 | } | 227 | } |
229 | 228 | ||
230 | static int iwm_wext_siwencode(struct net_device *dev, | ||
231 | struct iw_request_info *info, | ||
232 | struct iw_point *erq, char *key_buf) | ||
233 | { | ||
234 | struct iwm_priv *iwm = ndev_to_iwm(dev); | ||
235 | struct iwm_key *uninitialized_var(key); | ||
236 | int idx, i, uninitialized_var(alg), remove = 0, ret; | ||
237 | |||
238 | IWM_DBG_WEXT(iwm, DBG, "key len: %d\n", erq->length); | ||
239 | IWM_DBG_WEXT(iwm, DBG, "flags: 0x%x\n", erq->flags); | ||
240 | |||
241 | if (!iwm->umac_profile) { | ||
242 | IWM_ERR(iwm, "UMAC profile not allocated yet\n"); | ||
243 | return -ENODEV; | ||
244 | } | ||
245 | |||
246 | if (erq->length == WLAN_KEY_LEN_WEP40) { | ||
247 | alg = UMAC_CIPHER_TYPE_WEP_40; | ||
248 | iwm->umac_profile->sec.ucast_cipher = UMAC_CIPHER_TYPE_WEP_40; | ||
249 | iwm->umac_profile->sec.mcast_cipher = UMAC_CIPHER_TYPE_WEP_40; | ||
250 | } else if (erq->length == WLAN_KEY_LEN_WEP104) { | ||
251 | alg = UMAC_CIPHER_TYPE_WEP_104; | ||
252 | iwm->umac_profile->sec.ucast_cipher = UMAC_CIPHER_TYPE_WEP_104; | ||
253 | iwm->umac_profile->sec.mcast_cipher = UMAC_CIPHER_TYPE_WEP_104; | ||
254 | } | ||
255 | |||
256 | if (erq->flags & IW_ENCODE_RESTRICTED) | ||
257 | iwm->umac_profile->sec.auth_type = UMAC_AUTH_TYPE_LEGACY_PSK; | ||
258 | else | ||
259 | iwm->umac_profile->sec.auth_type = UMAC_AUTH_TYPE_OPEN; | ||
260 | |||
261 | idx = erq->flags & IW_ENCODE_INDEX; | ||
262 | if (idx == 0) { | ||
263 | if (iwm->default_key) | ||
264 | for (i = 0; i < IWM_NUM_KEYS; i++) { | ||
265 | if (iwm->default_key == &iwm->keys[i]) { | ||
266 | idx = i; | ||
267 | break; | ||
268 | } | ||
269 | } | ||
270 | else | ||
271 | iwm->default_key = &iwm->keys[idx]; | ||
272 | } else if (idx < 1 || idx > 4) { | ||
273 | return -EINVAL; | ||
274 | } else | ||
275 | idx--; | ||
276 | |||
277 | if (erq->flags & IW_ENCODE_DISABLED) | ||
278 | remove = 1; | ||
279 | else if (erq->length == 0) { | ||
280 | if (!iwm->keys[idx].in_use) | ||
281 | return -EINVAL; | ||
282 | iwm->default_key = &iwm->keys[idx]; | ||
283 | } | ||
284 | |||
285 | if (erq->length) { | ||
286 | key = &iwm->keys[idx]; | ||
287 | memset(key, 0, sizeof(struct iwm_key)); | ||
288 | memset(key->hdr.mac, 0xff, ETH_ALEN); | ||
289 | key->hdr.key_idx = idx; | ||
290 | key->hdr.multicast = 1; | ||
291 | key->in_use = !remove; | ||
292 | key->alg = alg; | ||
293 | key->key_len = erq->length; | ||
294 | memcpy(key->key, key_buf, erq->length); | ||
295 | |||
296 | IWM_DBG_WEXT(iwm, DBG, "Setting key %d, default: %d\n", | ||
297 | idx, !!iwm->default_key); | ||
298 | } | ||
299 | |||
300 | if (remove) { | ||
301 | if ((erq->flags & IW_ENCODE_NOKEY) || (erq->length == 0)) { | ||
302 | int j; | ||
303 | for (j = 0; j < IWM_NUM_KEYS; j++) | ||
304 | if (iwm->keys[j].in_use) { | ||
305 | struct iwm_key *k = &iwm->keys[j]; | ||
306 | |||
307 | k->in_use = 0; | ||
308 | ret = iwm_set_key(iwm, remove, 0, k); | ||
309 | if (ret < 0) | ||
310 | return ret; | ||
311 | } | ||
312 | |||
313 | iwm->umac_profile->sec.ucast_cipher = | ||
314 | UMAC_CIPHER_TYPE_NONE; | ||
315 | iwm->umac_profile->sec.mcast_cipher = | ||
316 | UMAC_CIPHER_TYPE_NONE; | ||
317 | iwm->umac_profile->sec.auth_type = | ||
318 | UMAC_AUTH_TYPE_OPEN; | ||
319 | |||
320 | return 0; | ||
321 | } else { | ||
322 | key->in_use = 0; | ||
323 | return iwm_set_key(iwm, remove, 0, key); | ||
324 | } | ||
325 | } | ||
326 | |||
327 | /* | ||
328 | * If we havent set a profile yet, we cant set keys. | ||
329 | * Keys will be pushed after we're associated. | ||
330 | */ | ||
331 | if (!iwm->umac_profile_active) | ||
332 | return 0; | ||
333 | |||
334 | /* | ||
335 | * If there is a current active profile, but no | ||
336 | * default key, it's not worth trying to associate again. | ||
337 | */ | ||
338 | if (!iwm->default_key) | ||
339 | return 0; | ||
340 | |||
341 | /* | ||
342 | * Here we have an active profile, but a key setting changed. | ||
343 | * We thus have to invalidate the current profile, and push the | ||
344 | * new one. Keys will be pushed when association takes place. | ||
345 | */ | ||
346 | ret = iwm_invalidate_mlme_profile(iwm); | ||
347 | if (ret < 0) { | ||
348 | IWM_ERR(iwm, "Couldn't invalidate profile\n"); | ||
349 | return ret; | ||
350 | } | ||
351 | |||
352 | return iwm_send_mlme_profile(iwm); | ||
353 | } | ||
354 | |||
355 | static int iwm_wext_giwencode(struct net_device *dev, | ||
356 | struct iw_request_info *info, | ||
357 | struct iw_point *erq, char *key) | ||
358 | { | ||
359 | struct iwm_priv *iwm = ndev_to_iwm(dev); | ||
360 | int idx, i; | ||
361 | |||
362 | idx = erq->flags & IW_ENCODE_INDEX; | ||
363 | if (idx < 1 || idx > 4) { | ||
364 | idx = -1; | ||
365 | if (!iwm->default_key) { | ||
366 | erq->length = 0; | ||
367 | erq->flags |= IW_ENCODE_NOKEY; | ||
368 | return 0; | ||
369 | } else | ||
370 | for (i = 0; i < IWM_NUM_KEYS; i++) { | ||
371 | if (iwm->default_key == &iwm->keys[i]) { | ||
372 | idx = i; | ||
373 | break; | ||
374 | } | ||
375 | } | ||
376 | if (idx < 0) | ||
377 | return -EINVAL; | ||
378 | } else | ||
379 | idx--; | ||
380 | |||
381 | erq->flags = idx + 1; | ||
382 | |||
383 | if (!iwm->keys[idx].in_use) { | ||
384 | erq->length = 0; | ||
385 | erq->flags |= IW_ENCODE_DISABLED; | ||
386 | return 0; | ||
387 | } | ||
388 | |||
389 | memcpy(key, iwm->keys[idx].key, | ||
390 | min_t(int, erq->length, iwm->keys[idx].key_len)); | ||
391 | erq->length = iwm->keys[idx].key_len; | ||
392 | erq->flags |= IW_ENCODE_ENABLED; | ||
393 | |||
394 | if (iwm->umac_profile->mode == UMAC_MODE_BSS) { | ||
395 | switch (iwm->umac_profile->sec.auth_type) { | ||
396 | case UMAC_AUTH_TYPE_OPEN: | ||
397 | erq->flags |= IW_ENCODE_OPEN; | ||
398 | break; | ||
399 | default: | ||
400 | erq->flags |= IW_ENCODE_RESTRICTED; | ||
401 | break; | ||
402 | } | ||
403 | } | ||
404 | |||
405 | return 0; | ||
406 | } | ||
407 | |||
408 | static int iwm_set_wpa_version(struct iwm_priv *iwm, u8 wpa_version) | 229 | static int iwm_set_wpa_version(struct iwm_priv *iwm, u8 wpa_version) |
409 | { | 230 | { |
410 | if (wpa_version & IW_AUTH_WPA_VERSION_WPA2) | 231 | if (wpa_version & IW_AUTH_WPA_VERSION_WPA2) |
@@ -417,53 +238,12 @@ static int iwm_set_wpa_version(struct iwm_priv *iwm, u8 wpa_version) | |||
417 | return 0; | 238 | return 0; |
418 | } | 239 | } |
419 | 240 | ||
420 | static int iwm_wext_siwpower(struct net_device *dev, | ||
421 | struct iw_request_info *info, | ||
422 | struct iw_param *wrq, char *extra) | ||
423 | { | ||
424 | struct iwm_priv *iwm = ndev_to_iwm(dev); | ||
425 | u32 power_index; | ||
426 | |||
427 | if (wrq->disabled) { | ||
428 | power_index = IWM_POWER_INDEX_MIN; | ||
429 | goto set; | ||
430 | } else | ||
431 | power_index = IWM_POWER_INDEX_DEFAULT; | ||
432 | |||
433 | switch (wrq->flags & IW_POWER_MODE) { | ||
434 | case IW_POWER_ON: | ||
435 | case IW_POWER_MODE: | ||
436 | case IW_POWER_ALL_R: | ||
437 | break; | ||
438 | default: | ||
439 | return -EINVAL; | ||
440 | } | ||
441 | |||
442 | set: | ||
443 | if (power_index == iwm->conf.power_index) | ||
444 | return 0; | ||
445 | |||
446 | iwm->conf.power_index = power_index; | ||
447 | |||
448 | return iwm_umac_set_config_fix(iwm, UMAC_PARAM_TBL_CFG_FIX, | ||
449 | CFG_POWER_INDEX, iwm->conf.power_index); | ||
450 | } | ||
451 | |||
452 | static int iwm_wext_giwpower(struct net_device *dev, | ||
453 | struct iw_request_info *info, | ||
454 | union iwreq_data *wrqu, char *extra) | ||
455 | { | ||
456 | struct iwm_priv *iwm = ndev_to_iwm(dev); | ||
457 | |||
458 | wrqu->power.disabled = (iwm->conf.power_index == IWM_POWER_INDEX_MIN); | ||
459 | |||
460 | return 0; | ||
461 | } | ||
462 | |||
463 | static int iwm_set_key_mgt(struct iwm_priv *iwm, u8 key_mgt) | 241 | static int iwm_set_key_mgt(struct iwm_priv *iwm, u8 key_mgt) |
464 | { | 242 | { |
465 | u8 *auth_type = &iwm->umac_profile->sec.auth_type; | 243 | u8 *auth_type = &iwm->umac_profile->sec.auth_type; |
466 | 244 | ||
245 | IWM_DBG_WEXT(iwm, DBG, "key_mgt: 0x%x\n", key_mgt); | ||
246 | |||
467 | if (key_mgt == IW_AUTH_KEY_MGMT_802_1X) | 247 | if (key_mgt == IW_AUTH_KEY_MGMT_802_1X) |
468 | *auth_type = UMAC_AUTH_TYPE_8021X; | 248 | *auth_type = UMAC_AUTH_TYPE_8021X; |
469 | else if (key_mgt == IW_AUTH_KEY_MGMT_PSK) { | 249 | else if (key_mgt == IW_AUTH_KEY_MGMT_PSK) { |
@@ -513,6 +293,8 @@ static int iwm_set_auth_alg(struct iwm_priv *iwm, u8 auth_alg) | |||
513 | { | 293 | { |
514 | u8 *auth_type = &iwm->umac_profile->sec.auth_type; | 294 | u8 *auth_type = &iwm->umac_profile->sec.auth_type; |
515 | 295 | ||
296 | IWM_DBG_WEXT(iwm, DBG, "auth_alg: 0x%x\n", auth_alg); | ||
297 | |||
516 | switch (auth_alg) { | 298 | switch (auth_alg) { |
517 | case IW_AUTH_ALG_OPEN_SYSTEM: | 299 | case IW_AUTH_ALG_OPEN_SYSTEM: |
518 | *auth_type = UMAC_AUTH_TYPE_OPEN; | 300 | *auth_type = UMAC_AUTH_TYPE_OPEN; |
@@ -524,6 +306,7 @@ static int iwm_set_auth_alg(struct iwm_priv *iwm, u8 auth_alg) | |||
524 | return -EINVAL; | 306 | return -EINVAL; |
525 | *auth_type = UMAC_AUTH_TYPE_RSNA_PSK; | 307 | *auth_type = UMAC_AUTH_TYPE_RSNA_PSK; |
526 | } else { | 308 | } else { |
309 | IWM_DBG_WEXT(iwm, DBG, "WEP shared key\n"); | ||
527 | *auth_type = UMAC_AUTH_TYPE_LEGACY_PSK; | 310 | *auth_type = UMAC_AUTH_TYPE_LEGACY_PSK; |
528 | } | 311 | } |
529 | break; | 312 | break; |
@@ -586,75 +369,6 @@ static int iwm_wext_giwauth(struct net_device *dev, | |||
586 | return 0; | 369 | return 0; |
587 | } | 370 | } |
588 | 371 | ||
589 | static int iwm_wext_siwencodeext(struct net_device *dev, | ||
590 | struct iw_request_info *info, | ||
591 | struct iw_point *erq, char *extra) | ||
592 | { | ||
593 | struct iwm_priv *iwm = ndev_to_iwm(dev); | ||
594 | struct iwm_key *key; | ||
595 | struct iw_encode_ext *ext = (struct iw_encode_ext *) extra; | ||
596 | int uninitialized_var(alg), idx, i, remove = 0; | ||
597 | |||
598 | IWM_DBG_WEXT(iwm, DBG, "alg: 0x%x\n", ext->alg); | ||
599 | IWM_DBG_WEXT(iwm, DBG, "key len: %d\n", ext->key_len); | ||
600 | IWM_DBG_WEXT(iwm, DBG, "ext_flags: 0x%x\n", ext->ext_flags); | ||
601 | IWM_DBG_WEXT(iwm, DBG, "flags: 0x%x\n", erq->flags); | ||
602 | IWM_DBG_WEXT(iwm, DBG, "length: 0x%x\n", erq->length); | ||
603 | |||
604 | switch (ext->alg) { | ||
605 | case IW_ENCODE_ALG_NONE: | ||
606 | remove = 1; | ||
607 | break; | ||
608 | case IW_ENCODE_ALG_WEP: | ||
609 | if (ext->key_len == WLAN_KEY_LEN_WEP40) | ||
610 | alg = UMAC_CIPHER_TYPE_WEP_40; | ||
611 | else if (ext->key_len == WLAN_KEY_LEN_WEP104) | ||
612 | alg = UMAC_CIPHER_TYPE_WEP_104; | ||
613 | else { | ||
614 | IWM_ERR(iwm, "Invalid key length: %d\n", ext->key_len); | ||
615 | return -EINVAL; | ||
616 | } | ||
617 | |||
618 | break; | ||
619 | case IW_ENCODE_ALG_TKIP: | ||
620 | alg = UMAC_CIPHER_TYPE_TKIP; | ||
621 | break; | ||
622 | case IW_ENCODE_ALG_CCMP: | ||
623 | alg = UMAC_CIPHER_TYPE_CCMP; | ||
624 | break; | ||
625 | default: | ||
626 | return -EOPNOTSUPP; | ||
627 | } | ||
628 | |||
629 | idx = erq->flags & IW_ENCODE_INDEX; | ||
630 | |||
631 | if (idx == 0) { | ||
632 | if (iwm->default_key) | ||
633 | for (i = 0; i < IWM_NUM_KEYS; i++) { | ||
634 | if (iwm->default_key == &iwm->keys[i]) { | ||
635 | idx = i; | ||
636 | break; | ||
637 | } | ||
638 | } | ||
639 | } else if (idx < 1 || idx > 4) { | ||
640 | return -EINVAL; | ||
641 | } else | ||
642 | idx--; | ||
643 | |||
644 | if (erq->flags & IW_ENCODE_DISABLED) | ||
645 | remove = 1; | ||
646 | else if ((erq->length == 0) || | ||
647 | (ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY)) { | ||
648 | iwm->default_key = &iwm->keys[idx]; | ||
649 | if (iwm->umac_profile_active && ext->alg == IW_ENCODE_ALG_WEP) | ||
650 | return iwm_set_tx_key(iwm, idx); | ||
651 | } | ||
652 | |||
653 | key = iwm_key_init(iwm, idx, !remove, ext, alg); | ||
654 | |||
655 | return iwm_set_key(iwm, remove, !iwm->default_key, key); | ||
656 | } | ||
657 | |||
658 | static const iw_handler iwm_handlers[] = | 372 | static const iw_handler iwm_handlers[] = |
659 | { | 373 | { |
660 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ | 374 | (iw_handler) NULL, /* SIOCSIWCOMMIT */ |
@@ -695,21 +409,21 @@ static const iw_handler iwm_handlers[] = | |||
695 | (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */ | 409 | (iw_handler) cfg80211_wext_giwrts, /* SIOCGIWRTS */ |
696 | (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */ | 410 | (iw_handler) cfg80211_wext_siwfrag, /* SIOCSIWFRAG */ |
697 | (iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */ | 411 | (iw_handler) cfg80211_wext_giwfrag, /* SIOCGIWFRAG */ |
698 | (iw_handler) NULL, /* SIOCSIWTXPOW */ | 412 | (iw_handler) cfg80211_wext_siwtxpower, /* SIOCSIWTXPOW */ |
699 | (iw_handler) NULL, /* SIOCGIWTXPOW */ | 413 | (iw_handler) cfg80211_wext_giwtxpower, /* SIOCGIWTXPOW */ |
700 | (iw_handler) NULL, /* SIOCSIWRETRY */ | 414 | (iw_handler) NULL, /* SIOCSIWRETRY */ |
701 | (iw_handler) NULL, /* SIOCGIWRETRY */ | 415 | (iw_handler) NULL, /* SIOCGIWRETRY */ |
702 | (iw_handler) iwm_wext_siwencode, /* SIOCSIWENCODE */ | 416 | (iw_handler) cfg80211_wext_siwencode, /* SIOCSIWENCODE */ |
703 | (iw_handler) iwm_wext_giwencode, /* SIOCGIWENCODE */ | 417 | (iw_handler) cfg80211_wext_giwencode, /* SIOCGIWENCODE */ |
704 | (iw_handler) iwm_wext_siwpower, /* SIOCSIWPOWER */ | 418 | (iw_handler) cfg80211_wext_siwpower, /* SIOCSIWPOWER */ |
705 | (iw_handler) iwm_wext_giwpower, /* SIOCGIWPOWER */ | 419 | (iw_handler) cfg80211_wext_giwpower, /* SIOCGIWPOWER */ |
706 | (iw_handler) NULL, /* -- hole -- */ | 420 | (iw_handler) NULL, /* -- hole -- */ |
707 | (iw_handler) NULL, /* -- hole -- */ | 421 | (iw_handler) NULL, /* -- hole -- */ |
708 | (iw_handler) NULL, /* SIOCSIWGENIE */ | 422 | (iw_handler) NULL, /* SIOCSIWGENIE */ |
709 | (iw_handler) NULL, /* SIOCGIWGENIE */ | 423 | (iw_handler) NULL, /* SIOCGIWGENIE */ |
710 | (iw_handler) iwm_wext_siwauth, /* SIOCSIWAUTH */ | 424 | (iw_handler) iwm_wext_siwauth, /* SIOCSIWAUTH */ |
711 | (iw_handler) iwm_wext_giwauth, /* SIOCGIWAUTH */ | 425 | (iw_handler) iwm_wext_giwauth, /* SIOCGIWAUTH */ |
712 | (iw_handler) iwm_wext_siwencodeext, /* SIOCSIWENCODEEXT */ | 426 | (iw_handler) cfg80211_wext_siwencodeext, /* SIOCSIWENCODEEXT */ |
713 | (iw_handler) NULL, /* SIOCGIWENCODEEXT */ | 427 | (iw_handler) NULL, /* SIOCGIWENCODEEXT */ |
714 | (iw_handler) NULL, /* SIOCSIWPMKSA */ | 428 | (iw_handler) NULL, /* SIOCSIWPMKSA */ |
715 | (iw_handler) NULL, /* -- hole -- */ | 429 | (iw_handler) NULL, /* -- hole -- */ |
diff --git a/drivers/net/wireless/libertas/assoc.c b/drivers/net/wireless/libertas/assoc.c index b9b374119033..fbf26499c9a9 100644 --- a/drivers/net/wireless/libertas/assoc.c +++ b/drivers/net/wireless/libertas/assoc.c | |||
@@ -1368,11 +1368,17 @@ static int assoc_helper_wpa_keys(struct lbs_private *priv, | |||
1368 | if (ret) | 1368 | if (ret) |
1369 | goto out; | 1369 | goto out; |
1370 | 1370 | ||
1371 | memcpy(&priv->wpa_unicast_key, &assoc_req->wpa_unicast_key, | ||
1372 | sizeof(struct enc_key)); | ||
1373 | |||
1371 | if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { | 1374 | if (test_bit(ASSOC_FLAG_WPA_MCAST_KEY, &assoc_req->flags)) { |
1372 | clear_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); | 1375 | clear_bit(ASSOC_FLAG_WPA_UCAST_KEY, &assoc_req->flags); |
1373 | 1376 | ||
1374 | ret = lbs_cmd_802_11_key_material(priv, CMD_ACT_SET, assoc_req); | 1377 | ret = lbs_cmd_802_11_key_material(priv, CMD_ACT_SET, assoc_req); |
1375 | assoc_req->flags = flags; | 1378 | assoc_req->flags = flags; |
1379 | |||
1380 | memcpy(&priv->wpa_mcast_key, &assoc_req->wpa_mcast_key, | ||
1381 | sizeof(struct enc_key)); | ||
1376 | } | 1382 | } |
1377 | 1383 | ||
1378 | out: | 1384 | out: |
diff --git a/drivers/net/wireless/libertas/dev.h b/drivers/net/wireless/libertas/dev.h index f9ec69e04734..578c69783589 100644 --- a/drivers/net/wireless/libertas/dev.h +++ b/drivers/net/wireless/libertas/dev.h | |||
@@ -260,7 +260,6 @@ struct lbs_private { | |||
260 | u16 psmode; /* Wlan802_11PowermodeCAM=disable | 260 | u16 psmode; /* Wlan802_11PowermodeCAM=disable |
261 | Wlan802_11PowermodeMAX_PSP=enable */ | 261 | Wlan802_11PowermodeMAX_PSP=enable */ |
262 | u32 psstate; | 262 | u32 psstate; |
263 | char ps_supported; | ||
264 | u8 needtowakeup; | 263 | u8 needtowakeup; |
265 | 264 | ||
266 | struct assoc_request * pending_assoc_req; | 265 | struct assoc_request * pending_assoc_req; |
diff --git a/drivers/net/wireless/libertas/if_cs.c b/drivers/net/wireless/libertas/if_cs.c index 2a5b083bf9bd..f658fd6a2c0c 100644 --- a/drivers/net/wireless/libertas/if_cs.c +++ b/drivers/net/wireless/libertas/if_cs.c | |||
@@ -933,9 +933,6 @@ static int if_cs_probe(struct pcmcia_device *p_dev) | |||
933 | goto out3; | 933 | goto out3; |
934 | } | 934 | } |
935 | 935 | ||
936 | /* The firmware for the CF card supports powersave */ | ||
937 | priv->ps_supported = 1; | ||
938 | |||
939 | ret = 0; | 936 | ret = 0; |
940 | goto out; | 937 | goto out; |
941 | 938 | ||
diff --git a/drivers/net/wireless/libertas/if_sdio.c b/drivers/net/wireless/libertas/if_sdio.c index 8cdb88c6ca28..485a8d406525 100644 --- a/drivers/net/wireless/libertas/if_sdio.c +++ b/drivers/net/wireless/libertas/if_sdio.c | |||
@@ -1039,9 +1039,6 @@ static int if_sdio_probe(struct sdio_func *func, | |||
1039 | if (ret) | 1039 | if (ret) |
1040 | goto err_activate_card; | 1040 | goto err_activate_card; |
1041 | 1041 | ||
1042 | if (priv->fwcapinfo & FW_CAPINFO_PS) | ||
1043 | priv->ps_supported = 1; | ||
1044 | |||
1045 | out: | 1042 | out: |
1046 | lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret); | 1043 | lbs_deb_leave_args(LBS_DEB_SDIO, "ret %d", ret); |
1047 | 1044 | ||
@@ -1096,11 +1093,11 @@ static void if_sdio_remove(struct sdio_func *func) | |||
1096 | lbs_pr_alert("CMD_FUNC_SHUTDOWN cmd failed\n"); | 1093 | lbs_pr_alert("CMD_FUNC_SHUTDOWN cmd failed\n"); |
1097 | } | 1094 | } |
1098 | 1095 | ||
1099 | card->priv->surpriseremoved = 1; | ||
1100 | 1096 | ||
1101 | lbs_deb_sdio("call remove card\n"); | 1097 | lbs_deb_sdio("call remove card\n"); |
1102 | lbs_stop_card(card->priv); | 1098 | lbs_stop_card(card->priv); |
1103 | lbs_remove_card(card->priv); | 1099 | lbs_remove_card(card->priv); |
1100 | card->priv->surpriseremoved = 1; | ||
1104 | 1101 | ||
1105 | flush_workqueue(card->workqueue); | 1102 | flush_workqueue(card->workqueue); |
1106 | destroy_workqueue(card->workqueue); | 1103 | destroy_workqueue(card->workqueue); |
diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c index 6564282ce476..963c20125fc9 100644 --- a/drivers/net/wireless/libertas/if_spi.c +++ b/drivers/net/wireless/libertas/if_spi.c | |||
@@ -737,7 +737,7 @@ static int if_spi_c2h_data(struct if_spi_card *card) | |||
737 | goto out; | 737 | goto out; |
738 | } else if (len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) { | 738 | } else if (len > MRVDRV_ETH_RX_PACKET_BUFFER_SIZE) { |
739 | lbs_pr_err("%s: error: card has %d bytes of data, but " | 739 | lbs_pr_err("%s: error: card has %d bytes of data, but " |
740 | "our maximum skb size is %lu\n", | 740 | "our maximum skb size is %zu\n", |
741 | __func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE); | 741 | __func__, len, MRVDRV_ETH_RX_PACKET_BUFFER_SIZE); |
742 | err = -EINVAL; | 742 | err = -EINVAL; |
743 | goto out; | 743 | goto out; |
@@ -1118,7 +1118,6 @@ static int __devinit if_spi_probe(struct spi_device *spi) | |||
1118 | priv->card = card; | 1118 | priv->card = card; |
1119 | priv->hw_host_to_card = if_spi_host_to_card; | 1119 | priv->hw_host_to_card = if_spi_host_to_card; |
1120 | priv->fw_ready = 1; | 1120 | priv->fw_ready = 1; |
1121 | priv->ps_supported = 1; | ||
1122 | 1121 | ||
1123 | /* Initialize interrupt handling stuff. */ | 1122 | /* Initialize interrupt handling stuff. */ |
1124 | card->run_thread = 1; | 1123 | card->run_thread = 1; |
@@ -1171,12 +1170,13 @@ static int __devexit libertas_spi_remove(struct spi_device *spi) | |||
1171 | 1170 | ||
1172 | lbs_deb_spi("libertas_spi_remove\n"); | 1171 | lbs_deb_spi("libertas_spi_remove\n"); |
1173 | lbs_deb_enter(LBS_DEB_SPI); | 1172 | lbs_deb_enter(LBS_DEB_SPI); |
1174 | priv->surpriseremoved = 1; | ||
1175 | 1173 | ||
1176 | lbs_stop_card(priv); | 1174 | lbs_stop_card(priv); |
1175 | lbs_remove_card(priv); /* will call free_netdev */ | ||
1176 | |||
1177 | priv->surpriseremoved = 1; | ||
1177 | free_irq(spi->irq, card); | 1178 | free_irq(spi->irq, card); |
1178 | if_spi_terminate_spi_thread(card); | 1179 | if_spi_terminate_spi_thread(card); |
1179 | lbs_remove_card(priv); /* will call free_netdev */ | ||
1180 | if (card->pdata->teardown) | 1180 | if (card->pdata->teardown) |
1181 | card->pdata->teardown(spi); | 1181 | card->pdata->teardown(spi); |
1182 | free_if_spi_card(card); | 1182 | free_if_spi_card(card); |
diff --git a/drivers/net/wireless/libertas/if_usb.c b/drivers/net/wireless/libertas/if_usb.c index 1844c5adf6e9..92bc8c5f1ca2 100644 --- a/drivers/net/wireless/libertas/if_usb.c +++ b/drivers/net/wireless/libertas/if_usb.c | |||
@@ -181,13 +181,14 @@ static void if_usb_setup_firmware(struct lbs_private *priv) | |||
181 | wake_method.action = cpu_to_le16(CMD_ACT_GET); | 181 | wake_method.action = cpu_to_le16(CMD_ACT_GET); |
182 | if (lbs_cmd_with_response(priv, CMD_802_11_FW_WAKE_METHOD, &wake_method)) { | 182 | if (lbs_cmd_with_response(priv, CMD_802_11_FW_WAKE_METHOD, &wake_method)) { |
183 | lbs_pr_info("Firmware does not seem to support PS mode\n"); | 183 | lbs_pr_info("Firmware does not seem to support PS mode\n"); |
184 | priv->fwcapinfo &= ~FW_CAPINFO_PS; | ||
184 | } else { | 185 | } else { |
185 | if (le16_to_cpu(wake_method.method) == CMD_WAKE_METHOD_COMMAND_INT) { | 186 | if (le16_to_cpu(wake_method.method) == CMD_WAKE_METHOD_COMMAND_INT) { |
186 | lbs_deb_usb("Firmware seems to support PS with wake-via-command\n"); | 187 | lbs_deb_usb("Firmware seems to support PS with wake-via-command\n"); |
187 | priv->ps_supported = 1; | ||
188 | } else { | 188 | } else { |
189 | /* The versions which boot up this way don't seem to | 189 | /* The versions which boot up this way don't seem to |
190 | work even if we set it to the command interrupt */ | 190 | work even if we set it to the command interrupt */ |
191 | priv->fwcapinfo &= ~FW_CAPINFO_PS; | ||
191 | lbs_pr_info("Firmware doesn't wake via command interrupt; disabling PS mode\n"); | 192 | lbs_pr_info("Firmware doesn't wake via command interrupt; disabling PS mode\n"); |
192 | } | 193 | } |
193 | } | 194 | } |
diff --git a/drivers/net/wireless/libertas/wext.c b/drivers/net/wireless/libertas/wext.c index 8bc1907458b1..e96451ce470b 100644 --- a/drivers/net/wireless/libertas/wext.c +++ b/drivers/net/wireless/libertas/wext.c | |||
@@ -712,7 +712,7 @@ static int lbs_set_power(struct net_device *dev, struct iw_request_info *info, | |||
712 | 712 | ||
713 | lbs_deb_enter(LBS_DEB_WEXT); | 713 | lbs_deb_enter(LBS_DEB_WEXT); |
714 | 714 | ||
715 | if (!priv->ps_supported) { | 715 | if (!(priv->fwcapinfo & FW_CAPINFO_PS)) { |
716 | if (vwrq->disabled) | 716 | if (vwrq->disabled) |
717 | return 0; | 717 | return 0; |
718 | else | 718 | else |
diff --git a/drivers/net/wireless/libertas_tf/main.c b/drivers/net/wireless/libertas_tf/main.c index 10a99e26d392..4872345a2f61 100644 --- a/drivers/net/wireless/libertas_tf/main.c +++ b/drivers/net/wireless/libertas_tf/main.c | |||
@@ -503,7 +503,8 @@ int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb) | |||
503 | skb_reserve(skb, 2); | 503 | skb_reserve(skb, 2); |
504 | } | 504 | } |
505 | 505 | ||
506 | ieee80211_rx_irqsafe(priv->hw, skb, &stats); | 506 | memcpy(IEEE80211_SKB_RXCB(skb), &stats, sizeof(stats)); |
507 | ieee80211_rx_irqsafe(priv->hw, skb); | ||
507 | return 0; | 508 | return 0; |
508 | } | 509 | } |
509 | EXPORT_SYMBOL_GPL(lbtf_rx); | 510 | EXPORT_SYMBOL_GPL(lbtf_rx); |
diff --git a/drivers/net/wireless/mac80211_hwsim.c b/drivers/net/wireless/mac80211_hwsim.c index a111bda392e2..4befa48dbc34 100644 --- a/drivers/net/wireless/mac80211_hwsim.c +++ b/drivers/net/wireless/mac80211_hwsim.c | |||
@@ -15,6 +15,8 @@ | |||
15 | 15 | ||
16 | #include <linux/list.h> | 16 | #include <linux/list.h> |
17 | #include <linux/spinlock.h> | 17 | #include <linux/spinlock.h> |
18 | #include <net/dst.h> | ||
19 | #include <net/xfrm.h> | ||
18 | #include <net/mac80211.h> | 20 | #include <net/mac80211.h> |
19 | #include <net/ieee80211_radiotap.h> | 21 | #include <net/ieee80211_radiotap.h> |
20 | #include <linux/if_arp.h> | 22 | #include <linux/if_arp.h> |
@@ -314,7 +316,7 @@ static int hwsim_mon_xmit(struct sk_buff *skb, struct net_device *dev) | |||
314 | { | 316 | { |
315 | /* TODO: allow packet injection */ | 317 | /* TODO: allow packet injection */ |
316 | dev_kfree_skb(skb); | 318 | dev_kfree_skb(skb); |
317 | return 0; | 319 | return NETDEV_TX_OK; |
318 | } | 320 | } |
319 | 321 | ||
320 | 322 | ||
@@ -409,6 +411,13 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, | |||
409 | if (data->ps != PS_DISABLED) | 411 | if (data->ps != PS_DISABLED) |
410 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); | 412 | hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); |
411 | 413 | ||
414 | /* release the skb's source info */ | ||
415 | skb_orphan(skb); | ||
416 | skb_dst_drop(skb); | ||
417 | skb->mark = 0; | ||
418 | secpath_reset(skb); | ||
419 | nf_reset(skb); | ||
420 | |||
412 | /* Copy skb to all enabled radios that are on the current frequency */ | 421 | /* Copy skb to all enabled radios that are on the current frequency */ |
413 | spin_lock(&hwsim_radio_lock); | 422 | spin_lock(&hwsim_radio_lock); |
414 | list_for_each_entry(data2, &hwsim_radios, list) { | 423 | list_for_each_entry(data2, &hwsim_radios, list) { |
@@ -430,7 +439,8 @@ static bool mac80211_hwsim_tx_frame(struct ieee80211_hw *hw, | |||
430 | if (memcmp(hdr->addr1, data2->hw->wiphy->perm_addr, | 439 | if (memcmp(hdr->addr1, data2->hw->wiphy->perm_addr, |
431 | ETH_ALEN) == 0) | 440 | ETH_ALEN) == 0) |
432 | ack = true; | 441 | ack = true; |
433 | ieee80211_rx_irqsafe(data2->hw, nskb, &rx_status); | 442 | memcpy(IEEE80211_SKB_RXCB(nskb), &rx_status, sizeof(rx_status)); |
443 | ieee80211_rx_irqsafe(data2->hw, nskb); | ||
434 | } | 444 | } |
435 | spin_unlock(&hwsim_radio_lock); | 445 | spin_unlock(&hwsim_radio_lock); |
436 | 446 | ||
@@ -690,6 +700,74 @@ static int mac80211_hwsim_conf_tx( | |||
690 | return 0; | 700 | return 0; |
691 | } | 701 | } |
692 | 702 | ||
703 | #ifdef CONFIG_NL80211_TESTMODE | ||
704 | /* | ||
705 | * This section contains example code for using netlink | ||
706 | * attributes with the testmode command in nl80211. | ||
707 | */ | ||
708 | |||
709 | /* These enums need to be kept in sync with userspace */ | ||
710 | enum hwsim_testmode_attr { | ||
711 | __HWSIM_TM_ATTR_INVALID = 0, | ||
712 | HWSIM_TM_ATTR_CMD = 1, | ||
713 | HWSIM_TM_ATTR_PS = 2, | ||
714 | |||
715 | /* keep last */ | ||
716 | __HWSIM_TM_ATTR_AFTER_LAST, | ||
717 | HWSIM_TM_ATTR_MAX = __HWSIM_TM_ATTR_AFTER_LAST - 1 | ||
718 | }; | ||
719 | |||
720 | enum hwsim_testmode_cmd { | ||
721 | HWSIM_TM_CMD_SET_PS = 0, | ||
722 | HWSIM_TM_CMD_GET_PS = 1, | ||
723 | }; | ||
724 | |||
725 | static const struct nla_policy hwsim_testmode_policy[HWSIM_TM_ATTR_MAX + 1] = { | ||
726 | [HWSIM_TM_ATTR_CMD] = { .type = NLA_U32 }, | ||
727 | [HWSIM_TM_ATTR_PS] = { .type = NLA_U32 }, | ||
728 | }; | ||
729 | |||
730 | static int hwsim_fops_ps_write(void *dat, u64 val); | ||
731 | |||
732 | static int mac80211_hwsim_testmode_cmd(struct ieee80211_hw *hw, | ||
733 | void *data, int len) | ||
734 | { | ||
735 | struct mac80211_hwsim_data *hwsim = hw->priv; | ||
736 | struct nlattr *tb[HWSIM_TM_ATTR_MAX + 1]; | ||
737 | struct sk_buff *skb; | ||
738 | int err, ps; | ||
739 | |||
740 | err = nla_parse(tb, HWSIM_TM_ATTR_MAX, data, len, | ||
741 | hwsim_testmode_policy); | ||
742 | if (err) | ||
743 | return err; | ||
744 | |||
745 | if (!tb[HWSIM_TM_ATTR_CMD]) | ||
746 | return -EINVAL; | ||
747 | |||
748 | switch (nla_get_u32(tb[HWSIM_TM_ATTR_CMD])) { | ||
749 | case HWSIM_TM_CMD_SET_PS: | ||
750 | if (!tb[HWSIM_TM_ATTR_PS]) | ||
751 | return -EINVAL; | ||
752 | ps = nla_get_u32(tb[HWSIM_TM_ATTR_PS]); | ||
753 | return hwsim_fops_ps_write(hwsim, ps); | ||
754 | case HWSIM_TM_CMD_GET_PS: | ||
755 | skb = cfg80211_testmode_alloc_reply_skb(hw->wiphy, | ||
756 | nla_total_size(sizeof(u32))); | ||
757 | if (!skb) | ||
758 | return -ENOMEM; | ||
759 | NLA_PUT_U32(skb, HWSIM_TM_ATTR_PS, hwsim->ps); | ||
760 | return cfg80211_testmode_reply(skb); | ||
761 | default: | ||
762 | return -EOPNOTSUPP; | ||
763 | } | ||
764 | |||
765 | nla_put_failure: | ||
766 | kfree_skb(skb); | ||
767 | return -ENOBUFS; | ||
768 | } | ||
769 | #endif | ||
770 | |||
693 | static const struct ieee80211_ops mac80211_hwsim_ops = | 771 | static const struct ieee80211_ops mac80211_hwsim_ops = |
694 | { | 772 | { |
695 | .tx = mac80211_hwsim_tx, | 773 | .tx = mac80211_hwsim_tx, |
@@ -703,6 +781,7 @@ static const struct ieee80211_ops mac80211_hwsim_ops = | |||
703 | .sta_notify = mac80211_hwsim_sta_notify, | 781 | .sta_notify = mac80211_hwsim_sta_notify, |
704 | .set_tim = mac80211_hwsim_set_tim, | 782 | .set_tim = mac80211_hwsim_set_tim, |
705 | .conf_tx = mac80211_hwsim_conf_tx, | 783 | .conf_tx = mac80211_hwsim_conf_tx, |
784 | CFG80211_TESTMODE_CMD(mac80211_hwsim_testmode_cmd) | ||
706 | }; | 785 | }; |
707 | 786 | ||
708 | 787 | ||
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c index a263d5c84c08..b9eded88c322 100644 --- a/drivers/net/wireless/mwl8k.c +++ b/drivers/net/wireless/mwl8k.c | |||
@@ -1047,7 +1047,8 @@ static int rxq_process(struct ieee80211_hw *hw, int index, int limit) | |||
1047 | status.flag = 0; | 1047 | status.flag = 0; |
1048 | status.band = IEEE80211_BAND_2GHZ; | 1048 | status.band = IEEE80211_BAND_2GHZ; |
1049 | status.freq = ieee80211_channel_to_frequency(rx_desc->channel); | 1049 | status.freq = ieee80211_channel_to_frequency(rx_desc->channel); |
1050 | ieee80211_rx_irqsafe(hw, skb, &status); | 1050 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); |
1051 | ieee80211_rx_irqsafe(hw, skb); | ||
1051 | 1052 | ||
1052 | processed++; | 1053 | processed++; |
1053 | } | 1054 | } |
diff --git a/drivers/net/wireless/netwave_cs.c b/drivers/net/wireless/netwave_cs.c index d63c8992f229..712f26eef35d 100644 --- a/drivers/net/wireless/netwave_cs.c +++ b/drivers/net/wireless/netwave_cs.c | |||
@@ -1047,7 +1047,7 @@ static int netwave_start_xmit(struct sk_buff *skb, struct net_device *dev) { | |||
1047 | } | 1047 | } |
1048 | dev_kfree_skb(skb); | 1048 | dev_kfree_skb(skb); |
1049 | 1049 | ||
1050 | return 0; | 1050 | return NETDEV_TX_OK; |
1051 | } /* netwave_start_xmit */ | 1051 | } /* netwave_start_xmit */ |
1052 | 1052 | ||
1053 | /* | 1053 | /* |
diff --git a/drivers/net/wireless/orinoco/Kconfig b/drivers/net/wireless/orinoco/Kconfig index 44411eb4e91b..83b635fd7784 100644 --- a/drivers/net/wireless/orinoco/Kconfig +++ b/drivers/net/wireless/orinoco/Kconfig | |||
@@ -1,6 +1,7 @@ | |||
1 | config HERMES | 1 | config HERMES |
2 | tristate "Hermes chipset 802.11b support (Orinoco/Prism2/Symbol)" | 2 | tristate "Hermes chipset 802.11b support (Orinoco/Prism2/Symbol)" |
3 | depends on (PPC_PMAC || PCI || PCMCIA) && WLAN_80211 | 3 | depends on (PPC_PMAC || PCI || PCMCIA) && WLAN_80211 |
4 | depends on CFG80211 | ||
4 | select WIRELESS_EXT | 5 | select WIRELESS_EXT |
5 | select FW_LOADER | 6 | select FW_LOADER |
6 | select CRYPTO | 7 | select CRYPTO |
diff --git a/drivers/net/wireless/orinoco/Makefile b/drivers/net/wireless/orinoco/Makefile index 1fc7409d6699..9abd6329bcbd 100644 --- a/drivers/net/wireless/orinoco/Makefile +++ b/drivers/net/wireless/orinoco/Makefile | |||
@@ -1,7 +1,7 @@ | |||
1 | # | 1 | # |
2 | # Makefile for the orinoco wireless device drivers. | 2 | # Makefile for the orinoco wireless device drivers. |
3 | # | 3 | # |
4 | orinoco-objs := main.o fw.o hw.o mic.o scan.o wext.o hermes_dld.o hermes.o | 4 | orinoco-objs := main.o fw.o hw.o mic.o scan.o wext.o hermes_dld.o hermes.o cfg.o |
5 | 5 | ||
6 | obj-$(CONFIG_HERMES) += orinoco.o | 6 | obj-$(CONFIG_HERMES) += orinoco.o |
7 | obj-$(CONFIG_PCMCIA_HERMES) += orinoco_cs.o | 7 | obj-$(CONFIG_PCMCIA_HERMES) += orinoco_cs.o |
diff --git a/drivers/net/wireless/orinoco/airport.c b/drivers/net/wireless/orinoco/airport.c index 8c4065f1b0d0..c60df2c1aca3 100644 --- a/drivers/net/wireless/orinoco/airport.c +++ b/drivers/net/wireless/orinoco/airport.c | |||
@@ -27,6 +27,7 @@ | |||
27 | struct airport { | 27 | struct airport { |
28 | struct macio_dev *mdev; | 28 | struct macio_dev *mdev; |
29 | void __iomem *vaddr; | 29 | void __iomem *vaddr; |
30 | unsigned int irq; | ||
30 | int irq_requested; | 31 | int irq_requested; |
31 | int ndev_registered; | 32 | int ndev_registered; |
32 | }; | 33 | }; |
@@ -34,8 +35,9 @@ struct airport { | |||
34 | static int | 35 | static int |
35 | airport_suspend(struct macio_dev *mdev, pm_message_t state) | 36 | airport_suspend(struct macio_dev *mdev, pm_message_t state) |
36 | { | 37 | { |
37 | struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev); | 38 | struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev); |
38 | struct orinoco_private *priv = netdev_priv(dev); | 39 | struct net_device *dev = priv->ndev; |
40 | struct airport *card = priv->card; | ||
39 | unsigned long flags; | 41 | unsigned long flags; |
40 | int err; | 42 | int err; |
41 | 43 | ||
@@ -48,18 +50,10 @@ airport_suspend(struct macio_dev *mdev, pm_message_t state) | |||
48 | return 0; | 50 | return 0; |
49 | } | 51 | } |
50 | 52 | ||
51 | err = __orinoco_down(dev); | 53 | orinoco_down(priv); |
52 | if (err) | ||
53 | printk(KERN_WARNING "%s: PBOOK_SLEEP_NOW: Error %d downing interface\n", | ||
54 | dev->name, err); | ||
55 | |||
56 | netif_device_detach(dev); | ||
57 | |||
58 | priv->hw_unavailable++; | ||
59 | |||
60 | orinoco_unlock(priv, &flags); | 54 | orinoco_unlock(priv, &flags); |
61 | 55 | ||
62 | disable_irq(dev->irq); | 56 | disable_irq(card->irq); |
63 | pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, | 57 | pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, |
64 | macio_get_of_node(mdev), 0, 0); | 58 | macio_get_of_node(mdev), 0, 0); |
65 | 59 | ||
@@ -69,8 +63,9 @@ airport_suspend(struct macio_dev *mdev, pm_message_t state) | |||
69 | static int | 63 | static int |
70 | airport_resume(struct macio_dev *mdev) | 64 | airport_resume(struct macio_dev *mdev) |
71 | { | 65 | { |
72 | struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev); | 66 | struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev); |
73 | struct orinoco_private *priv = netdev_priv(dev); | 67 | struct net_device *dev = priv->ndev; |
68 | struct airport *card = priv->card; | ||
74 | unsigned long flags; | 69 | unsigned long flags; |
75 | int err; | 70 | int err; |
76 | 71 | ||
@@ -80,47 +75,27 @@ airport_resume(struct macio_dev *mdev) | |||
80 | macio_get_of_node(mdev), 0, 1); | 75 | macio_get_of_node(mdev), 0, 1); |
81 | msleep(200); | 76 | msleep(200); |
82 | 77 | ||
83 | enable_irq(dev->irq); | 78 | enable_irq(card->irq); |
84 | |||
85 | err = orinoco_reinit_firmware(dev); | ||
86 | if (err) { | ||
87 | printk(KERN_ERR "%s: Error %d re-initializing firmware on PBOOK_WAKE\n", | ||
88 | dev->name, err); | ||
89 | return 0; | ||
90 | } | ||
91 | 79 | ||
92 | spin_lock_irqsave(&priv->lock, flags); | 80 | spin_lock_irqsave(&priv->lock, flags); |
93 | 81 | err = orinoco_up(priv); | |
94 | netif_device_attach(dev); | ||
95 | |||
96 | priv->hw_unavailable--; | ||
97 | |||
98 | if (priv->open && (!priv->hw_unavailable)) { | ||
99 | err = __orinoco_up(dev); | ||
100 | if (err) | ||
101 | printk(KERN_ERR "%s: Error %d restarting card on PBOOK_WAKE\n", | ||
102 | dev->name, err); | ||
103 | } | ||
104 | |||
105 | |||
106 | spin_unlock_irqrestore(&priv->lock, flags); | 82 | spin_unlock_irqrestore(&priv->lock, flags); |
107 | 83 | ||
108 | return 0; | 84 | return err; |
109 | } | 85 | } |
110 | 86 | ||
111 | static int | 87 | static int |
112 | airport_detach(struct macio_dev *mdev) | 88 | airport_detach(struct macio_dev *mdev) |
113 | { | 89 | { |
114 | struct net_device *dev = dev_get_drvdata(&mdev->ofdev.dev); | 90 | struct orinoco_private *priv = dev_get_drvdata(&mdev->ofdev.dev); |
115 | struct orinoco_private *priv = netdev_priv(dev); | ||
116 | struct airport *card = priv->card; | 91 | struct airport *card = priv->card; |
117 | 92 | ||
118 | if (card->ndev_registered) | 93 | if (card->ndev_registered) |
119 | unregister_netdev(dev); | 94 | orinoco_if_del(priv); |
120 | card->ndev_registered = 0; | 95 | card->ndev_registered = 0; |
121 | 96 | ||
122 | if (card->irq_requested) | 97 | if (card->irq_requested) |
123 | free_irq(dev->irq, dev); | 98 | free_irq(card->irq, priv); |
124 | card->irq_requested = 0; | 99 | card->irq_requested = 0; |
125 | 100 | ||
126 | if (card->vaddr) | 101 | if (card->vaddr) |
@@ -134,7 +109,7 @@ airport_detach(struct macio_dev *mdev) | |||
134 | ssleep(1); | 109 | ssleep(1); |
135 | 110 | ||
136 | macio_set_drvdata(mdev, NULL); | 111 | macio_set_drvdata(mdev, NULL); |
137 | free_orinocodev(dev); | 112 | free_orinocodev(priv); |
138 | 113 | ||
139 | return 0; | 114 | return 0; |
140 | } | 115 | } |
@@ -146,7 +121,6 @@ static int airport_hard_reset(struct orinoco_private *priv) | |||
146 | * re-initialize properly, it falls in a screaming heap | 121 | * re-initialize properly, it falls in a screaming heap |
147 | * shortly afterwards. */ | 122 | * shortly afterwards. */ |
148 | #if 0 | 123 | #if 0 |
149 | struct net_device *dev = priv->ndev; | ||
150 | struct airport *card = priv->card; | 124 | struct airport *card = priv->card; |
151 | 125 | ||
152 | /* Vitally important. If we don't do this it seems we get an | 126 | /* Vitally important. If we don't do this it seems we get an |
@@ -154,7 +128,7 @@ static int airport_hard_reset(struct orinoco_private *priv) | |||
154 | * hw_unavailable is already set it doesn't get ACKed, we get | 128 | * hw_unavailable is already set it doesn't get ACKed, we get |
155 | * into an interrupt loop and the PMU decides to turn us | 129 | * into an interrupt loop and the PMU decides to turn us |
156 | * off. */ | 130 | * off. */ |
157 | disable_irq(dev->irq); | 131 | disable_irq(card->irq); |
158 | 132 | ||
159 | pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, | 133 | pmac_call_feature(PMAC_FTR_AIRPORT_ENABLE, |
160 | macio_get_of_node(card->mdev), 0, 0); | 134 | macio_get_of_node(card->mdev), 0, 0); |
@@ -163,7 +137,7 @@ static int airport_hard_reset(struct orinoco_private *priv) | |||
163 | macio_get_of_node(card->mdev), 0, 1); | 137 | macio_get_of_node(card->mdev), 0, 1); |
164 | ssleep(1); | 138 | ssleep(1); |
165 | 139 | ||
166 | enable_irq(dev->irq); | 140 | enable_irq(card->irq); |
167 | ssleep(1); | 141 | ssleep(1); |
168 | #endif | 142 | #endif |
169 | 143 | ||
@@ -174,7 +148,6 @@ static int | |||
174 | airport_attach(struct macio_dev *mdev, const struct of_device_id *match) | 148 | airport_attach(struct macio_dev *mdev, const struct of_device_id *match) |
175 | { | 149 | { |
176 | struct orinoco_private *priv; | 150 | struct orinoco_private *priv; |
177 | struct net_device *dev; | ||
178 | struct airport *card; | 151 | struct airport *card; |
179 | unsigned long phys_addr; | 152 | unsigned long phys_addr; |
180 | hermes_t *hw; | 153 | hermes_t *hw; |
@@ -185,33 +158,29 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
185 | } | 158 | } |
186 | 159 | ||
187 | /* Allocate space for private device-specific data */ | 160 | /* Allocate space for private device-specific data */ |
188 | dev = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev, | 161 | priv = alloc_orinocodev(sizeof(*card), &mdev->ofdev.dev, |
189 | airport_hard_reset, NULL); | 162 | airport_hard_reset, NULL); |
190 | if (!dev) { | 163 | if (!priv) { |
191 | printk(KERN_ERR PFX "Cannot allocate network device\n"); | 164 | printk(KERN_ERR PFX "Cannot allocate network device\n"); |
192 | return -ENODEV; | 165 | return -ENODEV; |
193 | } | 166 | } |
194 | priv = netdev_priv(dev); | ||
195 | card = priv->card; | 167 | card = priv->card; |
196 | 168 | ||
197 | hw = &priv->hw; | 169 | hw = &priv->hw; |
198 | card->mdev = mdev; | 170 | card->mdev = mdev; |
199 | 171 | ||
200 | if (macio_request_resource(mdev, 0, "airport")) { | 172 | if (macio_request_resource(mdev, 0, DRIVER_NAME)) { |
201 | printk(KERN_ERR PFX "can't request IO resource !\n"); | 173 | printk(KERN_ERR PFX "can't request IO resource !\n"); |
202 | free_orinocodev(dev); | 174 | free_orinocodev(priv); |
203 | return -EBUSY; | 175 | return -EBUSY; |
204 | } | 176 | } |
205 | 177 | ||
206 | SET_NETDEV_DEV(dev, &mdev->ofdev.dev); | 178 | macio_set_drvdata(mdev, priv); |
207 | |||
208 | macio_set_drvdata(mdev, dev); | ||
209 | 179 | ||
210 | /* Setup interrupts & base address */ | 180 | /* Setup interrupts & base address */ |
211 | dev->irq = macio_irq(mdev, 0); | 181 | card->irq = macio_irq(mdev, 0); |
212 | phys_addr = macio_resource_start(mdev, 0); /* Physical address */ | 182 | phys_addr = macio_resource_start(mdev, 0); /* Physical address */ |
213 | printk(KERN_DEBUG PFX "Physical address %lx\n", phys_addr); | 183 | printk(KERN_DEBUG PFX "Physical address %lx\n", phys_addr); |
214 | dev->base_addr = phys_addr; | ||
215 | card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN); | 184 | card->vaddr = ioremap(phys_addr, AIRPORT_IO_LEN); |
216 | if (!card->vaddr) { | 185 | if (!card->vaddr) { |
217 | printk(KERN_ERR PFX "ioremap() failed\n"); | 186 | printk(KERN_ERR PFX "ioremap() failed\n"); |
@@ -228,18 +197,23 @@ airport_attach(struct macio_dev *mdev, const struct of_device_id *match) | |||
228 | /* Reset it before we get the interrupt */ | 197 | /* Reset it before we get the interrupt */ |
229 | hermes_init(hw); | 198 | hermes_init(hw); |
230 | 199 | ||
231 | if (request_irq(dev->irq, orinoco_interrupt, 0, dev->name, dev)) { | 200 | if (request_irq(card->irq, orinoco_interrupt, 0, DRIVER_NAME, priv)) { |
232 | printk(KERN_ERR PFX "Couldn't get IRQ %d\n", dev->irq); | 201 | printk(KERN_ERR PFX "Couldn't get IRQ %d\n", card->irq); |
233 | goto failed; | 202 | goto failed; |
234 | } | 203 | } |
235 | card->irq_requested = 1; | 204 | card->irq_requested = 1; |
236 | 205 | ||
237 | /* Tell the stack we exist */ | 206 | /* Initialise the main driver */ |
238 | if (register_netdev(dev) != 0) { | 207 | if (orinoco_init(priv) != 0) { |
239 | printk(KERN_ERR PFX "register_netdev() failed\n"); | 208 | printk(KERN_ERR PFX "orinoco_init() failed\n"); |
209 | goto failed; | ||
210 | } | ||
211 | |||
212 | /* Register an interface with the stack */ | ||
213 | if (orinoco_if_add(priv, phys_addr, card->irq) != 0) { | ||
214 | printk(KERN_ERR PFX "orinoco_if_add() failed\n"); | ||
240 | goto failed; | 215 | goto failed; |
241 | } | 216 | } |
242 | printk(KERN_DEBUG PFX "Card registered for interface %s\n", dev->name); | ||
243 | card->ndev_registered = 1; | 217 | card->ndev_registered = 1; |
244 | return 0; | 218 | return 0; |
245 | failed: | 219 | failed: |
diff --git a/drivers/net/wireless/orinoco/cfg.c b/drivers/net/wireless/orinoco/cfg.c new file mode 100644 index 000000000000..1a87d3a0967c --- /dev/null +++ b/drivers/net/wireless/orinoco/cfg.c | |||
@@ -0,0 +1,162 @@ | |||
1 | /* cfg80211 support | ||
2 | * | ||
3 | * See copyright notice in main.c | ||
4 | */ | ||
5 | #include <linux/ieee80211.h> | ||
6 | #include <net/cfg80211.h> | ||
7 | #include "hw.h" | ||
8 | #include "main.h" | ||
9 | #include "orinoco.h" | ||
10 | |||
11 | #include "cfg.h" | ||
12 | |||
13 | /* Supported bitrates. Must agree with hw.c */ | ||
14 | static struct ieee80211_rate orinoco_rates[] = { | ||
15 | { .bitrate = 10 }, | ||
16 | { .bitrate = 20 }, | ||
17 | { .bitrate = 55 }, | ||
18 | { .bitrate = 110 }, | ||
19 | }; | ||
20 | |||
21 | static const void * const orinoco_wiphy_privid = &orinoco_wiphy_privid; | ||
22 | |||
23 | /* Called after orinoco_private is allocated. */ | ||
24 | void orinoco_wiphy_init(struct wiphy *wiphy) | ||
25 | { | ||
26 | struct orinoco_private *priv = wiphy_priv(wiphy); | ||
27 | |||
28 | wiphy->privid = orinoco_wiphy_privid; | ||
29 | |||
30 | set_wiphy_dev(wiphy, priv->dev); | ||
31 | } | ||
32 | |||
33 | /* Called after firmware is initialised */ | ||
34 | int orinoco_wiphy_register(struct wiphy *wiphy) | ||
35 | { | ||
36 | struct orinoco_private *priv = wiphy_priv(wiphy); | ||
37 | int i, channels = 0; | ||
38 | |||
39 | if (priv->firmware_type == FIRMWARE_TYPE_AGERE) | ||
40 | wiphy->max_scan_ssids = 1; | ||
41 | else | ||
42 | wiphy->max_scan_ssids = 0; | ||
43 | |||
44 | wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); | ||
45 | |||
46 | /* TODO: should we set if we only have demo ad-hoc? | ||
47 | * (priv->has_port3) | ||
48 | */ | ||
49 | if (priv->has_ibss) | ||
50 | wiphy->interface_modes |= BIT(NL80211_IFTYPE_ADHOC); | ||
51 | |||
52 | if (!priv->broken_monitor || force_monitor) | ||
53 | wiphy->interface_modes |= BIT(NL80211_IFTYPE_MONITOR); | ||
54 | |||
55 | priv->band.bitrates = orinoco_rates; | ||
56 | priv->band.n_bitrates = ARRAY_SIZE(orinoco_rates); | ||
57 | |||
58 | /* Only support channels allowed by the card EEPROM */ | ||
59 | for (i = 0; i < NUM_CHANNELS; i++) { | ||
60 | if (priv->channel_mask & (1 << i)) { | ||
61 | priv->channels[i].center_freq = | ||
62 | ieee80211_dsss_chan_to_freq(i+1); | ||
63 | channels++; | ||
64 | } | ||
65 | } | ||
66 | priv->band.channels = priv->channels; | ||
67 | priv->band.n_channels = channels; | ||
68 | |||
69 | wiphy->bands[IEEE80211_BAND_2GHZ] = &priv->band; | ||
70 | wiphy->signal_type = CFG80211_SIGNAL_TYPE_MBM; | ||
71 | |||
72 | i = 0; | ||
73 | if (priv->has_wep) { | ||
74 | priv->cipher_suites[i] = WLAN_CIPHER_SUITE_WEP40; | ||
75 | i++; | ||
76 | |||
77 | if (priv->has_big_wep) { | ||
78 | priv->cipher_suites[i] = WLAN_CIPHER_SUITE_WEP104; | ||
79 | i++; | ||
80 | } | ||
81 | } | ||
82 | if (priv->has_wpa) { | ||
83 | priv->cipher_suites[i] = WLAN_CIPHER_SUITE_TKIP; | ||
84 | i++; | ||
85 | } | ||
86 | wiphy->cipher_suites = priv->cipher_suites; | ||
87 | wiphy->n_cipher_suites = i; | ||
88 | |||
89 | wiphy->rts_threshold = priv->rts_thresh; | ||
90 | if (!priv->has_mwo) | ||
91 | wiphy->frag_threshold = priv->frag_thresh; | ||
92 | |||
93 | return wiphy_register(wiphy); | ||
94 | } | ||
95 | |||
96 | static int orinoco_change_vif(struct wiphy *wiphy, struct net_device *dev, | ||
97 | enum nl80211_iftype type, u32 *flags, | ||
98 | struct vif_params *params) | ||
99 | { | ||
100 | struct orinoco_private *priv = wiphy_priv(wiphy); | ||
101 | int err = 0; | ||
102 | unsigned long lock; | ||
103 | |||
104 | if (orinoco_lock(priv, &lock) != 0) | ||
105 | return -EBUSY; | ||
106 | |||
107 | switch (type) { | ||
108 | case NL80211_IFTYPE_ADHOC: | ||
109 | if (!priv->has_ibss && !priv->has_port3) | ||
110 | err = -EINVAL; | ||
111 | break; | ||
112 | |||
113 | case NL80211_IFTYPE_STATION: | ||
114 | break; | ||
115 | |||
116 | case NL80211_IFTYPE_MONITOR: | ||
117 | if (priv->broken_monitor && !force_monitor) { | ||
118 | printk(KERN_WARNING "%s: Monitor mode support is " | ||
119 | "buggy in this firmware, not enabling\n", | ||
120 | wiphy_name(wiphy)); | ||
121 | err = -EINVAL; | ||
122 | } | ||
123 | break; | ||
124 | |||
125 | default: | ||
126 | err = -EINVAL; | ||
127 | } | ||
128 | |||
129 | if (!err) { | ||
130 | priv->iw_mode = type; | ||
131 | set_port_type(priv); | ||
132 | err = orinoco_commit(priv); | ||
133 | } | ||
134 | |||
135 | orinoco_unlock(priv, &lock); | ||
136 | |||
137 | return err; | ||
138 | } | ||
139 | |||
140 | static int orinoco_scan(struct wiphy *wiphy, struct net_device *dev, | ||
141 | struct cfg80211_scan_request *request) | ||
142 | { | ||
143 | struct orinoco_private *priv = wiphy_priv(wiphy); | ||
144 | int err; | ||
145 | |||
146 | if (!request) | ||
147 | return -EINVAL; | ||
148 | |||
149 | if (priv->scan_request && priv->scan_request != request) | ||
150 | return -EBUSY; | ||
151 | |||
152 | priv->scan_request = request; | ||
153 | |||
154 | err = orinoco_hw_trigger_scan(priv, request->ssids); | ||
155 | |||
156 | return err; | ||
157 | } | ||
158 | |||
159 | const struct cfg80211_ops orinoco_cfg_ops = { | ||
160 | .change_virtual_intf = orinoco_change_vif, | ||
161 | .scan = orinoco_scan, | ||
162 | }; | ||
diff --git a/drivers/net/wireless/orinoco/cfg.h b/drivers/net/wireless/orinoco/cfg.h new file mode 100644 index 000000000000..3ddc96a06cd7 --- /dev/null +++ b/drivers/net/wireless/orinoco/cfg.h | |||
@@ -0,0 +1,15 @@ | |||
1 | /* cfg80211 support. | ||
2 | * | ||
3 | * See copyright notice in main.c | ||
4 | */ | ||
5 | #ifndef ORINOCO_CFG_H | ||
6 | #define ORINOCO_CFG_H | ||
7 | |||
8 | #include <net/cfg80211.h> | ||
9 | |||
10 | extern const struct cfg80211_ops orinoco_cfg_ops; | ||
11 | |||
12 | void orinoco_wiphy_init(struct wiphy *wiphy); | ||
13 | int orinoco_wiphy_register(struct wiphy *wiphy); | ||
14 | |||
15 | #endif /* ORINOCO_CFG_H */ | ||
diff --git a/drivers/net/wireless/orinoco/fw.c b/drivers/net/wireless/orinoco/fw.c index 1084b43e04bc..1257250a1e22 100644 --- a/drivers/net/wireless/orinoco/fw.c +++ b/drivers/net/wireless/orinoco/fw.c | |||
@@ -4,6 +4,7 @@ | |||
4 | */ | 4 | */ |
5 | #include <linux/kernel.h> | 5 | #include <linux/kernel.h> |
6 | #include <linux/firmware.h> | 6 | #include <linux/firmware.h> |
7 | #include <linux/device.h> | ||
7 | 8 | ||
8 | #include "hermes.h" | 9 | #include "hermes.h" |
9 | #include "hermes_dld.h" | 10 | #include "hermes_dld.h" |
@@ -99,7 +100,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
99 | const void *end; | 100 | const void *end; |
100 | const char *firmware; | 101 | const char *firmware; |
101 | const char *fw_err; | 102 | const char *fw_err; |
102 | struct net_device *dev = priv->ndev; | 103 | struct device *dev = priv->dev; |
103 | int err = 0; | 104 | int err = 0; |
104 | 105 | ||
105 | pda = kzalloc(fw->pda_size, GFP_KERNEL); | 106 | pda = kzalloc(fw->pda_size, GFP_KERNEL); |
@@ -111,12 +112,11 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
111 | else | 112 | else |
112 | firmware = fw->sta_fw; | 113 | firmware = fw->sta_fw; |
113 | 114 | ||
114 | printk(KERN_DEBUG "%s: Attempting to download firmware %s\n", | 115 | dev_dbg(dev, "Attempting to download firmware %s\n", firmware); |
115 | dev->name, firmware); | ||
116 | 116 | ||
117 | /* Read current plug data */ | 117 | /* Read current plug data */ |
118 | err = hermes_read_pda(hw, pda, fw->pda_addr, fw->pda_size, 0); | 118 | err = hermes_read_pda(hw, pda, fw->pda_addr, fw->pda_size, 0); |
119 | printk(KERN_DEBUG "%s: Read PDA returned %d\n", dev->name, err); | 119 | dev_dbg(dev, "Read PDA returned %d\n", err); |
120 | if (err) | 120 | if (err) |
121 | goto free; | 121 | goto free; |
122 | 122 | ||
@@ -124,8 +124,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
124 | err = request_firmware(&fw_entry, firmware, priv->dev); | 124 | err = request_firmware(&fw_entry, firmware, priv->dev); |
125 | 125 | ||
126 | if (err) { | 126 | if (err) { |
127 | printk(KERN_ERR "%s: Cannot find firmware %s\n", | 127 | dev_err(dev, "Cannot find firmware %s\n", firmware); |
128 | dev->name, firmware); | ||
129 | err = -ENOENT; | 128 | err = -ENOENT; |
130 | goto free; | 129 | goto free; |
131 | } | 130 | } |
@@ -136,16 +135,15 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
136 | 135 | ||
137 | fw_err = validate_fw(hdr, fw_entry->size); | 136 | fw_err = validate_fw(hdr, fw_entry->size); |
138 | if (fw_err) { | 137 | if (fw_err) { |
139 | printk(KERN_WARNING "%s: Invalid firmware image detected (%s). " | 138 | dev_warn(dev, "Invalid firmware image detected (%s). " |
140 | "Aborting download\n", | 139 | "Aborting download\n", fw_err); |
141 | dev->name, fw_err); | ||
142 | err = -EINVAL; | 140 | err = -EINVAL; |
143 | goto abort; | 141 | goto abort; |
144 | } | 142 | } |
145 | 143 | ||
146 | /* Enable aux port to allow programming */ | 144 | /* Enable aux port to allow programming */ |
147 | err = hermesi_program_init(hw, le32_to_cpu(hdr->entry_point)); | 145 | err = hermesi_program_init(hw, le32_to_cpu(hdr->entry_point)); |
148 | printk(KERN_DEBUG "%s: Program init returned %d\n", dev->name, err); | 146 | dev_dbg(dev, "Program init returned %d\n", err); |
149 | if (err != 0) | 147 | if (err != 0) |
150 | goto abort; | 148 | goto abort; |
151 | 149 | ||
@@ -156,7 +154,7 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
156 | end = fw_entry->data + fw_entry->size; | 154 | end = fw_entry->data + fw_entry->size; |
157 | 155 | ||
158 | err = hermes_program(hw, first_block, end); | 156 | err = hermes_program(hw, first_block, end); |
159 | printk(KERN_DEBUG "%s: Program returned %d\n", dev->name, err); | 157 | dev_dbg(dev, "Program returned %d\n", err); |
160 | if (err != 0) | 158 | if (err != 0) |
161 | goto abort; | 159 | goto abort; |
162 | 160 | ||
@@ -167,19 +165,18 @@ orinoco_dl_firmware(struct orinoco_private *priv, | |||
167 | 165 | ||
168 | err = hermes_apply_pda_with_defaults(hw, first_block, end, pda, | 166 | err = hermes_apply_pda_with_defaults(hw, first_block, end, pda, |
169 | &pda[fw->pda_size / sizeof(*pda)]); | 167 | &pda[fw->pda_size / sizeof(*pda)]); |
170 | printk(KERN_DEBUG "%s: Apply PDA returned %d\n", dev->name, err); | 168 | dev_dbg(dev, "Apply PDA returned %d\n", err); |
171 | if (err) | 169 | if (err) |
172 | goto abort; | 170 | goto abort; |
173 | 171 | ||
174 | /* Tell card we've finished */ | 172 | /* Tell card we've finished */ |
175 | err = hermesi_program_end(hw); | 173 | err = hermesi_program_end(hw); |
176 | printk(KERN_DEBUG "%s: Program end returned %d\n", dev->name, err); | 174 | dev_dbg(dev, "Program end returned %d\n", err); |
177 | if (err != 0) | 175 | if (err != 0) |
178 | goto abort; | 176 | goto abort; |
179 | 177 | ||
180 | /* Check if we're running */ | 178 | /* Check if we're running */ |
181 | printk(KERN_DEBUG "%s: hermes_present returned %d\n", | 179 | dev_dbg(dev, "hermes_present returned %d\n", hermes_present(hw)); |
182 | dev->name, hermes_present(hw)); | ||
183 | 180 | ||
184 | abort: | 181 | abort: |
185 | /* If we requested the firmware, release it. */ | 182 | /* If we requested the firmware, release it. */ |
@@ -282,14 +279,13 @@ static int | |||
282 | symbol_dl_firmware(struct orinoco_private *priv, | 279 | symbol_dl_firmware(struct orinoco_private *priv, |
283 | const struct fw_info *fw) | 280 | const struct fw_info *fw) |
284 | { | 281 | { |
285 | struct net_device *dev = priv->ndev; | 282 | struct device *dev = priv->dev; |
286 | int ret; | 283 | int ret; |
287 | const struct firmware *fw_entry; | 284 | const struct firmware *fw_entry; |
288 | 285 | ||
289 | if (!orinoco_cached_fw_get(priv, true)) { | 286 | if (!orinoco_cached_fw_get(priv, true)) { |
290 | if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) { | 287 | if (request_firmware(&fw_entry, fw->pri_fw, priv->dev) != 0) { |
291 | printk(KERN_ERR "%s: Cannot find firmware: %s\n", | 288 | dev_err(dev, "Cannot find firmware: %s\n", fw->pri_fw); |
292 | dev->name, fw->pri_fw); | ||
293 | return -ENOENT; | 289 | return -ENOENT; |
294 | } | 290 | } |
295 | } else | 291 | } else |
@@ -302,15 +298,13 @@ symbol_dl_firmware(struct orinoco_private *priv, | |||
302 | if (!orinoco_cached_fw_get(priv, true)) | 298 | if (!orinoco_cached_fw_get(priv, true)) |
303 | release_firmware(fw_entry); | 299 | release_firmware(fw_entry); |
304 | if (ret) { | 300 | if (ret) { |
305 | printk(KERN_ERR "%s: Primary firmware download failed\n", | 301 | dev_err(dev, "Primary firmware download failed\n"); |
306 | dev->name); | ||
307 | return ret; | 302 | return ret; |
308 | } | 303 | } |
309 | 304 | ||
310 | if (!orinoco_cached_fw_get(priv, false)) { | 305 | if (!orinoco_cached_fw_get(priv, false)) { |
311 | if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) { | 306 | if (request_firmware(&fw_entry, fw->sta_fw, priv->dev) != 0) { |
312 | printk(KERN_ERR "%s: Cannot find firmware: %s\n", | 307 | dev_err(dev, "Cannot find firmware: %s\n", fw->sta_fw); |
313 | dev->name, fw->sta_fw); | ||
314 | return -ENOENT; | 308 | return -ENOENT; |
315 | } | 309 | } |
316 | } else | 310 | } else |
@@ -322,8 +316,7 @@ symbol_dl_firmware(struct orinoco_private *priv, | |||
322 | if (!orinoco_cached_fw_get(priv, false)) | 316 | if (!orinoco_cached_fw_get(priv, false)) |
323 | release_firmware(fw_entry); | 317 | release_firmware(fw_entry); |
324 | if (ret) { | 318 | if (ret) { |
325 | printk(KERN_ERR "%s: Secondary firmware download failed\n", | 319 | dev_err(dev, "Secondary firmware download failed\n"); |
326 | dev->name); | ||
327 | } | 320 | } |
328 | 321 | ||
329 | return ret; | 322 | return ret; |
diff --git a/drivers/net/wireless/orinoco/hermes.c b/drivers/net/wireless/orinoco/hermes.c index f2c918c2572d..1a2fca76fd3c 100644 --- a/drivers/net/wireless/orinoco/hermes.c +++ b/drivers/net/wireless/orinoco/hermes.c | |||
@@ -469,7 +469,7 @@ int hermes_read_ltv(hermes_t *hw, int bap, u16 rid, unsigned bufsize, | |||
469 | u16 rlength, rtype; | 469 | u16 rlength, rtype; |
470 | unsigned nwords; | 470 | unsigned nwords; |
471 | 471 | ||
472 | if ((bufsize < 0) || (bufsize % 2)) | 472 | if (bufsize % 2) |
473 | return -EINVAL; | 473 | return -EINVAL; |
474 | 474 | ||
475 | err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS, rid, NULL); | 475 | err = hermes_docmd_wait(hw, HERMES_CMD_ACCESS, rid, NULL); |
diff --git a/drivers/net/wireless/orinoco/hermes.h b/drivers/net/wireless/orinoco/hermes.h index c78c442a02c8..2dddbb597c4d 100644 --- a/drivers/net/wireless/orinoco/hermes.h +++ b/drivers/net/wireless/orinoco/hermes.h | |||
@@ -342,7 +342,7 @@ struct agere_ext_scan_info { | |||
342 | __le64 timestamp; | 342 | __le64 timestamp; |
343 | __le16 beacon_interval; | 343 | __le16 beacon_interval; |
344 | __le16 capabilities; | 344 | __le16 capabilities; |
345 | u8 data[316]; | 345 | u8 data[0]; |
346 | } __attribute__ ((packed)); | 346 | } __attribute__ ((packed)); |
347 | 347 | ||
348 | #define HERMES_LINKSTATUS_NOT_CONNECTED (0x0000) | 348 | #define HERMES_LINKSTATUS_NOT_CONNECTED (0x0000) |
diff --git a/drivers/net/wireless/orinoco/hermes_dld.c b/drivers/net/wireless/orinoco/hermes_dld.c index a9ba195cdada..a3eefe109df4 100644 --- a/drivers/net/wireless/orinoco/hermes_dld.c +++ b/drivers/net/wireless/orinoco/hermes_dld.c | |||
@@ -309,7 +309,7 @@ int hermes_read_pda(hermes_t *hw, | |||
309 | 309 | ||
310 | /* Open auxiliary port */ | 310 | /* Open auxiliary port */ |
311 | ret = hermes_aux_control(hw, 1); | 311 | ret = hermes_aux_control(hw, 1); |
312 | printk(KERN_DEBUG PFX "AUX enable returned %d\n", ret); | 312 | pr_debug(PFX "AUX enable returned %d\n", ret); |
313 | if (ret) | 313 | if (ret) |
314 | return ret; | 314 | return ret; |
315 | 315 | ||
@@ -319,12 +319,12 @@ int hermes_read_pda(hermes_t *hw, | |||
319 | 319 | ||
320 | /* Close aux port */ | 320 | /* Close aux port */ |
321 | ret = hermes_aux_control(hw, 0); | 321 | ret = hermes_aux_control(hw, 0); |
322 | printk(KERN_DEBUG PFX "AUX disable returned %d\n", ret); | 322 | pr_debug(PFX "AUX disable returned %d\n", ret); |
323 | 323 | ||
324 | /* Check PDA length */ | 324 | /* Check PDA length */ |
325 | pda_size = le16_to_cpu(pda[0]); | 325 | pda_size = le16_to_cpu(pda[0]); |
326 | printk(KERN_DEBUG PFX "Actual PDA length %d, Max allowed %d\n", | 326 | pr_debug(PFX "Actual PDA length %d, Max allowed %d\n", |
327 | pda_size, pda_len); | 327 | pda_size, pda_len); |
328 | if (pda_size > pda_len) | 328 | if (pda_size > pda_len) |
329 | return -EINVAL; | 329 | return -EINVAL; |
330 | 330 | ||
@@ -422,20 +422,19 @@ int hermesi_program_init(hermes_t *hw, u32 offset) | |||
422 | return err; | 422 | return err; |
423 | 423 | ||
424 | err = hermes_aux_control(hw, 1); | 424 | err = hermes_aux_control(hw, 1); |
425 | printk(KERN_DEBUG PFX "AUX enable returned %d\n", err); | 425 | pr_debug(PFX "AUX enable returned %d\n", err); |
426 | 426 | ||
427 | if (err) | 427 | if (err) |
428 | return err; | 428 | return err; |
429 | 429 | ||
430 | printk(KERN_DEBUG PFX "Enabling volatile, EP 0x%08x\n", offset); | 430 | pr_debug(KERN_DEBUG PFX "Enabling volatile, EP 0x%08x\n", offset); |
431 | err = hermes_doicmd_wait(hw, | 431 | err = hermes_doicmd_wait(hw, |
432 | HERMES_PROGRAM_ENABLE_VOLATILE, | 432 | HERMES_PROGRAM_ENABLE_VOLATILE, |
433 | offset & 0xFFFFu, | 433 | offset & 0xFFFFu, |
434 | offset >> 16, | 434 | offset >> 16, |
435 | 0, | 435 | 0, |
436 | NULL); | 436 | NULL); |
437 | printk(KERN_DEBUG PFX "PROGRAM_ENABLE returned %d\n", | 437 | pr_debug(PFX "PROGRAM_ENABLE returned %d\n", err); |
438 | err); | ||
439 | 438 | ||
440 | return err; | 439 | return err; |
441 | } | 440 | } |
@@ -454,16 +453,16 @@ int hermesi_program_end(hermes_t *hw) | |||
454 | 453 | ||
455 | rc = hermes_docmd_wait(hw, HERMES_PROGRAM_DISABLE, 0, &resp); | 454 | rc = hermes_docmd_wait(hw, HERMES_PROGRAM_DISABLE, 0, &resp); |
456 | 455 | ||
457 | printk(KERN_DEBUG PFX "PROGRAM_DISABLE returned %d, " | 456 | pr_debug(PFX "PROGRAM_DISABLE returned %d, " |
458 | "r0 0x%04x, r1 0x%04x, r2 0x%04x\n", | 457 | "r0 0x%04x, r1 0x%04x, r2 0x%04x\n", |
459 | rc, resp.resp0, resp.resp1, resp.resp2); | 458 | rc, resp.resp0, resp.resp1, resp.resp2); |
460 | 459 | ||
461 | if ((rc == 0) && | 460 | if ((rc == 0) && |
462 | ((resp.status & HERMES_STATUS_CMDCODE) != HERMES_CMD_DOWNLD)) | 461 | ((resp.status & HERMES_STATUS_CMDCODE) != HERMES_CMD_DOWNLD)) |
463 | rc = -EIO; | 462 | rc = -EIO; |
464 | 463 | ||
465 | err = hermes_aux_control(hw, 0); | 464 | err = hermes_aux_control(hw, 0); |
466 | printk(KERN_DEBUG PFX "AUX disable returned %d\n", err); | 465 | pr_debug(PFX "AUX disable returned %d\n", err); |
467 | 466 | ||
468 | /* Acknowledge any outstanding command */ | 467 | /* Acknowledge any outstanding command */ |
469 | hermes_write_regn(hw, EVACK, 0xFFFF); | 468 | hermes_write_regn(hw, EVACK, 0xFFFF); |
@@ -496,9 +495,8 @@ int hermes_program(hermes_t *hw, const char *first_block, const void *end) | |||
496 | 495 | ||
497 | while ((blkaddr != BLOCK_END) && | 496 | while ((blkaddr != BLOCK_END) && |
498 | (((void *) blk + blklen) <= end)) { | 497 | (((void *) blk + blklen) <= end)) { |
499 | printk(KERN_DEBUG PFX | 498 | pr_debug(PFX "Programming block of length %d " |
500 | "Programming block of length %d to address 0x%08x\n", | 499 | "to address 0x%08x\n", blklen, blkaddr); |
501 | blklen, blkaddr); | ||
502 | 500 | ||
503 | #if !LIMIT_PROGRAM_SIZE | 501 | #if !LIMIT_PROGRAM_SIZE |
504 | /* wl_lkm driver splits this into writes of 2000 bytes */ | 502 | /* wl_lkm driver splits this into writes of 2000 bytes */ |
@@ -510,10 +508,9 @@ int hermes_program(hermes_t *hw, const char *first_block, const void *end) | |||
510 | addr = blkaddr; | 508 | addr = blkaddr; |
511 | 509 | ||
512 | while (addr < (blkaddr + blklen)) { | 510 | while (addr < (blkaddr + blklen)) { |
513 | printk(KERN_DEBUG PFX | 511 | pr_debug(PFX "Programming subblock of length %d " |
514 | "Programming subblock of length %d " | 512 | "to address 0x%08x. Data @ %p\n", |
515 | "to address 0x%08x. Data @ %p\n", | 513 | len, addr, &blk->data[addr - blkaddr]); |
516 | len, addr, &blk->data[addr - blkaddr]); | ||
517 | 514 | ||
518 | hermes_aux_setaddr(hw, addr); | 515 | hermes_aux_setaddr(hw, addr); |
519 | hermes_write_bytes(hw, HERMES_AUXDATA, | 516 | hermes_write_bytes(hw, HERMES_AUXDATA, |
@@ -643,8 +640,8 @@ int hermes_apply_pda_with_defaults(hermes_t *hw, | |||
643 | 640 | ||
644 | pdi = hermes_find_pdi(first_pdi, record_id, pda_end); | 641 | pdi = hermes_find_pdi(first_pdi, record_id, pda_end); |
645 | if (pdi) | 642 | if (pdi) |
646 | printk(KERN_DEBUG PFX "Found record 0x%04x at %p\n", | 643 | pr_debug(PFX "Found record 0x%04x at %p\n", |
647 | record_id, pdi); | 644 | record_id, pdi); |
648 | 645 | ||
649 | switch (record_id) { | 646 | switch (record_id) { |
650 | case 0x110: /* Modem REFDAC values */ | 647 | case 0x110: /* Modem REFDAC values */ |
@@ -654,9 +651,9 @@ int hermes_apply_pda_with_defaults(hermes_t *hw, | |||
654 | default_pdi = NULL; | 651 | default_pdi = NULL; |
655 | if (outdoor_pdi) { | 652 | if (outdoor_pdi) { |
656 | pdi = outdoor_pdi; | 653 | pdi = outdoor_pdi; |
657 | printk(KERN_DEBUG PFX | 654 | pr_debug(PFX |
658 | "Using outdoor record 0x%04x at %p\n", | 655 | "Using outdoor record 0x%04x at %p\n", |
659 | record_id + 1, pdi); | 656 | record_id + 1, pdi); |
660 | } | 657 | } |
661 | break; | 658 | break; |
662 | case 0x5: /* HWIF Compatiblity */ | 659 | case 0x5: /* HWIF Compatiblity */ |
@@ -684,9 +681,8 @@ int hermes_apply_pda_with_defaults(hermes_t *hw, | |||
684 | if (!pdi && default_pdi) { | 681 | if (!pdi && default_pdi) { |
685 | /* Use default */ | 682 | /* Use default */ |
686 | pdi = default_pdi; | 683 | pdi = default_pdi; |
687 | printk(KERN_DEBUG PFX | 684 | pr_debug(PFX "Using default record 0x%04x at %p\n", |
688 | "Using default record 0x%04x at %p\n", | 685 | record_id, pdi); |
689 | record_id, pdi); | ||
690 | } | 686 | } |
691 | 687 | ||
692 | if (pdi) { | 688 | if (pdi) { |
diff --git a/drivers/net/wireless/orinoco/hw.c b/drivers/net/wireless/orinoco/hw.c index 632fac86a308..fa508af1a351 100644 --- a/drivers/net/wireless/orinoco/hw.c +++ b/drivers/net/wireless/orinoco/hw.c | |||
@@ -3,16 +3,22 @@ | |||
3 | * See copyright notice in main.c | 3 | * See copyright notice in main.c |
4 | */ | 4 | */ |
5 | #include <linux/kernel.h> | 5 | #include <linux/kernel.h> |
6 | #include <linux/device.h> | ||
6 | #include <linux/if_arp.h> | 7 | #include <linux/if_arp.h> |
7 | #include <linux/ieee80211.h> | 8 | #include <linux/ieee80211.h> |
8 | #include <linux/wireless.h> | 9 | #include <linux/wireless.h> |
9 | 10 | #include <net/cfg80211.h> | |
10 | #include "hermes.h" | 11 | #include "hermes.h" |
11 | #include "hermes_rid.h" | 12 | #include "hermes_rid.h" |
12 | #include "orinoco.h" | 13 | #include "orinoco.h" |
13 | 14 | ||
14 | #include "hw.h" | 15 | #include "hw.h" |
15 | 16 | ||
17 | #define SYMBOL_MAX_VER_LEN (14) | ||
18 | |||
19 | /* Symbol firmware has a bug allocating buffers larger than this */ | ||
20 | #define TX_NICBUF_SIZE_BUG 1585 | ||
21 | |||
16 | /********************************************************************/ | 22 | /********************************************************************/ |
17 | /* Data tables */ | 23 | /* Data tables */ |
18 | /********************************************************************/ | 24 | /********************************************************************/ |
@@ -36,6 +42,343 @@ static const struct { | |||
36 | }; | 42 | }; |
37 | #define BITRATE_TABLE_SIZE ARRAY_SIZE(bitrate_table) | 43 | #define BITRATE_TABLE_SIZE ARRAY_SIZE(bitrate_table) |
38 | 44 | ||
45 | /* Firmware version encoding */ | ||
46 | struct comp_id { | ||
47 | u16 id, variant, major, minor; | ||
48 | } __attribute__ ((packed)); | ||
49 | |||
50 | static inline fwtype_t determine_firmware_type(struct comp_id *nic_id) | ||
51 | { | ||
52 | if (nic_id->id < 0x8000) | ||
53 | return FIRMWARE_TYPE_AGERE; | ||
54 | else if (nic_id->id == 0x8000 && nic_id->major == 0) | ||
55 | return FIRMWARE_TYPE_SYMBOL; | ||
56 | else | ||
57 | return FIRMWARE_TYPE_INTERSIL; | ||
58 | } | ||
59 | |||
60 | /* Set priv->firmware type, determine firmware properties | ||
61 | * This function can be called before we have registerred with netdev, | ||
62 | * so all errors go out with dev_* rather than printk | ||
63 | */ | ||
64 | int determine_fw_capabilities(struct orinoco_private *priv) | ||
65 | { | ||
66 | struct device *dev = priv->dev; | ||
67 | hermes_t *hw = &priv->hw; | ||
68 | int err; | ||
69 | struct comp_id nic_id, sta_id; | ||
70 | unsigned int firmver; | ||
71 | char tmp[SYMBOL_MAX_VER_LEN+1] __attribute__((aligned(2))); | ||
72 | |||
73 | /* Get the hardware version */ | ||
74 | err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id); | ||
75 | if (err) { | ||
76 | dev_err(dev, "Cannot read hardware identity: error %d\n", | ||
77 | err); | ||
78 | return err; | ||
79 | } | ||
80 | |||
81 | le16_to_cpus(&nic_id.id); | ||
82 | le16_to_cpus(&nic_id.variant); | ||
83 | le16_to_cpus(&nic_id.major); | ||
84 | le16_to_cpus(&nic_id.minor); | ||
85 | dev_info(dev, "Hardware identity %04x:%04x:%04x:%04x\n", | ||
86 | nic_id.id, nic_id.variant, nic_id.major, nic_id.minor); | ||
87 | |||
88 | priv->firmware_type = determine_firmware_type(&nic_id); | ||
89 | |||
90 | /* Get the firmware version */ | ||
91 | err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_STAID, &sta_id); | ||
92 | if (err) { | ||
93 | dev_err(dev, "Cannot read station identity: error %d\n", | ||
94 | err); | ||
95 | return err; | ||
96 | } | ||
97 | |||
98 | le16_to_cpus(&sta_id.id); | ||
99 | le16_to_cpus(&sta_id.variant); | ||
100 | le16_to_cpus(&sta_id.major); | ||
101 | le16_to_cpus(&sta_id.minor); | ||
102 | dev_info(dev, "Station identity %04x:%04x:%04x:%04x\n", | ||
103 | sta_id.id, sta_id.variant, sta_id.major, sta_id.minor); | ||
104 | |||
105 | switch (sta_id.id) { | ||
106 | case 0x15: | ||
107 | dev_err(dev, "Primary firmware is active\n"); | ||
108 | return -ENODEV; | ||
109 | case 0x14b: | ||
110 | dev_err(dev, "Tertiary firmware is active\n"); | ||
111 | return -ENODEV; | ||
112 | case 0x1f: /* Intersil, Agere, Symbol Spectrum24 */ | ||
113 | case 0x21: /* Symbol Spectrum24 Trilogy */ | ||
114 | break; | ||
115 | default: | ||
116 | dev_notice(dev, "Unknown station ID, please report\n"); | ||
117 | break; | ||
118 | } | ||
119 | |||
120 | /* Default capabilities */ | ||
121 | priv->has_sensitivity = 1; | ||
122 | priv->has_mwo = 0; | ||
123 | priv->has_preamble = 0; | ||
124 | priv->has_port3 = 1; | ||
125 | priv->has_ibss = 1; | ||
126 | priv->has_wep = 0; | ||
127 | priv->has_big_wep = 0; | ||
128 | priv->has_alt_txcntl = 0; | ||
129 | priv->has_ext_scan = 0; | ||
130 | priv->has_wpa = 0; | ||
131 | priv->do_fw_download = 0; | ||
132 | |||
133 | /* Determine capabilities from the firmware version */ | ||
134 | switch (priv->firmware_type) { | ||
135 | case FIRMWARE_TYPE_AGERE: | ||
136 | /* Lucent Wavelan IEEE, Lucent Orinoco, Cabletron RoamAbout, | ||
137 | ELSA, Melco, HP, IBM, Dell 1150, Compaq 110/210 */ | ||
138 | snprintf(priv->fw_name, sizeof(priv->fw_name) - 1, | ||
139 | "Lucent/Agere %d.%02d", sta_id.major, sta_id.minor); | ||
140 | |||
141 | firmver = ((unsigned long)sta_id.major << 16) | sta_id.minor; | ||
142 | |||
143 | priv->has_ibss = (firmver >= 0x60006); | ||
144 | priv->has_wep = (firmver >= 0x40020); | ||
145 | priv->has_big_wep = 1; /* FIXME: this is wrong - how do we tell | ||
146 | Gold cards from the others? */ | ||
147 | priv->has_mwo = (firmver >= 0x60000); | ||
148 | priv->has_pm = (firmver >= 0x40020); /* Don't work in 7.52 ? */ | ||
149 | priv->ibss_port = 1; | ||
150 | priv->has_hostscan = (firmver >= 0x8000a); | ||
151 | priv->do_fw_download = 1; | ||
152 | priv->broken_monitor = (firmver >= 0x80000); | ||
153 | priv->has_alt_txcntl = (firmver >= 0x90000); /* All 9.x ? */ | ||
154 | priv->has_ext_scan = (firmver >= 0x90000); /* All 9.x ? */ | ||
155 | priv->has_wpa = (firmver >= 0x9002a); | ||
156 | /* Tested with Agere firmware : | ||
157 | * 1.16 ; 4.08 ; 4.52 ; 6.04 ; 6.16 ; 7.28 => Jean II | ||
158 | * Tested CableTron firmware : 4.32 => Anton */ | ||
159 | break; | ||
160 | case FIRMWARE_TYPE_SYMBOL: | ||
161 | /* Symbol , 3Com AirConnect, Intel, Ericsson WLAN */ | ||
162 | /* Intel MAC : 00:02:B3:* */ | ||
163 | /* 3Com MAC : 00:50:DA:* */ | ||
164 | memset(tmp, 0, sizeof(tmp)); | ||
165 | /* Get the Symbol firmware version */ | ||
166 | err = hermes_read_ltv(hw, USER_BAP, | ||
167 | HERMES_RID_SECONDARYVERSION_SYMBOL, | ||
168 | SYMBOL_MAX_VER_LEN, NULL, &tmp); | ||
169 | if (err) { | ||
170 | dev_warn(dev, "Error %d reading Symbol firmware info. " | ||
171 | "Wildly guessing capabilities...\n", err); | ||
172 | firmver = 0; | ||
173 | tmp[0] = '\0'; | ||
174 | } else { | ||
175 | /* The firmware revision is a string, the format is | ||
176 | * something like : "V2.20-01". | ||
177 | * Quick and dirty parsing... - Jean II | ||
178 | */ | ||
179 | firmver = ((tmp[1] - '0') << 16) | ||
180 | | ((tmp[3] - '0') << 12) | ||
181 | | ((tmp[4] - '0') << 8) | ||
182 | | ((tmp[6] - '0') << 4) | ||
183 | | (tmp[7] - '0'); | ||
184 | |||
185 | tmp[SYMBOL_MAX_VER_LEN] = '\0'; | ||
186 | } | ||
187 | |||
188 | snprintf(priv->fw_name, sizeof(priv->fw_name) - 1, | ||
189 | "Symbol %s", tmp); | ||
190 | |||
191 | priv->has_ibss = (firmver >= 0x20000); | ||
192 | priv->has_wep = (firmver >= 0x15012); | ||
193 | priv->has_big_wep = (firmver >= 0x20000); | ||
194 | priv->has_pm = (firmver >= 0x20000 && firmver < 0x22000) || | ||
195 | (firmver >= 0x29000 && firmver < 0x30000) || | ||
196 | firmver >= 0x31000; | ||
197 | priv->has_preamble = (firmver >= 0x20000); | ||
198 | priv->ibss_port = 4; | ||
199 | |||
200 | /* Symbol firmware is found on various cards, but | ||
201 | * there has been no attempt to check firmware | ||
202 | * download on non-spectrum_cs based cards. | ||
203 | * | ||
204 | * Given that the Agere firmware download works | ||
205 | * differently, we should avoid doing a firmware | ||
206 | * download with the Symbol algorithm on non-spectrum | ||
207 | * cards. | ||
208 | * | ||
209 | * For now we can identify a spectrum_cs based card | ||
210 | * because it has a firmware reset function. | ||
211 | */ | ||
212 | priv->do_fw_download = (priv->stop_fw != NULL); | ||
213 | |||
214 | priv->broken_disableport = (firmver == 0x25013) || | ||
215 | (firmver >= 0x30000 && firmver <= 0x31000); | ||
216 | priv->has_hostscan = (firmver >= 0x31001) || | ||
217 | (firmver >= 0x29057 && firmver < 0x30000); | ||
218 | /* Tested with Intel firmware : 0x20015 => Jean II */ | ||
219 | /* Tested with 3Com firmware : 0x15012 & 0x22001 => Jean II */ | ||
220 | break; | ||
221 | case FIRMWARE_TYPE_INTERSIL: | ||
222 | /* D-Link, Linksys, Adtron, ZoomAir, and many others... | ||
223 | * Samsung, Compaq 100/200 and Proxim are slightly | ||
224 | * different and less well tested */ | ||
225 | /* D-Link MAC : 00:40:05:* */ | ||
226 | /* Addtron MAC : 00:90:D1:* */ | ||
227 | snprintf(priv->fw_name, sizeof(priv->fw_name) - 1, | ||
228 | "Intersil %d.%d.%d", sta_id.major, sta_id.minor, | ||
229 | sta_id.variant); | ||
230 | |||
231 | firmver = ((unsigned long)sta_id.major << 16) | | ||
232 | ((unsigned long)sta_id.minor << 8) | sta_id.variant; | ||
233 | |||
234 | priv->has_ibss = (firmver >= 0x000700); /* FIXME */ | ||
235 | priv->has_big_wep = priv->has_wep = (firmver >= 0x000800); | ||
236 | priv->has_pm = (firmver >= 0x000700); | ||
237 | priv->has_hostscan = (firmver >= 0x010301); | ||
238 | |||
239 | if (firmver >= 0x000800) | ||
240 | priv->ibss_port = 0; | ||
241 | else { | ||
242 | dev_notice(dev, "Intersil firmware earlier than v0.8.x" | ||
243 | " - several features not supported\n"); | ||
244 | priv->ibss_port = 1; | ||
245 | } | ||
246 | break; | ||
247 | } | ||
248 | dev_info(dev, "Firmware determined as %s\n", priv->fw_name); | ||
249 | |||
250 | return 0; | ||
251 | } | ||
252 | |||
253 | /* Read settings from EEPROM into our private structure. | ||
254 | * MAC address gets dropped into callers buffer | ||
255 | * Can be called before netdev registration. | ||
256 | */ | ||
257 | int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr) | ||
258 | { | ||
259 | struct device *dev = priv->dev; | ||
260 | struct hermes_idstring nickbuf; | ||
261 | hermes_t *hw = &priv->hw; | ||
262 | int len; | ||
263 | int err; | ||
264 | u16 reclen; | ||
265 | |||
266 | /* Get the MAC address */ | ||
267 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, | ||
268 | ETH_ALEN, NULL, dev_addr); | ||
269 | if (err) { | ||
270 | dev_warn(dev, "Failed to read MAC address!\n"); | ||
271 | goto out; | ||
272 | } | ||
273 | |||
274 | dev_dbg(dev, "MAC address %pM\n", dev_addr); | ||
275 | |||
276 | /* Get the station name */ | ||
277 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, | ||
278 | sizeof(nickbuf), &reclen, &nickbuf); | ||
279 | if (err) { | ||
280 | dev_err(dev, "failed to read station name\n"); | ||
281 | goto out; | ||
282 | } | ||
283 | if (nickbuf.len) | ||
284 | len = min(IW_ESSID_MAX_SIZE, (int)le16_to_cpu(nickbuf.len)); | ||
285 | else | ||
286 | len = min(IW_ESSID_MAX_SIZE, 2 * reclen); | ||
287 | memcpy(priv->nick, &nickbuf.val, len); | ||
288 | priv->nick[len] = '\0'; | ||
289 | |||
290 | dev_dbg(dev, "Station name \"%s\"\n", priv->nick); | ||
291 | |||
292 | /* Get allowed channels */ | ||
293 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST, | ||
294 | &priv->channel_mask); | ||
295 | if (err) { | ||
296 | dev_err(dev, "Failed to read channel list!\n"); | ||
297 | goto out; | ||
298 | } | ||
299 | |||
300 | /* Get initial AP density */ | ||
301 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE, | ||
302 | &priv->ap_density); | ||
303 | if (err || priv->ap_density < 1 || priv->ap_density > 3) | ||
304 | priv->has_sensitivity = 0; | ||
305 | |||
306 | /* Get initial RTS threshold */ | ||
307 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, | ||
308 | &priv->rts_thresh); | ||
309 | if (err) { | ||
310 | dev_err(dev, "Failed to read RTS threshold!\n"); | ||
311 | goto out; | ||
312 | } | ||
313 | |||
314 | /* Get initial fragmentation settings */ | ||
315 | if (priv->has_mwo) | ||
316 | err = hermes_read_wordrec(hw, USER_BAP, | ||
317 | HERMES_RID_CNFMWOROBUST_AGERE, | ||
318 | &priv->mwo_robust); | ||
319 | else | ||
320 | err = hermes_read_wordrec(hw, USER_BAP, | ||
321 | HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, | ||
322 | &priv->frag_thresh); | ||
323 | if (err) { | ||
324 | dev_err(dev, "Failed to read fragmentation settings!\n"); | ||
325 | goto out; | ||
326 | } | ||
327 | |||
328 | /* Power management setup */ | ||
329 | if (priv->has_pm) { | ||
330 | priv->pm_on = 0; | ||
331 | priv->pm_mcast = 1; | ||
332 | err = hermes_read_wordrec(hw, USER_BAP, | ||
333 | HERMES_RID_CNFMAXSLEEPDURATION, | ||
334 | &priv->pm_period); | ||
335 | if (err) { | ||
336 | dev_err(dev, "Failed to read power management " | ||
337 | "period!\n"); | ||
338 | goto out; | ||
339 | } | ||
340 | err = hermes_read_wordrec(hw, USER_BAP, | ||
341 | HERMES_RID_CNFPMHOLDOVERDURATION, | ||
342 | &priv->pm_timeout); | ||
343 | if (err) { | ||
344 | dev_err(dev, "Failed to read power management " | ||
345 | "timeout!\n"); | ||
346 | goto out; | ||
347 | } | ||
348 | } | ||
349 | |||
350 | /* Preamble setup */ | ||
351 | if (priv->has_preamble) { | ||
352 | err = hermes_read_wordrec(hw, USER_BAP, | ||
353 | HERMES_RID_CNFPREAMBLE_SYMBOL, | ||
354 | &priv->preamble); | ||
355 | } | ||
356 | |||
357 | out: | ||
358 | return err; | ||
359 | } | ||
360 | |||
361 | /* Can be called before netdev registration */ | ||
362 | int orinoco_hw_allocate_fid(struct orinoco_private *priv) | ||
363 | { | ||
364 | struct device *dev = priv->dev; | ||
365 | struct hermes *hw = &priv->hw; | ||
366 | int err; | ||
367 | |||
368 | err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid); | ||
369 | if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) { | ||
370 | /* Try workaround for old Symbol firmware bug */ | ||
371 | priv->nicbuf_size = TX_NICBUF_SIZE_BUG; | ||
372 | err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid); | ||
373 | |||
374 | dev_warn(dev, "Firmware ALLOC bug detected " | ||
375 | "(old Symbol firmware?). Work around %s\n", | ||
376 | err ? "failed!" : "ok."); | ||
377 | } | ||
378 | |||
379 | return err; | ||
380 | } | ||
381 | |||
39 | int orinoco_get_bitratemode(int bitrate, int automatic) | 382 | int orinoco_get_bitratemode(int bitrate, int automatic) |
40 | { | 383 | { |
41 | int ratemode = -1; | 384 | int ratemode = -1; |
@@ -63,6 +406,237 @@ void orinoco_get_ratemode_cfg(int ratemode, int *bitrate, int *automatic) | |||
63 | *automatic = bitrate_table[ratemode].automatic; | 406 | *automatic = bitrate_table[ratemode].automatic; |
64 | } | 407 | } |
65 | 408 | ||
409 | int orinoco_hw_program_rids(struct orinoco_private *priv) | ||
410 | { | ||
411 | struct net_device *dev = priv->ndev; | ||
412 | struct wireless_dev *wdev = netdev_priv(dev); | ||
413 | hermes_t *hw = &priv->hw; | ||
414 | int err; | ||
415 | struct hermes_idstring idbuf; | ||
416 | |||
417 | /* Set the MAC address */ | ||
418 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, | ||
419 | HERMES_BYTES_TO_RECLEN(ETH_ALEN), dev->dev_addr); | ||
420 | if (err) { | ||
421 | printk(KERN_ERR "%s: Error %d setting MAC address\n", | ||
422 | dev->name, err); | ||
423 | return err; | ||
424 | } | ||
425 | |||
426 | /* Set up the link mode */ | ||
427 | err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFPORTTYPE, | ||
428 | priv->port_type); | ||
429 | if (err) { | ||
430 | printk(KERN_ERR "%s: Error %d setting port type\n", | ||
431 | dev->name, err); | ||
432 | return err; | ||
433 | } | ||
434 | /* Set the channel/frequency */ | ||
435 | if (priv->channel != 0 && priv->iw_mode != NL80211_IFTYPE_STATION) { | ||
436 | err = hermes_write_wordrec(hw, USER_BAP, | ||
437 | HERMES_RID_CNFOWNCHANNEL, | ||
438 | priv->channel); | ||
439 | if (err) { | ||
440 | printk(KERN_ERR "%s: Error %d setting channel %d\n", | ||
441 | dev->name, err, priv->channel); | ||
442 | return err; | ||
443 | } | ||
444 | } | ||
445 | |||
446 | if (priv->has_ibss) { | ||
447 | u16 createibss; | ||
448 | |||
449 | if ((strlen(priv->desired_essid) == 0) && (priv->createibss)) { | ||
450 | printk(KERN_WARNING "%s: This firmware requires an " | ||
451 | "ESSID in IBSS-Ad-Hoc mode.\n", dev->name); | ||
452 | /* With wvlan_cs, in this case, we would crash. | ||
453 | * hopefully, this driver will behave better... | ||
454 | * Jean II */ | ||
455 | createibss = 0; | ||
456 | } else { | ||
457 | createibss = priv->createibss; | ||
458 | } | ||
459 | |||
460 | err = hermes_write_wordrec(hw, USER_BAP, | ||
461 | HERMES_RID_CNFCREATEIBSS, | ||
462 | createibss); | ||
463 | if (err) { | ||
464 | printk(KERN_ERR "%s: Error %d setting CREATEIBSS\n", | ||
465 | dev->name, err); | ||
466 | return err; | ||
467 | } | ||
468 | } | ||
469 | |||
470 | /* Set the desired BSSID */ | ||
471 | err = __orinoco_hw_set_wap(priv); | ||
472 | if (err) { | ||
473 | printk(KERN_ERR "%s: Error %d setting AP address\n", | ||
474 | dev->name, err); | ||
475 | return err; | ||
476 | } | ||
477 | |||
478 | /* Set the desired ESSID */ | ||
479 | idbuf.len = cpu_to_le16(strlen(priv->desired_essid)); | ||
480 | memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val)); | ||
481 | /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */ | ||
482 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID, | ||
483 | HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2), | ||
484 | &idbuf); | ||
485 | if (err) { | ||
486 | printk(KERN_ERR "%s: Error %d setting OWNSSID\n", | ||
487 | dev->name, err); | ||
488 | return err; | ||
489 | } | ||
490 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID, | ||
491 | HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2), | ||
492 | &idbuf); | ||
493 | if (err) { | ||
494 | printk(KERN_ERR "%s: Error %d setting DESIREDSSID\n", | ||
495 | dev->name, err); | ||
496 | return err; | ||
497 | } | ||
498 | |||
499 | /* Set the station name */ | ||
500 | idbuf.len = cpu_to_le16(strlen(priv->nick)); | ||
501 | memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val)); | ||
502 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, | ||
503 | HERMES_BYTES_TO_RECLEN(strlen(priv->nick)+2), | ||
504 | &idbuf); | ||
505 | if (err) { | ||
506 | printk(KERN_ERR "%s: Error %d setting nickname\n", | ||
507 | dev->name, err); | ||
508 | return err; | ||
509 | } | ||
510 | |||
511 | /* Set AP density */ | ||
512 | if (priv->has_sensitivity) { | ||
513 | err = hermes_write_wordrec(hw, USER_BAP, | ||
514 | HERMES_RID_CNFSYSTEMSCALE, | ||
515 | priv->ap_density); | ||
516 | if (err) { | ||
517 | printk(KERN_WARNING "%s: Error %d setting SYSTEMSCALE. " | ||
518 | "Disabling sensitivity control\n", | ||
519 | dev->name, err); | ||
520 | |||
521 | priv->has_sensitivity = 0; | ||
522 | } | ||
523 | } | ||
524 | |||
525 | /* Set RTS threshold */ | ||
526 | err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, | ||
527 | priv->rts_thresh); | ||
528 | if (err) { | ||
529 | printk(KERN_ERR "%s: Error %d setting RTS threshold\n", | ||
530 | dev->name, err); | ||
531 | return err; | ||
532 | } | ||
533 | |||
534 | /* Set fragmentation threshold or MWO robustness */ | ||
535 | if (priv->has_mwo) | ||
536 | err = hermes_write_wordrec(hw, USER_BAP, | ||
537 | HERMES_RID_CNFMWOROBUST_AGERE, | ||
538 | priv->mwo_robust); | ||
539 | else | ||
540 | err = hermes_write_wordrec(hw, USER_BAP, | ||
541 | HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, | ||
542 | priv->frag_thresh); | ||
543 | if (err) { | ||
544 | printk(KERN_ERR "%s: Error %d setting fragmentation\n", | ||
545 | dev->name, err); | ||
546 | return err; | ||
547 | } | ||
548 | |||
549 | /* Set bitrate */ | ||
550 | err = __orinoco_hw_set_bitrate(priv); | ||
551 | if (err) { | ||
552 | printk(KERN_ERR "%s: Error %d setting bitrate\n", | ||
553 | dev->name, err); | ||
554 | return err; | ||
555 | } | ||
556 | |||
557 | /* Set power management */ | ||
558 | if (priv->has_pm) { | ||
559 | err = hermes_write_wordrec(hw, USER_BAP, | ||
560 | HERMES_RID_CNFPMENABLED, | ||
561 | priv->pm_on); | ||
562 | if (err) { | ||
563 | printk(KERN_ERR "%s: Error %d setting up PM\n", | ||
564 | dev->name, err); | ||
565 | return err; | ||
566 | } | ||
567 | |||
568 | err = hermes_write_wordrec(hw, USER_BAP, | ||
569 | HERMES_RID_CNFMULTICASTRECEIVE, | ||
570 | priv->pm_mcast); | ||
571 | if (err) { | ||
572 | printk(KERN_ERR "%s: Error %d setting up PM\n", | ||
573 | dev->name, err); | ||
574 | return err; | ||
575 | } | ||
576 | err = hermes_write_wordrec(hw, USER_BAP, | ||
577 | HERMES_RID_CNFMAXSLEEPDURATION, | ||
578 | priv->pm_period); | ||
579 | if (err) { | ||
580 | printk(KERN_ERR "%s: Error %d setting up PM\n", | ||
581 | dev->name, err); | ||
582 | return err; | ||
583 | } | ||
584 | err = hermes_write_wordrec(hw, USER_BAP, | ||
585 | HERMES_RID_CNFPMHOLDOVERDURATION, | ||
586 | priv->pm_timeout); | ||
587 | if (err) { | ||
588 | printk(KERN_ERR "%s: Error %d setting up PM\n", | ||
589 | dev->name, err); | ||
590 | return err; | ||
591 | } | ||
592 | } | ||
593 | |||
594 | /* Set preamble - only for Symbol so far... */ | ||
595 | if (priv->has_preamble) { | ||
596 | err = hermes_write_wordrec(hw, USER_BAP, | ||
597 | HERMES_RID_CNFPREAMBLE_SYMBOL, | ||
598 | priv->preamble); | ||
599 | if (err) { | ||
600 | printk(KERN_ERR "%s: Error %d setting preamble\n", | ||
601 | dev->name, err); | ||
602 | return err; | ||
603 | } | ||
604 | } | ||
605 | |||
606 | /* Set up encryption */ | ||
607 | if (priv->has_wep || priv->has_wpa) { | ||
608 | err = __orinoco_hw_setup_enc(priv); | ||
609 | if (err) { | ||
610 | printk(KERN_ERR "%s: Error %d activating encryption\n", | ||
611 | dev->name, err); | ||
612 | return err; | ||
613 | } | ||
614 | } | ||
615 | |||
616 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { | ||
617 | /* Enable monitor mode */ | ||
618 | dev->type = ARPHRD_IEEE80211; | ||
619 | err = hermes_docmd_wait(hw, HERMES_CMD_TEST | | ||
620 | HERMES_TEST_MONITOR, 0, NULL); | ||
621 | } else { | ||
622 | /* Disable monitor mode */ | ||
623 | dev->type = ARPHRD_ETHER; | ||
624 | err = hermes_docmd_wait(hw, HERMES_CMD_TEST | | ||
625 | HERMES_TEST_STOP, 0, NULL); | ||
626 | } | ||
627 | if (err) | ||
628 | return err; | ||
629 | |||
630 | /* Reset promiscuity / multicast*/ | ||
631 | priv->promiscuous = 0; | ||
632 | priv->mc_count = 0; | ||
633 | |||
634 | /* Record mode change */ | ||
635 | wdev->iftype = priv->iw_mode; | ||
636 | |||
637 | return 0; | ||
638 | } | ||
639 | |||
66 | /* Get tsc from the firmware */ | 640 | /* Get tsc from the firmware */ |
67 | int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc) | 641 | int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc) |
68 | { | 642 | { |
@@ -314,7 +888,7 @@ int __orinoco_hw_setup_enc(struct orinoco_private *priv) | |||
314 | } else | 888 | } else |
315 | master_wep_flag = 0; | 889 | master_wep_flag = 0; |
316 | 890 | ||
317 | if (priv->iw_mode == IW_MODE_MONITOR) | 891 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) |
318 | master_wep_flag |= HERMES_WEP_HOST_DECRYPT; | 892 | master_wep_flag |= HERMES_WEP_HOST_DECRYPT; |
319 | 893 | ||
320 | /* Master WEP setting : on/off */ | 894 | /* Master WEP setting : on/off */ |
@@ -334,8 +908,8 @@ int __orinoco_hw_setup_enc(struct orinoco_private *priv) | |||
334 | * rsc must be 8 bytes | 908 | * rsc must be 8 bytes |
335 | * tsc must be 8 bytes or NULL | 909 | * tsc must be 8 bytes or NULL |
336 | */ | 910 | */ |
337 | int __orinoco_hw_set_tkip_key(hermes_t *hw, int key_idx, int set_tx, | 911 | int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx, |
338 | u8 *key, u8 *rsc, u8 *tsc) | 912 | int set_tx, u8 *key, u8 *rsc, u8 *tsc) |
339 | { | 913 | { |
340 | struct { | 914 | struct { |
341 | __le16 idx; | 915 | __le16 idx; |
@@ -345,6 +919,7 @@ int __orinoco_hw_set_tkip_key(hermes_t *hw, int key_idx, int set_tx, | |||
345 | u8 rx_mic[MIC_KEYLEN]; | 919 | u8 rx_mic[MIC_KEYLEN]; |
346 | u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; | 920 | u8 tsc[IW_ENCODE_SEQ_MAX_SIZE]; |
347 | } __attribute__ ((packed)) buf; | 921 | } __attribute__ ((packed)) buf; |
922 | hermes_t *hw = &priv->hw; | ||
348 | int ret; | 923 | int ret; |
349 | int err; | 924 | int err; |
350 | int k; | 925 | int k; |
@@ -582,3 +1157,88 @@ int orinoco_hw_get_bitratelist(struct orinoco_private *priv, | |||
582 | 1157 | ||
583 | return 0; | 1158 | return 0; |
584 | } | 1159 | } |
1160 | |||
1161 | int orinoco_hw_trigger_scan(struct orinoco_private *priv, | ||
1162 | const struct cfg80211_ssid *ssid) | ||
1163 | { | ||
1164 | struct net_device *dev = priv->ndev; | ||
1165 | hermes_t *hw = &priv->hw; | ||
1166 | unsigned long flags; | ||
1167 | int err = 0; | ||
1168 | |||
1169 | if (orinoco_lock(priv, &flags) != 0) | ||
1170 | return -EBUSY; | ||
1171 | |||
1172 | /* Scanning with port 0 disabled would fail */ | ||
1173 | if (!netif_running(dev)) { | ||
1174 | err = -ENETDOWN; | ||
1175 | goto out; | ||
1176 | } | ||
1177 | |||
1178 | /* In monitor mode, the scan results are always empty. | ||
1179 | * Probe responses are passed to the driver as received | ||
1180 | * frames and could be processed in software. */ | ||
1181 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { | ||
1182 | err = -EOPNOTSUPP; | ||
1183 | goto out; | ||
1184 | } | ||
1185 | |||
1186 | if (priv->has_hostscan) { | ||
1187 | switch (priv->firmware_type) { | ||
1188 | case FIRMWARE_TYPE_SYMBOL: | ||
1189 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1190 | HERMES_RID_CNFHOSTSCAN_SYMBOL, | ||
1191 | HERMES_HOSTSCAN_SYMBOL_ONCE | | ||
1192 | HERMES_HOSTSCAN_SYMBOL_BCAST); | ||
1193 | break; | ||
1194 | case FIRMWARE_TYPE_INTERSIL: { | ||
1195 | __le16 req[3]; | ||
1196 | |||
1197 | req[0] = cpu_to_le16(0x3fff); /* All channels */ | ||
1198 | req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */ | ||
1199 | req[2] = 0; /* Any ESSID */ | ||
1200 | err = HERMES_WRITE_RECORD(hw, USER_BAP, | ||
1201 | HERMES_RID_CNFHOSTSCAN, &req); | ||
1202 | break; | ||
1203 | } | ||
1204 | case FIRMWARE_TYPE_AGERE: | ||
1205 | if (ssid->ssid_len > 0) { | ||
1206 | struct hermes_idstring idbuf; | ||
1207 | size_t len = ssid->ssid_len; | ||
1208 | |||
1209 | idbuf.len = cpu_to_le16(len); | ||
1210 | memcpy(idbuf.val, ssid->ssid, len); | ||
1211 | |||
1212 | err = hermes_write_ltv(hw, USER_BAP, | ||
1213 | HERMES_RID_CNFSCANSSID_AGERE, | ||
1214 | HERMES_BYTES_TO_RECLEN(len + 2), | ||
1215 | &idbuf); | ||
1216 | } else | ||
1217 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1218 | HERMES_RID_CNFSCANSSID_AGERE, | ||
1219 | 0); /* Any ESSID */ | ||
1220 | if (err) | ||
1221 | break; | ||
1222 | |||
1223 | if (priv->has_ext_scan) { | ||
1224 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1225 | HERMES_RID_CNFSCANCHANNELS2GHZ, | ||
1226 | 0x7FFF); | ||
1227 | if (err) | ||
1228 | goto out; | ||
1229 | |||
1230 | err = hermes_inquire(hw, | ||
1231 | HERMES_INQ_CHANNELINFO); | ||
1232 | } else | ||
1233 | err = hermes_inquire(hw, HERMES_INQ_SCAN); | ||
1234 | |||
1235 | break; | ||
1236 | } | ||
1237 | } else | ||
1238 | err = hermes_inquire(hw, HERMES_INQ_SCAN); | ||
1239 | |||
1240 | out: | ||
1241 | orinoco_unlock(priv, &flags); | ||
1242 | |||
1243 | return err; | ||
1244 | } | ||
diff --git a/drivers/net/wireless/orinoco/hw.h b/drivers/net/wireless/orinoco/hw.h index dc3f23a9c1c7..27b427649d1b 100644 --- a/drivers/net/wireless/orinoco/hw.h +++ b/drivers/net/wireless/orinoco/hw.h | |||
@@ -7,6 +7,7 @@ | |||
7 | 7 | ||
8 | #include <linux/types.h> | 8 | #include <linux/types.h> |
9 | #include <linux/wireless.h> | 9 | #include <linux/wireless.h> |
10 | #include <net/cfg80211.h> | ||
10 | 11 | ||
11 | /* Hardware BAPs */ | 12 | /* Hardware BAPs */ |
12 | #define USER_BAP 0 | 13 | #define USER_BAP 0 |
@@ -23,17 +24,21 @@ | |||
23 | struct orinoco_private; | 24 | struct orinoco_private; |
24 | struct dev_addr_list; | 25 | struct dev_addr_list; |
25 | 26 | ||
27 | int determine_fw_capabilities(struct orinoco_private *priv); | ||
28 | int orinoco_hw_read_card_settings(struct orinoco_private *priv, u8 *dev_addr); | ||
29 | int orinoco_hw_allocate_fid(struct orinoco_private *priv); | ||
26 | int orinoco_get_bitratemode(int bitrate, int automatic); | 30 | int orinoco_get_bitratemode(int bitrate, int automatic); |
27 | void orinoco_get_ratemode_cfg(int ratemode, int *bitrate, int *automatic); | 31 | void orinoco_get_ratemode_cfg(int ratemode, int *bitrate, int *automatic); |
28 | 32 | ||
33 | int orinoco_hw_program_rids(struct orinoco_private *priv); | ||
29 | int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc); | 34 | int orinoco_hw_get_tkip_iv(struct orinoco_private *priv, int key, u8 *tsc); |
30 | int __orinoco_hw_set_bitrate(struct orinoco_private *priv); | 35 | int __orinoco_hw_set_bitrate(struct orinoco_private *priv); |
31 | int orinoco_hw_get_act_bitrate(struct orinoco_private *priv, int *bitrate); | 36 | int orinoco_hw_get_act_bitrate(struct orinoco_private *priv, int *bitrate); |
32 | int __orinoco_hw_set_wap(struct orinoco_private *priv); | 37 | int __orinoco_hw_set_wap(struct orinoco_private *priv); |
33 | int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv); | 38 | int __orinoco_hw_setup_wepkeys(struct orinoco_private *priv); |
34 | int __orinoco_hw_setup_enc(struct orinoco_private *priv); | 39 | int __orinoco_hw_setup_enc(struct orinoco_private *priv); |
35 | int __orinoco_hw_set_tkip_key(hermes_t *hw, int key_idx, int set_tx, | 40 | int __orinoco_hw_set_tkip_key(struct orinoco_private *priv, int key_idx, |
36 | u8 *key, u8 *rsc, u8 *tsc); | 41 | int set_tx, u8 *key, u8 *rsc, u8 *tsc); |
37 | int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx); | 42 | int orinoco_clear_tkip_key(struct orinoco_private *priv, int key_idx); |
38 | int __orinoco_hw_set_multicast_list(struct orinoco_private *priv, | 43 | int __orinoco_hw_set_multicast_list(struct orinoco_private *priv, |
39 | struct dev_addr_list *mc_list, | 44 | struct dev_addr_list *mc_list, |
@@ -43,5 +48,7 @@ int orinoco_hw_get_essid(struct orinoco_private *priv, int *active, | |||
43 | int orinoco_hw_get_freq(struct orinoco_private *priv); | 48 | int orinoco_hw_get_freq(struct orinoco_private *priv); |
44 | int orinoco_hw_get_bitratelist(struct orinoco_private *priv, | 49 | int orinoco_hw_get_bitratelist(struct orinoco_private *priv, |
45 | int *numrates, s32 *rates, int max); | 50 | int *numrates, s32 *rates, int max); |
51 | int orinoco_hw_trigger_scan(struct orinoco_private *priv, | ||
52 | const struct cfg80211_ssid *ssid); | ||
46 | 53 | ||
47 | #endif /* _ORINOCO_HW_H_ */ | 54 | #endif /* _ORINOCO_HW_H_ */ |
diff --git a/drivers/net/wireless/orinoco/main.c b/drivers/net/wireless/orinoco/main.c index a370e510f19f..e8c550a61f33 100644 --- a/drivers/net/wireless/orinoco/main.c +++ b/drivers/net/wireless/orinoco/main.c | |||
@@ -80,6 +80,7 @@ | |||
80 | #include <linux/kernel.h> | 80 | #include <linux/kernel.h> |
81 | #include <linux/init.h> | 81 | #include <linux/init.h> |
82 | #include <linux/delay.h> | 82 | #include <linux/delay.h> |
83 | #include <linux/device.h> | ||
83 | #include <linux/netdevice.h> | 84 | #include <linux/netdevice.h> |
84 | #include <linux/etherdevice.h> | 85 | #include <linux/etherdevice.h> |
85 | #include <linux/ethtool.h> | 86 | #include <linux/ethtool.h> |
@@ -88,6 +89,7 @@ | |||
88 | #include <linux/wireless.h> | 89 | #include <linux/wireless.h> |
89 | #include <linux/ieee80211.h> | 90 | #include <linux/ieee80211.h> |
90 | #include <net/iw_handler.h> | 91 | #include <net/iw_handler.h> |
92 | #include <net/cfg80211.h> | ||
91 | 93 | ||
92 | #include "hermes_rid.h" | 94 | #include "hermes_rid.h" |
93 | #include "hermes_dld.h" | 95 | #include "hermes_dld.h" |
@@ -96,6 +98,7 @@ | |||
96 | #include "mic.h" | 98 | #include "mic.h" |
97 | #include "fw.h" | 99 | #include "fw.h" |
98 | #include "wext.h" | 100 | #include "wext.h" |
101 | #include "cfg.h" | ||
99 | #include "main.h" | 102 | #include "main.h" |
100 | 103 | ||
101 | #include "orinoco.h" | 104 | #include "orinoco.h" |
@@ -142,13 +145,11 @@ static const u8 encaps_hdr[] = {0xaa, 0xaa, 0x03, 0x00, 0x00, 0x00}; | |||
142 | #define ORINOCO_MIN_MTU 256 | 145 | #define ORINOCO_MIN_MTU 256 |
143 | #define ORINOCO_MAX_MTU (IEEE80211_MAX_DATA_LEN - ENCAPS_OVERHEAD) | 146 | #define ORINOCO_MAX_MTU (IEEE80211_MAX_DATA_LEN - ENCAPS_OVERHEAD) |
144 | 147 | ||
145 | #define SYMBOL_MAX_VER_LEN (14) | ||
146 | #define MAX_IRQLOOPS_PER_IRQ 10 | 148 | #define MAX_IRQLOOPS_PER_IRQ 10 |
147 | #define MAX_IRQLOOPS_PER_JIFFY (20000/HZ) /* Based on a guestimate of | 149 | #define MAX_IRQLOOPS_PER_JIFFY (20000/HZ) /* Based on a guestimate of |
148 | * how many events the | 150 | * how many events the |
149 | * device could | 151 | * device could |
150 | * legitimately generate */ | 152 | * legitimately generate */ |
151 | #define TX_NICBUF_SIZE_BUG 1585 /* Bug in Symbol firmware */ | ||
152 | 153 | ||
153 | #define DUMMY_FID 0xFFFF | 154 | #define DUMMY_FID 0xFFFF |
154 | 155 | ||
@@ -205,11 +206,21 @@ struct orinoco_rx_data { | |||
205 | struct list_head list; | 206 | struct list_head list; |
206 | }; | 207 | }; |
207 | 208 | ||
209 | struct orinoco_scan_data { | ||
210 | void *buf; | ||
211 | size_t len; | ||
212 | int type; | ||
213 | struct list_head list; | ||
214 | }; | ||
215 | |||
208 | /********************************************************************/ | 216 | /********************************************************************/ |
209 | /* Function prototypes */ | 217 | /* Function prototypes */ |
210 | /********************************************************************/ | 218 | /********************************************************************/ |
211 | 219 | ||
212 | static void __orinoco_set_multicast_list(struct net_device *dev); | 220 | static int __orinoco_set_multicast_list(struct net_device *dev); |
221 | static int __orinoco_up(struct orinoco_private *priv); | ||
222 | static int __orinoco_down(struct orinoco_private *priv); | ||
223 | static int __orinoco_commit(struct orinoco_private *priv); | ||
213 | 224 | ||
214 | /********************************************************************/ | 225 | /********************************************************************/ |
215 | /* Internal helper functions */ | 226 | /* Internal helper functions */ |
@@ -218,11 +229,11 @@ static void __orinoco_set_multicast_list(struct net_device *dev); | |||
218 | void set_port_type(struct orinoco_private *priv) | 229 | void set_port_type(struct orinoco_private *priv) |
219 | { | 230 | { |
220 | switch (priv->iw_mode) { | 231 | switch (priv->iw_mode) { |
221 | case IW_MODE_INFRA: | 232 | case NL80211_IFTYPE_STATION: |
222 | priv->port_type = 1; | 233 | priv->port_type = 1; |
223 | priv->createibss = 0; | 234 | priv->createibss = 0; |
224 | break; | 235 | break; |
225 | case IW_MODE_ADHOC: | 236 | case NL80211_IFTYPE_ADHOC: |
226 | if (priv->prefer_port3) { | 237 | if (priv->prefer_port3) { |
227 | priv->port_type = 3; | 238 | priv->port_type = 3; |
228 | priv->createibss = 0; | 239 | priv->createibss = 0; |
@@ -231,7 +242,7 @@ void set_port_type(struct orinoco_private *priv) | |||
231 | priv->createibss = 1; | 242 | priv->createibss = 1; |
232 | } | 243 | } |
233 | break; | 244 | break; |
234 | case IW_MODE_MONITOR: | 245 | case NL80211_IFTYPE_MONITOR: |
235 | priv->port_type = 3; | 246 | priv->port_type = 3; |
236 | priv->createibss = 0; | 247 | priv->createibss = 0; |
237 | break; | 248 | break; |
@@ -247,14 +258,14 @@ void set_port_type(struct orinoco_private *priv) | |||
247 | 258 | ||
248 | static int orinoco_open(struct net_device *dev) | 259 | static int orinoco_open(struct net_device *dev) |
249 | { | 260 | { |
250 | struct orinoco_private *priv = netdev_priv(dev); | 261 | struct orinoco_private *priv = ndev_priv(dev); |
251 | unsigned long flags; | 262 | unsigned long flags; |
252 | int err; | 263 | int err; |
253 | 264 | ||
254 | if (orinoco_lock(priv, &flags) != 0) | 265 | if (orinoco_lock(priv, &flags) != 0) |
255 | return -EBUSY; | 266 | return -EBUSY; |
256 | 267 | ||
257 | err = __orinoco_up(dev); | 268 | err = __orinoco_up(priv); |
258 | 269 | ||
259 | if (!err) | 270 | if (!err) |
260 | priv->open = 1; | 271 | priv->open = 1; |
@@ -266,7 +277,7 @@ static int orinoco_open(struct net_device *dev) | |||
266 | 277 | ||
267 | static int orinoco_stop(struct net_device *dev) | 278 | static int orinoco_stop(struct net_device *dev) |
268 | { | 279 | { |
269 | struct orinoco_private *priv = netdev_priv(dev); | 280 | struct orinoco_private *priv = ndev_priv(dev); |
270 | int err = 0; | 281 | int err = 0; |
271 | 282 | ||
272 | /* We mustn't use orinoco_lock() here, because we need to be | 283 | /* We mustn't use orinoco_lock() here, because we need to be |
@@ -276,7 +287,7 @@ static int orinoco_stop(struct net_device *dev) | |||
276 | 287 | ||
277 | priv->open = 0; | 288 | priv->open = 0; |
278 | 289 | ||
279 | err = __orinoco_down(dev); | 290 | err = __orinoco_down(priv); |
280 | 291 | ||
281 | spin_unlock_irq(&priv->lock); | 292 | spin_unlock_irq(&priv->lock); |
282 | 293 | ||
@@ -285,14 +296,14 @@ static int orinoco_stop(struct net_device *dev) | |||
285 | 296 | ||
286 | static struct net_device_stats *orinoco_get_stats(struct net_device *dev) | 297 | static struct net_device_stats *orinoco_get_stats(struct net_device *dev) |
287 | { | 298 | { |
288 | struct orinoco_private *priv = netdev_priv(dev); | 299 | struct orinoco_private *priv = ndev_priv(dev); |
289 | 300 | ||
290 | return &priv->stats; | 301 | return &priv->stats; |
291 | } | 302 | } |
292 | 303 | ||
293 | static void orinoco_set_multicast_list(struct net_device *dev) | 304 | static void orinoco_set_multicast_list(struct net_device *dev) |
294 | { | 305 | { |
295 | struct orinoco_private *priv = netdev_priv(dev); | 306 | struct orinoco_private *priv = ndev_priv(dev); |
296 | unsigned long flags; | 307 | unsigned long flags; |
297 | 308 | ||
298 | if (orinoco_lock(priv, &flags) != 0) { | 309 | if (orinoco_lock(priv, &flags) != 0) { |
@@ -307,7 +318,7 @@ static void orinoco_set_multicast_list(struct net_device *dev) | |||
307 | 318 | ||
308 | static int orinoco_change_mtu(struct net_device *dev, int new_mtu) | 319 | static int orinoco_change_mtu(struct net_device *dev, int new_mtu) |
309 | { | 320 | { |
310 | struct orinoco_private *priv = netdev_priv(dev); | 321 | struct orinoco_private *priv = ndev_priv(dev); |
311 | 322 | ||
312 | if ((new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU)) | 323 | if ((new_mtu < ORINOCO_MIN_MTU) || (new_mtu > ORINOCO_MAX_MTU)) |
313 | return -EINVAL; | 324 | return -EINVAL; |
@@ -328,7 +339,7 @@ static int orinoco_change_mtu(struct net_device *dev, int new_mtu) | |||
328 | 339 | ||
329 | static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev) | 340 | static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev) |
330 | { | 341 | { |
331 | struct orinoco_private *priv = netdev_priv(dev); | 342 | struct orinoco_private *priv = ndev_priv(dev); |
332 | struct net_device_stats *stats = &priv->stats; | 343 | struct net_device_stats *stats = &priv->stats; |
333 | hermes_t *hw = &priv->hw; | 344 | hermes_t *hw = &priv->hw; |
334 | int err = 0; | 345 | int err = 0; |
@@ -355,7 +366,8 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev) | |||
355 | return NETDEV_TX_BUSY; | 366 | return NETDEV_TX_BUSY; |
356 | } | 367 | } |
357 | 368 | ||
358 | if (!netif_carrier_ok(dev) || (priv->iw_mode == IW_MODE_MONITOR)) { | 369 | if (!netif_carrier_ok(dev) || |
370 | (priv->iw_mode == NL80211_IFTYPE_MONITOR)) { | ||
359 | /* Oops, the firmware hasn't established a connection, | 371 | /* Oops, the firmware hasn't established a connection, |
360 | silently drop the packet (this seems to be the | 372 | silently drop the packet (this seems to be the |
361 | safest approach). */ | 373 | safest approach). */ |
@@ -518,7 +530,7 @@ static int orinoco_xmit(struct sk_buff *skb, struct net_device *dev) | |||
518 | 530 | ||
519 | static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw) | 531 | static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw) |
520 | { | 532 | { |
521 | struct orinoco_private *priv = netdev_priv(dev); | 533 | struct orinoco_private *priv = ndev_priv(dev); |
522 | u16 fid = hermes_read_regn(hw, ALLOCFID); | 534 | u16 fid = hermes_read_regn(hw, ALLOCFID); |
523 | 535 | ||
524 | if (fid != priv->txfid) { | 536 | if (fid != priv->txfid) { |
@@ -533,7 +545,7 @@ static void __orinoco_ev_alloc(struct net_device *dev, hermes_t *hw) | |||
533 | 545 | ||
534 | static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw) | 546 | static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw) |
535 | { | 547 | { |
536 | struct orinoco_private *priv = netdev_priv(dev); | 548 | struct orinoco_private *priv = ndev_priv(dev); |
537 | struct net_device_stats *stats = &priv->stats; | 549 | struct net_device_stats *stats = &priv->stats; |
538 | 550 | ||
539 | stats->tx_packets++; | 551 | stats->tx_packets++; |
@@ -545,7 +557,7 @@ static void __orinoco_ev_tx(struct net_device *dev, hermes_t *hw) | |||
545 | 557 | ||
546 | static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw) | 558 | static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw) |
547 | { | 559 | { |
548 | struct orinoco_private *priv = netdev_priv(dev); | 560 | struct orinoco_private *priv = ndev_priv(dev); |
549 | struct net_device_stats *stats = &priv->stats; | 561 | struct net_device_stats *stats = &priv->stats; |
550 | u16 fid = hermes_read_regn(hw, TXCOMPLFID); | 562 | u16 fid = hermes_read_regn(hw, TXCOMPLFID); |
551 | u16 status; | 563 | u16 status; |
@@ -601,7 +613,7 @@ static void __orinoco_ev_txexc(struct net_device *dev, hermes_t *hw) | |||
601 | 613 | ||
602 | static void orinoco_tx_timeout(struct net_device *dev) | 614 | static void orinoco_tx_timeout(struct net_device *dev) |
603 | { | 615 | { |
604 | struct orinoco_private *priv = netdev_priv(dev); | 616 | struct orinoco_private *priv = ndev_priv(dev); |
605 | struct net_device_stats *stats = &priv->stats; | 617 | struct net_device_stats *stats = &priv->stats; |
606 | struct hermes *hw = &priv->hw; | 618 | struct hermes *hw = &priv->hw; |
607 | 619 | ||
@@ -650,7 +662,7 @@ static void orinoco_stat_gather(struct net_device *dev, | |||
650 | struct sk_buff *skb, | 662 | struct sk_buff *skb, |
651 | struct hermes_rx_descriptor *desc) | 663 | struct hermes_rx_descriptor *desc) |
652 | { | 664 | { |
653 | struct orinoco_private *priv = netdev_priv(dev); | 665 | struct orinoco_private *priv = ndev_priv(dev); |
654 | 666 | ||
655 | /* Using spy support with lots of Rx packets, like in an | 667 | /* Using spy support with lots of Rx packets, like in an |
656 | * infrastructure (AP), will really slow down everything, because | 668 | * infrastructure (AP), will really slow down everything, because |
@@ -687,7 +699,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid, | |||
687 | int err; | 699 | int err; |
688 | int len; | 700 | int len; |
689 | struct sk_buff *skb; | 701 | struct sk_buff *skb; |
690 | struct orinoco_private *priv = netdev_priv(dev); | 702 | struct orinoco_private *priv = ndev_priv(dev); |
691 | struct net_device_stats *stats = &priv->stats; | 703 | struct net_device_stats *stats = &priv->stats; |
692 | hermes_t *hw = &priv->hw; | 704 | hermes_t *hw = &priv->hw; |
693 | 705 | ||
@@ -778,7 +790,7 @@ static void orinoco_rx_monitor(struct net_device *dev, u16 rxfid, | |||
778 | 790 | ||
779 | static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw) | 791 | static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw) |
780 | { | 792 | { |
781 | struct orinoco_private *priv = netdev_priv(dev); | 793 | struct orinoco_private *priv = ndev_priv(dev); |
782 | struct net_device_stats *stats = &priv->stats; | 794 | struct net_device_stats *stats = &priv->stats; |
783 | struct iw_statistics *wstats = &priv->wstats; | 795 | struct iw_statistics *wstats = &priv->wstats; |
784 | struct sk_buff *skb = NULL; | 796 | struct sk_buff *skb = NULL; |
@@ -816,7 +828,7 @@ static void __orinoco_ev_rx(struct net_device *dev, hermes_t *hw) | |||
816 | } | 828 | } |
817 | 829 | ||
818 | /* Handle frames in monitor mode */ | 830 | /* Handle frames in monitor mode */ |
819 | if (priv->iw_mode == IW_MODE_MONITOR) { | 831 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { |
820 | orinoco_rx_monitor(dev, rxfid, desc); | 832 | orinoco_rx_monitor(dev, rxfid, desc); |
821 | goto out; | 833 | goto out; |
822 | } | 834 | } |
@@ -902,7 +914,7 @@ static void orinoco_rx(struct net_device *dev, | |||
902 | struct hermes_rx_descriptor *desc, | 914 | struct hermes_rx_descriptor *desc, |
903 | struct sk_buff *skb) | 915 | struct sk_buff *skb) |
904 | { | 916 | { |
905 | struct orinoco_private *priv = netdev_priv(dev); | 917 | struct orinoco_private *priv = ndev_priv(dev); |
906 | struct net_device_stats *stats = &priv->stats; | 918 | struct net_device_stats *stats = &priv->stats; |
907 | u16 status, fc; | 919 | u16 status, fc; |
908 | int length; | 920 | int length; |
@@ -1016,8 +1028,8 @@ static void orinoco_rx(struct net_device *dev, | |||
1016 | 1028 | ||
1017 | static void orinoco_rx_isr_tasklet(unsigned long data) | 1029 | static void orinoco_rx_isr_tasklet(unsigned long data) |
1018 | { | 1030 | { |
1019 | struct net_device *dev = (struct net_device *) data; | 1031 | struct orinoco_private *priv = (struct orinoco_private *) data; |
1020 | struct orinoco_private *priv = netdev_priv(dev); | 1032 | struct net_device *dev = priv->ndev; |
1021 | struct orinoco_rx_data *rx_data, *temp; | 1033 | struct orinoco_rx_data *rx_data, *temp; |
1022 | struct hermes_rx_descriptor *desc; | 1034 | struct hermes_rx_descriptor *desc; |
1023 | struct sk_buff *skb; | 1035 | struct sk_buff *skb; |
@@ -1260,9 +1272,81 @@ static void orinoco_send_wevents(struct work_struct *work) | |||
1260 | orinoco_unlock(priv, &flags); | 1272 | orinoco_unlock(priv, &flags); |
1261 | } | 1273 | } |
1262 | 1274 | ||
1275 | static void qbuf_scan(struct orinoco_private *priv, void *buf, | ||
1276 | int len, int type) | ||
1277 | { | ||
1278 | struct orinoco_scan_data *sd; | ||
1279 | unsigned long flags; | ||
1280 | |||
1281 | sd = kmalloc(sizeof(*sd), GFP_ATOMIC); | ||
1282 | sd->buf = buf; | ||
1283 | sd->len = len; | ||
1284 | sd->type = type; | ||
1285 | |||
1286 | spin_lock_irqsave(&priv->scan_lock, flags); | ||
1287 | list_add_tail(&sd->list, &priv->scan_list); | ||
1288 | spin_unlock_irqrestore(&priv->scan_lock, flags); | ||
1289 | |||
1290 | schedule_work(&priv->process_scan); | ||
1291 | } | ||
1292 | |||
1293 | static void qabort_scan(struct orinoco_private *priv) | ||
1294 | { | ||
1295 | struct orinoco_scan_data *sd; | ||
1296 | unsigned long flags; | ||
1297 | |||
1298 | sd = kmalloc(sizeof(*sd), GFP_ATOMIC); | ||
1299 | sd->len = -1; /* Abort */ | ||
1300 | |||
1301 | spin_lock_irqsave(&priv->scan_lock, flags); | ||
1302 | list_add_tail(&sd->list, &priv->scan_list); | ||
1303 | spin_unlock_irqrestore(&priv->scan_lock, flags); | ||
1304 | |||
1305 | schedule_work(&priv->process_scan); | ||
1306 | } | ||
1307 | |||
1308 | static void orinoco_process_scan_results(struct work_struct *work) | ||
1309 | { | ||
1310 | struct orinoco_private *priv = | ||
1311 | container_of(work, struct orinoco_private, process_scan); | ||
1312 | struct orinoco_scan_data *sd, *temp; | ||
1313 | unsigned long flags; | ||
1314 | void *buf; | ||
1315 | int len; | ||
1316 | int type; | ||
1317 | |||
1318 | spin_lock_irqsave(&priv->scan_lock, flags); | ||
1319 | list_for_each_entry_safe(sd, temp, &priv->scan_list, list) { | ||
1320 | spin_unlock_irqrestore(&priv->scan_lock, flags); | ||
1321 | |||
1322 | buf = sd->buf; | ||
1323 | len = sd->len; | ||
1324 | type = sd->type; | ||
1325 | |||
1326 | list_del(&sd->list); | ||
1327 | kfree(sd); | ||
1328 | |||
1329 | if (len > 0) { | ||
1330 | if (type == HERMES_INQ_CHANNELINFO) | ||
1331 | orinoco_add_extscan_result(priv, buf, len); | ||
1332 | else | ||
1333 | orinoco_add_hostscan_results(priv, buf, len); | ||
1334 | |||
1335 | kfree(buf); | ||
1336 | } else if (priv->scan_request) { | ||
1337 | /* Either abort or complete the scan */ | ||
1338 | cfg80211_scan_done(priv->scan_request, (len < 0)); | ||
1339 | priv->scan_request = NULL; | ||
1340 | } | ||
1341 | |||
1342 | spin_lock_irqsave(&priv->scan_lock, flags); | ||
1343 | } | ||
1344 | spin_unlock_irqrestore(&priv->scan_lock, flags); | ||
1345 | } | ||
1346 | |||
1263 | static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | 1347 | static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) |
1264 | { | 1348 | { |
1265 | struct orinoco_private *priv = netdev_priv(dev); | 1349 | struct orinoco_private *priv = ndev_priv(dev); |
1266 | u16 infofid; | 1350 | u16 infofid; |
1267 | struct { | 1351 | struct { |
1268 | __le16 len; | 1352 | __le16 len; |
@@ -1327,7 +1411,7 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | |||
1327 | u16 newstatus; | 1411 | u16 newstatus; |
1328 | int connected; | 1412 | int connected; |
1329 | 1413 | ||
1330 | if (priv->iw_mode == IW_MODE_MONITOR) | 1414 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) |
1331 | break; | 1415 | break; |
1332 | 1416 | ||
1333 | if (len != sizeof(linkstatus)) { | 1417 | if (len != sizeof(linkstatus)) { |
@@ -1346,7 +1430,7 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | |||
1346 | * the hostscan frame can be requested. */ | 1430 | * the hostscan frame can be requested. */ |
1347 | if (newstatus == HERMES_LINKSTATUS_AP_OUT_OF_RANGE && | 1431 | if (newstatus == HERMES_LINKSTATUS_AP_OUT_OF_RANGE && |
1348 | priv->firmware_type == FIRMWARE_TYPE_SYMBOL && | 1432 | priv->firmware_type == FIRMWARE_TYPE_SYMBOL && |
1349 | priv->has_hostscan && priv->scan_inprogress) { | 1433 | priv->has_hostscan && priv->scan_request) { |
1350 | hermes_inquire(hw, HERMES_INQ_HOSTSCAN_SYMBOL); | 1434 | hermes_inquire(hw, HERMES_INQ_HOSTSCAN_SYMBOL); |
1351 | break; | 1435 | break; |
1352 | } | 1436 | } |
@@ -1372,7 +1456,7 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | |||
1372 | } | 1456 | } |
1373 | break; | 1457 | break; |
1374 | case HERMES_INQ_SCAN: | 1458 | case HERMES_INQ_SCAN: |
1375 | if (!priv->scan_inprogress && priv->bssid_fixed && | 1459 | if (!priv->scan_request && priv->bssid_fixed && |
1376 | priv->firmware_type == FIRMWARE_TYPE_INTERSIL) { | 1460 | priv->firmware_type == FIRMWARE_TYPE_INTERSIL) { |
1377 | schedule_work(&priv->join_work); | 1461 | schedule_work(&priv->join_work); |
1378 | break; | 1462 | break; |
@@ -1382,30 +1466,30 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | |||
1382 | case HERMES_INQ_HOSTSCAN_SYMBOL: { | 1466 | case HERMES_INQ_HOSTSCAN_SYMBOL: { |
1383 | /* Result of a scanning. Contains information about | 1467 | /* Result of a scanning. Contains information about |
1384 | * cells in the vicinity - Jean II */ | 1468 | * cells in the vicinity - Jean II */ |
1385 | union iwreq_data wrqu; | ||
1386 | unsigned char *buf; | 1469 | unsigned char *buf; |
1387 | 1470 | ||
1388 | /* Scan is no longer in progress */ | ||
1389 | priv->scan_inprogress = 0; | ||
1390 | |||
1391 | /* Sanity check */ | 1471 | /* Sanity check */ |
1392 | if (len > 4096) { | 1472 | if (len > 4096) { |
1393 | printk(KERN_WARNING "%s: Scan results too large (%d bytes)\n", | 1473 | printk(KERN_WARNING "%s: Scan results too large (%d bytes)\n", |
1394 | dev->name, len); | 1474 | dev->name, len); |
1475 | qabort_scan(priv); | ||
1395 | break; | 1476 | break; |
1396 | } | 1477 | } |
1397 | 1478 | ||
1398 | /* Allocate buffer for results */ | 1479 | /* Allocate buffer for results */ |
1399 | buf = kmalloc(len, GFP_ATOMIC); | 1480 | buf = kmalloc(len, GFP_ATOMIC); |
1400 | if (buf == NULL) | 1481 | if (buf == NULL) { |
1401 | /* No memory, so can't printk()... */ | 1482 | /* No memory, so can't printk()... */ |
1483 | qabort_scan(priv); | ||
1402 | break; | 1484 | break; |
1485 | } | ||
1403 | 1486 | ||
1404 | /* Read scan data */ | 1487 | /* Read scan data */ |
1405 | err = hermes_bap_pread(hw, IRQ_BAP, (void *) buf, len, | 1488 | err = hermes_bap_pread(hw, IRQ_BAP, (void *) buf, len, |
1406 | infofid, sizeof(info)); | 1489 | infofid, sizeof(info)); |
1407 | if (err) { | 1490 | if (err) { |
1408 | kfree(buf); | 1491 | kfree(buf); |
1492 | qabort_scan(priv); | ||
1409 | break; | 1493 | break; |
1410 | } | 1494 | } |
1411 | 1495 | ||
@@ -1419,24 +1503,14 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | |||
1419 | } | 1503 | } |
1420 | #endif /* ORINOCO_DEBUG */ | 1504 | #endif /* ORINOCO_DEBUG */ |
1421 | 1505 | ||
1422 | if (orinoco_process_scan_results(priv, buf, len) == 0) { | 1506 | qbuf_scan(priv, buf, len, type); |
1423 | /* Send an empty event to user space. | ||
1424 | * We don't send the received data on the event because | ||
1425 | * it would require us to do complex transcoding, and | ||
1426 | * we want to minimise the work done in the irq handler | ||
1427 | * Use a request to extract the data - Jean II */ | ||
1428 | wrqu.data.length = 0; | ||
1429 | wrqu.data.flags = 0; | ||
1430 | wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); | ||
1431 | } | ||
1432 | kfree(buf); | ||
1433 | } | 1507 | } |
1434 | break; | 1508 | break; |
1435 | case HERMES_INQ_CHANNELINFO: | 1509 | case HERMES_INQ_CHANNELINFO: |
1436 | { | 1510 | { |
1437 | struct agere_ext_scan_info *bss; | 1511 | struct agere_ext_scan_info *bss; |
1438 | 1512 | ||
1439 | if (!priv->scan_inprogress) { | 1513 | if (!priv->scan_request) { |
1440 | printk(KERN_DEBUG "%s: Got chaninfo without scan, " | 1514 | printk(KERN_DEBUG "%s: Got chaninfo without scan, " |
1441 | "len=%d\n", dev->name, len); | 1515 | "len=%d\n", dev->name, len); |
1442 | break; | 1516 | break; |
@@ -1444,25 +1518,12 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | |||
1444 | 1518 | ||
1445 | /* An empty result indicates that the scan is complete */ | 1519 | /* An empty result indicates that the scan is complete */ |
1446 | if (len == 0) { | 1520 | if (len == 0) { |
1447 | union iwreq_data wrqu; | 1521 | qbuf_scan(priv, NULL, len, type); |
1448 | |||
1449 | /* Scan is no longer in progress */ | ||
1450 | priv->scan_inprogress = 0; | ||
1451 | |||
1452 | wrqu.data.length = 0; | ||
1453 | wrqu.data.flags = 0; | ||
1454 | wireless_send_event(dev, SIOCGIWSCAN, &wrqu, NULL); | ||
1455 | break; | 1522 | break; |
1456 | } | 1523 | } |
1457 | 1524 | ||
1458 | /* Sanity check */ | 1525 | /* Sanity check */ |
1459 | else if (len > sizeof(*bss)) { | 1526 | else if (len < (offsetof(struct agere_ext_scan_info, |
1460 | printk(KERN_WARNING | ||
1461 | "%s: Ext scan results too large (%d bytes). " | ||
1462 | "Truncating results to %zd bytes.\n", | ||
1463 | dev->name, len, sizeof(*bss)); | ||
1464 | len = sizeof(*bss); | ||
1465 | } else if (len < (offsetof(struct agere_ext_scan_info, | ||
1466 | data) + 2)) { | 1527 | data) + 2)) { |
1467 | /* Drop this result now so we don't have to | 1528 | /* Drop this result now so we don't have to |
1468 | * keep checking later */ | 1529 | * keep checking later */ |
@@ -1472,21 +1533,18 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | |||
1472 | break; | 1533 | break; |
1473 | } | 1534 | } |
1474 | 1535 | ||
1475 | bss = kmalloc(sizeof(*bss), GFP_ATOMIC); | 1536 | bss = kmalloc(len, GFP_ATOMIC); |
1476 | if (bss == NULL) | 1537 | if (bss == NULL) |
1477 | break; | 1538 | break; |
1478 | 1539 | ||
1479 | /* Read scan data */ | 1540 | /* Read scan data */ |
1480 | err = hermes_bap_pread(hw, IRQ_BAP, (void *) bss, len, | 1541 | err = hermes_bap_pread(hw, IRQ_BAP, (void *) bss, len, |
1481 | infofid, sizeof(info)); | 1542 | infofid, sizeof(info)); |
1482 | if (err) { | 1543 | if (err) |
1483 | kfree(bss); | 1544 | kfree(bss); |
1484 | break; | 1545 | else |
1485 | } | 1546 | qbuf_scan(priv, bss, len, type); |
1486 | |||
1487 | orinoco_add_ext_scan_result(priv, bss); | ||
1488 | 1547 | ||
1489 | kfree(bss); | ||
1490 | break; | 1548 | break; |
1491 | } | 1549 | } |
1492 | case HERMES_INQ_SEC_STAT_AGERE: | 1550 | case HERMES_INQ_SEC_STAT_AGERE: |
@@ -1501,6 +1559,8 @@ static void __orinoco_ev_info(struct net_device *dev, hermes_t *hw) | |||
1501 | /* We don't actually do anything about it */ | 1559 | /* We don't actually do anything about it */ |
1502 | break; | 1560 | break; |
1503 | } | 1561 | } |
1562 | |||
1563 | return; | ||
1504 | } | 1564 | } |
1505 | 1565 | ||
1506 | static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw) | 1566 | static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw) |
@@ -1513,15 +1573,15 @@ static void __orinoco_ev_infdrop(struct net_device *dev, hermes_t *hw) | |||
1513 | /* Internal hardware control routines */ | 1573 | /* Internal hardware control routines */ |
1514 | /********************************************************************/ | 1574 | /********************************************************************/ |
1515 | 1575 | ||
1516 | int __orinoco_up(struct net_device *dev) | 1576 | static int __orinoco_up(struct orinoco_private *priv) |
1517 | { | 1577 | { |
1518 | struct orinoco_private *priv = netdev_priv(dev); | 1578 | struct net_device *dev = priv->ndev; |
1519 | struct hermes *hw = &priv->hw; | 1579 | struct hermes *hw = &priv->hw; |
1520 | int err; | 1580 | int err; |
1521 | 1581 | ||
1522 | netif_carrier_off(dev); /* just to make sure */ | 1582 | netif_carrier_off(dev); /* just to make sure */ |
1523 | 1583 | ||
1524 | err = __orinoco_program_rids(dev); | 1584 | err = __orinoco_commit(priv); |
1525 | if (err) { | 1585 | if (err) { |
1526 | printk(KERN_ERR "%s: Error %d configuring card\n", | 1586 | printk(KERN_ERR "%s: Error %d configuring card\n", |
1527 | dev->name, err); | 1587 | dev->name, err); |
@@ -1541,11 +1601,10 @@ int __orinoco_up(struct net_device *dev) | |||
1541 | 1601 | ||
1542 | return 0; | 1602 | return 0; |
1543 | } | 1603 | } |
1544 | EXPORT_SYMBOL(__orinoco_up); | ||
1545 | 1604 | ||
1546 | int __orinoco_down(struct net_device *dev) | 1605 | static int __orinoco_down(struct orinoco_private *priv) |
1547 | { | 1606 | { |
1548 | struct orinoco_private *priv = netdev_priv(dev); | 1607 | struct net_device *dev = priv->ndev; |
1549 | struct hermes *hw = &priv->hw; | 1608 | struct hermes *hw = &priv->hw; |
1550 | int err; | 1609 | int err; |
1551 | 1610 | ||
@@ -1573,31 +1632,9 @@ int __orinoco_down(struct net_device *dev) | |||
1573 | 1632 | ||
1574 | return 0; | 1633 | return 0; |
1575 | } | 1634 | } |
1576 | EXPORT_SYMBOL(__orinoco_down); | ||
1577 | 1635 | ||
1578 | static int orinoco_allocate_fid(struct net_device *dev) | 1636 | static int orinoco_reinit_firmware(struct orinoco_private *priv) |
1579 | { | 1637 | { |
1580 | struct orinoco_private *priv = netdev_priv(dev); | ||
1581 | struct hermes *hw = &priv->hw; | ||
1582 | int err; | ||
1583 | |||
1584 | err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid); | ||
1585 | if (err == -EIO && priv->nicbuf_size > TX_NICBUF_SIZE_BUG) { | ||
1586 | /* Try workaround for old Symbol firmware bug */ | ||
1587 | priv->nicbuf_size = TX_NICBUF_SIZE_BUG; | ||
1588 | err = hermes_allocate(hw, priv->nicbuf_size, &priv->txfid); | ||
1589 | |||
1590 | printk(KERN_WARNING "%s: firmware ALLOC bug detected " | ||
1591 | "(old Symbol firmware?). Work around %s\n", | ||
1592 | dev->name, err ? "failed!" : "ok."); | ||
1593 | } | ||
1594 | |||
1595 | return err; | ||
1596 | } | ||
1597 | |||
1598 | int orinoco_reinit_firmware(struct net_device *dev) | ||
1599 | { | ||
1600 | struct orinoco_private *priv = netdev_priv(dev); | ||
1601 | struct hermes *hw = &priv->hw; | 1638 | struct hermes *hw = &priv->hw; |
1602 | int err; | 1639 | int err; |
1603 | 1640 | ||
@@ -1608,246 +1645,15 @@ int orinoco_reinit_firmware(struct net_device *dev) | |||
1608 | priv->do_fw_download = 0; | 1645 | priv->do_fw_download = 0; |
1609 | } | 1646 | } |
1610 | if (!err) | 1647 | if (!err) |
1611 | err = orinoco_allocate_fid(dev); | 1648 | err = orinoco_hw_allocate_fid(priv); |
1612 | 1649 | ||
1613 | return err; | 1650 | return err; |
1614 | } | 1651 | } |
1615 | EXPORT_SYMBOL(orinoco_reinit_firmware); | ||
1616 | |||
1617 | int __orinoco_program_rids(struct net_device *dev) | ||
1618 | { | ||
1619 | struct orinoco_private *priv = netdev_priv(dev); | ||
1620 | hermes_t *hw = &priv->hw; | ||
1621 | int err; | ||
1622 | struct hermes_idstring idbuf; | ||
1623 | |||
1624 | /* Set the MAC address */ | ||
1625 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, | ||
1626 | HERMES_BYTES_TO_RECLEN(ETH_ALEN), dev->dev_addr); | ||
1627 | if (err) { | ||
1628 | printk(KERN_ERR "%s: Error %d setting MAC address\n", | ||
1629 | dev->name, err); | ||
1630 | return err; | ||
1631 | } | ||
1632 | |||
1633 | /* Set up the link mode */ | ||
1634 | err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFPORTTYPE, | ||
1635 | priv->port_type); | ||
1636 | if (err) { | ||
1637 | printk(KERN_ERR "%s: Error %d setting port type\n", | ||
1638 | dev->name, err); | ||
1639 | return err; | ||
1640 | } | ||
1641 | /* Set the channel/frequency */ | ||
1642 | if (priv->channel != 0 && priv->iw_mode != IW_MODE_INFRA) { | ||
1643 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1644 | HERMES_RID_CNFOWNCHANNEL, | ||
1645 | priv->channel); | ||
1646 | if (err) { | ||
1647 | printk(KERN_ERR "%s: Error %d setting channel %d\n", | ||
1648 | dev->name, err, priv->channel); | ||
1649 | return err; | ||
1650 | } | ||
1651 | } | ||
1652 | |||
1653 | if (priv->has_ibss) { | ||
1654 | u16 createibss; | ||
1655 | |||
1656 | if ((strlen(priv->desired_essid) == 0) && (priv->createibss)) { | ||
1657 | printk(KERN_WARNING "%s: This firmware requires an " | ||
1658 | "ESSID in IBSS-Ad-Hoc mode.\n", dev->name); | ||
1659 | /* With wvlan_cs, in this case, we would crash. | ||
1660 | * hopefully, this driver will behave better... | ||
1661 | * Jean II */ | ||
1662 | createibss = 0; | ||
1663 | } else { | ||
1664 | createibss = priv->createibss; | ||
1665 | } | ||
1666 | |||
1667 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1668 | HERMES_RID_CNFCREATEIBSS, | ||
1669 | createibss); | ||
1670 | if (err) { | ||
1671 | printk(KERN_ERR "%s: Error %d setting CREATEIBSS\n", | ||
1672 | dev->name, err); | ||
1673 | return err; | ||
1674 | } | ||
1675 | } | ||
1676 | |||
1677 | /* Set the desired BSSID */ | ||
1678 | err = __orinoco_hw_set_wap(priv); | ||
1679 | if (err) { | ||
1680 | printk(KERN_ERR "%s: Error %d setting AP address\n", | ||
1681 | dev->name, err); | ||
1682 | return err; | ||
1683 | } | ||
1684 | /* Set the desired ESSID */ | ||
1685 | idbuf.len = cpu_to_le16(strlen(priv->desired_essid)); | ||
1686 | memcpy(&idbuf.val, priv->desired_essid, sizeof(idbuf.val)); | ||
1687 | /* WinXP wants partner to configure OWNSSID even in IBSS mode. (jimc) */ | ||
1688 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNSSID, | ||
1689 | HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2), | ||
1690 | &idbuf); | ||
1691 | if (err) { | ||
1692 | printk(KERN_ERR "%s: Error %d setting OWNSSID\n", | ||
1693 | dev->name, err); | ||
1694 | return err; | ||
1695 | } | ||
1696 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFDESIREDSSID, | ||
1697 | HERMES_BYTES_TO_RECLEN(strlen(priv->desired_essid)+2), | ||
1698 | &idbuf); | ||
1699 | if (err) { | ||
1700 | printk(KERN_ERR "%s: Error %d setting DESIREDSSID\n", | ||
1701 | dev->name, err); | ||
1702 | return err; | ||
1703 | } | ||
1704 | |||
1705 | /* Set the station name */ | ||
1706 | idbuf.len = cpu_to_le16(strlen(priv->nick)); | ||
1707 | memcpy(&idbuf.val, priv->nick, sizeof(idbuf.val)); | ||
1708 | err = hermes_write_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, | ||
1709 | HERMES_BYTES_TO_RECLEN(strlen(priv->nick)+2), | ||
1710 | &idbuf); | ||
1711 | if (err) { | ||
1712 | printk(KERN_ERR "%s: Error %d setting nickname\n", | ||
1713 | dev->name, err); | ||
1714 | return err; | ||
1715 | } | ||
1716 | |||
1717 | /* Set AP density */ | ||
1718 | if (priv->has_sensitivity) { | ||
1719 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1720 | HERMES_RID_CNFSYSTEMSCALE, | ||
1721 | priv->ap_density); | ||
1722 | if (err) { | ||
1723 | printk(KERN_WARNING "%s: Error %d setting SYSTEMSCALE. " | ||
1724 | "Disabling sensitivity control\n", | ||
1725 | dev->name, err); | ||
1726 | |||
1727 | priv->has_sensitivity = 0; | ||
1728 | } | ||
1729 | } | ||
1730 | |||
1731 | /* Set RTS threshold */ | ||
1732 | err = hermes_write_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, | ||
1733 | priv->rts_thresh); | ||
1734 | if (err) { | ||
1735 | printk(KERN_ERR "%s: Error %d setting RTS threshold\n", | ||
1736 | dev->name, err); | ||
1737 | return err; | ||
1738 | } | ||
1739 | |||
1740 | /* Set fragmentation threshold or MWO robustness */ | ||
1741 | if (priv->has_mwo) | ||
1742 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1743 | HERMES_RID_CNFMWOROBUST_AGERE, | ||
1744 | priv->mwo_robust); | ||
1745 | else | ||
1746 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1747 | HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, | ||
1748 | priv->frag_thresh); | ||
1749 | if (err) { | ||
1750 | printk(KERN_ERR "%s: Error %d setting fragmentation\n", | ||
1751 | dev->name, err); | ||
1752 | return err; | ||
1753 | } | ||
1754 | |||
1755 | /* Set bitrate */ | ||
1756 | err = __orinoco_hw_set_bitrate(priv); | ||
1757 | if (err) { | ||
1758 | printk(KERN_ERR "%s: Error %d setting bitrate\n", | ||
1759 | dev->name, err); | ||
1760 | return err; | ||
1761 | } | ||
1762 | |||
1763 | /* Set power management */ | ||
1764 | if (priv->has_pm) { | ||
1765 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1766 | HERMES_RID_CNFPMENABLED, | ||
1767 | priv->pm_on); | ||
1768 | if (err) { | ||
1769 | printk(KERN_ERR "%s: Error %d setting up PM\n", | ||
1770 | dev->name, err); | ||
1771 | return err; | ||
1772 | } | ||
1773 | |||
1774 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1775 | HERMES_RID_CNFMULTICASTRECEIVE, | ||
1776 | priv->pm_mcast); | ||
1777 | if (err) { | ||
1778 | printk(KERN_ERR "%s: Error %d setting up PM\n", | ||
1779 | dev->name, err); | ||
1780 | return err; | ||
1781 | } | ||
1782 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1783 | HERMES_RID_CNFMAXSLEEPDURATION, | ||
1784 | priv->pm_period); | ||
1785 | if (err) { | ||
1786 | printk(KERN_ERR "%s: Error %d setting up PM\n", | ||
1787 | dev->name, err); | ||
1788 | return err; | ||
1789 | } | ||
1790 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1791 | HERMES_RID_CNFPMHOLDOVERDURATION, | ||
1792 | priv->pm_timeout); | ||
1793 | if (err) { | ||
1794 | printk(KERN_ERR "%s: Error %d setting up PM\n", | ||
1795 | dev->name, err); | ||
1796 | return err; | ||
1797 | } | ||
1798 | } | ||
1799 | |||
1800 | /* Set preamble - only for Symbol so far... */ | ||
1801 | if (priv->has_preamble) { | ||
1802 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1803 | HERMES_RID_CNFPREAMBLE_SYMBOL, | ||
1804 | priv->preamble); | ||
1805 | if (err) { | ||
1806 | printk(KERN_ERR "%s: Error %d setting preamble\n", | ||
1807 | dev->name, err); | ||
1808 | return err; | ||
1809 | } | ||
1810 | } | ||
1811 | |||
1812 | /* Set up encryption */ | ||
1813 | if (priv->has_wep || priv->has_wpa) { | ||
1814 | err = __orinoco_hw_setup_enc(priv); | ||
1815 | if (err) { | ||
1816 | printk(KERN_ERR "%s: Error %d activating encryption\n", | ||
1817 | dev->name, err); | ||
1818 | return err; | ||
1819 | } | ||
1820 | } | ||
1821 | |||
1822 | if (priv->iw_mode == IW_MODE_MONITOR) { | ||
1823 | /* Enable monitor mode */ | ||
1824 | dev->type = ARPHRD_IEEE80211; | ||
1825 | err = hermes_docmd_wait(hw, HERMES_CMD_TEST | | ||
1826 | HERMES_TEST_MONITOR, 0, NULL); | ||
1827 | } else { | ||
1828 | /* Disable monitor mode */ | ||
1829 | dev->type = ARPHRD_ETHER; | ||
1830 | err = hermes_docmd_wait(hw, HERMES_CMD_TEST | | ||
1831 | HERMES_TEST_STOP, 0, NULL); | ||
1832 | } | ||
1833 | if (err) | ||
1834 | return err; | ||
1835 | |||
1836 | /* Set promiscuity / multicast*/ | ||
1837 | priv->promiscuous = 0; | ||
1838 | priv->mc_count = 0; | ||
1839 | |||
1840 | /* FIXME: what about netif_tx_lock */ | ||
1841 | __orinoco_set_multicast_list(dev); | ||
1842 | |||
1843 | return 0; | ||
1844 | } | ||
1845 | 1652 | ||
1846 | /* FIXME: return int? */ | 1653 | static int |
1847 | static void | ||
1848 | __orinoco_set_multicast_list(struct net_device *dev) | 1654 | __orinoco_set_multicast_list(struct net_device *dev) |
1849 | { | 1655 | { |
1850 | struct orinoco_private *priv = netdev_priv(dev); | 1656 | struct orinoco_private *priv = ndev_priv(dev); |
1851 | int err = 0; | 1657 | int err = 0; |
1852 | int promisc, mc_count; | 1658 | int promisc, mc_count; |
1853 | 1659 | ||
@@ -1864,6 +1670,8 @@ __orinoco_set_multicast_list(struct net_device *dev) | |||
1864 | 1670 | ||
1865 | err = __orinoco_hw_set_multicast_list(priv, dev->mc_list, mc_count, | 1671 | err = __orinoco_hw_set_multicast_list(priv, dev->mc_list, mc_count, |
1866 | promisc); | 1672 | promisc); |
1673 | |||
1674 | return err; | ||
1867 | } | 1675 | } |
1868 | 1676 | ||
1869 | /* This must be called from user context, without locks held - use | 1677 | /* This must be called from user context, without locks held - use |
@@ -1896,9 +1704,11 @@ void orinoco_reset(struct work_struct *work) | |||
1896 | 1704 | ||
1897 | orinoco_unlock(priv, &flags); | 1705 | orinoco_unlock(priv, &flags); |
1898 | 1706 | ||
1899 | /* Scanning support: Cleanup of driver struct */ | 1707 | /* Scanning support: Notify scan cancellation */ |
1900 | orinoco_clear_scan_results(priv, 0); | 1708 | if (priv->scan_request) { |
1901 | priv->scan_inprogress = 0; | 1709 | cfg80211_scan_done(priv->scan_request, 1); |
1710 | priv->scan_request = NULL; | ||
1711 | } | ||
1902 | 1712 | ||
1903 | if (priv->hard_reset) { | 1713 | if (priv->hard_reset) { |
1904 | err = (*priv->hard_reset)(priv); | 1714 | err = (*priv->hard_reset)(priv); |
@@ -1909,7 +1719,7 @@ void orinoco_reset(struct work_struct *work) | |||
1909 | } | 1719 | } |
1910 | } | 1720 | } |
1911 | 1721 | ||
1912 | err = orinoco_reinit_firmware(dev); | 1722 | err = orinoco_reinit_firmware(priv); |
1913 | if (err) { | 1723 | if (err) { |
1914 | printk(KERN_ERR "%s: orinoco_reset: Error %d re-initializing firmware\n", | 1724 | printk(KERN_ERR "%s: orinoco_reset: Error %d re-initializing firmware\n", |
1915 | dev->name, err); | 1725 | dev->name, err); |
@@ -1924,7 +1734,7 @@ void orinoco_reset(struct work_struct *work) | |||
1924 | /* priv->open or priv->hw_unavailable might have changed while | 1734 | /* priv->open or priv->hw_unavailable might have changed while |
1925 | * we dropped the lock */ | 1735 | * we dropped the lock */ |
1926 | if (priv->open && (!priv->hw_unavailable)) { | 1736 | if (priv->open && (!priv->hw_unavailable)) { |
1927 | err = __orinoco_up(dev); | 1737 | err = __orinoco_up(priv); |
1928 | if (err) { | 1738 | if (err) { |
1929 | printk(KERN_ERR "%s: orinoco_reset: Error %d reenabling card\n", | 1739 | printk(KERN_ERR "%s: orinoco_reset: Error %d reenabling card\n", |
1930 | dev->name, err); | 1740 | dev->name, err); |
@@ -1941,6 +1751,64 @@ void orinoco_reset(struct work_struct *work) | |||
1941 | printk(KERN_ERR "%s: Device has been disabled!\n", dev->name); | 1751 | printk(KERN_ERR "%s: Device has been disabled!\n", dev->name); |
1942 | } | 1752 | } |
1943 | 1753 | ||
1754 | static int __orinoco_commit(struct orinoco_private *priv) | ||
1755 | { | ||
1756 | struct net_device *dev = priv->ndev; | ||
1757 | int err = 0; | ||
1758 | |||
1759 | err = orinoco_hw_program_rids(priv); | ||
1760 | |||
1761 | /* FIXME: what about netif_tx_lock */ | ||
1762 | (void) __orinoco_set_multicast_list(dev); | ||
1763 | |||
1764 | return err; | ||
1765 | } | ||
1766 | |||
1767 | /* Ensures configuration changes are applied. May result in a reset. | ||
1768 | * The caller should hold priv->lock | ||
1769 | */ | ||
1770 | int orinoco_commit(struct orinoco_private *priv) | ||
1771 | { | ||
1772 | struct net_device *dev = priv->ndev; | ||
1773 | hermes_t *hw = &priv->hw; | ||
1774 | int err; | ||
1775 | |||
1776 | if (priv->broken_disableport) { | ||
1777 | schedule_work(&priv->reset_work); | ||
1778 | return 0; | ||
1779 | } | ||
1780 | |||
1781 | err = hermes_disable_port(hw, 0); | ||
1782 | if (err) { | ||
1783 | printk(KERN_WARNING "%s: Unable to disable port " | ||
1784 | "while reconfiguring card\n", dev->name); | ||
1785 | priv->broken_disableport = 1; | ||
1786 | goto out; | ||
1787 | } | ||
1788 | |||
1789 | err = __orinoco_commit(priv); | ||
1790 | if (err) { | ||
1791 | printk(KERN_WARNING "%s: Unable to reconfigure card\n", | ||
1792 | dev->name); | ||
1793 | goto out; | ||
1794 | } | ||
1795 | |||
1796 | err = hermes_enable_port(hw, 0); | ||
1797 | if (err) { | ||
1798 | printk(KERN_WARNING "%s: Unable to enable port while reconfiguring card\n", | ||
1799 | dev->name); | ||
1800 | goto out; | ||
1801 | } | ||
1802 | |||
1803 | out: | ||
1804 | if (err) { | ||
1805 | printk(KERN_WARNING "%s: Resetting instead...\n", dev->name); | ||
1806 | schedule_work(&priv->reset_work); | ||
1807 | err = 0; | ||
1808 | } | ||
1809 | return err; | ||
1810 | } | ||
1811 | |||
1944 | /********************************************************************/ | 1812 | /********************************************************************/ |
1945 | /* Interrupt handler */ | 1813 | /* Interrupt handler */ |
1946 | /********************************************************************/ | 1814 | /********************************************************************/ |
@@ -1960,8 +1828,8 @@ static void __orinoco_ev_wterr(struct net_device *dev, hermes_t *hw) | |||
1960 | 1828 | ||
1961 | irqreturn_t orinoco_interrupt(int irq, void *dev_id) | 1829 | irqreturn_t orinoco_interrupt(int irq, void *dev_id) |
1962 | { | 1830 | { |
1963 | struct net_device *dev = dev_id; | 1831 | struct orinoco_private *priv = dev_id; |
1964 | struct orinoco_private *priv = netdev_priv(dev); | 1832 | struct net_device *dev = priv->ndev; |
1965 | hermes_t *hw = &priv->hw; | 1833 | hermes_t *hw = &priv->hw; |
1966 | int count = MAX_IRQLOOPS_PER_IRQ; | 1834 | int count = MAX_IRQLOOPS_PER_IRQ; |
1967 | u16 evstat, events; | 1835 | u16 evstat, events; |
@@ -2096,227 +1964,12 @@ static void orinoco_unregister_pm_notifier(struct orinoco_private *priv) | |||
2096 | /* Initialization */ | 1964 | /* Initialization */ |
2097 | /********************************************************************/ | 1965 | /********************************************************************/ |
2098 | 1966 | ||
2099 | struct comp_id { | 1967 | int orinoco_init(struct orinoco_private *priv) |
2100 | u16 id, variant, major, minor; | ||
2101 | } __attribute__ ((packed)); | ||
2102 | |||
2103 | static inline fwtype_t determine_firmware_type(struct comp_id *nic_id) | ||
2104 | { | ||
2105 | if (nic_id->id < 0x8000) | ||
2106 | return FIRMWARE_TYPE_AGERE; | ||
2107 | else if (nic_id->id == 0x8000 && nic_id->major == 0) | ||
2108 | return FIRMWARE_TYPE_SYMBOL; | ||
2109 | else | ||
2110 | return FIRMWARE_TYPE_INTERSIL; | ||
2111 | } | ||
2112 | |||
2113 | /* Set priv->firmware type, determine firmware properties */ | ||
2114 | static int determine_firmware(struct net_device *dev) | ||
2115 | { | ||
2116 | struct orinoco_private *priv = netdev_priv(dev); | ||
2117 | hermes_t *hw = &priv->hw; | ||
2118 | int err; | ||
2119 | struct comp_id nic_id, sta_id; | ||
2120 | unsigned int firmver; | ||
2121 | char tmp[SYMBOL_MAX_VER_LEN+1] __attribute__((aligned(2))); | ||
2122 | |||
2123 | /* Get the hardware version */ | ||
2124 | err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_NICID, &nic_id); | ||
2125 | if (err) { | ||
2126 | printk(KERN_ERR "%s: Cannot read hardware identity: error %d\n", | ||
2127 | dev->name, err); | ||
2128 | return err; | ||
2129 | } | ||
2130 | |||
2131 | le16_to_cpus(&nic_id.id); | ||
2132 | le16_to_cpus(&nic_id.variant); | ||
2133 | le16_to_cpus(&nic_id.major); | ||
2134 | le16_to_cpus(&nic_id.minor); | ||
2135 | printk(KERN_DEBUG "%s: Hardware identity %04x:%04x:%04x:%04x\n", | ||
2136 | dev->name, nic_id.id, nic_id.variant, | ||
2137 | nic_id.major, nic_id.minor); | ||
2138 | |||
2139 | priv->firmware_type = determine_firmware_type(&nic_id); | ||
2140 | |||
2141 | /* Get the firmware version */ | ||
2142 | err = HERMES_READ_RECORD(hw, USER_BAP, HERMES_RID_STAID, &sta_id); | ||
2143 | if (err) { | ||
2144 | printk(KERN_ERR "%s: Cannot read station identity: error %d\n", | ||
2145 | dev->name, err); | ||
2146 | return err; | ||
2147 | } | ||
2148 | |||
2149 | le16_to_cpus(&sta_id.id); | ||
2150 | le16_to_cpus(&sta_id.variant); | ||
2151 | le16_to_cpus(&sta_id.major); | ||
2152 | le16_to_cpus(&sta_id.minor); | ||
2153 | printk(KERN_DEBUG "%s: Station identity %04x:%04x:%04x:%04x\n", | ||
2154 | dev->name, sta_id.id, sta_id.variant, | ||
2155 | sta_id.major, sta_id.minor); | ||
2156 | |||
2157 | switch (sta_id.id) { | ||
2158 | case 0x15: | ||
2159 | printk(KERN_ERR "%s: Primary firmware is active\n", | ||
2160 | dev->name); | ||
2161 | return -ENODEV; | ||
2162 | case 0x14b: | ||
2163 | printk(KERN_ERR "%s: Tertiary firmware is active\n", | ||
2164 | dev->name); | ||
2165 | return -ENODEV; | ||
2166 | case 0x1f: /* Intersil, Agere, Symbol Spectrum24 */ | ||
2167 | case 0x21: /* Symbol Spectrum24 Trilogy */ | ||
2168 | break; | ||
2169 | default: | ||
2170 | printk(KERN_NOTICE "%s: Unknown station ID, please report\n", | ||
2171 | dev->name); | ||
2172 | break; | ||
2173 | } | ||
2174 | |||
2175 | /* Default capabilities */ | ||
2176 | priv->has_sensitivity = 1; | ||
2177 | priv->has_mwo = 0; | ||
2178 | priv->has_preamble = 0; | ||
2179 | priv->has_port3 = 1; | ||
2180 | priv->has_ibss = 1; | ||
2181 | priv->has_wep = 0; | ||
2182 | priv->has_big_wep = 0; | ||
2183 | priv->has_alt_txcntl = 0; | ||
2184 | priv->has_ext_scan = 0; | ||
2185 | priv->has_wpa = 0; | ||
2186 | priv->do_fw_download = 0; | ||
2187 | |||
2188 | /* Determine capabilities from the firmware version */ | ||
2189 | switch (priv->firmware_type) { | ||
2190 | case FIRMWARE_TYPE_AGERE: | ||
2191 | /* Lucent Wavelan IEEE, Lucent Orinoco, Cabletron RoamAbout, | ||
2192 | ELSA, Melco, HP, IBM, Dell 1150, Compaq 110/210 */ | ||
2193 | snprintf(priv->fw_name, sizeof(priv->fw_name) - 1, | ||
2194 | "Lucent/Agere %d.%02d", sta_id.major, sta_id.minor); | ||
2195 | |||
2196 | firmver = ((unsigned long)sta_id.major << 16) | sta_id.minor; | ||
2197 | |||
2198 | priv->has_ibss = (firmver >= 0x60006); | ||
2199 | priv->has_wep = (firmver >= 0x40020); | ||
2200 | priv->has_big_wep = 1; /* FIXME: this is wrong - how do we tell | ||
2201 | Gold cards from the others? */ | ||
2202 | priv->has_mwo = (firmver >= 0x60000); | ||
2203 | priv->has_pm = (firmver >= 0x40020); /* Don't work in 7.52 ? */ | ||
2204 | priv->ibss_port = 1; | ||
2205 | priv->has_hostscan = (firmver >= 0x8000a); | ||
2206 | priv->do_fw_download = 1; | ||
2207 | priv->broken_monitor = (firmver >= 0x80000); | ||
2208 | priv->has_alt_txcntl = (firmver >= 0x90000); /* All 9.x ? */ | ||
2209 | priv->has_ext_scan = (firmver >= 0x90000); /* All 9.x ? */ | ||
2210 | priv->has_wpa = (firmver >= 0x9002a); | ||
2211 | /* Tested with Agere firmware : | ||
2212 | * 1.16 ; 4.08 ; 4.52 ; 6.04 ; 6.16 ; 7.28 => Jean II | ||
2213 | * Tested CableTron firmware : 4.32 => Anton */ | ||
2214 | break; | ||
2215 | case FIRMWARE_TYPE_SYMBOL: | ||
2216 | /* Symbol , 3Com AirConnect, Intel, Ericsson WLAN */ | ||
2217 | /* Intel MAC : 00:02:B3:* */ | ||
2218 | /* 3Com MAC : 00:50:DA:* */ | ||
2219 | memset(tmp, 0, sizeof(tmp)); | ||
2220 | /* Get the Symbol firmware version */ | ||
2221 | err = hermes_read_ltv(hw, USER_BAP, | ||
2222 | HERMES_RID_SECONDARYVERSION_SYMBOL, | ||
2223 | SYMBOL_MAX_VER_LEN, NULL, &tmp); | ||
2224 | if (err) { | ||
2225 | printk(KERN_WARNING | ||
2226 | "%s: Error %d reading Symbol firmware info. " | ||
2227 | "Wildly guessing capabilities...\n", | ||
2228 | dev->name, err); | ||
2229 | firmver = 0; | ||
2230 | tmp[0] = '\0'; | ||
2231 | } else { | ||
2232 | /* The firmware revision is a string, the format is | ||
2233 | * something like : "V2.20-01". | ||
2234 | * Quick and dirty parsing... - Jean II | ||
2235 | */ | ||
2236 | firmver = ((tmp[1] - '0') << 16) | ||
2237 | | ((tmp[3] - '0') << 12) | ||
2238 | | ((tmp[4] - '0') << 8) | ||
2239 | | ((tmp[6] - '0') << 4) | ||
2240 | | (tmp[7] - '0'); | ||
2241 | |||
2242 | tmp[SYMBOL_MAX_VER_LEN] = '\0'; | ||
2243 | } | ||
2244 | |||
2245 | snprintf(priv->fw_name, sizeof(priv->fw_name) - 1, | ||
2246 | "Symbol %s", tmp); | ||
2247 | |||
2248 | priv->has_ibss = (firmver >= 0x20000); | ||
2249 | priv->has_wep = (firmver >= 0x15012); | ||
2250 | priv->has_big_wep = (firmver >= 0x20000); | ||
2251 | priv->has_pm = (firmver >= 0x20000 && firmver < 0x22000) || | ||
2252 | (firmver >= 0x29000 && firmver < 0x30000) || | ||
2253 | firmver >= 0x31000; | ||
2254 | priv->has_preamble = (firmver >= 0x20000); | ||
2255 | priv->ibss_port = 4; | ||
2256 | |||
2257 | /* Symbol firmware is found on various cards, but | ||
2258 | * there has been no attempt to check firmware | ||
2259 | * download on non-spectrum_cs based cards. | ||
2260 | * | ||
2261 | * Given that the Agere firmware download works | ||
2262 | * differently, we should avoid doing a firmware | ||
2263 | * download with the Symbol algorithm on non-spectrum | ||
2264 | * cards. | ||
2265 | * | ||
2266 | * For now we can identify a spectrum_cs based card | ||
2267 | * because it has a firmware reset function. | ||
2268 | */ | ||
2269 | priv->do_fw_download = (priv->stop_fw != NULL); | ||
2270 | |||
2271 | priv->broken_disableport = (firmver == 0x25013) || | ||
2272 | (firmver >= 0x30000 && firmver <= 0x31000); | ||
2273 | priv->has_hostscan = (firmver >= 0x31001) || | ||
2274 | (firmver >= 0x29057 && firmver < 0x30000); | ||
2275 | /* Tested with Intel firmware : 0x20015 => Jean II */ | ||
2276 | /* Tested with 3Com firmware : 0x15012 & 0x22001 => Jean II */ | ||
2277 | break; | ||
2278 | case FIRMWARE_TYPE_INTERSIL: | ||
2279 | /* D-Link, Linksys, Adtron, ZoomAir, and many others... | ||
2280 | * Samsung, Compaq 100/200 and Proxim are slightly | ||
2281 | * different and less well tested */ | ||
2282 | /* D-Link MAC : 00:40:05:* */ | ||
2283 | /* Addtron MAC : 00:90:D1:* */ | ||
2284 | snprintf(priv->fw_name, sizeof(priv->fw_name) - 1, | ||
2285 | "Intersil %d.%d.%d", sta_id.major, sta_id.minor, | ||
2286 | sta_id.variant); | ||
2287 | |||
2288 | firmver = ((unsigned long)sta_id.major << 16) | | ||
2289 | ((unsigned long)sta_id.minor << 8) | sta_id.variant; | ||
2290 | |||
2291 | priv->has_ibss = (firmver >= 0x000700); /* FIXME */ | ||
2292 | priv->has_big_wep = priv->has_wep = (firmver >= 0x000800); | ||
2293 | priv->has_pm = (firmver >= 0x000700); | ||
2294 | priv->has_hostscan = (firmver >= 0x010301); | ||
2295 | |||
2296 | if (firmver >= 0x000800) | ||
2297 | priv->ibss_port = 0; | ||
2298 | else { | ||
2299 | printk(KERN_NOTICE "%s: Intersil firmware earlier " | ||
2300 | "than v0.8.x - several features not supported\n", | ||
2301 | dev->name); | ||
2302 | priv->ibss_port = 1; | ||
2303 | } | ||
2304 | break; | ||
2305 | } | ||
2306 | printk(KERN_DEBUG "%s: Firmware determined as %s\n", dev->name, | ||
2307 | priv->fw_name); | ||
2308 | |||
2309 | return 0; | ||
2310 | } | ||
2311 | |||
2312 | static int orinoco_init(struct net_device *dev) | ||
2313 | { | 1968 | { |
2314 | struct orinoco_private *priv = netdev_priv(dev); | 1969 | struct device *dev = priv->dev; |
1970 | struct wiphy *wiphy = priv_to_wiphy(priv); | ||
2315 | hermes_t *hw = &priv->hw; | 1971 | hermes_t *hw = &priv->hw; |
2316 | int err = 0; | 1972 | int err = 0; |
2317 | struct hermes_idstring nickbuf; | ||
2318 | u16 reclen; | ||
2319 | int len; | ||
2320 | 1973 | ||
2321 | /* No need to lock, the hw_unavailable flag is already set in | 1974 | /* No need to lock, the hw_unavailable flag is already set in |
2322 | * alloc_orinocodev() */ | 1975 | * alloc_orinocodev() */ |
@@ -2325,15 +1978,14 @@ static int orinoco_init(struct net_device *dev) | |||
2325 | /* Initialize the firmware */ | 1978 | /* Initialize the firmware */ |
2326 | err = hermes_init(hw); | 1979 | err = hermes_init(hw); |
2327 | if (err != 0) { | 1980 | if (err != 0) { |
2328 | printk(KERN_ERR "%s: failed to initialize firmware (err = %d)\n", | 1981 | dev_err(dev, "Failed to initialize firmware (err = %d)\n", |
2329 | dev->name, err); | 1982 | err); |
2330 | goto out; | 1983 | goto out; |
2331 | } | 1984 | } |
2332 | 1985 | ||
2333 | err = determine_firmware(dev); | 1986 | err = determine_fw_capabilities(priv); |
2334 | if (err != 0) { | 1987 | if (err != 0) { |
2335 | printk(KERN_ERR "%s: Incompatible firmware, aborting\n", | 1988 | dev_err(dev, "Incompatible firmware, aborting\n"); |
2336 | dev->name); | ||
2337 | goto out; | 1989 | goto out; |
2338 | } | 1990 | } |
2339 | 1991 | ||
@@ -2347,147 +1999,41 @@ static int orinoco_init(struct net_device *dev) | |||
2347 | priv->do_fw_download = 0; | 1999 | priv->do_fw_download = 0; |
2348 | 2000 | ||
2349 | /* Check firmware version again */ | 2001 | /* Check firmware version again */ |
2350 | err = determine_firmware(dev); | 2002 | err = determine_fw_capabilities(priv); |
2351 | if (err != 0) { | 2003 | if (err != 0) { |
2352 | printk(KERN_ERR "%s: Incompatible firmware, aborting\n", | 2004 | dev_err(dev, "Incompatible firmware, aborting\n"); |
2353 | dev->name); | ||
2354 | goto out; | 2005 | goto out; |
2355 | } | 2006 | } |
2356 | } | 2007 | } |
2357 | 2008 | ||
2358 | if (priv->has_port3) | 2009 | if (priv->has_port3) |
2359 | printk(KERN_DEBUG "%s: Ad-hoc demo mode supported\n", | 2010 | dev_info(dev, "Ad-hoc demo mode supported\n"); |
2360 | dev->name); | ||
2361 | if (priv->has_ibss) | 2011 | if (priv->has_ibss) |
2362 | printk(KERN_DEBUG "%s: IEEE standard IBSS ad-hoc mode supported\n", | 2012 | dev_info(dev, "IEEE standard IBSS ad-hoc mode supported\n"); |
2363 | dev->name); | 2013 | if (priv->has_wep) |
2364 | if (priv->has_wep) { | 2014 | dev_info(dev, "WEP supported, %s-bit key\n", |
2365 | printk(KERN_DEBUG "%s: WEP supported, %s-bit key\n", dev->name, | 2015 | priv->has_big_wep ? "104" : "40"); |
2366 | priv->has_big_wep ? "104" : "40"); | ||
2367 | } | ||
2368 | if (priv->has_wpa) { | 2016 | if (priv->has_wpa) { |
2369 | printk(KERN_DEBUG "%s: WPA-PSK supported\n", dev->name); | 2017 | dev_info(dev, "WPA-PSK supported\n"); |
2370 | if (orinoco_mic_init(priv)) { | 2018 | if (orinoco_mic_init(priv)) { |
2371 | printk(KERN_ERR "%s: Failed to setup MIC crypto " | 2019 | dev_err(dev, "Failed to setup MIC crypto algorithm. " |
2372 | "algorithm. Disabling WPA support\n", dev->name); | 2020 | "Disabling WPA support\n"); |
2373 | priv->has_wpa = 0; | 2021 | priv->has_wpa = 0; |
2374 | } | 2022 | } |
2375 | } | 2023 | } |
2376 | 2024 | ||
2377 | /* Now we have the firmware capabilities, allocate appropiate | 2025 | err = orinoco_hw_read_card_settings(priv, wiphy->perm_addr); |
2378 | * sized scan buffers */ | 2026 | if (err) |
2379 | if (orinoco_bss_data_allocate(priv)) | ||
2380 | goto out; | ||
2381 | orinoco_bss_data_init(priv); | ||
2382 | |||
2383 | /* Get the MAC address */ | ||
2384 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNMACADDR, | ||
2385 | ETH_ALEN, NULL, dev->dev_addr); | ||
2386 | if (err) { | ||
2387 | printk(KERN_WARNING "%s: failed to read MAC address!\n", | ||
2388 | dev->name); | ||
2389 | goto out; | ||
2390 | } | ||
2391 | |||
2392 | printk(KERN_DEBUG "%s: MAC address %pM\n", | ||
2393 | dev->name, dev->dev_addr); | ||
2394 | |||
2395 | /* Get the station name */ | ||
2396 | err = hermes_read_ltv(hw, USER_BAP, HERMES_RID_CNFOWNNAME, | ||
2397 | sizeof(nickbuf), &reclen, &nickbuf); | ||
2398 | if (err) { | ||
2399 | printk(KERN_ERR "%s: failed to read station name\n", | ||
2400 | dev->name); | ||
2401 | goto out; | ||
2402 | } | ||
2403 | if (nickbuf.len) | ||
2404 | len = min(IW_ESSID_MAX_SIZE, (int)le16_to_cpu(nickbuf.len)); | ||
2405 | else | ||
2406 | len = min(IW_ESSID_MAX_SIZE, 2 * reclen); | ||
2407 | memcpy(priv->nick, &nickbuf.val, len); | ||
2408 | priv->nick[len] = '\0'; | ||
2409 | |||
2410 | printk(KERN_DEBUG "%s: Station name \"%s\"\n", dev->name, priv->nick); | ||
2411 | |||
2412 | err = orinoco_allocate_fid(dev); | ||
2413 | if (err) { | ||
2414 | printk(KERN_ERR "%s: failed to allocate NIC buffer!\n", | ||
2415 | dev->name); | ||
2416 | goto out; | ||
2417 | } | ||
2418 | |||
2419 | /* Get allowed channels */ | ||
2420 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CHANNELLIST, | ||
2421 | &priv->channel_mask); | ||
2422 | if (err) { | ||
2423 | printk(KERN_ERR "%s: failed to read channel list!\n", | ||
2424 | dev->name); | ||
2425 | goto out; | ||
2426 | } | ||
2427 | |||
2428 | /* Get initial AP density */ | ||
2429 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFSYSTEMSCALE, | ||
2430 | &priv->ap_density); | ||
2431 | if (err || priv->ap_density < 1 || priv->ap_density > 3) | ||
2432 | priv->has_sensitivity = 0; | ||
2433 | |||
2434 | /* Get initial RTS threshold */ | ||
2435 | err = hermes_read_wordrec(hw, USER_BAP, HERMES_RID_CNFRTSTHRESHOLD, | ||
2436 | &priv->rts_thresh); | ||
2437 | if (err) { | ||
2438 | printk(KERN_ERR "%s: failed to read RTS threshold!\n", | ||
2439 | dev->name); | ||
2440 | goto out; | 2027 | goto out; |
2441 | } | ||
2442 | 2028 | ||
2443 | /* Get initial fragmentation settings */ | 2029 | err = orinoco_hw_allocate_fid(priv); |
2444 | if (priv->has_mwo) | ||
2445 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2446 | HERMES_RID_CNFMWOROBUST_AGERE, | ||
2447 | &priv->mwo_robust); | ||
2448 | else | ||
2449 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2450 | HERMES_RID_CNFFRAGMENTATIONTHRESHOLD, | ||
2451 | &priv->frag_thresh); | ||
2452 | if (err) { | 2030 | if (err) { |
2453 | printk(KERN_ERR "%s: failed to read fragmentation settings!\n", | 2031 | dev_err(dev, "Failed to allocate NIC buffer!\n"); |
2454 | dev->name); | ||
2455 | goto out; | 2032 | goto out; |
2456 | } | 2033 | } |
2457 | 2034 | ||
2458 | /* Power management setup */ | ||
2459 | if (priv->has_pm) { | ||
2460 | priv->pm_on = 0; | ||
2461 | priv->pm_mcast = 1; | ||
2462 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2463 | HERMES_RID_CNFMAXSLEEPDURATION, | ||
2464 | &priv->pm_period); | ||
2465 | if (err) { | ||
2466 | printk(KERN_ERR "%s: failed to read power management period!\n", | ||
2467 | dev->name); | ||
2468 | goto out; | ||
2469 | } | ||
2470 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2471 | HERMES_RID_CNFPMHOLDOVERDURATION, | ||
2472 | &priv->pm_timeout); | ||
2473 | if (err) { | ||
2474 | printk(KERN_ERR "%s: failed to read power management timeout!\n", | ||
2475 | dev->name); | ||
2476 | goto out; | ||
2477 | } | ||
2478 | } | ||
2479 | |||
2480 | /* Preamble setup */ | ||
2481 | if (priv->has_preamble) { | ||
2482 | err = hermes_read_wordrec(hw, USER_BAP, | ||
2483 | HERMES_RID_CNFPREAMBLE_SYMBOL, | ||
2484 | &priv->preamble); | ||
2485 | if (err) | ||
2486 | goto out; | ||
2487 | } | ||
2488 | |||
2489 | /* Set up the default configuration */ | 2035 | /* Set up the default configuration */ |
2490 | priv->iw_mode = IW_MODE_INFRA; | 2036 | priv->iw_mode = NL80211_IFTYPE_STATION; |
2491 | /* By default use IEEE/IBSS ad-hoc mode if we have it */ | 2037 | /* By default use IEEE/IBSS ad-hoc mode if we have it */ |
2492 | priv->prefer_port3 = priv->has_port3 && (!priv->has_ibss); | 2038 | priv->prefer_port3 = priv->has_port3 && (!priv->has_ibss); |
2493 | set_port_type(priv); | 2039 | set_port_type(priv); |
@@ -2502,20 +2048,25 @@ static int orinoco_init(struct net_device *dev) | |||
2502 | priv->wpa_ie_len = 0; | 2048 | priv->wpa_ie_len = 0; |
2503 | priv->wpa_ie = NULL; | 2049 | priv->wpa_ie = NULL; |
2504 | 2050 | ||
2051 | if (orinoco_wiphy_register(wiphy)) { | ||
2052 | err = -ENODEV; | ||
2053 | goto out; | ||
2054 | } | ||
2055 | |||
2505 | /* Make the hardware available, as long as it hasn't been | 2056 | /* Make the hardware available, as long as it hasn't been |
2506 | * removed elsewhere (e.g. by PCMCIA hot unplug) */ | 2057 | * removed elsewhere (e.g. by PCMCIA hot unplug) */ |
2507 | spin_lock_irq(&priv->lock); | 2058 | spin_lock_irq(&priv->lock); |
2508 | priv->hw_unavailable--; | 2059 | priv->hw_unavailable--; |
2509 | spin_unlock_irq(&priv->lock); | 2060 | spin_unlock_irq(&priv->lock); |
2510 | 2061 | ||
2511 | printk(KERN_DEBUG "%s: ready\n", dev->name); | 2062 | dev_dbg(dev, "Ready\n"); |
2512 | 2063 | ||
2513 | out: | 2064 | out: |
2514 | return err; | 2065 | return err; |
2515 | } | 2066 | } |
2067 | EXPORT_SYMBOL(orinoco_init); | ||
2516 | 2068 | ||
2517 | static const struct net_device_ops orinoco_netdev_ops = { | 2069 | static const struct net_device_ops orinoco_netdev_ops = { |
2518 | .ndo_init = orinoco_init, | ||
2519 | .ndo_open = orinoco_open, | 2070 | .ndo_open = orinoco_open, |
2520 | .ndo_stop = orinoco_stop, | 2071 | .ndo_stop = orinoco_stop, |
2521 | .ndo_start_xmit = orinoco_xmit, | 2072 | .ndo_start_xmit = orinoco_xmit, |
@@ -2527,40 +2078,64 @@ static const struct net_device_ops orinoco_netdev_ops = { | |||
2527 | .ndo_get_stats = orinoco_get_stats, | 2078 | .ndo_get_stats = orinoco_get_stats, |
2528 | }; | 2079 | }; |
2529 | 2080 | ||
2530 | struct net_device | 2081 | /* Allocate private data. |
2082 | * | ||
2083 | * This driver has a number of structures associated with it | ||
2084 | * netdev - Net device structure for each network interface | ||
2085 | * wiphy - structure associated with wireless phy | ||
2086 | * wireless_dev (wdev) - structure for each wireless interface | ||
2087 | * hw - structure for hermes chip info | ||
2088 | * card - card specific structure for use by the card driver | ||
2089 | * (airport, orinoco_cs) | ||
2090 | * priv - orinoco private data | ||
2091 | * device - generic linux device structure | ||
2092 | * | ||
2093 | * +---------+ +---------+ | ||
2094 | * | wiphy | | netdev | | ||
2095 | * | +-------+ | +-------+ | ||
2096 | * | | priv | | | wdev | | ||
2097 | * | | +-----+ +-+-------+ | ||
2098 | * | | | hw | | ||
2099 | * | +-+-----+ | ||
2100 | * | | card | | ||
2101 | * +-+-------+ | ||
2102 | * | ||
2103 | * priv has a link to netdev and device | ||
2104 | * wdev has a link to wiphy | ||
2105 | */ | ||
2106 | struct orinoco_private | ||
2531 | *alloc_orinocodev(int sizeof_card, | 2107 | *alloc_orinocodev(int sizeof_card, |
2532 | struct device *device, | 2108 | struct device *device, |
2533 | int (*hard_reset)(struct orinoco_private *), | 2109 | int (*hard_reset)(struct orinoco_private *), |
2534 | int (*stop_fw)(struct orinoco_private *, int)) | 2110 | int (*stop_fw)(struct orinoco_private *, int)) |
2535 | { | 2111 | { |
2536 | struct net_device *dev; | ||
2537 | struct orinoco_private *priv; | 2112 | struct orinoco_private *priv; |
2113 | struct wiphy *wiphy; | ||
2538 | 2114 | ||
2539 | dev = alloc_etherdev(sizeof(struct orinoco_private) + sizeof_card); | 2115 | /* allocate wiphy |
2540 | if (!dev) | 2116 | * NOTE: We only support a single virtual interface |
2117 | * but this may change when monitor mode is added | ||
2118 | */ | ||
2119 | wiphy = wiphy_new(&orinoco_cfg_ops, | ||
2120 | sizeof(struct orinoco_private) + sizeof_card); | ||
2121 | if (!wiphy) | ||
2541 | return NULL; | 2122 | return NULL; |
2542 | priv = netdev_priv(dev); | 2123 | |
2543 | priv->ndev = dev; | 2124 | priv = wiphy_priv(wiphy); |
2125 | priv->dev = device; | ||
2126 | |||
2544 | if (sizeof_card) | 2127 | if (sizeof_card) |
2545 | priv->card = (void *)((unsigned long)priv | 2128 | priv->card = (void *)((unsigned long)priv |
2546 | + sizeof(struct orinoco_private)); | 2129 | + sizeof(struct orinoco_private)); |
2547 | else | 2130 | else |
2548 | priv->card = NULL; | 2131 | priv->card = NULL; |
2549 | priv->dev = device; | ||
2550 | 2132 | ||
2551 | /* Setup / override net_device fields */ | 2133 | orinoco_wiphy_init(wiphy); |
2552 | dev->netdev_ops = &orinoco_netdev_ops; | 2134 | |
2553 | dev->watchdog_timeo = HZ; /* 1 second timeout */ | ||
2554 | dev->ethtool_ops = &orinoco_ethtool_ops; | ||
2555 | dev->wireless_handlers = &orinoco_handler_def; | ||
2556 | #ifdef WIRELESS_SPY | 2135 | #ifdef WIRELESS_SPY |
2557 | priv->wireless_data.spy_data = &priv->spy_data; | 2136 | priv->wireless_data.spy_data = &priv->spy_data; |
2558 | dev->wireless_data = &priv->wireless_data; | ||
2559 | #endif | 2137 | #endif |
2560 | 2138 | ||
2561 | /* Reserve space in skb for the SNAP header */ | ||
2562 | dev->hard_header_len += ENCAPS_OVERHEAD; | ||
2563 | |||
2564 | /* Set up default callbacks */ | 2139 | /* Set up default callbacks */ |
2565 | priv->hard_reset = hard_reset; | 2140 | priv->hard_reset = hard_reset; |
2566 | priv->stop_fw = stop_fw; | 2141 | priv->stop_fw = stop_fw; |
@@ -2576,9 +2151,12 @@ struct net_device | |||
2576 | 2151 | ||
2577 | INIT_LIST_HEAD(&priv->rx_list); | 2152 | INIT_LIST_HEAD(&priv->rx_list); |
2578 | tasklet_init(&priv->rx_tasklet, orinoco_rx_isr_tasklet, | 2153 | tasklet_init(&priv->rx_tasklet, orinoco_rx_isr_tasklet, |
2579 | (unsigned long) dev); | 2154 | (unsigned long) priv); |
2155 | |||
2156 | spin_lock_init(&priv->scan_lock); | ||
2157 | INIT_LIST_HEAD(&priv->scan_list); | ||
2158 | INIT_WORK(&priv->process_scan, orinoco_process_scan_results); | ||
2580 | 2159 | ||
2581 | netif_carrier_off(dev); | ||
2582 | priv->last_linkstatus = 0xffff; | 2160 | priv->last_linkstatus = 0xffff; |
2583 | 2161 | ||
2584 | #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) | 2162 | #if defined(CONFIG_HERMES_CACHE_FW_ON_INIT) || defined(CONFIG_PM_SLEEP) |
@@ -2589,14 +2167,91 @@ struct net_device | |||
2589 | /* Register PM notifiers */ | 2167 | /* Register PM notifiers */ |
2590 | orinoco_register_pm_notifier(priv); | 2168 | orinoco_register_pm_notifier(priv); |
2591 | 2169 | ||
2592 | return dev; | 2170 | return priv; |
2593 | } | 2171 | } |
2594 | EXPORT_SYMBOL(alloc_orinocodev); | 2172 | EXPORT_SYMBOL(alloc_orinocodev); |
2595 | 2173 | ||
2596 | void free_orinocodev(struct net_device *dev) | 2174 | /* We can only support a single interface. We provide a separate |
2175 | * function to set it up to distinguish between hardware | ||
2176 | * initialisation and interface setup. | ||
2177 | * | ||
2178 | * The base_addr and irq parameters are passed on to netdev for use | ||
2179 | * with SIOCGIFMAP. | ||
2180 | */ | ||
2181 | int orinoco_if_add(struct orinoco_private *priv, | ||
2182 | unsigned long base_addr, | ||
2183 | unsigned int irq) | ||
2184 | { | ||
2185 | struct wiphy *wiphy = priv_to_wiphy(priv); | ||
2186 | struct wireless_dev *wdev; | ||
2187 | struct net_device *dev; | ||
2188 | int ret; | ||
2189 | |||
2190 | dev = alloc_etherdev(sizeof(struct wireless_dev)); | ||
2191 | |||
2192 | if (!dev) | ||
2193 | return -ENOMEM; | ||
2194 | |||
2195 | /* Initialise wireless_dev */ | ||
2196 | wdev = netdev_priv(dev); | ||
2197 | wdev->wiphy = wiphy; | ||
2198 | wdev->iftype = NL80211_IFTYPE_STATION; | ||
2199 | |||
2200 | /* Setup / override net_device fields */ | ||
2201 | dev->ieee80211_ptr = wdev; | ||
2202 | dev->netdev_ops = &orinoco_netdev_ops; | ||
2203 | dev->watchdog_timeo = HZ; /* 1 second timeout */ | ||
2204 | dev->ethtool_ops = &orinoco_ethtool_ops; | ||
2205 | dev->wireless_handlers = &orinoco_handler_def; | ||
2206 | #ifdef WIRELESS_SPY | ||
2207 | dev->wireless_data = &priv->wireless_data; | ||
2208 | #endif | ||
2209 | /* we use the default eth_mac_addr for setting the MAC addr */ | ||
2210 | |||
2211 | /* Reserve space in skb for the SNAP header */ | ||
2212 | dev->hard_header_len += ENCAPS_OVERHEAD; | ||
2213 | |||
2214 | netif_carrier_off(dev); | ||
2215 | |||
2216 | memcpy(dev->dev_addr, wiphy->perm_addr, ETH_ALEN); | ||
2217 | |||
2218 | dev->base_addr = base_addr; | ||
2219 | dev->irq = irq; | ||
2220 | |||
2221 | SET_NETDEV_DEV(dev, priv->dev); | ||
2222 | ret = register_netdev(dev); | ||
2223 | if (ret) | ||
2224 | goto fail; | ||
2225 | |||
2226 | priv->ndev = dev; | ||
2227 | |||
2228 | /* Report what we've done */ | ||
2229 | dev_dbg(priv->dev, "Registerred interface %s.\n", dev->name); | ||
2230 | |||
2231 | return 0; | ||
2232 | |||
2233 | fail: | ||
2234 | free_netdev(dev); | ||
2235 | return ret; | ||
2236 | } | ||
2237 | EXPORT_SYMBOL(orinoco_if_add); | ||
2238 | |||
2239 | void orinoco_if_del(struct orinoco_private *priv) | ||
2240 | { | ||
2241 | struct net_device *dev = priv->ndev; | ||
2242 | |||
2243 | unregister_netdev(dev); | ||
2244 | free_netdev(dev); | ||
2245 | } | ||
2246 | EXPORT_SYMBOL(orinoco_if_del); | ||
2247 | |||
2248 | void free_orinocodev(struct orinoco_private *priv) | ||
2597 | { | 2249 | { |
2598 | struct orinoco_private *priv = netdev_priv(dev); | 2250 | struct wiphy *wiphy = priv_to_wiphy(priv); |
2599 | struct orinoco_rx_data *rx_data, *temp; | 2251 | struct orinoco_rx_data *rx_data, *temp; |
2252 | struct orinoco_scan_data *sd, *sdtemp; | ||
2253 | |||
2254 | wiphy_unregister(wiphy); | ||
2600 | 2255 | ||
2601 | /* If the tasklet is scheduled when we call tasklet_kill it | 2256 | /* If the tasklet is scheduled when we call tasklet_kill it |
2602 | * will run one final time. However the tasklet will only | 2257 | * will run one final time. However the tasklet will only |
@@ -2612,21 +2267,80 @@ void free_orinocodev(struct net_device *dev) | |||
2612 | kfree(rx_data); | 2267 | kfree(rx_data); |
2613 | } | 2268 | } |
2614 | 2269 | ||
2270 | cancel_work_sync(&priv->process_scan); | ||
2271 | /* Explicitly drain priv->scan_list */ | ||
2272 | list_for_each_entry_safe(sd, sdtemp, &priv->scan_list, list) { | ||
2273 | list_del(&sd->list); | ||
2274 | |||
2275 | if ((sd->len > 0) && sd->buf) | ||
2276 | kfree(sd->buf); | ||
2277 | kfree(sd); | ||
2278 | } | ||
2279 | |||
2615 | orinoco_unregister_pm_notifier(priv); | 2280 | orinoco_unregister_pm_notifier(priv); |
2616 | orinoco_uncache_fw(priv); | 2281 | orinoco_uncache_fw(priv); |
2617 | 2282 | ||
2618 | priv->wpa_ie_len = 0; | 2283 | priv->wpa_ie_len = 0; |
2619 | kfree(priv->wpa_ie); | 2284 | kfree(priv->wpa_ie); |
2620 | orinoco_mic_free(priv); | 2285 | orinoco_mic_free(priv); |
2621 | orinoco_bss_data_free(priv); | 2286 | wiphy_free(wiphy); |
2622 | free_netdev(dev); | ||
2623 | } | 2287 | } |
2624 | EXPORT_SYMBOL(free_orinocodev); | 2288 | EXPORT_SYMBOL(free_orinocodev); |
2625 | 2289 | ||
2290 | int orinoco_up(struct orinoco_private *priv) | ||
2291 | { | ||
2292 | struct net_device *dev = priv->ndev; | ||
2293 | unsigned long flags; | ||
2294 | int err; | ||
2295 | |||
2296 | spin_lock_irqsave(&priv->lock, flags); | ||
2297 | |||
2298 | err = orinoco_reinit_firmware(priv); | ||
2299 | if (err) { | ||
2300 | printk(KERN_ERR "%s: Error %d re-initializing firmware\n", | ||
2301 | dev->name, err); | ||
2302 | goto exit; | ||
2303 | } | ||
2304 | |||
2305 | netif_device_attach(dev); | ||
2306 | priv->hw_unavailable--; | ||
2307 | |||
2308 | if (priv->open && !priv->hw_unavailable) { | ||
2309 | err = __orinoco_up(priv); | ||
2310 | if (err) | ||
2311 | printk(KERN_ERR "%s: Error %d restarting card\n", | ||
2312 | dev->name, err); | ||
2313 | } | ||
2314 | |||
2315 | exit: | ||
2316 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2317 | |||
2318 | return 0; | ||
2319 | } | ||
2320 | EXPORT_SYMBOL(orinoco_up); | ||
2321 | |||
2322 | void orinoco_down(struct orinoco_private *priv) | ||
2323 | { | ||
2324 | struct net_device *dev = priv->ndev; | ||
2325 | unsigned long flags; | ||
2326 | int err; | ||
2327 | |||
2328 | spin_lock_irqsave(&priv->lock, flags); | ||
2329 | err = __orinoco_down(priv); | ||
2330 | if (err) | ||
2331 | printk(KERN_WARNING "%s: Error %d downing interface\n", | ||
2332 | dev->name, err); | ||
2333 | |||
2334 | netif_device_detach(dev); | ||
2335 | priv->hw_unavailable++; | ||
2336 | spin_unlock_irqrestore(&priv->lock, flags); | ||
2337 | } | ||
2338 | EXPORT_SYMBOL(orinoco_down); | ||
2339 | |||
2626 | static void orinoco_get_drvinfo(struct net_device *dev, | 2340 | static void orinoco_get_drvinfo(struct net_device *dev, |
2627 | struct ethtool_drvinfo *info) | 2341 | struct ethtool_drvinfo *info) |
2628 | { | 2342 | { |
2629 | struct orinoco_private *priv = netdev_priv(dev); | 2343 | struct orinoco_private *priv = ndev_priv(dev); |
2630 | 2344 | ||
2631 | strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1); | 2345 | strncpy(info->driver, DRIVER_NAME, sizeof(info->driver) - 1); |
2632 | strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1); | 2346 | strncpy(info->version, DRIVER_VERSION, sizeof(info->version) - 1); |
diff --git a/drivers/net/wireless/orinoco/main.h b/drivers/net/wireless/orinoco/main.h index af2bae4fe395..21ab36cd76c7 100644 --- a/drivers/net/wireless/orinoco/main.h +++ b/drivers/net/wireless/orinoco/main.h | |||
@@ -29,10 +29,9 @@ struct net_device; | |||
29 | struct work_struct; | 29 | struct work_struct; |
30 | 30 | ||
31 | void set_port_type(struct orinoco_private *priv); | 31 | void set_port_type(struct orinoco_private *priv); |
32 | int __orinoco_program_rids(struct net_device *dev); | 32 | int orinoco_commit(struct orinoco_private *priv); |
33 | void orinoco_reset(struct work_struct *work); | 33 | void orinoco_reset(struct work_struct *work); |
34 | 34 | ||
35 | |||
36 | /* Information element helpers - find a home for these... */ | 35 | /* Information element helpers - find a home for these... */ |
37 | static inline u8 *orinoco_get_ie(u8 *data, size_t len, | 36 | static inline u8 *orinoco_get_ie(u8 *data, size_t len, |
38 | enum ieee80211_eid eid) | 37 | enum ieee80211_eid eid) |
diff --git a/drivers/net/wireless/orinoco/orinoco.h b/drivers/net/wireless/orinoco/orinoco.h index 8e5a72cc297f..5f4f5c9eef79 100644 --- a/drivers/net/wireless/orinoco/orinoco.h +++ b/drivers/net/wireless/orinoco/orinoco.h | |||
@@ -14,6 +14,7 @@ | |||
14 | #include <linux/netdevice.h> | 14 | #include <linux/netdevice.h> |
15 | #include <linux/wireless.h> | 15 | #include <linux/wireless.h> |
16 | #include <net/iw_handler.h> | 16 | #include <net/iw_handler.h> |
17 | #include <net/cfg80211.h> | ||
17 | 18 | ||
18 | #include "hermes.h" | 19 | #include "hermes.h" |
19 | 20 | ||
@@ -47,18 +48,6 @@ typedef enum { | |||
47 | FIRMWARE_TYPE_SYMBOL | 48 | FIRMWARE_TYPE_SYMBOL |
48 | } fwtype_t; | 49 | } fwtype_t; |
49 | 50 | ||
50 | struct bss_element { | ||
51 | union hermes_scan_info bss; | ||
52 | unsigned long last_scanned; | ||
53 | struct list_head list; | ||
54 | }; | ||
55 | |||
56 | struct xbss_element { | ||
57 | struct agere_ext_scan_info bss; | ||
58 | unsigned long last_scanned; | ||
59 | struct list_head list; | ||
60 | }; | ||
61 | |||
62 | struct firmware; | 51 | struct firmware; |
63 | 52 | ||
64 | struct orinoco_private { | 53 | struct orinoco_private { |
@@ -67,6 +56,10 @@ struct orinoco_private { | |||
67 | int (*hard_reset)(struct orinoco_private *); | 56 | int (*hard_reset)(struct orinoco_private *); |
68 | int (*stop_fw)(struct orinoco_private *, int); | 57 | int (*stop_fw)(struct orinoco_private *, int); |
69 | 58 | ||
59 | struct ieee80211_supported_band band; | ||
60 | struct ieee80211_channel channels[14]; | ||
61 | u32 cipher_suites[3]; | ||
62 | |||
70 | /* Synchronisation stuff */ | 63 | /* Synchronisation stuff */ |
71 | spinlock_t lock; | 64 | spinlock_t lock; |
72 | int hw_unavailable; | 65 | int hw_unavailable; |
@@ -116,7 +109,7 @@ struct orinoco_private { | |||
116 | unsigned int broken_monitor:1; | 109 | unsigned int broken_monitor:1; |
117 | 110 | ||
118 | /* Configuration paramaters */ | 111 | /* Configuration paramaters */ |
119 | u32 iw_mode; | 112 | enum nl80211_iftype iw_mode; |
120 | int prefer_port3; | 113 | int prefer_port3; |
121 | u16 encode_alg, wep_restrict, tx_key; | 114 | u16 encode_alg, wep_restrict, tx_key; |
122 | struct orinoco_key keys[ORINOCO_MAX_KEYS]; | 115 | struct orinoco_key keys[ORINOCO_MAX_KEYS]; |
@@ -140,12 +133,10 @@ struct orinoco_private { | |||
140 | int promiscuous, mc_count; | 133 | int promiscuous, mc_count; |
141 | 134 | ||
142 | /* Scanning support */ | 135 | /* Scanning support */ |
143 | struct list_head bss_list; | 136 | struct cfg80211_scan_request *scan_request; |
144 | struct list_head bss_free_list; | 137 | struct work_struct process_scan; |
145 | void *bss_xbss_data; | 138 | struct list_head scan_list; |
146 | 139 | spinlock_t scan_lock; /* protects the scan list */ | |
147 | int scan_inprogress; /* Scan pending... */ | ||
148 | u32 scan_mode; /* Type of scan done */ | ||
149 | 140 | ||
150 | /* WPA support */ | 141 | /* WPA support */ |
151 | u8 *wpa_ie; | 142 | u8 *wpa_ie; |
@@ -182,14 +173,18 @@ extern int orinoco_debug; | |||
182 | /* Exported prototypes */ | 173 | /* Exported prototypes */ |
183 | /********************************************************************/ | 174 | /********************************************************************/ |
184 | 175 | ||
185 | extern struct net_device *alloc_orinocodev( | 176 | extern struct orinoco_private *alloc_orinocodev( |
186 | int sizeof_card, struct device *device, | 177 | int sizeof_card, struct device *device, |
187 | int (*hard_reset)(struct orinoco_private *), | 178 | int (*hard_reset)(struct orinoco_private *), |
188 | int (*stop_fw)(struct orinoco_private *, int)); | 179 | int (*stop_fw)(struct orinoco_private *, int)); |
189 | extern void free_orinocodev(struct net_device *dev); | 180 | extern void free_orinocodev(struct orinoco_private *priv); |
190 | extern int __orinoco_up(struct net_device *dev); | 181 | extern int orinoco_init(struct orinoco_private *priv); |
191 | extern int __orinoco_down(struct net_device *dev); | 182 | extern int orinoco_if_add(struct orinoco_private *priv, |
192 | extern int orinoco_reinit_firmware(struct net_device *dev); | 183 | unsigned long base_addr, |
184 | unsigned int irq); | ||
185 | extern void orinoco_if_del(struct orinoco_private *priv); | ||
186 | extern int orinoco_up(struct orinoco_private *priv); | ||
187 | extern void orinoco_down(struct orinoco_private *priv); | ||
193 | extern irqreturn_t orinoco_interrupt(int irq, void *dev_id); | 188 | extern irqreturn_t orinoco_interrupt(int irq, void *dev_id); |
194 | 189 | ||
195 | /********************************************************************/ | 190 | /********************************************************************/ |
@@ -215,4 +210,10 @@ static inline void orinoco_unlock(struct orinoco_private *priv, | |||
215 | spin_unlock_irqrestore(&priv->lock, *flags); | 210 | spin_unlock_irqrestore(&priv->lock, *flags); |
216 | } | 211 | } |
217 | 212 | ||
213 | /*** Navigate from net_device to orinoco_private ***/ | ||
214 | static inline struct orinoco_private *ndev_priv(struct net_device *dev) | ||
215 | { | ||
216 | struct wireless_dev *wdev = netdev_priv(dev); | ||
217 | return wdev_priv(wdev); | ||
218 | } | ||
218 | #endif /* _ORINOCO_H */ | 219 | #endif /* _ORINOCO_H */ |
diff --git a/drivers/net/wireless/orinoco/orinoco_cs.c b/drivers/net/wireless/orinoco/orinoco_cs.c index b381aed24d73..38c1c9d2abb8 100644 --- a/drivers/net/wireless/orinoco/orinoco_cs.c +++ b/drivers/net/wireless/orinoco/orinoco_cs.c | |||
@@ -106,26 +106,24 @@ orinoco_cs_hard_reset(struct orinoco_private *priv) | |||
106 | static int | 106 | static int |
107 | orinoco_cs_probe(struct pcmcia_device *link) | 107 | orinoco_cs_probe(struct pcmcia_device *link) |
108 | { | 108 | { |
109 | struct net_device *dev; | ||
110 | struct orinoco_private *priv; | 109 | struct orinoco_private *priv; |
111 | struct orinoco_pccard *card; | 110 | struct orinoco_pccard *card; |
112 | 111 | ||
113 | dev = alloc_orinocodev(sizeof(*card), &handle_to_dev(link), | 112 | priv = alloc_orinocodev(sizeof(*card), &handle_to_dev(link), |
114 | orinoco_cs_hard_reset, NULL); | 113 | orinoco_cs_hard_reset, NULL); |
115 | if (!dev) | 114 | if (!priv) |
116 | return -ENOMEM; | 115 | return -ENOMEM; |
117 | priv = netdev_priv(dev); | ||
118 | card = priv->card; | 116 | card = priv->card; |
119 | 117 | ||
120 | /* Link both structures together */ | 118 | /* Link both structures together */ |
121 | card->p_dev = link; | 119 | card->p_dev = link; |
122 | link->priv = dev; | 120 | link->priv = priv; |
123 | 121 | ||
124 | /* Interrupt setup */ | 122 | /* Interrupt setup */ |
125 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; | 123 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; |
126 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 124 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
127 | link->irq.Handler = orinoco_interrupt; | 125 | link->irq.Handler = orinoco_interrupt; |
128 | link->irq.Instance = dev; | 126 | link->irq.Instance = priv; |
129 | 127 | ||
130 | /* General socket configuration defaults can go here. In this | 128 | /* General socket configuration defaults can go here. In this |
131 | * client, we assume very little, and rely on the CIS for | 129 | * client, we assume very little, and rely on the CIS for |
@@ -146,14 +144,14 @@ orinoco_cs_probe(struct pcmcia_device *link) | |||
146 | */ | 144 | */ |
147 | static void orinoco_cs_detach(struct pcmcia_device *link) | 145 | static void orinoco_cs_detach(struct pcmcia_device *link) |
148 | { | 146 | { |
149 | struct net_device *dev = link->priv; | 147 | struct orinoco_private *priv = link->priv; |
150 | 148 | ||
151 | if (link->dev_node) | 149 | if (link->dev_node) |
152 | unregister_netdev(dev); | 150 | orinoco_if_del(priv); |
153 | 151 | ||
154 | orinoco_cs_release(link); | 152 | orinoco_cs_release(link); |
155 | 153 | ||
156 | free_orinocodev(dev); | 154 | free_orinocodev(priv); |
157 | } /* orinoco_cs_detach */ | 155 | } /* orinoco_cs_detach */ |
158 | 156 | ||
159 | /* | 157 | /* |
@@ -239,8 +237,7 @@ next_entry: | |||
239 | static int | 237 | static int |
240 | orinoco_cs_config(struct pcmcia_device *link) | 238 | orinoco_cs_config(struct pcmcia_device *link) |
241 | { | 239 | { |
242 | struct net_device *dev = link->priv; | 240 | struct orinoco_private *priv = link->priv; |
243 | struct orinoco_private *priv = netdev_priv(dev); | ||
244 | struct orinoco_pccard *card = priv->card; | 241 | struct orinoco_pccard *card = priv->card; |
245 | hermes_t *hw = &priv->hw; | 242 | hermes_t *hw = &priv->hw; |
246 | int last_fn, last_ret; | 243 | int last_fn, last_ret; |
@@ -295,29 +292,27 @@ orinoco_cs_config(struct pcmcia_device *link) | |||
295 | pcmcia_request_configuration(link, &link->conf)); | 292 | pcmcia_request_configuration(link, &link->conf)); |
296 | 293 | ||
297 | /* Ok, we have the configuration, prepare to register the netdev */ | 294 | /* Ok, we have the configuration, prepare to register the netdev */ |
298 | dev->base_addr = link->io.BasePort1; | ||
299 | dev->irq = link->irq.AssignedIRQ; | ||
300 | card->node.major = card->node.minor = 0; | 295 | card->node.major = card->node.minor = 0; |
301 | 296 | ||
302 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); | 297 | /* Initialise the main driver */ |
303 | /* Tell the stack we exist */ | 298 | if (orinoco_init(priv) != 0) { |
304 | if (register_netdev(dev) != 0) { | 299 | printk(KERN_ERR PFX "orinoco_init() failed\n"); |
305 | printk(KERN_ERR PFX "register_netdev() failed\n"); | 300 | goto failed; |
301 | } | ||
302 | |||
303 | /* Register an interface with the stack */ | ||
304 | if (orinoco_if_add(priv, link->io.BasePort1, | ||
305 | link->irq.AssignedIRQ) != 0) { | ||
306 | printk(KERN_ERR PFX "orinoco_if_add() failed\n"); | ||
306 | goto failed; | 307 | goto failed; |
307 | } | 308 | } |
308 | 309 | ||
309 | /* At this point, the dev_node_t structure(s) needs to be | 310 | /* At this point, the dev_node_t structure(s) needs to be |
310 | * initialized and arranged in a linked list at link->dev_node. */ | 311 | * initialized and arranged in a linked list at link->dev_node. */ |
311 | strcpy(card->node.dev_name, dev->name); | 312 | strcpy(card->node.dev_name, priv->ndev->name); |
312 | link->dev_node = &card->node; /* link->dev_node being non-NULL is also | 313 | link->dev_node = &card->node; /* link->dev_node being non-NULL is also |
313 | * used to indicate that the | 314 | * used to indicate that the |
314 | * net_device has been registered */ | 315 | * net_device has been registered */ |
315 | |||
316 | /* Finally, report what we've done */ | ||
317 | printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " | ||
318 | "0x%04x-0x%04x\n", dev->name, dev_name(dev->dev.parent), | ||
319 | link->irq.AssignedIRQ, link->io.BasePort1, | ||
320 | link->io.BasePort1 + link->io.NumPorts1 - 1); | ||
321 | return 0; | 316 | return 0; |
322 | 317 | ||
323 | cs_failed: | 318 | cs_failed: |
@@ -336,8 +331,7 @@ orinoco_cs_config(struct pcmcia_device *link) | |||
336 | static void | 331 | static void |
337 | orinoco_cs_release(struct pcmcia_device *link) | 332 | orinoco_cs_release(struct pcmcia_device *link) |
338 | { | 333 | { |
339 | struct net_device *dev = link->priv; | 334 | struct orinoco_private *priv = link->priv; |
340 | struct orinoco_private *priv = netdev_priv(dev); | ||
341 | unsigned long flags; | 335 | unsigned long flags; |
342 | 336 | ||
343 | /* We're committed to taking the device away now, so mark the | 337 | /* We're committed to taking the device away now, so mark the |
@@ -353,62 +347,26 @@ orinoco_cs_release(struct pcmcia_device *link) | |||
353 | 347 | ||
354 | static int orinoco_cs_suspend(struct pcmcia_device *link) | 348 | static int orinoco_cs_suspend(struct pcmcia_device *link) |
355 | { | 349 | { |
356 | struct net_device *dev = link->priv; | 350 | struct orinoco_private *priv = link->priv; |
357 | struct orinoco_private *priv = netdev_priv(dev); | ||
358 | struct orinoco_pccard *card = priv->card; | 351 | struct orinoco_pccard *card = priv->card; |
359 | int err = 0; | ||
360 | unsigned long flags; | ||
361 | 352 | ||
362 | /* This is probably racy, but I can't think of | 353 | /* This is probably racy, but I can't think of |
363 | a better way, short of rewriting the PCMCIA | 354 | a better way, short of rewriting the PCMCIA |
364 | layer to not suck :-( */ | 355 | layer to not suck :-( */ |
365 | if (!test_bit(0, &card->hard_reset_in_progress)) { | 356 | if (!test_bit(0, &card->hard_reset_in_progress)) |
366 | spin_lock_irqsave(&priv->lock, flags); | 357 | orinoco_down(priv); |
367 | |||
368 | err = __orinoco_down(dev); | ||
369 | if (err) | ||
370 | printk(KERN_WARNING "%s: Error %d downing interface\n", | ||
371 | dev->name, err); | ||
372 | |||
373 | netif_device_detach(dev); | ||
374 | priv->hw_unavailable++; | ||
375 | |||
376 | spin_unlock_irqrestore(&priv->lock, flags); | ||
377 | } | ||
378 | 358 | ||
379 | return 0; | 359 | return 0; |
380 | } | 360 | } |
381 | 361 | ||
382 | static int orinoco_cs_resume(struct pcmcia_device *link) | 362 | static int orinoco_cs_resume(struct pcmcia_device *link) |
383 | { | 363 | { |
384 | struct net_device *dev = link->priv; | 364 | struct orinoco_private *priv = link->priv; |
385 | struct orinoco_private *priv = netdev_priv(dev); | ||
386 | struct orinoco_pccard *card = priv->card; | 365 | struct orinoco_pccard *card = priv->card; |
387 | int err = 0; | 366 | int err = 0; |
388 | unsigned long flags; | ||
389 | |||
390 | if (!test_bit(0, &card->hard_reset_in_progress)) { | ||
391 | err = orinoco_reinit_firmware(dev); | ||
392 | if (err) { | ||
393 | printk(KERN_ERR "%s: Error %d re-initializing firmware\n", | ||
394 | dev->name, err); | ||
395 | return -EIO; | ||
396 | } | ||
397 | |||
398 | spin_lock_irqsave(&priv->lock, flags); | ||
399 | 367 | ||
400 | netif_device_attach(dev); | 368 | if (!test_bit(0, &card->hard_reset_in_progress)) |
401 | priv->hw_unavailable--; | 369 | err = orinoco_up(priv); |
402 | |||
403 | if (priv->open && !priv->hw_unavailable) { | ||
404 | err = __orinoco_up(dev); | ||
405 | if (err) | ||
406 | printk(KERN_ERR "%s: Error %d restarting card\n", | ||
407 | dev->name, err); | ||
408 | } | ||
409 | |||
410 | spin_unlock_irqrestore(&priv->lock, flags); | ||
411 | } | ||
412 | 370 | ||
413 | return err; | 371 | return err; |
414 | } | 372 | } |
diff --git a/drivers/net/wireless/orinoco/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c index b01726255c6f..c13a4c383410 100644 --- a/drivers/net/wireless/orinoco/orinoco_nortel.c +++ b/drivers/net/wireless/orinoco/orinoco_nortel.c | |||
@@ -144,7 +144,6 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev, | |||
144 | int err; | 144 | int err; |
145 | struct orinoco_private *priv; | 145 | struct orinoco_private *priv; |
146 | struct orinoco_pci_card *card; | 146 | struct orinoco_pci_card *card; |
147 | struct net_device *dev; | ||
148 | void __iomem *hermes_io, *bridge_io, *attr_io; | 147 | void __iomem *hermes_io, *bridge_io, *attr_io; |
149 | 148 | ||
150 | err = pci_enable_device(pdev); | 149 | err = pci_enable_device(pdev); |
@@ -181,24 +180,22 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev, | |||
181 | } | 180 | } |
182 | 181 | ||
183 | /* Allocate network device */ | 182 | /* Allocate network device */ |
184 | dev = alloc_orinocodev(sizeof(*card), &pdev->dev, | 183 | priv = alloc_orinocodev(sizeof(*card), &pdev->dev, |
185 | orinoco_nortel_cor_reset, NULL); | 184 | orinoco_nortel_cor_reset, NULL); |
186 | if (!dev) { | 185 | if (!priv) { |
187 | printk(KERN_ERR PFX "Cannot allocate network device\n"); | 186 | printk(KERN_ERR PFX "Cannot allocate network device\n"); |
188 | err = -ENOMEM; | 187 | err = -ENOMEM; |
189 | goto fail_alloc; | 188 | goto fail_alloc; |
190 | } | 189 | } |
191 | 190 | ||
192 | priv = netdev_priv(dev); | ||
193 | card = priv->card; | 191 | card = priv->card; |
194 | card->bridge_io = bridge_io; | 192 | card->bridge_io = bridge_io; |
195 | card->attr_io = attr_io; | 193 | card->attr_io = attr_io; |
196 | SET_NETDEV_DEV(dev, &pdev->dev); | ||
197 | 194 | ||
198 | hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); | 195 | hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); |
199 | 196 | ||
200 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, | 197 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, |
201 | dev->name, dev); | 198 | DRIVER_NAME, priv); |
202 | if (err) { | 199 | if (err) { |
203 | printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); | 200 | printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); |
204 | err = -EBUSY; | 201 | err = -EBUSY; |
@@ -217,24 +214,28 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev, | |||
217 | goto fail; | 214 | goto fail; |
218 | } | 215 | } |
219 | 216 | ||
220 | err = register_netdev(dev); | 217 | err = orinoco_init(priv); |
221 | if (err) { | 218 | if (err) { |
222 | printk(KERN_ERR PFX "Cannot register network device\n"); | 219 | printk(KERN_ERR PFX "orinoco_init() failed\n"); |
223 | goto fail; | 220 | goto fail; |
224 | } | 221 | } |
225 | 222 | ||
226 | pci_set_drvdata(pdev, dev); | 223 | err = orinoco_if_add(priv, 0, 0); |
227 | printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name, | 224 | if (err) { |
228 | pci_name(pdev)); | 225 | printk(KERN_ERR PFX "orinoco_if_add() failed\n"); |
226 | goto fail; | ||
227 | } | ||
228 | |||
229 | pci_set_drvdata(pdev, priv); | ||
229 | 230 | ||
230 | return 0; | 231 | return 0; |
231 | 232 | ||
232 | fail: | 233 | fail: |
233 | free_irq(pdev->irq, dev); | 234 | free_irq(pdev->irq, priv); |
234 | 235 | ||
235 | fail_irq: | 236 | fail_irq: |
236 | pci_set_drvdata(pdev, NULL); | 237 | pci_set_drvdata(pdev, NULL); |
237 | free_orinocodev(dev); | 238 | free_orinocodev(priv); |
238 | 239 | ||
239 | fail_alloc: | 240 | fail_alloc: |
240 | pci_iounmap(pdev, hermes_io); | 241 | pci_iounmap(pdev, hermes_io); |
@@ -256,17 +257,16 @@ static int orinoco_nortel_init_one(struct pci_dev *pdev, | |||
256 | 257 | ||
257 | static void __devexit orinoco_nortel_remove_one(struct pci_dev *pdev) | 258 | static void __devexit orinoco_nortel_remove_one(struct pci_dev *pdev) |
258 | { | 259 | { |
259 | struct net_device *dev = pci_get_drvdata(pdev); | 260 | struct orinoco_private *priv = pci_get_drvdata(pdev); |
260 | struct orinoco_private *priv = netdev_priv(dev); | ||
261 | struct orinoco_pci_card *card = priv->card; | 261 | struct orinoco_pci_card *card = priv->card; |
262 | 262 | ||
263 | /* Clear LEDs */ | 263 | /* Clear LEDs */ |
264 | iowrite16(0, card->bridge_io + 10); | 264 | iowrite16(0, card->bridge_io + 10); |
265 | 265 | ||
266 | unregister_netdev(dev); | 266 | orinoco_if_del(priv); |
267 | free_irq(pdev->irq, dev); | 267 | free_irq(pdev->irq, priv); |
268 | pci_set_drvdata(pdev, NULL); | 268 | pci_set_drvdata(pdev, NULL); |
269 | free_orinocodev(dev); | 269 | free_orinocodev(priv); |
270 | pci_iounmap(pdev, priv->hw.iobase); | 270 | pci_iounmap(pdev, priv->hw.iobase); |
271 | pci_iounmap(pdev, card->attr_io); | 271 | pci_iounmap(pdev, card->attr_io); |
272 | pci_iounmap(pdev, card->bridge_io); | 272 | pci_iounmap(pdev, card->bridge_io); |
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c index 78cafff1fb2e..fea7781948e7 100644 --- a/drivers/net/wireless/orinoco/orinoco_pci.c +++ b/drivers/net/wireless/orinoco/orinoco_pci.c | |||
@@ -116,7 +116,6 @@ static int orinoco_pci_init_one(struct pci_dev *pdev, | |||
116 | int err; | 116 | int err; |
117 | struct orinoco_private *priv; | 117 | struct orinoco_private *priv; |
118 | struct orinoco_pci_card *card; | 118 | struct orinoco_pci_card *card; |
119 | struct net_device *dev; | ||
120 | void __iomem *hermes_io; | 119 | void __iomem *hermes_io; |
121 | 120 | ||
122 | err = pci_enable_device(pdev); | 121 | err = pci_enable_device(pdev); |
@@ -139,22 +138,20 @@ static int orinoco_pci_init_one(struct pci_dev *pdev, | |||
139 | } | 138 | } |
140 | 139 | ||
141 | /* Allocate network device */ | 140 | /* Allocate network device */ |
142 | dev = alloc_orinocodev(sizeof(*card), &pdev->dev, | 141 | priv = alloc_orinocodev(sizeof(*card), &pdev->dev, |
143 | orinoco_pci_cor_reset, NULL); | 142 | orinoco_pci_cor_reset, NULL); |
144 | if (!dev) { | 143 | if (!priv) { |
145 | printk(KERN_ERR PFX "Cannot allocate network device\n"); | 144 | printk(KERN_ERR PFX "Cannot allocate network device\n"); |
146 | err = -ENOMEM; | 145 | err = -ENOMEM; |
147 | goto fail_alloc; | 146 | goto fail_alloc; |
148 | } | 147 | } |
149 | 148 | ||
150 | priv = netdev_priv(dev); | ||
151 | card = priv->card; | 149 | card = priv->card; |
152 | SET_NETDEV_DEV(dev, &pdev->dev); | ||
153 | 150 | ||
154 | hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING); | 151 | hermes_struct_init(&priv->hw, hermes_io, HERMES_32BIT_REGSPACING); |
155 | 152 | ||
156 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, | 153 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, |
157 | dev->name, dev); | 154 | DRIVER_NAME, priv); |
158 | if (err) { | 155 | if (err) { |
159 | printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); | 156 | printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); |
160 | err = -EBUSY; | 157 | err = -EBUSY; |
@@ -167,24 +164,28 @@ static int orinoco_pci_init_one(struct pci_dev *pdev, | |||
167 | goto fail; | 164 | goto fail; |
168 | } | 165 | } |
169 | 166 | ||
170 | err = register_netdev(dev); | 167 | err = orinoco_init(priv); |
171 | if (err) { | 168 | if (err) { |
172 | printk(KERN_ERR PFX "Cannot register network device\n"); | 169 | printk(KERN_ERR PFX "orinoco_init() failed\n"); |
173 | goto fail; | 170 | goto fail; |
174 | } | 171 | } |
175 | 172 | ||
176 | pci_set_drvdata(pdev, dev); | 173 | err = orinoco_if_add(priv, 0, 0); |
177 | printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name, | 174 | if (err) { |
178 | pci_name(pdev)); | 175 | printk(KERN_ERR PFX "orinoco_if_add() failed\n"); |
176 | goto fail; | ||
177 | } | ||
178 | |||
179 | pci_set_drvdata(pdev, priv); | ||
179 | 180 | ||
180 | return 0; | 181 | return 0; |
181 | 182 | ||
182 | fail: | 183 | fail: |
183 | free_irq(pdev->irq, dev); | 184 | free_irq(pdev->irq, priv); |
184 | 185 | ||
185 | fail_irq: | 186 | fail_irq: |
186 | pci_set_drvdata(pdev, NULL); | 187 | pci_set_drvdata(pdev, NULL); |
187 | free_orinocodev(dev); | 188 | free_orinocodev(priv); |
188 | 189 | ||
189 | fail_alloc: | 190 | fail_alloc: |
190 | pci_iounmap(pdev, hermes_io); | 191 | pci_iounmap(pdev, hermes_io); |
@@ -200,13 +201,12 @@ static int orinoco_pci_init_one(struct pci_dev *pdev, | |||
200 | 201 | ||
201 | static void __devexit orinoco_pci_remove_one(struct pci_dev *pdev) | 202 | static void __devexit orinoco_pci_remove_one(struct pci_dev *pdev) |
202 | { | 203 | { |
203 | struct net_device *dev = pci_get_drvdata(pdev); | 204 | struct orinoco_private *priv = pci_get_drvdata(pdev); |
204 | struct orinoco_private *priv = netdev_priv(dev); | ||
205 | 205 | ||
206 | unregister_netdev(dev); | 206 | orinoco_if_del(priv); |
207 | free_irq(pdev->irq, dev); | 207 | free_irq(pdev->irq, priv); |
208 | pci_set_drvdata(pdev, NULL); | 208 | pci_set_drvdata(pdev, NULL); |
209 | free_orinocodev(dev); | 209 | free_orinocodev(priv); |
210 | pci_iounmap(pdev, priv->hw.iobase); | 210 | pci_iounmap(pdev, priv->hw.iobase); |
211 | pci_release_regions(pdev); | 211 | pci_release_regions(pdev); |
212 | pci_disable_device(pdev); | 212 | pci_disable_device(pdev); |
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.h b/drivers/net/wireless/orinoco/orinoco_pci.h index c655b4a3de16..ea7231af40a8 100644 --- a/drivers/net/wireless/orinoco/orinoco_pci.h +++ b/drivers/net/wireless/orinoco/orinoco_pci.h | |||
@@ -21,30 +21,10 @@ struct orinoco_pci_card { | |||
21 | #ifdef CONFIG_PM | 21 | #ifdef CONFIG_PM |
22 | static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state) | 22 | static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state) |
23 | { | 23 | { |
24 | struct net_device *dev = pci_get_drvdata(pdev); | 24 | struct orinoco_private *priv = pci_get_drvdata(pdev); |
25 | struct orinoco_private *priv = netdev_priv(dev); | ||
26 | unsigned long flags; | ||
27 | int err; | ||
28 | |||
29 | err = orinoco_lock(priv, &flags); | ||
30 | if (err) { | ||
31 | printk(KERN_ERR "%s: cannot lock hardware for suspend\n", | ||
32 | dev->name); | ||
33 | return err; | ||
34 | } | ||
35 | |||
36 | err = __orinoco_down(dev); | ||
37 | if (err) | ||
38 | printk(KERN_WARNING "%s: error %d bringing interface down " | ||
39 | "for suspend\n", dev->name, err); | ||
40 | |||
41 | netif_device_detach(dev); | ||
42 | |||
43 | priv->hw_unavailable++; | ||
44 | |||
45 | orinoco_unlock(priv, &flags); | ||
46 | 25 | ||
47 | free_irq(pdev->irq, dev); | 26 | orinoco_down(priv); |
27 | free_irq(pdev->irq, priv); | ||
48 | pci_save_state(pdev); | 28 | pci_save_state(pdev); |
49 | pci_disable_device(pdev); | 29 | pci_disable_device(pdev); |
50 | pci_set_power_state(pdev, PCI_D3hot); | 30 | pci_set_power_state(pdev, PCI_D3hot); |
@@ -54,9 +34,8 @@ static int orinoco_pci_suspend(struct pci_dev *pdev, pm_message_t state) | |||
54 | 34 | ||
55 | static int orinoco_pci_resume(struct pci_dev *pdev) | 35 | static int orinoco_pci_resume(struct pci_dev *pdev) |
56 | { | 36 | { |
57 | struct net_device *dev = pci_get_drvdata(pdev); | 37 | struct orinoco_private *priv = pci_get_drvdata(pdev); |
58 | struct orinoco_private *priv = netdev_priv(dev); | 38 | struct net_device *dev = priv->ndev; |
59 | unsigned long flags; | ||
60 | int err; | 39 | int err; |
61 | 40 | ||
62 | pci_set_power_state(pdev, 0); | 41 | pci_set_power_state(pdev, 0); |
@@ -69,7 +48,7 @@ static int orinoco_pci_resume(struct pci_dev *pdev) | |||
69 | pci_restore_state(pdev); | 48 | pci_restore_state(pdev); |
70 | 49 | ||
71 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, | 50 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, |
72 | dev->name, dev); | 51 | dev->name, priv); |
73 | if (err) { | 52 | if (err) { |
74 | printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n", | 53 | printk(KERN_ERR "%s: cannot re-allocate IRQ on resume\n", |
75 | dev->name); | 54 | dev->name); |
@@ -77,29 +56,9 @@ static int orinoco_pci_resume(struct pci_dev *pdev) | |||
77 | return -EBUSY; | 56 | return -EBUSY; |
78 | } | 57 | } |
79 | 58 | ||
80 | err = orinoco_reinit_firmware(dev); | 59 | err = orinoco_up(priv); |
81 | if (err) { | ||
82 | printk(KERN_ERR "%s: error %d re-initializing firmware " | ||
83 | "on resume\n", dev->name, err); | ||
84 | return err; | ||
85 | } | ||
86 | |||
87 | spin_lock_irqsave(&priv->lock, flags); | ||
88 | |||
89 | netif_device_attach(dev); | ||
90 | 60 | ||
91 | priv->hw_unavailable--; | 61 | return err; |
92 | |||
93 | if (priv->open && (!priv->hw_unavailable)) { | ||
94 | err = __orinoco_up(dev); | ||
95 | if (err) | ||
96 | printk(KERN_ERR "%s: Error %d restarting card on resume\n", | ||
97 | dev->name, err); | ||
98 | } | ||
99 | |||
100 | spin_unlock_irqrestore(&priv->lock, flags); | ||
101 | |||
102 | return 0; | ||
103 | } | 62 | } |
104 | #else | 63 | #else |
105 | #define orinoco_pci_suspend NULL | 64 | #define orinoco_pci_suspend NULL |
diff --git a/drivers/net/wireless/orinoco/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c index a2a4471c0337..3f2942a1e4f5 100644 --- a/drivers/net/wireless/orinoco/orinoco_plx.c +++ b/drivers/net/wireless/orinoco/orinoco_plx.c | |||
@@ -183,7 +183,6 @@ static int orinoco_plx_init_one(struct pci_dev *pdev, | |||
183 | int err; | 183 | int err; |
184 | struct orinoco_private *priv; | 184 | struct orinoco_private *priv; |
185 | struct orinoco_pci_card *card; | 185 | struct orinoco_pci_card *card; |
186 | struct net_device *dev; | ||
187 | void __iomem *hermes_io, *attr_io, *bridge_io; | 186 | void __iomem *hermes_io, *attr_io, *bridge_io; |
188 | 187 | ||
189 | err = pci_enable_device(pdev); | 188 | err = pci_enable_device(pdev); |
@@ -220,24 +219,22 @@ static int orinoco_plx_init_one(struct pci_dev *pdev, | |||
220 | } | 219 | } |
221 | 220 | ||
222 | /* Allocate network device */ | 221 | /* Allocate network device */ |
223 | dev = alloc_orinocodev(sizeof(*card), &pdev->dev, | 222 | priv = alloc_orinocodev(sizeof(*card), &pdev->dev, |
224 | orinoco_plx_cor_reset, NULL); | 223 | orinoco_plx_cor_reset, NULL); |
225 | if (!dev) { | 224 | if (!priv) { |
226 | printk(KERN_ERR PFX "Cannot allocate network device\n"); | 225 | printk(KERN_ERR PFX "Cannot allocate network device\n"); |
227 | err = -ENOMEM; | 226 | err = -ENOMEM; |
228 | goto fail_alloc; | 227 | goto fail_alloc; |
229 | } | 228 | } |
230 | 229 | ||
231 | priv = netdev_priv(dev); | ||
232 | card = priv->card; | 230 | card = priv->card; |
233 | card->bridge_io = bridge_io; | 231 | card->bridge_io = bridge_io; |
234 | card->attr_io = attr_io; | 232 | card->attr_io = attr_io; |
235 | SET_NETDEV_DEV(dev, &pdev->dev); | ||
236 | 233 | ||
237 | hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); | 234 | hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); |
238 | 235 | ||
239 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, | 236 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, |
240 | dev->name, dev); | 237 | DRIVER_NAME, priv); |
241 | if (err) { | 238 | if (err) { |
242 | printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); | 239 | printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); |
243 | err = -EBUSY; | 240 | err = -EBUSY; |
@@ -256,24 +253,28 @@ static int orinoco_plx_init_one(struct pci_dev *pdev, | |||
256 | goto fail; | 253 | goto fail; |
257 | } | 254 | } |
258 | 255 | ||
259 | err = register_netdev(dev); | 256 | err = orinoco_init(priv); |
260 | if (err) { | 257 | if (err) { |
261 | printk(KERN_ERR PFX "Cannot register network device\n"); | 258 | printk(KERN_ERR PFX "orinoco_init() failed\n"); |
262 | goto fail; | 259 | goto fail; |
263 | } | 260 | } |
264 | 261 | ||
265 | pci_set_drvdata(pdev, dev); | 262 | err = orinoco_if_add(priv, 0, 0); |
266 | printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name, | 263 | if (err) { |
267 | pci_name(pdev)); | 264 | printk(KERN_ERR PFX "orinoco_if_add() failed\n"); |
265 | goto fail; | ||
266 | } | ||
267 | |||
268 | pci_set_drvdata(pdev, priv); | ||
268 | 269 | ||
269 | return 0; | 270 | return 0; |
270 | 271 | ||
271 | fail: | 272 | fail: |
272 | free_irq(pdev->irq, dev); | 273 | free_irq(pdev->irq, priv); |
273 | 274 | ||
274 | fail_irq: | 275 | fail_irq: |
275 | pci_set_drvdata(pdev, NULL); | 276 | pci_set_drvdata(pdev, NULL); |
276 | free_orinocodev(dev); | 277 | free_orinocodev(priv); |
277 | 278 | ||
278 | fail_alloc: | 279 | fail_alloc: |
279 | pci_iounmap(pdev, hermes_io); | 280 | pci_iounmap(pdev, hermes_io); |
@@ -295,14 +296,13 @@ static int orinoco_plx_init_one(struct pci_dev *pdev, | |||
295 | 296 | ||
296 | static void __devexit orinoco_plx_remove_one(struct pci_dev *pdev) | 297 | static void __devexit orinoco_plx_remove_one(struct pci_dev *pdev) |
297 | { | 298 | { |
298 | struct net_device *dev = pci_get_drvdata(pdev); | 299 | struct orinoco_private *priv = pci_get_drvdata(pdev); |
299 | struct orinoco_private *priv = netdev_priv(dev); | ||
300 | struct orinoco_pci_card *card = priv->card; | 300 | struct orinoco_pci_card *card = priv->card; |
301 | 301 | ||
302 | unregister_netdev(dev); | 302 | orinoco_if_del(priv); |
303 | free_irq(pdev->irq, dev); | 303 | free_irq(pdev->irq, priv); |
304 | pci_set_drvdata(pdev, NULL); | 304 | pci_set_drvdata(pdev, NULL); |
305 | free_orinocodev(dev); | 305 | free_orinocodev(priv); |
306 | pci_iounmap(pdev, priv->hw.iobase); | 306 | pci_iounmap(pdev, priv->hw.iobase); |
307 | pci_iounmap(pdev, card->attr_io); | 307 | pci_iounmap(pdev, card->attr_io); |
308 | pci_iounmap(pdev, card->bridge_io); | 308 | pci_iounmap(pdev, card->bridge_io); |
diff --git a/drivers/net/wireless/orinoco/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c index cda0e6e4d7a1..d3452548cc71 100644 --- a/drivers/net/wireless/orinoco/orinoco_tmd.c +++ b/drivers/net/wireless/orinoco/orinoco_tmd.c | |||
@@ -94,7 +94,6 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev, | |||
94 | int err; | 94 | int err; |
95 | struct orinoco_private *priv; | 95 | struct orinoco_private *priv; |
96 | struct orinoco_pci_card *card; | 96 | struct orinoco_pci_card *card; |
97 | struct net_device *dev; | ||
98 | void __iomem *hermes_io, *bridge_io; | 97 | void __iomem *hermes_io, *bridge_io; |
99 | 98 | ||
100 | err = pci_enable_device(pdev); | 99 | err = pci_enable_device(pdev); |
@@ -124,23 +123,21 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev, | |||
124 | } | 123 | } |
125 | 124 | ||
126 | /* Allocate network device */ | 125 | /* Allocate network device */ |
127 | dev = alloc_orinocodev(sizeof(*card), &pdev->dev, | 126 | priv = alloc_orinocodev(sizeof(*card), &pdev->dev, |
128 | orinoco_tmd_cor_reset, NULL); | 127 | orinoco_tmd_cor_reset, NULL); |
129 | if (!dev) { | 128 | if (!priv) { |
130 | printk(KERN_ERR PFX "Cannot allocate network device\n"); | 129 | printk(KERN_ERR PFX "Cannot allocate network device\n"); |
131 | err = -ENOMEM; | 130 | err = -ENOMEM; |
132 | goto fail_alloc; | 131 | goto fail_alloc; |
133 | } | 132 | } |
134 | 133 | ||
135 | priv = netdev_priv(dev); | ||
136 | card = priv->card; | 134 | card = priv->card; |
137 | card->bridge_io = bridge_io; | 135 | card->bridge_io = bridge_io; |
138 | SET_NETDEV_DEV(dev, &pdev->dev); | ||
139 | 136 | ||
140 | hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); | 137 | hermes_struct_init(&priv->hw, hermes_io, HERMES_16BIT_REGSPACING); |
141 | 138 | ||
142 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, | 139 | err = request_irq(pdev->irq, orinoco_interrupt, IRQF_SHARED, |
143 | dev->name, dev); | 140 | DRIVER_NAME, priv); |
144 | if (err) { | 141 | if (err) { |
145 | printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); | 142 | printk(KERN_ERR PFX "Cannot allocate IRQ %d\n", pdev->irq); |
146 | err = -EBUSY; | 143 | err = -EBUSY; |
@@ -153,24 +150,28 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev, | |||
153 | goto fail; | 150 | goto fail; |
154 | } | 151 | } |
155 | 152 | ||
156 | err = register_netdev(dev); | 153 | err = orinoco_init(priv); |
157 | if (err) { | 154 | if (err) { |
158 | printk(KERN_ERR PFX "Cannot register network device\n"); | 155 | printk(KERN_ERR PFX "orinoco_init() failed\n"); |
159 | goto fail; | 156 | goto fail; |
160 | } | 157 | } |
161 | 158 | ||
162 | pci_set_drvdata(pdev, dev); | 159 | err = orinoco_if_add(priv, 0, 0); |
163 | printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s\n", dev->name, | 160 | if (err) { |
164 | pci_name(pdev)); | 161 | printk(KERN_ERR PFX "orinoco_if_add() failed\n"); |
162 | goto fail; | ||
163 | } | ||
164 | |||
165 | pci_set_drvdata(pdev, priv); | ||
165 | 166 | ||
166 | return 0; | 167 | return 0; |
167 | 168 | ||
168 | fail: | 169 | fail: |
169 | free_irq(pdev->irq, dev); | 170 | free_irq(pdev->irq, priv); |
170 | 171 | ||
171 | fail_irq: | 172 | fail_irq: |
172 | pci_set_drvdata(pdev, NULL); | 173 | pci_set_drvdata(pdev, NULL); |
173 | free_orinocodev(dev); | 174 | free_orinocodev(priv); |
174 | 175 | ||
175 | fail_alloc: | 176 | fail_alloc: |
176 | pci_iounmap(pdev, hermes_io); | 177 | pci_iounmap(pdev, hermes_io); |
@@ -189,14 +190,13 @@ static int orinoco_tmd_init_one(struct pci_dev *pdev, | |||
189 | 190 | ||
190 | static void __devexit orinoco_tmd_remove_one(struct pci_dev *pdev) | 191 | static void __devexit orinoco_tmd_remove_one(struct pci_dev *pdev) |
191 | { | 192 | { |
192 | struct net_device *dev = pci_get_drvdata(pdev); | 193 | struct orinoco_private *priv = pci_get_drvdata(pdev); |
193 | struct orinoco_private *priv = netdev_priv(dev); | ||
194 | struct orinoco_pci_card *card = priv->card; | 194 | struct orinoco_pci_card *card = priv->card; |
195 | 195 | ||
196 | unregister_netdev(dev); | 196 | orinoco_if_del(priv); |
197 | free_irq(pdev->irq, dev); | 197 | free_irq(pdev->irq, priv); |
198 | pci_set_drvdata(pdev, NULL); | 198 | pci_set_drvdata(pdev, NULL); |
199 | free_orinocodev(dev); | 199 | free_orinocodev(priv); |
200 | pci_iounmap(pdev, priv->hw.iobase); | 200 | pci_iounmap(pdev, priv->hw.iobase); |
201 | pci_iounmap(pdev, card->bridge_io); | 201 | pci_iounmap(pdev, card->bridge_io); |
202 | pci_release_regions(pdev); | 202 | pci_release_regions(pdev); |
diff --git a/drivers/net/wireless/orinoco/scan.c b/drivers/net/wireless/orinoco/scan.c index 89d699d4dfe6..d2f10e9c2162 100644 --- a/drivers/net/wireless/orinoco/scan.c +++ b/drivers/net/wireless/orinoco/scan.c | |||
@@ -5,147 +5,166 @@ | |||
5 | 5 | ||
6 | #include <linux/kernel.h> | 6 | #include <linux/kernel.h> |
7 | #include <linux/string.h> | 7 | #include <linux/string.h> |
8 | #include <linux/etherdevice.h> | 8 | #include <linux/ieee80211.h> |
9 | #include <net/cfg80211.h> | ||
9 | 10 | ||
10 | #include "hermes.h" | 11 | #include "hermes.h" |
11 | #include "orinoco.h" | 12 | #include "orinoco.h" |
13 | #include "main.h" | ||
12 | 14 | ||
13 | #include "scan.h" | 15 | #include "scan.h" |
14 | 16 | ||
15 | #define ORINOCO_MAX_BSS_COUNT 64 | 17 | #define ZERO_DBM_OFFSET 0x95 |
18 | #define MAX_SIGNAL_LEVEL 0x8A | ||
19 | #define MIN_SIGNAL_LEVEL 0x2F | ||
16 | 20 | ||
17 | #define PRIV_BSS ((struct bss_element *)priv->bss_xbss_data) | 21 | #define SIGNAL_TO_DBM(x) \ |
18 | #define PRIV_XBSS ((struct xbss_element *)priv->bss_xbss_data) | 22 | (clamp_t(s32, (x), MIN_SIGNAL_LEVEL, MAX_SIGNAL_LEVEL) \ |
23 | - ZERO_DBM_OFFSET) | ||
24 | #define SIGNAL_TO_MBM(x) (SIGNAL_TO_DBM(x) * 100) | ||
19 | 25 | ||
20 | int orinoco_bss_data_allocate(struct orinoco_private *priv) | 26 | static int symbol_build_supp_rates(u8 *buf, const __le16 *rates) |
21 | { | 27 | { |
22 | if (priv->bss_xbss_data) | 28 | int i; |
23 | return 0; | 29 | u8 rate; |
24 | 30 | ||
25 | if (priv->has_ext_scan) | 31 | buf[0] = WLAN_EID_SUPP_RATES; |
26 | priv->bss_xbss_data = kzalloc(ORINOCO_MAX_BSS_COUNT * | 32 | for (i = 0; i < 5; i++) { |
27 | sizeof(struct xbss_element), | 33 | rate = le16_to_cpu(rates[i]); |
28 | GFP_KERNEL); | 34 | /* NULL terminated */ |
29 | else | 35 | if (rate == 0x0) |
30 | priv->bss_xbss_data = kzalloc(ORINOCO_MAX_BSS_COUNT * | 36 | break; |
31 | sizeof(struct bss_element), | 37 | buf[i + 2] = rate; |
32 | GFP_KERNEL); | ||
33 | |||
34 | if (!priv->bss_xbss_data) { | ||
35 | printk(KERN_WARNING "Out of memory allocating beacons"); | ||
36 | return -ENOMEM; | ||
37 | } | 38 | } |
38 | return 0; | 39 | buf[1] = i; |
39 | } | ||
40 | 40 | ||
41 | void orinoco_bss_data_free(struct orinoco_private *priv) | 41 | return i + 2; |
42 | { | ||
43 | kfree(priv->bss_xbss_data); | ||
44 | priv->bss_xbss_data = NULL; | ||
45 | } | 42 | } |
46 | 43 | ||
47 | void orinoco_bss_data_init(struct orinoco_private *priv) | 44 | static int prism_build_supp_rates(u8 *buf, const u8 *rates) |
48 | { | 45 | { |
49 | int i; | 46 | int i; |
50 | 47 | ||
51 | INIT_LIST_HEAD(&priv->bss_free_list); | 48 | buf[0] = WLAN_EID_SUPP_RATES; |
52 | INIT_LIST_HEAD(&priv->bss_list); | 49 | for (i = 0; i < 8; i++) { |
53 | if (priv->has_ext_scan) | 50 | /* NULL terminated */ |
54 | for (i = 0; i < ORINOCO_MAX_BSS_COUNT; i++) | 51 | if (rates[i] == 0x0) |
55 | list_add_tail(&(PRIV_XBSS[i].list), | 52 | break; |
56 | &priv->bss_free_list); | 53 | buf[i + 2] = rates[i]; |
57 | else | 54 | } |
58 | for (i = 0; i < ORINOCO_MAX_BSS_COUNT; i++) | 55 | buf[1] = i; |
59 | list_add_tail(&(PRIV_BSS[i].list), | 56 | |
60 | &priv->bss_free_list); | 57 | /* We might still have another 2 rates, which need to go in |
61 | 58 | * extended supported rates */ | |
62 | } | 59 | if (i == 8 && rates[i] > 0) { |
63 | 60 | buf[10] = WLAN_EID_EXT_SUPP_RATES; | |
64 | void orinoco_clear_scan_results(struct orinoco_private *priv, | 61 | for (; i < 10; i++) { |
65 | unsigned long scan_age) | 62 | /* NULL terminated */ |
66 | { | 63 | if (rates[i] == 0x0) |
67 | if (priv->has_ext_scan) { | 64 | break; |
68 | struct xbss_element *bss; | 65 | buf[i + 2] = rates[i]; |
69 | struct xbss_element *tmp_bss; | ||
70 | |||
71 | /* Blow away current list of scan results */ | ||
72 | list_for_each_entry_safe(bss, tmp_bss, &priv->bss_list, list) { | ||
73 | if (!scan_age || | ||
74 | time_after(jiffies, bss->last_scanned + scan_age)) { | ||
75 | list_move_tail(&bss->list, | ||
76 | &priv->bss_free_list); | ||
77 | /* Don't blow away ->list, just BSS data */ | ||
78 | memset(&bss->bss, 0, sizeof(bss->bss)); | ||
79 | bss->last_scanned = 0; | ||
80 | } | ||
81 | } | ||
82 | } else { | ||
83 | struct bss_element *bss; | ||
84 | struct bss_element *tmp_bss; | ||
85 | |||
86 | /* Blow away current list of scan results */ | ||
87 | list_for_each_entry_safe(bss, tmp_bss, &priv->bss_list, list) { | ||
88 | if (!scan_age || | ||
89 | time_after(jiffies, bss->last_scanned + scan_age)) { | ||
90 | list_move_tail(&bss->list, | ||
91 | &priv->bss_free_list); | ||
92 | /* Don't blow away ->list, just BSS data */ | ||
93 | memset(&bss->bss, 0, sizeof(bss->bss)); | ||
94 | bss->last_scanned = 0; | ||
95 | } | ||
96 | } | 66 | } |
67 | buf[11] = i - 8; | ||
97 | } | 68 | } |
69 | |||
70 | return (i < 8) ? i + 2 : i + 4; | ||
98 | } | 71 | } |
99 | 72 | ||
100 | void orinoco_add_ext_scan_result(struct orinoco_private *priv, | 73 | static void orinoco_add_hostscan_result(struct orinoco_private *priv, |
101 | struct agere_ext_scan_info *atom) | 74 | const union hermes_scan_info *bss) |
102 | { | 75 | { |
103 | struct xbss_element *bss = NULL; | 76 | struct wiphy *wiphy = priv_to_wiphy(priv); |
104 | int found = 0; | 77 | struct ieee80211_channel *channel; |
105 | 78 | u8 *ie; | |
106 | /* Try to update an existing bss first */ | 79 | u8 ie_buf[46]; |
107 | list_for_each_entry(bss, &priv->bss_list, list) { | 80 | u64 timestamp; |
108 | if (compare_ether_addr(bss->bss.bssid, atom->bssid)) | 81 | s32 signal; |
109 | continue; | 82 | u16 capability; |
110 | /* ESSID lengths */ | 83 | u16 beacon_interval; |
111 | if (bss->bss.data[1] != atom->data[1]) | 84 | int ie_len; |
112 | continue; | 85 | int freq; |
113 | if (memcmp(&bss->bss.data[2], &atom->data[2], | 86 | int len; |
114 | atom->data[1])) | 87 | |
115 | continue; | 88 | len = le16_to_cpu(bss->a.essid_len); |
116 | found = 1; | 89 | |
90 | /* Reconstruct SSID and bitrate IEs to pass up */ | ||
91 | ie_buf[0] = WLAN_EID_SSID; | ||
92 | ie_buf[1] = len; | ||
93 | memcpy(&ie_buf[2], bss->a.essid, len); | ||
94 | |||
95 | ie = ie_buf + len + 2; | ||
96 | ie_len = ie_buf[1] + 2; | ||
97 | switch (priv->firmware_type) { | ||
98 | case FIRMWARE_TYPE_SYMBOL: | ||
99 | ie_len += symbol_build_supp_rates(ie, bss->s.rates); | ||
117 | break; | 100 | break; |
118 | } | ||
119 | 101 | ||
120 | /* Grab a bss off the free list */ | 102 | case FIRMWARE_TYPE_INTERSIL: |
121 | if (!found && !list_empty(&priv->bss_free_list)) { | 103 | ie_len += prism_build_supp_rates(ie, bss->p.rates); |
122 | bss = list_entry(priv->bss_free_list.next, | 104 | break; |
123 | struct xbss_element, list); | ||
124 | list_del(priv->bss_free_list.next); | ||
125 | 105 | ||
126 | list_add_tail(&bss->list, &priv->bss_list); | 106 | case FIRMWARE_TYPE_AGERE: |
107 | default: | ||
108 | break; | ||
127 | } | 109 | } |
128 | 110 | ||
129 | if (bss) { | 111 | freq = ieee80211_dsss_chan_to_freq(le16_to_cpu(bss->a.channel)); |
130 | /* Always update the BSS to get latest beacon info */ | 112 | channel = ieee80211_get_channel(wiphy, freq); |
131 | memcpy(&bss->bss, atom, sizeof(bss->bss)); | 113 | timestamp = 0; |
132 | bss->last_scanned = jiffies; | 114 | capability = le16_to_cpu(bss->a.capabilities); |
133 | } | 115 | beacon_interval = le16_to_cpu(bss->a.beacon_interv); |
116 | signal = SIGNAL_TO_MBM(le16_to_cpu(bss->a.level)); | ||
117 | |||
118 | cfg80211_inform_bss(wiphy, channel, bss->a.bssid, timestamp, | ||
119 | capability, beacon_interval, ie_buf, ie_len, | ||
120 | signal, GFP_KERNEL); | ||
134 | } | 121 | } |
135 | 122 | ||
136 | int orinoco_process_scan_results(struct orinoco_private *priv, | 123 | void orinoco_add_extscan_result(struct orinoco_private *priv, |
137 | unsigned char *buf, | 124 | struct agere_ext_scan_info *bss, |
138 | int len) | 125 | size_t len) |
139 | { | 126 | { |
140 | int offset; /* In the scan data */ | 127 | struct wiphy *wiphy = priv_to_wiphy(priv); |
141 | union hermes_scan_info *atom; | 128 | struct ieee80211_channel *channel; |
142 | int atom_len; | 129 | u8 *ie; |
130 | u64 timestamp; | ||
131 | s32 signal; | ||
132 | u16 capability; | ||
133 | u16 beacon_interval; | ||
134 | size_t ie_len; | ||
135 | int chan, freq; | ||
136 | |||
137 | ie_len = len - sizeof(*bss); | ||
138 | ie = orinoco_get_ie(bss->data, ie_len, WLAN_EID_DS_PARAMS); | ||
139 | chan = ie ? ie[2] : 0; | ||
140 | freq = ieee80211_dsss_chan_to_freq(chan); | ||
141 | channel = ieee80211_get_channel(wiphy, freq); | ||
142 | |||
143 | timestamp = le64_to_cpu(bss->timestamp); | ||
144 | capability = le16_to_cpu(bss->capabilities); | ||
145 | beacon_interval = le16_to_cpu(bss->beacon_interval); | ||
146 | ie = bss->data; | ||
147 | signal = SIGNAL_TO_MBM(bss->level); | ||
148 | |||
149 | cfg80211_inform_bss(wiphy, channel, bss->bssid, timestamp, | ||
150 | capability, beacon_interval, ie, ie_len, | ||
151 | signal, GFP_KERNEL); | ||
152 | } | ||
153 | |||
154 | void orinoco_add_hostscan_results(struct orinoco_private *priv, | ||
155 | unsigned char *buf, | ||
156 | size_t len) | ||
157 | { | ||
158 | int offset; /* In the scan data */ | ||
159 | size_t atom_len; | ||
160 | bool abort = false; | ||
143 | 161 | ||
144 | switch (priv->firmware_type) { | 162 | switch (priv->firmware_type) { |
145 | case FIRMWARE_TYPE_AGERE: | 163 | case FIRMWARE_TYPE_AGERE: |
146 | atom_len = sizeof(struct agere_scan_apinfo); | 164 | atom_len = sizeof(struct agere_scan_apinfo); |
147 | offset = 0; | 165 | offset = 0; |
148 | break; | 166 | break; |
167 | |||
149 | case FIRMWARE_TYPE_SYMBOL: | 168 | case FIRMWARE_TYPE_SYMBOL: |
150 | /* Lack of documentation necessitates this hack. | 169 | /* Lack of documentation necessitates this hack. |
151 | * Different firmwares have 68 or 76 byte long atoms. | 170 | * Different firmwares have 68 or 76 byte long atoms. |
@@ -163,6 +182,7 @@ int orinoco_process_scan_results(struct orinoco_private *priv, | |||
163 | atom_len = 68; | 182 | atom_len = 68; |
164 | offset = 0; | 183 | offset = 0; |
165 | break; | 184 | break; |
185 | |||
166 | case FIRMWARE_TYPE_INTERSIL: | 186 | case FIRMWARE_TYPE_INTERSIL: |
167 | offset = 4; | 187 | offset = 4; |
168 | if (priv->has_hostscan) { | 188 | if (priv->has_hostscan) { |
@@ -170,64 +190,41 @@ int orinoco_process_scan_results(struct orinoco_private *priv, | |||
170 | /* Sanity check for atom_len */ | 190 | /* Sanity check for atom_len */ |
171 | if (atom_len < sizeof(struct prism2_scan_apinfo)) { | 191 | if (atom_len < sizeof(struct prism2_scan_apinfo)) { |
172 | printk(KERN_ERR "%s: Invalid atom_len in scan " | 192 | printk(KERN_ERR "%s: Invalid atom_len in scan " |
173 | "data: %d\n", priv->ndev->name, | 193 | "data: %zu\n", priv->ndev->name, |
174 | atom_len); | 194 | atom_len); |
175 | return -EIO; | 195 | abort = true; |
196 | goto scan_abort; | ||
176 | } | 197 | } |
177 | } else | 198 | } else |
178 | atom_len = offsetof(struct prism2_scan_apinfo, atim); | 199 | atom_len = offsetof(struct prism2_scan_apinfo, atim); |
179 | break; | 200 | break; |
201 | |||
180 | default: | 202 | default: |
181 | return -EOPNOTSUPP; | 203 | abort = true; |
204 | goto scan_abort; | ||
182 | } | 205 | } |
183 | 206 | ||
184 | /* Check that we got an whole number of atoms */ | 207 | /* Check that we got an whole number of atoms */ |
185 | if ((len - offset) % atom_len) { | 208 | if ((len - offset) % atom_len) { |
186 | printk(KERN_ERR "%s: Unexpected scan data length %d, " | 209 | printk(KERN_ERR "%s: Unexpected scan data length %zu, " |
187 | "atom_len %d, offset %d\n", priv->ndev->name, len, | 210 | "atom_len %zu, offset %d\n", priv->ndev->name, len, |
188 | atom_len, offset); | 211 | atom_len, offset); |
189 | return -EIO; | 212 | abort = true; |
213 | goto scan_abort; | ||
190 | } | 214 | } |
191 | 215 | ||
192 | orinoco_clear_scan_results(priv, msecs_to_jiffies(15000)); | 216 | /* Process the entries one by one */ |
193 | |||
194 | /* Read the entries one by one */ | ||
195 | for (; offset + atom_len <= len; offset += atom_len) { | 217 | for (; offset + atom_len <= len; offset += atom_len) { |
196 | int found = 0; | 218 | union hermes_scan_info *atom; |
197 | struct bss_element *bss = NULL; | ||
198 | 219 | ||
199 | /* Get next atom */ | ||
200 | atom = (union hermes_scan_info *) (buf + offset); | 220 | atom = (union hermes_scan_info *) (buf + offset); |
201 | 221 | ||
202 | /* Try to update an existing bss first */ | 222 | orinoco_add_hostscan_result(priv, atom); |
203 | list_for_each_entry(bss, &priv->bss_list, list) { | ||
204 | if (compare_ether_addr(bss->bss.a.bssid, atom->a.bssid)) | ||
205 | continue; | ||
206 | if (le16_to_cpu(bss->bss.a.essid_len) != | ||
207 | le16_to_cpu(atom->a.essid_len)) | ||
208 | continue; | ||
209 | if (memcmp(bss->bss.a.essid, atom->a.essid, | ||
210 | le16_to_cpu(atom->a.essid_len))) | ||
211 | continue; | ||
212 | found = 1; | ||
213 | break; | ||
214 | } | ||
215 | |||
216 | /* Grab a bss off the free list */ | ||
217 | if (!found && !list_empty(&priv->bss_free_list)) { | ||
218 | bss = list_entry(priv->bss_free_list.next, | ||
219 | struct bss_element, list); | ||
220 | list_del(priv->bss_free_list.next); | ||
221 | |||
222 | list_add_tail(&bss->list, &priv->bss_list); | ||
223 | } | ||
224 | |||
225 | if (bss) { | ||
226 | /* Always update the BSS to get latest beacon info */ | ||
227 | memcpy(&bss->bss, atom, sizeof(bss->bss)); | ||
228 | bss->last_scanned = jiffies; | ||
229 | } | ||
230 | } | 223 | } |
231 | 224 | ||
232 | return 0; | 225 | scan_abort: |
226 | if (priv->scan_request) { | ||
227 | cfg80211_scan_done(priv->scan_request, abort); | ||
228 | priv->scan_request = NULL; | ||
229 | } | ||
233 | } | 230 | } |
diff --git a/drivers/net/wireless/orinoco/scan.h b/drivers/net/wireless/orinoco/scan.h index f319f7466af1..2dc4e046dbdb 100644 --- a/drivers/net/wireless/orinoco/scan.h +++ b/drivers/net/wireless/orinoco/scan.h | |||
@@ -9,21 +9,12 @@ | |||
9 | struct orinoco_private; | 9 | struct orinoco_private; |
10 | struct agere_ext_scan_info; | 10 | struct agere_ext_scan_info; |
11 | 11 | ||
12 | /* Setup and free memory for scan results */ | ||
13 | int orinoco_bss_data_allocate(struct orinoco_private *priv); | ||
14 | void orinoco_bss_data_free(struct orinoco_private *priv); | ||
15 | void orinoco_bss_data_init(struct orinoco_private *priv); | ||
16 | |||
17 | /* Add scan results */ | 12 | /* Add scan results */ |
18 | void orinoco_add_ext_scan_result(struct orinoco_private *priv, | 13 | void orinoco_add_extscan_result(struct orinoco_private *priv, |
19 | struct agere_ext_scan_info *atom); | 14 | struct agere_ext_scan_info *atom, |
20 | int orinoco_process_scan_results(struct orinoco_private *dev, | 15 | size_t len); |
21 | unsigned char *buf, | 16 | void orinoco_add_hostscan_results(struct orinoco_private *dev, |
22 | int len); | 17 | unsigned char *buf, |
23 | 18 | size_t len); | |
24 | /* Clear scan results */ | ||
25 | void orinoco_clear_scan_results(struct orinoco_private *priv, | ||
26 | unsigned long scan_age); | ||
27 | |||
28 | 19 | ||
29 | #endif /* _ORINOCO_SCAN_H_ */ | 20 | #endif /* _ORINOCO_SCAN_H_ */ |
diff --git a/drivers/net/wireless/orinoco/spectrum_cs.c b/drivers/net/wireless/orinoco/spectrum_cs.c index 38e5198e44c7..c361310b885d 100644 --- a/drivers/net/wireless/orinoco/spectrum_cs.c +++ b/drivers/net/wireless/orinoco/spectrum_cs.c | |||
@@ -178,27 +178,25 @@ spectrum_cs_stop_firmware(struct orinoco_private *priv, int idle) | |||
178 | static int | 178 | static int |
179 | spectrum_cs_probe(struct pcmcia_device *link) | 179 | spectrum_cs_probe(struct pcmcia_device *link) |
180 | { | 180 | { |
181 | struct net_device *dev; | ||
182 | struct orinoco_private *priv; | 181 | struct orinoco_private *priv; |
183 | struct orinoco_pccard *card; | 182 | struct orinoco_pccard *card; |
184 | 183 | ||
185 | dev = alloc_orinocodev(sizeof(*card), &handle_to_dev(link), | 184 | priv = alloc_orinocodev(sizeof(*card), &handle_to_dev(link), |
186 | spectrum_cs_hard_reset, | 185 | spectrum_cs_hard_reset, |
187 | spectrum_cs_stop_firmware); | 186 | spectrum_cs_stop_firmware); |
188 | if (!dev) | 187 | if (!priv) |
189 | return -ENOMEM; | 188 | return -ENOMEM; |
190 | priv = netdev_priv(dev); | ||
191 | card = priv->card; | 189 | card = priv->card; |
192 | 190 | ||
193 | /* Link both structures together */ | 191 | /* Link both structures together */ |
194 | card->p_dev = link; | 192 | card->p_dev = link; |
195 | link->priv = dev; | 193 | link->priv = priv; |
196 | 194 | ||
197 | /* Interrupt setup */ | 195 | /* Interrupt setup */ |
198 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; | 196 | link->irq.Attributes = IRQ_TYPE_DYNAMIC_SHARING | IRQ_HANDLE_PRESENT; |
199 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; | 197 | link->irq.IRQInfo1 = IRQ_LEVEL_ID; |
200 | link->irq.Handler = orinoco_interrupt; | 198 | link->irq.Handler = orinoco_interrupt; |
201 | link->irq.Instance = dev; | 199 | link->irq.Instance = priv; |
202 | 200 | ||
203 | /* General socket configuration defaults can go here. In this | 201 | /* General socket configuration defaults can go here. In this |
204 | * client, we assume very little, and rely on the CIS for | 202 | * client, we assume very little, and rely on the CIS for |
@@ -219,14 +217,14 @@ spectrum_cs_probe(struct pcmcia_device *link) | |||
219 | */ | 217 | */ |
220 | static void spectrum_cs_detach(struct pcmcia_device *link) | 218 | static void spectrum_cs_detach(struct pcmcia_device *link) |
221 | { | 219 | { |
222 | struct net_device *dev = link->priv; | 220 | struct orinoco_private *priv = link->priv; |
223 | 221 | ||
224 | if (link->dev_node) | 222 | if (link->dev_node) |
225 | unregister_netdev(dev); | 223 | orinoco_if_del(priv); |
226 | 224 | ||
227 | spectrum_cs_release(link); | 225 | spectrum_cs_release(link); |
228 | 226 | ||
229 | free_orinocodev(dev); | 227 | free_orinocodev(priv); |
230 | } /* spectrum_cs_detach */ | 228 | } /* spectrum_cs_detach */ |
231 | 229 | ||
232 | /* | 230 | /* |
@@ -306,8 +304,7 @@ next_entry: | |||
306 | static int | 304 | static int |
307 | spectrum_cs_config(struct pcmcia_device *link) | 305 | spectrum_cs_config(struct pcmcia_device *link) |
308 | { | 306 | { |
309 | struct net_device *dev = link->priv; | 307 | struct orinoco_private *priv = link->priv; |
310 | struct orinoco_private *priv = netdev_priv(dev); | ||
311 | struct orinoco_pccard *card = priv->card; | 308 | struct orinoco_pccard *card = priv->card; |
312 | hermes_t *hw = &priv->hw; | 309 | hermes_t *hw = &priv->hw; |
313 | int last_fn, last_ret; | 310 | int last_fn, last_ret; |
@@ -362,34 +359,31 @@ spectrum_cs_config(struct pcmcia_device *link) | |||
362 | pcmcia_request_configuration(link, &link->conf)); | 359 | pcmcia_request_configuration(link, &link->conf)); |
363 | 360 | ||
364 | /* Ok, we have the configuration, prepare to register the netdev */ | 361 | /* Ok, we have the configuration, prepare to register the netdev */ |
365 | dev->base_addr = link->io.BasePort1; | ||
366 | dev->irq = link->irq.AssignedIRQ; | ||
367 | card->node.major = card->node.minor = 0; | 362 | card->node.major = card->node.minor = 0; |
368 | 363 | ||
369 | /* Reset card */ | 364 | /* Reset card */ |
370 | if (spectrum_cs_hard_reset(priv) != 0) | 365 | if (spectrum_cs_hard_reset(priv) != 0) |
371 | goto failed; | 366 | goto failed; |
372 | 367 | ||
373 | SET_NETDEV_DEV(dev, &handle_to_dev(link)); | 368 | /* Initialise the main driver */ |
374 | /* Tell the stack we exist */ | 369 | if (orinoco_init(priv) != 0) { |
375 | if (register_netdev(dev) != 0) { | 370 | printk(KERN_ERR PFX "orinoco_init() failed\n"); |
376 | printk(KERN_ERR PFX "register_netdev() failed\n"); | 371 | goto failed; |
372 | } | ||
373 | |||
374 | /* Register an interface with the stack */ | ||
375 | if (orinoco_if_add(priv, link->io.BasePort1, | ||
376 | link->irq.AssignedIRQ) != 0) { | ||
377 | printk(KERN_ERR PFX "orinoco_if_add() failed\n"); | ||
377 | goto failed; | 378 | goto failed; |
378 | } | 379 | } |
379 | 380 | ||
380 | /* At this point, the dev_node_t structure(s) needs to be | 381 | /* At this point, the dev_node_t structure(s) needs to be |
381 | * initialized and arranged in a linked list at link->dev_node. */ | 382 | * initialized and arranged in a linked list at link->dev_node. */ |
382 | strcpy(card->node.dev_name, dev->name); | 383 | strcpy(card->node.dev_name, priv->ndev->name); |
383 | link->dev_node = &card->node; /* link->dev_node being non-NULL is also | 384 | link->dev_node = &card->node; /* link->dev_node being non-NULL is also |
384 | * used to indicate that the | 385 | * used to indicate that the |
385 | * net_device has been registered */ | 386 | * net_device has been registered */ |
386 | |||
387 | /* Finally, report what we've done */ | ||
388 | printk(KERN_DEBUG "%s: " DRIVER_NAME " at %s, irq %d, io " | ||
389 | "0x%04x-0x%04x\n", dev->name, dev_name(dev->dev.parent), | ||
390 | link->irq.AssignedIRQ, link->io.BasePort1, | ||
391 | link->io.BasePort1 + link->io.NumPorts1 - 1); | ||
392 | |||
393 | return 0; | 387 | return 0; |
394 | 388 | ||
395 | cs_failed: | 389 | cs_failed: |
@@ -408,8 +402,7 @@ spectrum_cs_config(struct pcmcia_device *link) | |||
408 | static void | 402 | static void |
409 | spectrum_cs_release(struct pcmcia_device *link) | 403 | spectrum_cs_release(struct pcmcia_device *link) |
410 | { | 404 | { |
411 | struct net_device *dev = link->priv; | 405 | struct orinoco_private *priv = link->priv; |
412 | struct orinoco_private *priv = netdev_priv(dev); | ||
413 | unsigned long flags; | 406 | unsigned long flags; |
414 | 407 | ||
415 | /* We're committed to taking the device away now, so mark the | 408 | /* We're committed to taking the device away now, so mark the |
@@ -427,23 +420,11 @@ spectrum_cs_release(struct pcmcia_device *link) | |||
427 | static int | 420 | static int |
428 | spectrum_cs_suspend(struct pcmcia_device *link) | 421 | spectrum_cs_suspend(struct pcmcia_device *link) |
429 | { | 422 | { |
430 | struct net_device *dev = link->priv; | 423 | struct orinoco_private *priv = link->priv; |
431 | struct orinoco_private *priv = netdev_priv(dev); | ||
432 | unsigned long flags; | ||
433 | int err = 0; | 424 | int err = 0; |
434 | 425 | ||
435 | /* Mark the device as stopped, to block IO until later */ | 426 | /* Mark the device as stopped, to block IO until later */ |
436 | spin_lock_irqsave(&priv->lock, flags); | 427 | orinoco_down(priv); |
437 | |||
438 | err = __orinoco_down(dev); | ||
439 | if (err) | ||
440 | printk(KERN_WARNING "%s: Error %d downing interface\n", | ||
441 | dev->name, err); | ||
442 | |||
443 | netif_device_detach(dev); | ||
444 | priv->hw_unavailable++; | ||
445 | |||
446 | spin_unlock_irqrestore(&priv->lock, flags); | ||
447 | 428 | ||
448 | return err; | 429 | return err; |
449 | } | 430 | } |
@@ -451,33 +432,10 @@ spectrum_cs_suspend(struct pcmcia_device *link) | |||
451 | static int | 432 | static int |
452 | spectrum_cs_resume(struct pcmcia_device *link) | 433 | spectrum_cs_resume(struct pcmcia_device *link) |
453 | { | 434 | { |
454 | struct net_device *dev = link->priv; | 435 | struct orinoco_private *priv = link->priv; |
455 | struct orinoco_private *priv = netdev_priv(dev); | 436 | int err = orinoco_up(priv); |
456 | unsigned long flags; | ||
457 | int err; | ||
458 | |||
459 | err = orinoco_reinit_firmware(dev); | ||
460 | if (err) { | ||
461 | printk(KERN_ERR "%s: Error %d re-initializing firmware\n", | ||
462 | dev->name, err); | ||
463 | return -EIO; | ||
464 | } | ||
465 | |||
466 | spin_lock_irqsave(&priv->lock, flags); | ||
467 | |||
468 | netif_device_attach(dev); | ||
469 | priv->hw_unavailable--; | ||
470 | 437 | ||
471 | if (priv->open && !priv->hw_unavailable) { | 438 | return err; |
472 | err = __orinoco_up(dev); | ||
473 | if (err) | ||
474 | printk(KERN_ERR "%s: Error %d restarting card\n", | ||
475 | dev->name, err); | ||
476 | } | ||
477 | |||
478 | spin_unlock_irqrestore(&priv->lock, flags); | ||
479 | |||
480 | return 0; | ||
481 | } | 439 | } |
482 | 440 | ||
483 | 441 | ||
diff --git a/drivers/net/wireless/orinoco/wext.c b/drivers/net/wireless/orinoco/wext.c index 3f0814234392..b6ff3dbb7dd6 100644 --- a/drivers/net/wireless/orinoco/wext.c +++ b/drivers/net/wireless/orinoco/wext.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/wireless.h> | 7 | #include <linux/wireless.h> |
8 | #include <linux/ieee80211.h> | 8 | #include <linux/ieee80211.h> |
9 | #include <net/iw_handler.h> | 9 | #include <net/iw_handler.h> |
10 | #include <net/cfg80211.h> | ||
10 | 11 | ||
11 | #include "hermes.h" | 12 | #include "hermes.h" |
12 | #include "hermes_rid.h" | 13 | #include "hermes_rid.h" |
@@ -23,7 +24,7 @@ | |||
23 | 24 | ||
24 | static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev) | 25 | static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev) |
25 | { | 26 | { |
26 | struct orinoco_private *priv = netdev_priv(dev); | 27 | struct orinoco_private *priv = ndev_priv(dev); |
27 | hermes_t *hw = &priv->hw; | 28 | hermes_t *hw = &priv->hw; |
28 | struct iw_statistics *wstats = &priv->wstats; | 29 | struct iw_statistics *wstats = &priv->wstats; |
29 | int err; | 30 | int err; |
@@ -51,7 +52,7 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev) | |||
51 | * here so we're not safe to sleep here. */ | 52 | * here so we're not safe to sleep here. */ |
52 | hermes_inquire(hw, HERMES_INQ_TALLIES); | 53 | hermes_inquire(hw, HERMES_INQ_TALLIES); |
53 | 54 | ||
54 | if (priv->iw_mode == IW_MODE_ADHOC) { | 55 | if (priv->iw_mode == NL80211_IFTYPE_ADHOC) { |
55 | memset(&wstats->qual, 0, sizeof(wstats->qual)); | 56 | memset(&wstats->qual, 0, sizeof(wstats->qual)); |
56 | /* If a spy address is defined, we report stats of the | 57 | /* If a spy address is defined, we report stats of the |
57 | * first spy address - Jean II */ | 58 | * first spy address - Jean II */ |
@@ -87,31 +88,12 @@ static struct iw_statistics *orinoco_get_wireless_stats(struct net_device *dev) | |||
87 | /* Wireless extensions */ | 88 | /* Wireless extensions */ |
88 | /********************************************************************/ | 89 | /********************************************************************/ |
89 | 90 | ||
90 | static int orinoco_ioctl_getname(struct net_device *dev, | ||
91 | struct iw_request_info *info, | ||
92 | char *name, | ||
93 | char *extra) | ||
94 | { | ||
95 | struct orinoco_private *priv = netdev_priv(dev); | ||
96 | int numrates; | ||
97 | int err; | ||
98 | |||
99 | err = orinoco_hw_get_bitratelist(priv, &numrates, NULL, 0); | ||
100 | |||
101 | if (!err && (numrates > 2)) | ||
102 | strcpy(name, "IEEE 802.11b"); | ||
103 | else | ||
104 | strcpy(name, "IEEE 802.11-DS"); | ||
105 | |||
106 | return 0; | ||
107 | } | ||
108 | |||
109 | static int orinoco_ioctl_setwap(struct net_device *dev, | 91 | static int orinoco_ioctl_setwap(struct net_device *dev, |
110 | struct iw_request_info *info, | 92 | struct iw_request_info *info, |
111 | struct sockaddr *ap_addr, | 93 | struct sockaddr *ap_addr, |
112 | char *extra) | 94 | char *extra) |
113 | { | 95 | { |
114 | struct orinoco_private *priv = netdev_priv(dev); | 96 | struct orinoco_private *priv = ndev_priv(dev); |
115 | int err = -EINPROGRESS; /* Call commit handler */ | 97 | int err = -EINPROGRESS; /* Call commit handler */ |
116 | unsigned long flags; | 98 | unsigned long flags; |
117 | static const u8 off_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; | 99 | static const u8 off_addr[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; |
@@ -142,7 +124,7 @@ static int orinoco_ioctl_setwap(struct net_device *dev, | |||
142 | goto out; | 124 | goto out; |
143 | } | 125 | } |
144 | 126 | ||
145 | if (priv->iw_mode != IW_MODE_INFRA) { | 127 | if (priv->iw_mode != NL80211_IFTYPE_STATION) { |
146 | printk(KERN_WARNING "%s: Manual roaming supported only in " | 128 | printk(KERN_WARNING "%s: Manual roaming supported only in " |
147 | "managed mode\n", dev->name); | 129 | "managed mode\n", dev->name); |
148 | err = -EOPNOTSUPP; | 130 | err = -EOPNOTSUPP; |
@@ -172,7 +154,7 @@ static int orinoco_ioctl_getwap(struct net_device *dev, | |||
172 | struct sockaddr *ap_addr, | 154 | struct sockaddr *ap_addr, |
173 | char *extra) | 155 | char *extra) |
174 | { | 156 | { |
175 | struct orinoco_private *priv = netdev_priv(dev); | 157 | struct orinoco_private *priv = ndev_priv(dev); |
176 | 158 | ||
177 | hermes_t *hw = &priv->hw; | 159 | hermes_t *hw = &priv->hw; |
178 | int err = 0; | 160 | int err = 0; |
@@ -190,184 +172,12 @@ static int orinoco_ioctl_getwap(struct net_device *dev, | |||
190 | return err; | 172 | return err; |
191 | } | 173 | } |
192 | 174 | ||
193 | static int orinoco_ioctl_setmode(struct net_device *dev, | ||
194 | struct iw_request_info *info, | ||
195 | u32 *mode, | ||
196 | char *extra) | ||
197 | { | ||
198 | struct orinoco_private *priv = netdev_priv(dev); | ||
199 | int err = -EINPROGRESS; /* Call commit handler */ | ||
200 | unsigned long flags; | ||
201 | |||
202 | if (priv->iw_mode == *mode) | ||
203 | return 0; | ||
204 | |||
205 | if (orinoco_lock(priv, &flags) != 0) | ||
206 | return -EBUSY; | ||
207 | |||
208 | switch (*mode) { | ||
209 | case IW_MODE_ADHOC: | ||
210 | if (!priv->has_ibss && !priv->has_port3) | ||
211 | err = -EOPNOTSUPP; | ||
212 | break; | ||
213 | |||
214 | case IW_MODE_INFRA: | ||
215 | break; | ||
216 | |||
217 | case IW_MODE_MONITOR: | ||
218 | if (priv->broken_monitor && !force_monitor) { | ||
219 | printk(KERN_WARNING "%s: Monitor mode support is " | ||
220 | "buggy in this firmware, not enabling\n", | ||
221 | dev->name); | ||
222 | err = -EOPNOTSUPP; | ||
223 | } | ||
224 | break; | ||
225 | |||
226 | default: | ||
227 | err = -EOPNOTSUPP; | ||
228 | break; | ||
229 | } | ||
230 | |||
231 | if (err == -EINPROGRESS) { | ||
232 | priv->iw_mode = *mode; | ||
233 | set_port_type(priv); | ||
234 | } | ||
235 | |||
236 | orinoco_unlock(priv, &flags); | ||
237 | |||
238 | return err; | ||
239 | } | ||
240 | |||
241 | static int orinoco_ioctl_getmode(struct net_device *dev, | ||
242 | struct iw_request_info *info, | ||
243 | u32 *mode, | ||
244 | char *extra) | ||
245 | { | ||
246 | struct orinoco_private *priv = netdev_priv(dev); | ||
247 | |||
248 | *mode = priv->iw_mode; | ||
249 | return 0; | ||
250 | } | ||
251 | |||
252 | static int orinoco_ioctl_getiwrange(struct net_device *dev, | ||
253 | struct iw_request_info *info, | ||
254 | struct iw_point *rrq, | ||
255 | char *extra) | ||
256 | { | ||
257 | struct orinoco_private *priv = netdev_priv(dev); | ||
258 | int err = 0; | ||
259 | struct iw_range *range = (struct iw_range *) extra; | ||
260 | int numrates; | ||
261 | int i, k; | ||
262 | |||
263 | rrq->length = sizeof(struct iw_range); | ||
264 | memset(range, 0, sizeof(struct iw_range)); | ||
265 | |||
266 | range->we_version_compiled = WIRELESS_EXT; | ||
267 | range->we_version_source = 22; | ||
268 | |||
269 | /* Set available channels/frequencies */ | ||
270 | range->num_channels = NUM_CHANNELS; | ||
271 | k = 0; | ||
272 | for (i = 0; i < NUM_CHANNELS; i++) { | ||
273 | if (priv->channel_mask & (1 << i)) { | ||
274 | range->freq[k].i = i + 1; | ||
275 | range->freq[k].m = (ieee80211_dsss_chan_to_freq(i + 1) * | ||
276 | 100000); | ||
277 | range->freq[k].e = 1; | ||
278 | k++; | ||
279 | } | ||
280 | |||
281 | if (k >= IW_MAX_FREQUENCIES) | ||
282 | break; | ||
283 | } | ||
284 | range->num_frequency = k; | ||
285 | range->sensitivity = 3; | ||
286 | |||
287 | if (priv->has_wep) { | ||
288 | range->max_encoding_tokens = ORINOCO_MAX_KEYS; | ||
289 | range->encoding_size[0] = SMALL_KEY_SIZE; | ||
290 | range->num_encoding_sizes = 1; | ||
291 | |||
292 | if (priv->has_big_wep) { | ||
293 | range->encoding_size[1] = LARGE_KEY_SIZE; | ||
294 | range->num_encoding_sizes = 2; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | if (priv->has_wpa) | ||
299 | range->enc_capa = IW_ENC_CAPA_WPA | IW_ENC_CAPA_CIPHER_TKIP; | ||
300 | |||
301 | if ((priv->iw_mode == IW_MODE_ADHOC) && (!SPY_NUMBER(priv))) { | ||
302 | /* Quality stats meaningless in ad-hoc mode */ | ||
303 | } else { | ||
304 | range->max_qual.qual = 0x8b - 0x2f; | ||
305 | range->max_qual.level = 0x2f - 0x95 - 1; | ||
306 | range->max_qual.noise = 0x2f - 0x95 - 1; | ||
307 | /* Need to get better values */ | ||
308 | range->avg_qual.qual = 0x24; | ||
309 | range->avg_qual.level = 0xC2; | ||
310 | range->avg_qual.noise = 0x9E; | ||
311 | } | ||
312 | |||
313 | err = orinoco_hw_get_bitratelist(priv, &numrates, | ||
314 | range->bitrate, IW_MAX_BITRATES); | ||
315 | if (err) | ||
316 | return err; | ||
317 | range->num_bitrates = numrates; | ||
318 | |||
319 | /* Set an indication of the max TCP throughput in bit/s that we can | ||
320 | * expect using this interface. May be use for QoS stuff... | ||
321 | * Jean II */ | ||
322 | if (numrates > 2) | ||
323 | range->throughput = 5 * 1000 * 1000; /* ~5 Mb/s */ | ||
324 | else | ||
325 | range->throughput = 1.5 * 1000 * 1000; /* ~1.5 Mb/s */ | ||
326 | |||
327 | range->min_rts = 0; | ||
328 | range->max_rts = 2347; | ||
329 | range->min_frag = 256; | ||
330 | range->max_frag = 2346; | ||
331 | |||
332 | range->min_pmp = 0; | ||
333 | range->max_pmp = 65535000; | ||
334 | range->min_pmt = 0; | ||
335 | range->max_pmt = 65535 * 1000; /* ??? */ | ||
336 | range->pmp_flags = IW_POWER_PERIOD; | ||
337 | range->pmt_flags = IW_POWER_TIMEOUT; | ||
338 | range->pm_capa = (IW_POWER_PERIOD | IW_POWER_TIMEOUT | | ||
339 | IW_POWER_UNICAST_R); | ||
340 | |||
341 | range->retry_capa = IW_RETRY_LIMIT | IW_RETRY_LIFETIME; | ||
342 | range->retry_flags = IW_RETRY_LIMIT; | ||
343 | range->r_time_flags = IW_RETRY_LIFETIME; | ||
344 | range->min_retry = 0; | ||
345 | range->max_retry = 65535; /* ??? */ | ||
346 | range->min_r_time = 0; | ||
347 | range->max_r_time = 65535 * 1000; /* ??? */ | ||
348 | |||
349 | if (priv->firmware_type == FIRMWARE_TYPE_AGERE) | ||
350 | range->scan_capa = IW_SCAN_CAPA_ESSID; | ||
351 | else | ||
352 | range->scan_capa = IW_SCAN_CAPA_NONE; | ||
353 | |||
354 | /* Event capability (kernel) */ | ||
355 | IW_EVENT_CAPA_SET_KERNEL(range->event_capa); | ||
356 | /* Event capability (driver) */ | ||
357 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWTHRSPY); | ||
358 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWAP); | ||
359 | IW_EVENT_CAPA_SET(range->event_capa, SIOCGIWSCAN); | ||
360 | IW_EVENT_CAPA_SET(range->event_capa, IWEVTXDROP); | ||
361 | |||
362 | return 0; | ||
363 | } | ||
364 | |||
365 | static int orinoco_ioctl_setiwencode(struct net_device *dev, | 175 | static int orinoco_ioctl_setiwencode(struct net_device *dev, |
366 | struct iw_request_info *info, | 176 | struct iw_request_info *info, |
367 | struct iw_point *erq, | 177 | struct iw_point *erq, |
368 | char *keybuf) | 178 | char *keybuf) |
369 | { | 179 | { |
370 | struct orinoco_private *priv = netdev_priv(dev); | 180 | struct orinoco_private *priv = ndev_priv(dev); |
371 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; | 181 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; |
372 | int setindex = priv->tx_key; | 182 | int setindex = priv->tx_key; |
373 | int encode_alg = priv->encode_alg; | 183 | int encode_alg = priv->encode_alg; |
@@ -469,7 +279,7 @@ static int orinoco_ioctl_getiwencode(struct net_device *dev, | |||
469 | struct iw_point *erq, | 279 | struct iw_point *erq, |
470 | char *keybuf) | 280 | char *keybuf) |
471 | { | 281 | { |
472 | struct orinoco_private *priv = netdev_priv(dev); | 282 | struct orinoco_private *priv = ndev_priv(dev); |
473 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; | 283 | int index = (erq->flags & IW_ENCODE_INDEX) - 1; |
474 | u16 xlen = 0; | 284 | u16 xlen = 0; |
475 | unsigned long flags; | 285 | unsigned long flags; |
@@ -508,7 +318,7 @@ static int orinoco_ioctl_setessid(struct net_device *dev, | |||
508 | struct iw_point *erq, | 318 | struct iw_point *erq, |
509 | char *essidbuf) | 319 | char *essidbuf) |
510 | { | 320 | { |
511 | struct orinoco_private *priv = netdev_priv(dev); | 321 | struct orinoco_private *priv = ndev_priv(dev); |
512 | unsigned long flags; | 322 | unsigned long flags; |
513 | 323 | ||
514 | /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it | 324 | /* Note : ESSID is ignored in Ad-Hoc demo mode, but we can set it |
@@ -539,7 +349,7 @@ static int orinoco_ioctl_getessid(struct net_device *dev, | |||
539 | struct iw_point *erq, | 349 | struct iw_point *erq, |
540 | char *essidbuf) | 350 | char *essidbuf) |
541 | { | 351 | { |
542 | struct orinoco_private *priv = netdev_priv(dev); | 352 | struct orinoco_private *priv = ndev_priv(dev); |
543 | int active; | 353 | int active; |
544 | int err = 0; | 354 | int err = 0; |
545 | unsigned long flags; | 355 | unsigned long flags; |
@@ -562,59 +372,18 @@ static int orinoco_ioctl_getessid(struct net_device *dev, | |||
562 | return 0; | 372 | return 0; |
563 | } | 373 | } |
564 | 374 | ||
565 | static int orinoco_ioctl_setnick(struct net_device *dev, | ||
566 | struct iw_request_info *info, | ||
567 | struct iw_point *nrq, | ||
568 | char *nickbuf) | ||
569 | { | ||
570 | struct orinoco_private *priv = netdev_priv(dev); | ||
571 | unsigned long flags; | ||
572 | |||
573 | if (nrq->length > IW_ESSID_MAX_SIZE) | ||
574 | return -E2BIG; | ||
575 | |||
576 | if (orinoco_lock(priv, &flags) != 0) | ||
577 | return -EBUSY; | ||
578 | |||
579 | memset(priv->nick, 0, sizeof(priv->nick)); | ||
580 | memcpy(priv->nick, nickbuf, nrq->length); | ||
581 | |||
582 | orinoco_unlock(priv, &flags); | ||
583 | |||
584 | return -EINPROGRESS; /* Call commit handler */ | ||
585 | } | ||
586 | |||
587 | static int orinoco_ioctl_getnick(struct net_device *dev, | ||
588 | struct iw_request_info *info, | ||
589 | struct iw_point *nrq, | ||
590 | char *nickbuf) | ||
591 | { | ||
592 | struct orinoco_private *priv = netdev_priv(dev); | ||
593 | unsigned long flags; | ||
594 | |||
595 | if (orinoco_lock(priv, &flags) != 0) | ||
596 | return -EBUSY; | ||
597 | |||
598 | memcpy(nickbuf, priv->nick, IW_ESSID_MAX_SIZE); | ||
599 | orinoco_unlock(priv, &flags); | ||
600 | |||
601 | nrq->length = strlen(priv->nick); | ||
602 | |||
603 | return 0; | ||
604 | } | ||
605 | |||
606 | static int orinoco_ioctl_setfreq(struct net_device *dev, | 375 | static int orinoco_ioctl_setfreq(struct net_device *dev, |
607 | struct iw_request_info *info, | 376 | struct iw_request_info *info, |
608 | struct iw_freq *frq, | 377 | struct iw_freq *frq, |
609 | char *extra) | 378 | char *extra) |
610 | { | 379 | { |
611 | struct orinoco_private *priv = netdev_priv(dev); | 380 | struct orinoco_private *priv = ndev_priv(dev); |
612 | int chan = -1; | 381 | int chan = -1; |
613 | unsigned long flags; | 382 | unsigned long flags; |
614 | int err = -EINPROGRESS; /* Call commit handler */ | 383 | int err = -EINPROGRESS; /* Call commit handler */ |
615 | 384 | ||
616 | /* In infrastructure mode the AP sets the channel */ | 385 | /* In infrastructure mode the AP sets the channel */ |
617 | if (priv->iw_mode == IW_MODE_INFRA) | 386 | if (priv->iw_mode == NL80211_IFTYPE_STATION) |
618 | return -EBUSY; | 387 | return -EBUSY; |
619 | 388 | ||
620 | if ((frq->e == 0) && (frq->m <= 1000)) { | 389 | if ((frq->e == 0) && (frq->m <= 1000)) { |
@@ -640,7 +409,7 @@ static int orinoco_ioctl_setfreq(struct net_device *dev, | |||
640 | return -EBUSY; | 409 | return -EBUSY; |
641 | 410 | ||
642 | priv->channel = chan; | 411 | priv->channel = chan; |
643 | if (priv->iw_mode == IW_MODE_MONITOR) { | 412 | if (priv->iw_mode == NL80211_IFTYPE_MONITOR) { |
644 | /* Fast channel change - no commit if successful */ | 413 | /* Fast channel change - no commit if successful */ |
645 | hermes_t *hw = &priv->hw; | 414 | hermes_t *hw = &priv->hw; |
646 | err = hermes_docmd_wait(hw, HERMES_CMD_TEST | | 415 | err = hermes_docmd_wait(hw, HERMES_CMD_TEST | |
@@ -657,7 +426,7 @@ static int orinoco_ioctl_getfreq(struct net_device *dev, | |||
657 | struct iw_freq *frq, | 426 | struct iw_freq *frq, |
658 | char *extra) | 427 | char *extra) |
659 | { | 428 | { |
660 | struct orinoco_private *priv = netdev_priv(dev); | 429 | struct orinoco_private *priv = ndev_priv(dev); |
661 | int tmp; | 430 | int tmp; |
662 | 431 | ||
663 | /* Locking done in there */ | 432 | /* Locking done in there */ |
@@ -676,7 +445,7 @@ static int orinoco_ioctl_getsens(struct net_device *dev, | |||
676 | struct iw_param *srq, | 445 | struct iw_param *srq, |
677 | char *extra) | 446 | char *extra) |
678 | { | 447 | { |
679 | struct orinoco_private *priv = netdev_priv(dev); | 448 | struct orinoco_private *priv = ndev_priv(dev); |
680 | hermes_t *hw = &priv->hw; | 449 | hermes_t *hw = &priv->hw; |
681 | u16 val; | 450 | u16 val; |
682 | int err; | 451 | int err; |
@@ -705,7 +474,7 @@ static int orinoco_ioctl_setsens(struct net_device *dev, | |||
705 | struct iw_param *srq, | 474 | struct iw_param *srq, |
706 | char *extra) | 475 | char *extra) |
707 | { | 476 | { |
708 | struct orinoco_private *priv = netdev_priv(dev); | 477 | struct orinoco_private *priv = ndev_priv(dev); |
709 | int val = srq->value; | 478 | int val = srq->value; |
710 | unsigned long flags; | 479 | unsigned long flags; |
711 | 480 | ||
@@ -728,7 +497,7 @@ static int orinoco_ioctl_setrts(struct net_device *dev, | |||
728 | struct iw_param *rrq, | 497 | struct iw_param *rrq, |
729 | char *extra) | 498 | char *extra) |
730 | { | 499 | { |
731 | struct orinoco_private *priv = netdev_priv(dev); | 500 | struct orinoco_private *priv = ndev_priv(dev); |
732 | int val = rrq->value; | 501 | int val = rrq->value; |
733 | unsigned long flags; | 502 | unsigned long flags; |
734 | 503 | ||
@@ -752,7 +521,7 @@ static int orinoco_ioctl_getrts(struct net_device *dev, | |||
752 | struct iw_param *rrq, | 521 | struct iw_param *rrq, |
753 | char *extra) | 522 | char *extra) |
754 | { | 523 | { |
755 | struct orinoco_private *priv = netdev_priv(dev); | 524 | struct orinoco_private *priv = ndev_priv(dev); |
756 | 525 | ||
757 | rrq->value = priv->rts_thresh; | 526 | rrq->value = priv->rts_thresh; |
758 | rrq->disabled = (rrq->value == 2347); | 527 | rrq->disabled = (rrq->value == 2347); |
@@ -766,7 +535,7 @@ static int orinoco_ioctl_setfrag(struct net_device *dev, | |||
766 | struct iw_param *frq, | 535 | struct iw_param *frq, |
767 | char *extra) | 536 | char *extra) |
768 | { | 537 | { |
769 | struct orinoco_private *priv = netdev_priv(dev); | 538 | struct orinoco_private *priv = ndev_priv(dev); |
770 | int err = -EINPROGRESS; /* Call commit handler */ | 539 | int err = -EINPROGRESS; /* Call commit handler */ |
771 | unsigned long flags; | 540 | unsigned long flags; |
772 | 541 | ||
@@ -806,7 +575,7 @@ static int orinoco_ioctl_getfrag(struct net_device *dev, | |||
806 | struct iw_param *frq, | 575 | struct iw_param *frq, |
807 | char *extra) | 576 | char *extra) |
808 | { | 577 | { |
809 | struct orinoco_private *priv = netdev_priv(dev); | 578 | struct orinoco_private *priv = ndev_priv(dev); |
810 | hermes_t *hw = &priv->hw; | 579 | hermes_t *hw = &priv->hw; |
811 | int err; | 580 | int err; |
812 | u16 val; | 581 | u16 val; |
@@ -847,7 +616,7 @@ static int orinoco_ioctl_setrate(struct net_device *dev, | |||
847 | struct iw_param *rrq, | 616 | struct iw_param *rrq, |
848 | char *extra) | 617 | char *extra) |
849 | { | 618 | { |
850 | struct orinoco_private *priv = netdev_priv(dev); | 619 | struct orinoco_private *priv = ndev_priv(dev); |
851 | int ratemode; | 620 | int ratemode; |
852 | int bitrate; /* 100s of kilobits */ | 621 | int bitrate; /* 100s of kilobits */ |
853 | unsigned long flags; | 622 | unsigned long flags; |
@@ -881,7 +650,7 @@ static int orinoco_ioctl_getrate(struct net_device *dev, | |||
881 | struct iw_param *rrq, | 650 | struct iw_param *rrq, |
882 | char *extra) | 651 | char *extra) |
883 | { | 652 | { |
884 | struct orinoco_private *priv = netdev_priv(dev); | 653 | struct orinoco_private *priv = ndev_priv(dev); |
885 | int err = 0; | 654 | int err = 0; |
886 | int bitrate, automatic; | 655 | int bitrate, automatic; |
887 | unsigned long flags; | 656 | unsigned long flags; |
@@ -910,7 +679,7 @@ static int orinoco_ioctl_setpower(struct net_device *dev, | |||
910 | struct iw_param *prq, | 679 | struct iw_param *prq, |
911 | char *extra) | 680 | char *extra) |
912 | { | 681 | { |
913 | struct orinoco_private *priv = netdev_priv(dev); | 682 | struct orinoco_private *priv = ndev_priv(dev); |
914 | int err = -EINPROGRESS; /* Call commit handler */ | 683 | int err = -EINPROGRESS; /* Call commit handler */ |
915 | unsigned long flags; | 684 | unsigned long flags; |
916 | 685 | ||
@@ -964,7 +733,7 @@ static int orinoco_ioctl_getpower(struct net_device *dev, | |||
964 | struct iw_param *prq, | 733 | struct iw_param *prq, |
965 | char *extra) | 734 | char *extra) |
966 | { | 735 | { |
967 | struct orinoco_private *priv = netdev_priv(dev); | 736 | struct orinoco_private *priv = ndev_priv(dev); |
968 | hermes_t *hw = &priv->hw; | 737 | hermes_t *hw = &priv->hw; |
969 | int err = 0; | 738 | int err = 0; |
970 | u16 enable, period, timeout, mcast; | 739 | u16 enable, period, timeout, mcast; |
@@ -1018,7 +787,7 @@ static int orinoco_ioctl_set_encodeext(struct net_device *dev, | |||
1018 | union iwreq_data *wrqu, | 787 | union iwreq_data *wrqu, |
1019 | char *extra) | 788 | char *extra) |
1020 | { | 789 | { |
1021 | struct orinoco_private *priv = netdev_priv(dev); | 790 | struct orinoco_private *priv = ndev_priv(dev); |
1022 | struct iw_point *encoding = &wrqu->encoding; | 791 | struct iw_point *encoding = &wrqu->encoding; |
1023 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; | 792 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
1024 | int idx, alg = ext->alg, set_key = 1; | 793 | int idx, alg = ext->alg, set_key = 1; |
@@ -1079,7 +848,6 @@ static int orinoco_ioctl_set_encodeext(struct net_device *dev, | |||
1079 | 848 | ||
1080 | case IW_ENCODE_ALG_TKIP: | 849 | case IW_ENCODE_ALG_TKIP: |
1081 | { | 850 | { |
1082 | hermes_t *hw = &priv->hw; | ||
1083 | u8 *tkip_iv = NULL; | 851 | u8 *tkip_iv = NULL; |
1084 | 852 | ||
1085 | if (!priv->has_wpa || | 853 | if (!priv->has_wpa || |
@@ -1094,7 +862,7 @@ static int orinoco_ioctl_set_encodeext(struct net_device *dev, | |||
1094 | if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) | 862 | if (ext->ext_flags & IW_ENCODE_EXT_RX_SEQ_VALID) |
1095 | tkip_iv = &ext->rx_seq[0]; | 863 | tkip_iv = &ext->rx_seq[0]; |
1096 | 864 | ||
1097 | err = __orinoco_hw_set_tkip_key(hw, idx, | 865 | err = __orinoco_hw_set_tkip_key(priv, idx, |
1098 | ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, | 866 | ext->ext_flags & IW_ENCODE_EXT_SET_TX_KEY, |
1099 | (u8 *) &priv->tkip_key[idx], | 867 | (u8 *) &priv->tkip_key[idx], |
1100 | tkip_iv, NULL); | 868 | tkip_iv, NULL); |
@@ -1120,7 +888,7 @@ static int orinoco_ioctl_get_encodeext(struct net_device *dev, | |||
1120 | union iwreq_data *wrqu, | 888 | union iwreq_data *wrqu, |
1121 | char *extra) | 889 | char *extra) |
1122 | { | 890 | { |
1123 | struct orinoco_private *priv = netdev_priv(dev); | 891 | struct orinoco_private *priv = ndev_priv(dev); |
1124 | struct iw_point *encoding = &wrqu->encoding; | 892 | struct iw_point *encoding = &wrqu->encoding; |
1125 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; | 893 | struct iw_encode_ext *ext = (struct iw_encode_ext *)extra; |
1126 | int idx, max_key_len; | 894 | int idx, max_key_len; |
@@ -1177,7 +945,7 @@ static int orinoco_ioctl_set_auth(struct net_device *dev, | |||
1177 | struct iw_request_info *info, | 945 | struct iw_request_info *info, |
1178 | union iwreq_data *wrqu, char *extra) | 946 | union iwreq_data *wrqu, char *extra) |
1179 | { | 947 | { |
1180 | struct orinoco_private *priv = netdev_priv(dev); | 948 | struct orinoco_private *priv = ndev_priv(dev); |
1181 | hermes_t *hw = &priv->hw; | 949 | hermes_t *hw = &priv->hw; |
1182 | struct iw_param *param = &wrqu->param; | 950 | struct iw_param *param = &wrqu->param; |
1183 | unsigned long flags; | 951 | unsigned long flags; |
@@ -1255,7 +1023,7 @@ static int orinoco_ioctl_get_auth(struct net_device *dev, | |||
1255 | struct iw_request_info *info, | 1023 | struct iw_request_info *info, |
1256 | union iwreq_data *wrqu, char *extra) | 1024 | union iwreq_data *wrqu, char *extra) |
1257 | { | 1025 | { |
1258 | struct orinoco_private *priv = netdev_priv(dev); | 1026 | struct orinoco_private *priv = ndev_priv(dev); |
1259 | struct iw_param *param = &wrqu->param; | 1027 | struct iw_param *param = &wrqu->param; |
1260 | unsigned long flags; | 1028 | unsigned long flags; |
1261 | int ret = 0; | 1029 | int ret = 0; |
@@ -1295,7 +1063,7 @@ static int orinoco_ioctl_set_genie(struct net_device *dev, | |||
1295 | struct iw_request_info *info, | 1063 | struct iw_request_info *info, |
1296 | union iwreq_data *wrqu, char *extra) | 1064 | union iwreq_data *wrqu, char *extra) |
1297 | { | 1065 | { |
1298 | struct orinoco_private *priv = netdev_priv(dev); | 1066 | struct orinoco_private *priv = ndev_priv(dev); |
1299 | u8 *buf; | 1067 | u8 *buf; |
1300 | unsigned long flags; | 1068 | unsigned long flags; |
1301 | 1069 | ||
@@ -1338,7 +1106,7 @@ static int orinoco_ioctl_get_genie(struct net_device *dev, | |||
1338 | struct iw_request_info *info, | 1106 | struct iw_request_info *info, |
1339 | union iwreq_data *wrqu, char *extra) | 1107 | union iwreq_data *wrqu, char *extra) |
1340 | { | 1108 | { |
1341 | struct orinoco_private *priv = netdev_priv(dev); | 1109 | struct orinoco_private *priv = ndev_priv(dev); |
1342 | unsigned long flags; | 1110 | unsigned long flags; |
1343 | int err = 0; | 1111 | int err = 0; |
1344 | 1112 | ||
@@ -1367,7 +1135,7 @@ static int orinoco_ioctl_set_mlme(struct net_device *dev, | |||
1367 | struct iw_request_info *info, | 1135 | struct iw_request_info *info, |
1368 | union iwreq_data *wrqu, char *extra) | 1136 | union iwreq_data *wrqu, char *extra) |
1369 | { | 1137 | { |
1370 | struct orinoco_private *priv = netdev_priv(dev); | 1138 | struct orinoco_private *priv = ndev_priv(dev); |
1371 | hermes_t *hw = &priv->hw; | 1139 | hermes_t *hw = &priv->hw; |
1372 | struct iw_mlme *mlme = (struct iw_mlme *)extra; | 1140 | struct iw_mlme *mlme = (struct iw_mlme *)extra; |
1373 | unsigned long flags; | 1141 | unsigned long flags; |
@@ -1408,7 +1176,7 @@ static int orinoco_ioctl_getretry(struct net_device *dev, | |||
1408 | struct iw_param *rrq, | 1176 | struct iw_param *rrq, |
1409 | char *extra) | 1177 | char *extra) |
1410 | { | 1178 | { |
1411 | struct orinoco_private *priv = netdev_priv(dev); | 1179 | struct orinoco_private *priv = ndev_priv(dev); |
1412 | hermes_t *hw = &priv->hw; | 1180 | hermes_t *hw = &priv->hw; |
1413 | int err = 0; | 1181 | int err = 0; |
1414 | u16 short_limit, long_limit, lifetime; | 1182 | u16 short_limit, long_limit, lifetime; |
@@ -1462,7 +1230,7 @@ static int orinoco_ioctl_reset(struct net_device *dev, | |||
1462 | void *wrqu, | 1230 | void *wrqu, |
1463 | char *extra) | 1231 | char *extra) |
1464 | { | 1232 | { |
1465 | struct orinoco_private *priv = netdev_priv(dev); | 1233 | struct orinoco_private *priv = ndev_priv(dev); |
1466 | 1234 | ||
1467 | if (!capable(CAP_NET_ADMIN)) | 1235 | if (!capable(CAP_NET_ADMIN)) |
1468 | return -EPERM; | 1236 | return -EPERM; |
@@ -1487,7 +1255,7 @@ static int orinoco_ioctl_setibssport(struct net_device *dev, | |||
1487 | char *extra) | 1255 | char *extra) |
1488 | 1256 | ||
1489 | { | 1257 | { |
1490 | struct orinoco_private *priv = netdev_priv(dev); | 1258 | struct orinoco_private *priv = ndev_priv(dev); |
1491 | int val = *((int *) extra); | 1259 | int val = *((int *) extra); |
1492 | unsigned long flags; | 1260 | unsigned long flags; |
1493 | 1261 | ||
@@ -1508,7 +1276,7 @@ static int orinoco_ioctl_getibssport(struct net_device *dev, | |||
1508 | void *wrqu, | 1276 | void *wrqu, |
1509 | char *extra) | 1277 | char *extra) |
1510 | { | 1278 | { |
1511 | struct orinoco_private *priv = netdev_priv(dev); | 1279 | struct orinoco_private *priv = ndev_priv(dev); |
1512 | int *val = (int *) extra; | 1280 | int *val = (int *) extra; |
1513 | 1281 | ||
1514 | *val = priv->ibss_port; | 1282 | *val = priv->ibss_port; |
@@ -1520,7 +1288,7 @@ static int orinoco_ioctl_setport3(struct net_device *dev, | |||
1520 | void *wrqu, | 1288 | void *wrqu, |
1521 | char *extra) | 1289 | char *extra) |
1522 | { | 1290 | { |
1523 | struct orinoco_private *priv = netdev_priv(dev); | 1291 | struct orinoco_private *priv = ndev_priv(dev); |
1524 | int val = *((int *) extra); | 1292 | int val = *((int *) extra); |
1525 | int err = 0; | 1293 | int err = 0; |
1526 | unsigned long flags; | 1294 | unsigned long flags; |
@@ -1566,7 +1334,7 @@ static int orinoco_ioctl_getport3(struct net_device *dev, | |||
1566 | void *wrqu, | 1334 | void *wrqu, |
1567 | char *extra) | 1335 | char *extra) |
1568 | { | 1336 | { |
1569 | struct orinoco_private *priv = netdev_priv(dev); | 1337 | struct orinoco_private *priv = ndev_priv(dev); |
1570 | int *val = (int *) extra; | 1338 | int *val = (int *) extra; |
1571 | 1339 | ||
1572 | *val = priv->prefer_port3; | 1340 | *val = priv->prefer_port3; |
@@ -1578,7 +1346,7 @@ static int orinoco_ioctl_setpreamble(struct net_device *dev, | |||
1578 | void *wrqu, | 1346 | void *wrqu, |
1579 | char *extra) | 1347 | char *extra) |
1580 | { | 1348 | { |
1581 | struct orinoco_private *priv = netdev_priv(dev); | 1349 | struct orinoco_private *priv = ndev_priv(dev); |
1582 | unsigned long flags; | 1350 | unsigned long flags; |
1583 | int val; | 1351 | int val; |
1584 | 1352 | ||
@@ -1610,7 +1378,7 @@ static int orinoco_ioctl_getpreamble(struct net_device *dev, | |||
1610 | void *wrqu, | 1378 | void *wrqu, |
1611 | char *extra) | 1379 | char *extra) |
1612 | { | 1380 | { |
1613 | struct orinoco_private *priv = netdev_priv(dev); | 1381 | struct orinoco_private *priv = ndev_priv(dev); |
1614 | int *val = (int *) extra; | 1382 | int *val = (int *) extra; |
1615 | 1383 | ||
1616 | if (!priv->has_preamble) | 1384 | if (!priv->has_preamble) |
@@ -1630,7 +1398,7 @@ static int orinoco_ioctl_getrid(struct net_device *dev, | |||
1630 | struct iw_point *data, | 1398 | struct iw_point *data, |
1631 | char *extra) | 1399 | char *extra) |
1632 | { | 1400 | { |
1633 | struct orinoco_private *priv = netdev_priv(dev); | 1401 | struct orinoco_private *priv = ndev_priv(dev); |
1634 | hermes_t *hw = &priv->hw; | 1402 | hermes_t *hw = &priv->hw; |
1635 | int rid = data->flags; | 1403 | int rid = data->flags; |
1636 | u16 length; | 1404 | u16 length; |
@@ -1661,519 +1429,6 @@ static int orinoco_ioctl_getrid(struct net_device *dev, | |||
1661 | return err; | 1429 | return err; |
1662 | } | 1430 | } |
1663 | 1431 | ||
1664 | /* Trigger a scan (look for other cells in the vicinity) */ | ||
1665 | static int orinoco_ioctl_setscan(struct net_device *dev, | ||
1666 | struct iw_request_info *info, | ||
1667 | struct iw_point *srq, | ||
1668 | char *extra) | ||
1669 | { | ||
1670 | struct orinoco_private *priv = netdev_priv(dev); | ||
1671 | hermes_t *hw = &priv->hw; | ||
1672 | struct iw_scan_req *si = (struct iw_scan_req *) extra; | ||
1673 | int err = 0; | ||
1674 | unsigned long flags; | ||
1675 | |||
1676 | /* Note : you may have realised that, as this is a SET operation, | ||
1677 | * this is privileged and therefore a normal user can't | ||
1678 | * perform scanning. | ||
1679 | * This is not an error, while the device perform scanning, | ||
1680 | * traffic doesn't flow, so it's a perfect DoS... | ||
1681 | * Jean II */ | ||
1682 | |||
1683 | if (orinoco_lock(priv, &flags) != 0) | ||
1684 | return -EBUSY; | ||
1685 | |||
1686 | /* Scanning with port 0 disabled would fail */ | ||
1687 | if (!netif_running(dev)) { | ||
1688 | err = -ENETDOWN; | ||
1689 | goto out; | ||
1690 | } | ||
1691 | |||
1692 | /* In monitor mode, the scan results are always empty. | ||
1693 | * Probe responses are passed to the driver as received | ||
1694 | * frames and could be processed in software. */ | ||
1695 | if (priv->iw_mode == IW_MODE_MONITOR) { | ||
1696 | err = -EOPNOTSUPP; | ||
1697 | goto out; | ||
1698 | } | ||
1699 | |||
1700 | /* Note : because we don't lock out the irq handler, the way | ||
1701 | * we access scan variables in priv is critical. | ||
1702 | * o scan_inprogress : not touched by irq handler | ||
1703 | * o scan_mode : not touched by irq handler | ||
1704 | * Before modifying anything on those variables, please think hard ! | ||
1705 | * Jean II */ | ||
1706 | |||
1707 | /* Save flags */ | ||
1708 | priv->scan_mode = srq->flags; | ||
1709 | |||
1710 | /* Always trigger scanning, even if it's in progress. | ||
1711 | * This way, if the info frame get lost, we will recover somewhat | ||
1712 | * gracefully - Jean II */ | ||
1713 | |||
1714 | if (priv->has_hostscan) { | ||
1715 | switch (priv->firmware_type) { | ||
1716 | case FIRMWARE_TYPE_SYMBOL: | ||
1717 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1718 | HERMES_RID_CNFHOSTSCAN_SYMBOL, | ||
1719 | HERMES_HOSTSCAN_SYMBOL_ONCE | | ||
1720 | HERMES_HOSTSCAN_SYMBOL_BCAST); | ||
1721 | break; | ||
1722 | case FIRMWARE_TYPE_INTERSIL: { | ||
1723 | __le16 req[3]; | ||
1724 | |||
1725 | req[0] = cpu_to_le16(0x3fff); /* All channels */ | ||
1726 | req[1] = cpu_to_le16(0x0001); /* rate 1 Mbps */ | ||
1727 | req[2] = 0; /* Any ESSID */ | ||
1728 | err = HERMES_WRITE_RECORD(hw, USER_BAP, | ||
1729 | HERMES_RID_CNFHOSTSCAN, &req); | ||
1730 | } | ||
1731 | break; | ||
1732 | case FIRMWARE_TYPE_AGERE: | ||
1733 | if (priv->scan_mode & IW_SCAN_THIS_ESSID) { | ||
1734 | struct hermes_idstring idbuf; | ||
1735 | size_t len = min(sizeof(idbuf.val), | ||
1736 | (size_t) si->essid_len); | ||
1737 | idbuf.len = cpu_to_le16(len); | ||
1738 | memcpy(idbuf.val, si->essid, len); | ||
1739 | |||
1740 | err = hermes_write_ltv(hw, USER_BAP, | ||
1741 | HERMES_RID_CNFSCANSSID_AGERE, | ||
1742 | HERMES_BYTES_TO_RECLEN(len + 2), | ||
1743 | &idbuf); | ||
1744 | } else | ||
1745 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1746 | HERMES_RID_CNFSCANSSID_AGERE, | ||
1747 | 0); /* Any ESSID */ | ||
1748 | if (err) | ||
1749 | break; | ||
1750 | |||
1751 | if (priv->has_ext_scan) { | ||
1752 | /* Clear scan results at the start of | ||
1753 | * an extended scan */ | ||
1754 | orinoco_clear_scan_results(priv, | ||
1755 | msecs_to_jiffies(15000)); | ||
1756 | |||
1757 | /* TODO: Is this available on older firmware? | ||
1758 | * Can we use it to scan specific channels | ||
1759 | * for IW_SCAN_THIS_FREQ? */ | ||
1760 | err = hermes_write_wordrec(hw, USER_BAP, | ||
1761 | HERMES_RID_CNFSCANCHANNELS2GHZ, | ||
1762 | 0x7FFF); | ||
1763 | if (err) | ||
1764 | goto out; | ||
1765 | |||
1766 | err = hermes_inquire(hw, | ||
1767 | HERMES_INQ_CHANNELINFO); | ||
1768 | } else | ||
1769 | err = hermes_inquire(hw, HERMES_INQ_SCAN); | ||
1770 | break; | ||
1771 | } | ||
1772 | } else | ||
1773 | err = hermes_inquire(hw, HERMES_INQ_SCAN); | ||
1774 | |||
1775 | /* One more client */ | ||
1776 | if (!err) | ||
1777 | priv->scan_inprogress = 1; | ||
1778 | |||
1779 | out: | ||
1780 | orinoco_unlock(priv, &flags); | ||
1781 | return err; | ||
1782 | } | ||
1783 | |||
1784 | #define MAX_CUSTOM_LEN 64 | ||
1785 | |||
1786 | /* Translate scan data returned from the card to a card independant | ||
1787 | * format that the Wireless Tools will understand - Jean II */ | ||
1788 | static inline char *orinoco_translate_scan(struct net_device *dev, | ||
1789 | struct iw_request_info *info, | ||
1790 | char *current_ev, | ||
1791 | char *end_buf, | ||
1792 | union hermes_scan_info *bss, | ||
1793 | unsigned long last_scanned) | ||
1794 | { | ||
1795 | struct orinoco_private *priv = netdev_priv(dev); | ||
1796 | u16 capabilities; | ||
1797 | u16 channel; | ||
1798 | struct iw_event iwe; /* Temporary buffer */ | ||
1799 | char custom[MAX_CUSTOM_LEN]; | ||
1800 | |||
1801 | memset(&iwe, 0, sizeof(iwe)); | ||
1802 | |||
1803 | /* First entry *MUST* be the AP MAC address */ | ||
1804 | iwe.cmd = SIOCGIWAP; | ||
1805 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | ||
1806 | memcpy(iwe.u.ap_addr.sa_data, bss->a.bssid, ETH_ALEN); | ||
1807 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1808 | &iwe, IW_EV_ADDR_LEN); | ||
1809 | |||
1810 | /* Other entries will be displayed in the order we give them */ | ||
1811 | |||
1812 | /* Add the ESSID */ | ||
1813 | iwe.u.data.length = le16_to_cpu(bss->a.essid_len); | ||
1814 | if (iwe.u.data.length > 32) | ||
1815 | iwe.u.data.length = 32; | ||
1816 | iwe.cmd = SIOCGIWESSID; | ||
1817 | iwe.u.data.flags = 1; | ||
1818 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1819 | &iwe, bss->a.essid); | ||
1820 | |||
1821 | /* Add mode */ | ||
1822 | iwe.cmd = SIOCGIWMODE; | ||
1823 | capabilities = le16_to_cpu(bss->a.capabilities); | ||
1824 | if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { | ||
1825 | if (capabilities & WLAN_CAPABILITY_ESS) | ||
1826 | iwe.u.mode = IW_MODE_MASTER; | ||
1827 | else | ||
1828 | iwe.u.mode = IW_MODE_ADHOC; | ||
1829 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1830 | &iwe, IW_EV_UINT_LEN); | ||
1831 | } | ||
1832 | |||
1833 | channel = bss->s.channel; | ||
1834 | if ((channel >= 1) && (channel <= NUM_CHANNELS)) { | ||
1835 | /* Add channel and frequency */ | ||
1836 | iwe.cmd = SIOCGIWFREQ; | ||
1837 | iwe.u.freq.m = channel; | ||
1838 | iwe.u.freq.e = 0; | ||
1839 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1840 | &iwe, IW_EV_FREQ_LEN); | ||
1841 | |||
1842 | iwe.u.freq.m = ieee80211_dsss_chan_to_freq(channel) * 100000; | ||
1843 | iwe.u.freq.e = 1; | ||
1844 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1845 | &iwe, IW_EV_FREQ_LEN); | ||
1846 | } | ||
1847 | |||
1848 | /* Add quality statistics. level and noise in dB. No link quality */ | ||
1849 | iwe.cmd = IWEVQUAL; | ||
1850 | iwe.u.qual.updated = IW_QUAL_DBM | IW_QUAL_QUAL_INVALID; | ||
1851 | iwe.u.qual.level = (__u8) le16_to_cpu(bss->a.level) - 0x95; | ||
1852 | iwe.u.qual.noise = (__u8) le16_to_cpu(bss->a.noise) - 0x95; | ||
1853 | /* Wireless tools prior to 27.pre22 will show link quality | ||
1854 | * anyway, so we provide a reasonable value. */ | ||
1855 | if (iwe.u.qual.level > iwe.u.qual.noise) | ||
1856 | iwe.u.qual.qual = iwe.u.qual.level - iwe.u.qual.noise; | ||
1857 | else | ||
1858 | iwe.u.qual.qual = 0; | ||
1859 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1860 | &iwe, IW_EV_QUAL_LEN); | ||
1861 | |||
1862 | /* Add encryption capability */ | ||
1863 | iwe.cmd = SIOCGIWENCODE; | ||
1864 | if (capabilities & WLAN_CAPABILITY_PRIVACY) | ||
1865 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; | ||
1866 | else | ||
1867 | iwe.u.data.flags = IW_ENCODE_DISABLED; | ||
1868 | iwe.u.data.length = 0; | ||
1869 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1870 | &iwe, NULL); | ||
1871 | |||
1872 | /* Bit rate is not available in Lucent/Agere firmwares */ | ||
1873 | if (priv->firmware_type != FIRMWARE_TYPE_AGERE) { | ||
1874 | char *current_val = current_ev + iwe_stream_lcp_len(info); | ||
1875 | int i; | ||
1876 | int step; | ||
1877 | |||
1878 | if (priv->firmware_type == FIRMWARE_TYPE_SYMBOL) | ||
1879 | step = 2; | ||
1880 | else | ||
1881 | step = 1; | ||
1882 | |||
1883 | iwe.cmd = SIOCGIWRATE; | ||
1884 | /* Those two flags are ignored... */ | ||
1885 | iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; | ||
1886 | /* Max 10 values */ | ||
1887 | for (i = 0; i < 10; i += step) { | ||
1888 | /* NULL terminated */ | ||
1889 | if (bss->p.rates[i] == 0x0) | ||
1890 | break; | ||
1891 | /* Bit rate given in 500 kb/s units (+ 0x80) */ | ||
1892 | iwe.u.bitrate.value = | ||
1893 | ((bss->p.rates[i] & 0x7f) * 500000); | ||
1894 | current_val = iwe_stream_add_value(info, current_ev, | ||
1895 | current_val, | ||
1896 | end_buf, &iwe, | ||
1897 | IW_EV_PARAM_LEN); | ||
1898 | } | ||
1899 | /* Check if we added any event */ | ||
1900 | if ((current_val - current_ev) > iwe_stream_lcp_len(info)) | ||
1901 | current_ev = current_val; | ||
1902 | } | ||
1903 | |||
1904 | /* Beacon interval */ | ||
1905 | iwe.cmd = IWEVCUSTOM; | ||
1906 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
1907 | "bcn_int=%d", | ||
1908 | le16_to_cpu(bss->a.beacon_interv)); | ||
1909 | if (iwe.u.data.length) | ||
1910 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1911 | &iwe, custom); | ||
1912 | |||
1913 | /* Capabilites */ | ||
1914 | iwe.cmd = IWEVCUSTOM; | ||
1915 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
1916 | "capab=0x%04x", | ||
1917 | capabilities); | ||
1918 | if (iwe.u.data.length) | ||
1919 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1920 | &iwe, custom); | ||
1921 | |||
1922 | /* Add EXTRA: Age to display seconds since last beacon/probe response | ||
1923 | * for given network. */ | ||
1924 | iwe.cmd = IWEVCUSTOM; | ||
1925 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
1926 | " Last beacon: %dms ago", | ||
1927 | jiffies_to_msecs(jiffies - last_scanned)); | ||
1928 | if (iwe.u.data.length) | ||
1929 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1930 | &iwe, custom); | ||
1931 | |||
1932 | return current_ev; | ||
1933 | } | ||
1934 | |||
1935 | static inline char *orinoco_translate_ext_scan(struct net_device *dev, | ||
1936 | struct iw_request_info *info, | ||
1937 | char *current_ev, | ||
1938 | char *end_buf, | ||
1939 | struct agere_ext_scan_info *bss, | ||
1940 | unsigned long last_scanned) | ||
1941 | { | ||
1942 | u16 capabilities; | ||
1943 | u16 channel; | ||
1944 | struct iw_event iwe; /* Temporary buffer */ | ||
1945 | char custom[MAX_CUSTOM_LEN]; | ||
1946 | u8 *ie; | ||
1947 | |||
1948 | memset(&iwe, 0, sizeof(iwe)); | ||
1949 | |||
1950 | /* First entry *MUST* be the AP MAC address */ | ||
1951 | iwe.cmd = SIOCGIWAP; | ||
1952 | iwe.u.ap_addr.sa_family = ARPHRD_ETHER; | ||
1953 | memcpy(iwe.u.ap_addr.sa_data, bss->bssid, ETH_ALEN); | ||
1954 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1955 | &iwe, IW_EV_ADDR_LEN); | ||
1956 | |||
1957 | /* Other entries will be displayed in the order we give them */ | ||
1958 | |||
1959 | /* Add the ESSID */ | ||
1960 | ie = bss->data; | ||
1961 | iwe.u.data.length = ie[1]; | ||
1962 | if (iwe.u.data.length) { | ||
1963 | if (iwe.u.data.length > 32) | ||
1964 | iwe.u.data.length = 32; | ||
1965 | iwe.cmd = SIOCGIWESSID; | ||
1966 | iwe.u.data.flags = 1; | ||
1967 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
1968 | &iwe, &ie[2]); | ||
1969 | } | ||
1970 | |||
1971 | /* Add mode */ | ||
1972 | capabilities = le16_to_cpu(bss->capabilities); | ||
1973 | if (capabilities & (WLAN_CAPABILITY_ESS | WLAN_CAPABILITY_IBSS)) { | ||
1974 | iwe.cmd = SIOCGIWMODE; | ||
1975 | if (capabilities & WLAN_CAPABILITY_ESS) | ||
1976 | iwe.u.mode = IW_MODE_MASTER; | ||
1977 | else | ||
1978 | iwe.u.mode = IW_MODE_ADHOC; | ||
1979 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1980 | &iwe, IW_EV_UINT_LEN); | ||
1981 | } | ||
1982 | |||
1983 | ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_DS_PARAMS); | ||
1984 | channel = ie ? ie[2] : 0; | ||
1985 | if ((channel >= 1) && (channel <= NUM_CHANNELS)) { | ||
1986 | /* Add channel and frequency */ | ||
1987 | iwe.cmd = SIOCGIWFREQ; | ||
1988 | iwe.u.freq.m = channel; | ||
1989 | iwe.u.freq.e = 0; | ||
1990 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1991 | &iwe, IW_EV_FREQ_LEN); | ||
1992 | |||
1993 | iwe.u.freq.m = ieee80211_dsss_chan_to_freq(channel) * 100000; | ||
1994 | iwe.u.freq.e = 1; | ||
1995 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
1996 | &iwe, IW_EV_FREQ_LEN); | ||
1997 | } | ||
1998 | |||
1999 | /* Add quality statistics. level and noise in dB. No link quality */ | ||
2000 | iwe.cmd = IWEVQUAL; | ||
2001 | iwe.u.qual.updated = IW_QUAL_DBM | IW_QUAL_QUAL_INVALID; | ||
2002 | iwe.u.qual.level = bss->level - 0x95; | ||
2003 | iwe.u.qual.noise = bss->noise - 0x95; | ||
2004 | /* Wireless tools prior to 27.pre22 will show link quality | ||
2005 | * anyway, so we provide a reasonable value. */ | ||
2006 | if (iwe.u.qual.level > iwe.u.qual.noise) | ||
2007 | iwe.u.qual.qual = iwe.u.qual.level - iwe.u.qual.noise; | ||
2008 | else | ||
2009 | iwe.u.qual.qual = 0; | ||
2010 | current_ev = iwe_stream_add_event(info, current_ev, end_buf, | ||
2011 | &iwe, IW_EV_QUAL_LEN); | ||
2012 | |||
2013 | /* Add encryption capability */ | ||
2014 | iwe.cmd = SIOCGIWENCODE; | ||
2015 | if (capabilities & WLAN_CAPABILITY_PRIVACY) | ||
2016 | iwe.u.data.flags = IW_ENCODE_ENABLED | IW_ENCODE_NOKEY; | ||
2017 | else | ||
2018 | iwe.u.data.flags = IW_ENCODE_DISABLED; | ||
2019 | iwe.u.data.length = 0; | ||
2020 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2021 | &iwe, NULL); | ||
2022 | |||
2023 | /* WPA IE */ | ||
2024 | ie = orinoco_get_wpa_ie(bss->data, sizeof(bss->data)); | ||
2025 | if (ie) { | ||
2026 | iwe.cmd = IWEVGENIE; | ||
2027 | iwe.u.data.length = ie[1] + 2; | ||
2028 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2029 | &iwe, ie); | ||
2030 | } | ||
2031 | |||
2032 | /* RSN IE */ | ||
2033 | ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_RSN); | ||
2034 | if (ie) { | ||
2035 | iwe.cmd = IWEVGENIE; | ||
2036 | iwe.u.data.length = ie[1] + 2; | ||
2037 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2038 | &iwe, ie); | ||
2039 | } | ||
2040 | |||
2041 | ie = orinoco_get_ie(bss->data, sizeof(bss->data), WLAN_EID_SUPP_RATES); | ||
2042 | if (ie) { | ||
2043 | char *p = current_ev + iwe_stream_lcp_len(info); | ||
2044 | int i; | ||
2045 | |||
2046 | iwe.cmd = SIOCGIWRATE; | ||
2047 | /* Those two flags are ignored... */ | ||
2048 | iwe.u.bitrate.fixed = iwe.u.bitrate.disabled = 0; | ||
2049 | |||
2050 | for (i = 2; i < (ie[1] + 2); i++) { | ||
2051 | iwe.u.bitrate.value = ((ie[i] & 0x7F) * 500000); | ||
2052 | p = iwe_stream_add_value(info, current_ev, p, end_buf, | ||
2053 | &iwe, IW_EV_PARAM_LEN); | ||
2054 | } | ||
2055 | /* Check if we added any event */ | ||
2056 | if (p > (current_ev + iwe_stream_lcp_len(info))) | ||
2057 | current_ev = p; | ||
2058 | } | ||
2059 | |||
2060 | /* Timestamp */ | ||
2061 | iwe.cmd = IWEVCUSTOM; | ||
2062 | iwe.u.data.length = | ||
2063 | snprintf(custom, MAX_CUSTOM_LEN, "tsf=%016llx", | ||
2064 | (unsigned long long) le64_to_cpu(bss->timestamp)); | ||
2065 | if (iwe.u.data.length) | ||
2066 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2067 | &iwe, custom); | ||
2068 | |||
2069 | /* Beacon interval */ | ||
2070 | iwe.cmd = IWEVCUSTOM; | ||
2071 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
2072 | "bcn_int=%d", | ||
2073 | le16_to_cpu(bss->beacon_interval)); | ||
2074 | if (iwe.u.data.length) | ||
2075 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2076 | &iwe, custom); | ||
2077 | |||
2078 | /* Capabilites */ | ||
2079 | iwe.cmd = IWEVCUSTOM; | ||
2080 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
2081 | "capab=0x%04x", | ||
2082 | capabilities); | ||
2083 | if (iwe.u.data.length) | ||
2084 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2085 | &iwe, custom); | ||
2086 | |||
2087 | /* Add EXTRA: Age to display seconds since last beacon/probe response | ||
2088 | * for given network. */ | ||
2089 | iwe.cmd = IWEVCUSTOM; | ||
2090 | iwe.u.data.length = snprintf(custom, MAX_CUSTOM_LEN, | ||
2091 | " Last beacon: %dms ago", | ||
2092 | jiffies_to_msecs(jiffies - last_scanned)); | ||
2093 | if (iwe.u.data.length) | ||
2094 | current_ev = iwe_stream_add_point(info, current_ev, end_buf, | ||
2095 | &iwe, custom); | ||
2096 | |||
2097 | return current_ev; | ||
2098 | } | ||
2099 | |||
2100 | /* Return results of a scan */ | ||
2101 | static int orinoco_ioctl_getscan(struct net_device *dev, | ||
2102 | struct iw_request_info *info, | ||
2103 | struct iw_point *srq, | ||
2104 | char *extra) | ||
2105 | { | ||
2106 | struct orinoco_private *priv = netdev_priv(dev); | ||
2107 | int err = 0; | ||
2108 | unsigned long flags; | ||
2109 | char *current_ev = extra; | ||
2110 | |||
2111 | if (orinoco_lock(priv, &flags) != 0) | ||
2112 | return -EBUSY; | ||
2113 | |||
2114 | if (priv->scan_inprogress) { | ||
2115 | /* Important note : we don't want to block the caller | ||
2116 | * until results are ready for various reasons. | ||
2117 | * First, managing wait queues is complex and racy. | ||
2118 | * Second, we grab some rtnetlink lock before comming | ||
2119 | * here (in dev_ioctl()). | ||
2120 | * Third, we generate an Wireless Event, so the | ||
2121 | * caller can wait itself on that - Jean II */ | ||
2122 | err = -EAGAIN; | ||
2123 | goto out; | ||
2124 | } | ||
2125 | |||
2126 | if (priv->has_ext_scan) { | ||
2127 | struct xbss_element *bss; | ||
2128 | |||
2129 | list_for_each_entry(bss, &priv->bss_list, list) { | ||
2130 | /* Translate this entry to WE format */ | ||
2131 | current_ev = | ||
2132 | orinoco_translate_ext_scan(dev, info, | ||
2133 | current_ev, | ||
2134 | extra + srq->length, | ||
2135 | &bss->bss, | ||
2136 | bss->last_scanned); | ||
2137 | |||
2138 | /* Check if there is space for one more entry */ | ||
2139 | if ((extra + srq->length - current_ev) | ||
2140 | <= IW_EV_ADDR_LEN) { | ||
2141 | /* Ask user space to try again with a | ||
2142 | * bigger buffer */ | ||
2143 | err = -E2BIG; | ||
2144 | goto out; | ||
2145 | } | ||
2146 | } | ||
2147 | |||
2148 | } else { | ||
2149 | struct bss_element *bss; | ||
2150 | |||
2151 | list_for_each_entry(bss, &priv->bss_list, list) { | ||
2152 | /* Translate this entry to WE format */ | ||
2153 | current_ev = orinoco_translate_scan(dev, info, | ||
2154 | current_ev, | ||
2155 | extra + srq->length, | ||
2156 | &bss->bss, | ||
2157 | bss->last_scanned); | ||
2158 | |||
2159 | /* Check if there is space for one more entry */ | ||
2160 | if ((extra + srq->length - current_ev) | ||
2161 | <= IW_EV_ADDR_LEN) { | ||
2162 | /* Ask user space to try again with a | ||
2163 | * bigger buffer */ | ||
2164 | err = -E2BIG; | ||
2165 | goto out; | ||
2166 | } | ||
2167 | } | ||
2168 | } | ||
2169 | |||
2170 | srq->length = (current_ev - extra); | ||
2171 | srq->flags = (__u16) priv->scan_mode; | ||
2172 | |||
2173 | out: | ||
2174 | orinoco_unlock(priv, &flags); | ||
2175 | return err; | ||
2176 | } | ||
2177 | 1432 | ||
2178 | /* Commit handler, called after set operations */ | 1433 | /* Commit handler, called after set operations */ |
2179 | static int orinoco_ioctl_commit(struct net_device *dev, | 1434 | static int orinoco_ioctl_commit(struct net_device *dev, |
@@ -2181,50 +1436,17 @@ static int orinoco_ioctl_commit(struct net_device *dev, | |||
2181 | void *wrqu, | 1436 | void *wrqu, |
2182 | char *extra) | 1437 | char *extra) |
2183 | { | 1438 | { |
2184 | struct orinoco_private *priv = netdev_priv(dev); | 1439 | struct orinoco_private *priv = ndev_priv(dev); |
2185 | struct hermes *hw = &priv->hw; | ||
2186 | unsigned long flags; | 1440 | unsigned long flags; |
2187 | int err = 0; | 1441 | int err = 0; |
2188 | 1442 | ||
2189 | if (!priv->open) | 1443 | if (!priv->open) |
2190 | return 0; | 1444 | return 0; |
2191 | 1445 | ||
2192 | if (priv->broken_disableport) { | ||
2193 | orinoco_reset(&priv->reset_work); | ||
2194 | return 0; | ||
2195 | } | ||
2196 | |||
2197 | if (orinoco_lock(priv, &flags) != 0) | 1446 | if (orinoco_lock(priv, &flags) != 0) |
2198 | return err; | 1447 | return err; |
2199 | 1448 | ||
2200 | err = hermes_disable_port(hw, 0); | 1449 | err = orinoco_commit(priv); |
2201 | if (err) { | ||
2202 | printk(KERN_WARNING "%s: Unable to disable port " | ||
2203 | "while reconfiguring card\n", dev->name); | ||
2204 | priv->broken_disableport = 1; | ||
2205 | goto out; | ||
2206 | } | ||
2207 | |||
2208 | err = __orinoco_program_rids(dev); | ||
2209 | if (err) { | ||
2210 | printk(KERN_WARNING "%s: Unable to reconfigure card\n", | ||
2211 | dev->name); | ||
2212 | goto out; | ||
2213 | } | ||
2214 | |||
2215 | err = hermes_enable_port(hw, 0); | ||
2216 | if (err) { | ||
2217 | printk(KERN_WARNING "%s: Unable to enable port while reconfiguring card\n", | ||
2218 | dev->name); | ||
2219 | goto out; | ||
2220 | } | ||
2221 | |||
2222 | out: | ||
2223 | if (err) { | ||
2224 | printk(KERN_WARNING "%s: Resetting instead...\n", dev->name); | ||
2225 | schedule_work(&priv->reset_work); | ||
2226 | err = 0; | ||
2227 | } | ||
2228 | 1450 | ||
2229 | orinoco_unlock(priv, &flags); | 1451 | orinoco_unlock(priv, &flags); |
2230 | return err; | 1452 | return err; |
@@ -2258,26 +1480,24 @@ static const struct iw_priv_args orinoco_privtab[] = { | |||
2258 | [IW_IOCTL_IDX(id)] = (iw_handler) func | 1480 | [IW_IOCTL_IDX(id)] = (iw_handler) func |
2259 | static const iw_handler orinoco_handler[] = { | 1481 | static const iw_handler orinoco_handler[] = { |
2260 | STD_IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit), | 1482 | STD_IW_HANDLER(SIOCSIWCOMMIT, orinoco_ioctl_commit), |
2261 | STD_IW_HANDLER(SIOCGIWNAME, orinoco_ioctl_getname), | 1483 | STD_IW_HANDLER(SIOCGIWNAME, cfg80211_wext_giwname), |
2262 | STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq), | 1484 | STD_IW_HANDLER(SIOCSIWFREQ, orinoco_ioctl_setfreq), |
2263 | STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq), | 1485 | STD_IW_HANDLER(SIOCGIWFREQ, orinoco_ioctl_getfreq), |
2264 | STD_IW_HANDLER(SIOCSIWMODE, orinoco_ioctl_setmode), | 1486 | STD_IW_HANDLER(SIOCSIWMODE, cfg80211_wext_siwmode), |
2265 | STD_IW_HANDLER(SIOCGIWMODE, orinoco_ioctl_getmode), | 1487 | STD_IW_HANDLER(SIOCGIWMODE, cfg80211_wext_giwmode), |
2266 | STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens), | 1488 | STD_IW_HANDLER(SIOCSIWSENS, orinoco_ioctl_setsens), |
2267 | STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens), | 1489 | STD_IW_HANDLER(SIOCGIWSENS, orinoco_ioctl_getsens), |
2268 | STD_IW_HANDLER(SIOCGIWRANGE, orinoco_ioctl_getiwrange), | 1490 | STD_IW_HANDLER(SIOCGIWRANGE, cfg80211_wext_giwrange), |
2269 | STD_IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy), | 1491 | STD_IW_HANDLER(SIOCSIWSPY, iw_handler_set_spy), |
2270 | STD_IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy), | 1492 | STD_IW_HANDLER(SIOCGIWSPY, iw_handler_get_spy), |
2271 | STD_IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy), | 1493 | STD_IW_HANDLER(SIOCSIWTHRSPY, iw_handler_set_thrspy), |
2272 | STD_IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy), | 1494 | STD_IW_HANDLER(SIOCGIWTHRSPY, iw_handler_get_thrspy), |
2273 | STD_IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap), | 1495 | STD_IW_HANDLER(SIOCSIWAP, orinoco_ioctl_setwap), |
2274 | STD_IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap), | 1496 | STD_IW_HANDLER(SIOCGIWAP, orinoco_ioctl_getwap), |
2275 | STD_IW_HANDLER(SIOCSIWSCAN, orinoco_ioctl_setscan), | 1497 | STD_IW_HANDLER(SIOCSIWSCAN, cfg80211_wext_siwscan), |
2276 | STD_IW_HANDLER(SIOCGIWSCAN, orinoco_ioctl_getscan), | 1498 | STD_IW_HANDLER(SIOCGIWSCAN, cfg80211_wext_giwscan), |
2277 | STD_IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid), | 1499 | STD_IW_HANDLER(SIOCSIWESSID, orinoco_ioctl_setessid), |
2278 | STD_IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid), | 1500 | STD_IW_HANDLER(SIOCGIWESSID, orinoco_ioctl_getessid), |
2279 | STD_IW_HANDLER(SIOCSIWNICKN, orinoco_ioctl_setnick), | ||
2280 | STD_IW_HANDLER(SIOCGIWNICKN, orinoco_ioctl_getnick), | ||
2281 | STD_IW_HANDLER(SIOCSIWRATE, orinoco_ioctl_setrate), | 1501 | STD_IW_HANDLER(SIOCSIWRATE, orinoco_ioctl_setrate), |
2282 | STD_IW_HANDLER(SIOCGIWRATE, orinoco_ioctl_getrate), | 1502 | STD_IW_HANDLER(SIOCGIWRATE, orinoco_ioctl_getrate), |
2283 | STD_IW_HANDLER(SIOCSIWRTS, orinoco_ioctl_setrts), | 1503 | STD_IW_HANDLER(SIOCSIWRTS, orinoco_ioctl_setrts), |
diff --git a/drivers/net/wireless/p54/Makefile b/drivers/net/wireless/p54/Makefile index c2050dee6293..b542e68f1781 100644 --- a/drivers/net/wireless/p54/Makefile +++ b/drivers/net/wireless/p54/Makefile | |||
@@ -1,3 +1,6 @@ | |||
1 | p54common-objs := eeprom.o fwio.o txrx.o main.o | ||
2 | p54common-$(CONFIG_P54_LEDS) += led.o | ||
3 | |||
1 | obj-$(CONFIG_P54_COMMON) += p54common.o | 4 | obj-$(CONFIG_P54_COMMON) += p54common.o |
2 | obj-$(CONFIG_P54_USB) += p54usb.o | 5 | obj-$(CONFIG_P54_USB) += p54usb.o |
3 | obj-$(CONFIG_P54_PCI) += p54pci.o | 6 | obj-$(CONFIG_P54_PCI) += p54pci.o |
diff --git a/drivers/net/wireless/p54/eeprom.c b/drivers/net/wireless/p54/eeprom.c new file mode 100644 index 000000000000..a2a044ef1012 --- /dev/null +++ b/drivers/net/wireless/p54/eeprom.c | |||
@@ -0,0 +1,564 @@ | |||
1 | /* | ||
2 | * EEPROM parser code for mac80211 Prism54 drivers | ||
3 | * | ||
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
5 | * Copyright (c) 2007-2009, Christian Lamparter <chunkeey@web.de> | ||
6 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> | ||
7 | * | ||
8 | * Based on: | ||
9 | * - the islsm (softmac prism54) driver, which is: | ||
10 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
11 | * - stlc45xx driver | ||
12 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | |||
19 | #include <linux/init.h> | ||
20 | #include <linux/firmware.h> | ||
21 | #include <linux/etherdevice.h> | ||
22 | |||
23 | #include <net/mac80211.h> | ||
24 | |||
25 | #include "p54.h" | ||
26 | #include "eeprom.h" | ||
27 | #include "lmac.h" | ||
28 | |||
29 | static struct ieee80211_rate p54_bgrates[] = { | ||
30 | { .bitrate = 10, .hw_value = 0, }, | ||
31 | { .bitrate = 20, .hw_value = 1, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
32 | { .bitrate = 55, .hw_value = 2, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
33 | { .bitrate = 110, .hw_value = 3, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
34 | { .bitrate = 60, .hw_value = 4, }, | ||
35 | { .bitrate = 90, .hw_value = 5, }, | ||
36 | { .bitrate = 120, .hw_value = 6, }, | ||
37 | { .bitrate = 180, .hw_value = 7, }, | ||
38 | { .bitrate = 240, .hw_value = 8, }, | ||
39 | { .bitrate = 360, .hw_value = 9, }, | ||
40 | { .bitrate = 480, .hw_value = 10, }, | ||
41 | { .bitrate = 540, .hw_value = 11, }, | ||
42 | }; | ||
43 | |||
44 | static struct ieee80211_channel p54_bgchannels[] = { | ||
45 | { .center_freq = 2412, .hw_value = 1, }, | ||
46 | { .center_freq = 2417, .hw_value = 2, }, | ||
47 | { .center_freq = 2422, .hw_value = 3, }, | ||
48 | { .center_freq = 2427, .hw_value = 4, }, | ||
49 | { .center_freq = 2432, .hw_value = 5, }, | ||
50 | { .center_freq = 2437, .hw_value = 6, }, | ||
51 | { .center_freq = 2442, .hw_value = 7, }, | ||
52 | { .center_freq = 2447, .hw_value = 8, }, | ||
53 | { .center_freq = 2452, .hw_value = 9, }, | ||
54 | { .center_freq = 2457, .hw_value = 10, }, | ||
55 | { .center_freq = 2462, .hw_value = 11, }, | ||
56 | { .center_freq = 2467, .hw_value = 12, }, | ||
57 | { .center_freq = 2472, .hw_value = 13, }, | ||
58 | { .center_freq = 2484, .hw_value = 14, }, | ||
59 | }; | ||
60 | |||
61 | static struct ieee80211_supported_band band_2GHz = { | ||
62 | .channels = p54_bgchannels, | ||
63 | .n_channels = ARRAY_SIZE(p54_bgchannels), | ||
64 | .bitrates = p54_bgrates, | ||
65 | .n_bitrates = ARRAY_SIZE(p54_bgrates), | ||
66 | }; | ||
67 | |||
68 | static struct ieee80211_rate p54_arates[] = { | ||
69 | { .bitrate = 60, .hw_value = 4, }, | ||
70 | { .bitrate = 90, .hw_value = 5, }, | ||
71 | { .bitrate = 120, .hw_value = 6, }, | ||
72 | { .bitrate = 180, .hw_value = 7, }, | ||
73 | { .bitrate = 240, .hw_value = 8, }, | ||
74 | { .bitrate = 360, .hw_value = 9, }, | ||
75 | { .bitrate = 480, .hw_value = 10, }, | ||
76 | { .bitrate = 540, .hw_value = 11, }, | ||
77 | }; | ||
78 | |||
79 | static struct ieee80211_channel p54_achannels[] = { | ||
80 | { .center_freq = 4920 }, | ||
81 | { .center_freq = 4940 }, | ||
82 | { .center_freq = 4960 }, | ||
83 | { .center_freq = 4980 }, | ||
84 | { .center_freq = 5040 }, | ||
85 | { .center_freq = 5060 }, | ||
86 | { .center_freq = 5080 }, | ||
87 | { .center_freq = 5170 }, | ||
88 | { .center_freq = 5180 }, | ||
89 | { .center_freq = 5190 }, | ||
90 | { .center_freq = 5200 }, | ||
91 | { .center_freq = 5210 }, | ||
92 | { .center_freq = 5220 }, | ||
93 | { .center_freq = 5230 }, | ||
94 | { .center_freq = 5240 }, | ||
95 | { .center_freq = 5260 }, | ||
96 | { .center_freq = 5280 }, | ||
97 | { .center_freq = 5300 }, | ||
98 | { .center_freq = 5320 }, | ||
99 | { .center_freq = 5500 }, | ||
100 | { .center_freq = 5520 }, | ||
101 | { .center_freq = 5540 }, | ||
102 | { .center_freq = 5560 }, | ||
103 | { .center_freq = 5580 }, | ||
104 | { .center_freq = 5600 }, | ||
105 | { .center_freq = 5620 }, | ||
106 | { .center_freq = 5640 }, | ||
107 | { .center_freq = 5660 }, | ||
108 | { .center_freq = 5680 }, | ||
109 | { .center_freq = 5700 }, | ||
110 | { .center_freq = 5745 }, | ||
111 | { .center_freq = 5765 }, | ||
112 | { .center_freq = 5785 }, | ||
113 | { .center_freq = 5805 }, | ||
114 | { .center_freq = 5825 }, | ||
115 | }; | ||
116 | |||
117 | static struct ieee80211_supported_band band_5GHz = { | ||
118 | .channels = p54_achannels, | ||
119 | .n_channels = ARRAY_SIZE(p54_achannels), | ||
120 | .bitrates = p54_arates, | ||
121 | .n_bitrates = ARRAY_SIZE(p54_arates), | ||
122 | }; | ||
123 | |||
124 | static int p54_convert_rev0(struct ieee80211_hw *dev, | ||
125 | struct pda_pa_curve_data *curve_data) | ||
126 | { | ||
127 | struct p54_common *priv = dev->priv; | ||
128 | struct p54_pa_curve_data_sample *dst; | ||
129 | struct pda_pa_curve_data_sample_rev0 *src; | ||
130 | size_t cd_len = sizeof(*curve_data) + | ||
131 | (curve_data->points_per_channel*sizeof(*dst) + 2) * | ||
132 | curve_data->channels; | ||
133 | unsigned int i, j; | ||
134 | void *source, *target; | ||
135 | |||
136 | priv->curve_data = kmalloc(sizeof(*priv->curve_data) + cd_len, | ||
137 | GFP_KERNEL); | ||
138 | if (!priv->curve_data) | ||
139 | return -ENOMEM; | ||
140 | |||
141 | priv->curve_data->entries = curve_data->channels; | ||
142 | priv->curve_data->entry_size = sizeof(__le16) + | ||
143 | sizeof(*dst) * curve_data->points_per_channel; | ||
144 | priv->curve_data->offset = offsetof(struct pda_pa_curve_data, data); | ||
145 | priv->curve_data->len = cd_len; | ||
146 | memcpy(priv->curve_data->data, curve_data, sizeof(*curve_data)); | ||
147 | source = curve_data->data; | ||
148 | target = ((struct pda_pa_curve_data *) priv->curve_data->data)->data; | ||
149 | for (i = 0; i < curve_data->channels; i++) { | ||
150 | __le16 *freq = source; | ||
151 | source += sizeof(__le16); | ||
152 | *((__le16 *)target) = *freq; | ||
153 | target += sizeof(__le16); | ||
154 | for (j = 0; j < curve_data->points_per_channel; j++) { | ||
155 | dst = target; | ||
156 | src = source; | ||
157 | |||
158 | dst->rf_power = src->rf_power; | ||
159 | dst->pa_detector = src->pa_detector; | ||
160 | dst->data_64qam = src->pcv; | ||
161 | /* "invent" the points for the other modulations */ | ||
162 | #define SUB(x, y) (u8)(((x) - (y)) > (x) ? 0 : (x) - (y)) | ||
163 | dst->data_16qam = SUB(src->pcv, 12); | ||
164 | dst->data_qpsk = SUB(dst->data_16qam, 12); | ||
165 | dst->data_bpsk = SUB(dst->data_qpsk, 12); | ||
166 | dst->data_barker = SUB(dst->data_bpsk, 14); | ||
167 | #undef SUB | ||
168 | target += sizeof(*dst); | ||
169 | source += sizeof(*src); | ||
170 | } | ||
171 | } | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | static int p54_convert_rev1(struct ieee80211_hw *dev, | ||
177 | struct pda_pa_curve_data *curve_data) | ||
178 | { | ||
179 | struct p54_common *priv = dev->priv; | ||
180 | struct p54_pa_curve_data_sample *dst; | ||
181 | struct pda_pa_curve_data_sample_rev1 *src; | ||
182 | size_t cd_len = sizeof(*curve_data) + | ||
183 | (curve_data->points_per_channel*sizeof(*dst) + 2) * | ||
184 | curve_data->channels; | ||
185 | unsigned int i, j; | ||
186 | void *source, *target; | ||
187 | |||
188 | priv->curve_data = kzalloc(cd_len + sizeof(*priv->curve_data), | ||
189 | GFP_KERNEL); | ||
190 | if (!priv->curve_data) | ||
191 | return -ENOMEM; | ||
192 | |||
193 | priv->curve_data->entries = curve_data->channels; | ||
194 | priv->curve_data->entry_size = sizeof(__le16) + | ||
195 | sizeof(*dst) * curve_data->points_per_channel; | ||
196 | priv->curve_data->offset = offsetof(struct pda_pa_curve_data, data); | ||
197 | priv->curve_data->len = cd_len; | ||
198 | memcpy(priv->curve_data->data, curve_data, sizeof(*curve_data)); | ||
199 | source = curve_data->data; | ||
200 | target = ((struct pda_pa_curve_data *) priv->curve_data->data)->data; | ||
201 | for (i = 0; i < curve_data->channels; i++) { | ||
202 | __le16 *freq = source; | ||
203 | source += sizeof(__le16); | ||
204 | *((__le16 *)target) = *freq; | ||
205 | target += sizeof(__le16); | ||
206 | for (j = 0; j < curve_data->points_per_channel; j++) { | ||
207 | memcpy(target, source, sizeof(*src)); | ||
208 | |||
209 | target += sizeof(*dst); | ||
210 | source += sizeof(*src); | ||
211 | } | ||
212 | source++; | ||
213 | } | ||
214 | |||
215 | return 0; | ||
216 | } | ||
217 | |||
218 | static const char *p54_rf_chips[] = { "INVALID-0", "Duette3", "Duette2", | ||
219 | "Frisbee", "Xbow", "Longbow", "INVALID-6", "INVALID-7" }; | ||
220 | |||
221 | static void p54_parse_rssical(struct ieee80211_hw *dev, void *data, int len, | ||
222 | u16 type) | ||
223 | { | ||
224 | struct p54_common *priv = dev->priv; | ||
225 | int offset = (type == PDR_RSSI_LINEAR_APPROXIMATION_EXTENDED) ? 2 : 0; | ||
226 | int entry_size = sizeof(struct pda_rssi_cal_entry) + offset; | ||
227 | int num_entries = (type == PDR_RSSI_LINEAR_APPROXIMATION) ? 1 : 2; | ||
228 | int i; | ||
229 | |||
230 | if (len != (entry_size * num_entries)) { | ||
231 | printk(KERN_ERR "%s: unknown rssi calibration data packing " | ||
232 | " type:(%x) len:%d.\n", | ||
233 | wiphy_name(dev->wiphy), type, len); | ||
234 | |||
235 | print_hex_dump_bytes("rssical:", DUMP_PREFIX_NONE, | ||
236 | data, len); | ||
237 | |||
238 | printk(KERN_ERR "%s: please report this issue.\n", | ||
239 | wiphy_name(dev->wiphy)); | ||
240 | return; | ||
241 | } | ||
242 | |||
243 | for (i = 0; i < num_entries; i++) { | ||
244 | struct pda_rssi_cal_entry *cal = data + | ||
245 | (offset + i * entry_size); | ||
246 | priv->rssical_db[i].mul = (s16) le16_to_cpu(cal->mul); | ||
247 | priv->rssical_db[i].add = (s16) le16_to_cpu(cal->add); | ||
248 | } | ||
249 | } | ||
250 | |||
251 | static void p54_parse_default_country(struct ieee80211_hw *dev, | ||
252 | void *data, int len) | ||
253 | { | ||
254 | struct pda_country *country; | ||
255 | |||
256 | if (len != sizeof(*country)) { | ||
257 | printk(KERN_ERR "%s: found possible invalid default country " | ||
258 | "eeprom entry. (entry size: %d)\n", | ||
259 | wiphy_name(dev->wiphy), len); | ||
260 | |||
261 | print_hex_dump_bytes("country:", DUMP_PREFIX_NONE, | ||
262 | data, len); | ||
263 | |||
264 | printk(KERN_ERR "%s: please report this issue.\n", | ||
265 | wiphy_name(dev->wiphy)); | ||
266 | return; | ||
267 | } | ||
268 | |||
269 | country = (struct pda_country *) data; | ||
270 | if (country->flags == PDR_COUNTRY_CERT_CODE_PSEUDO) | ||
271 | regulatory_hint(dev->wiphy, country->alpha2); | ||
272 | else { | ||
273 | /* TODO: | ||
274 | * write a shared/common function that converts | ||
275 | * "Regulatory domain codes" (802.11-2007 14.8.2.2) | ||
276 | * into ISO/IEC 3166-1 alpha2 for regulatory_hint. | ||
277 | */ | ||
278 | } | ||
279 | } | ||
280 | |||
281 | static int p54_convert_output_limits(struct ieee80211_hw *dev, | ||
282 | u8 *data, size_t len) | ||
283 | { | ||
284 | struct p54_common *priv = dev->priv; | ||
285 | |||
286 | if (len < 2) | ||
287 | return -EINVAL; | ||
288 | |||
289 | if (data[0] != 0) { | ||
290 | printk(KERN_ERR "%s: unknown output power db revision:%x\n", | ||
291 | wiphy_name(dev->wiphy), data[0]); | ||
292 | return -EINVAL; | ||
293 | } | ||
294 | |||
295 | if (2 + data[1] * sizeof(struct pda_channel_output_limit) > len) | ||
296 | return -EINVAL; | ||
297 | |||
298 | priv->output_limit = kmalloc(data[1] * | ||
299 | sizeof(struct pda_channel_output_limit) + | ||
300 | sizeof(*priv->output_limit), GFP_KERNEL); | ||
301 | |||
302 | if (!priv->output_limit) | ||
303 | return -ENOMEM; | ||
304 | |||
305 | priv->output_limit->offset = 0; | ||
306 | priv->output_limit->entries = data[1]; | ||
307 | priv->output_limit->entry_size = | ||
308 | sizeof(struct pda_channel_output_limit); | ||
309 | priv->output_limit->len = priv->output_limit->entry_size * | ||
310 | priv->output_limit->entries + | ||
311 | priv->output_limit->offset; | ||
312 | |||
313 | memcpy(priv->output_limit->data, &data[2], | ||
314 | data[1] * sizeof(struct pda_channel_output_limit)); | ||
315 | |||
316 | return 0; | ||
317 | } | ||
318 | |||
319 | static struct p54_cal_database *p54_convert_db(struct pda_custom_wrapper *src, | ||
320 | size_t total_len) | ||
321 | { | ||
322 | struct p54_cal_database *dst; | ||
323 | size_t payload_len, entries, entry_size, offset; | ||
324 | |||
325 | payload_len = le16_to_cpu(src->len); | ||
326 | entries = le16_to_cpu(src->entries); | ||
327 | entry_size = le16_to_cpu(src->entry_size); | ||
328 | offset = le16_to_cpu(src->offset); | ||
329 | if (((entries * entry_size + offset) != payload_len) || | ||
330 | (payload_len + sizeof(*src) != total_len)) | ||
331 | return NULL; | ||
332 | |||
333 | dst = kmalloc(sizeof(*dst) + payload_len, GFP_KERNEL); | ||
334 | if (!dst) | ||
335 | return NULL; | ||
336 | |||
337 | dst->entries = entries; | ||
338 | dst->entry_size = entry_size; | ||
339 | dst->offset = offset; | ||
340 | dst->len = payload_len; | ||
341 | |||
342 | memcpy(dst->data, src->data, payload_len); | ||
343 | return dst; | ||
344 | } | ||
345 | |||
346 | int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len) | ||
347 | { | ||
348 | struct p54_common *priv = dev->priv; | ||
349 | struct eeprom_pda_wrap *wrap = NULL; | ||
350 | struct pda_entry *entry; | ||
351 | unsigned int data_len, entry_len; | ||
352 | void *tmp; | ||
353 | int err; | ||
354 | u8 *end = (u8 *)eeprom + len; | ||
355 | u16 synth = 0; | ||
356 | |||
357 | wrap = (struct eeprom_pda_wrap *) eeprom; | ||
358 | entry = (void *)wrap->data + le16_to_cpu(wrap->len); | ||
359 | |||
360 | /* verify that at least the entry length/code fits */ | ||
361 | while ((u8 *)entry <= end - sizeof(*entry)) { | ||
362 | entry_len = le16_to_cpu(entry->len); | ||
363 | data_len = ((entry_len - 1) << 1); | ||
364 | |||
365 | /* abort if entry exceeds whole structure */ | ||
366 | if ((u8 *)entry + sizeof(*entry) + data_len > end) | ||
367 | break; | ||
368 | |||
369 | switch (le16_to_cpu(entry->code)) { | ||
370 | case PDR_MAC_ADDRESS: | ||
371 | if (data_len != ETH_ALEN) | ||
372 | break; | ||
373 | SET_IEEE80211_PERM_ADDR(dev, entry->data); | ||
374 | break; | ||
375 | case PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS: | ||
376 | if (priv->output_limit) | ||
377 | break; | ||
378 | err = p54_convert_output_limits(dev, entry->data, | ||
379 | data_len); | ||
380 | if (err) | ||
381 | goto err; | ||
382 | break; | ||
383 | case PDR_PRISM_PA_CAL_CURVE_DATA: { | ||
384 | struct pda_pa_curve_data *curve_data = | ||
385 | (struct pda_pa_curve_data *)entry->data; | ||
386 | if (data_len < sizeof(*curve_data)) { | ||
387 | err = -EINVAL; | ||
388 | goto err; | ||
389 | } | ||
390 | |||
391 | switch (curve_data->cal_method_rev) { | ||
392 | case 0: | ||
393 | err = p54_convert_rev0(dev, curve_data); | ||
394 | break; | ||
395 | case 1: | ||
396 | err = p54_convert_rev1(dev, curve_data); | ||
397 | break; | ||
398 | default: | ||
399 | printk(KERN_ERR "%s: unknown curve data " | ||
400 | "revision %d\n", | ||
401 | wiphy_name(dev->wiphy), | ||
402 | curve_data->cal_method_rev); | ||
403 | err = -ENODEV; | ||
404 | break; | ||
405 | } | ||
406 | if (err) | ||
407 | goto err; | ||
408 | } | ||
409 | break; | ||
410 | case PDR_PRISM_ZIF_TX_IQ_CALIBRATION: | ||
411 | priv->iq_autocal = kmalloc(data_len, GFP_KERNEL); | ||
412 | if (!priv->iq_autocal) { | ||
413 | err = -ENOMEM; | ||
414 | goto err; | ||
415 | } | ||
416 | |||
417 | memcpy(priv->iq_autocal, entry->data, data_len); | ||
418 | priv->iq_autocal_len = data_len / sizeof(struct pda_iq_autocal_entry); | ||
419 | break; | ||
420 | case PDR_DEFAULT_COUNTRY: | ||
421 | p54_parse_default_country(dev, entry->data, data_len); | ||
422 | break; | ||
423 | case PDR_INTERFACE_LIST: | ||
424 | tmp = entry->data; | ||
425 | while ((u8 *)tmp < entry->data + data_len) { | ||
426 | struct exp_if *exp_if = tmp; | ||
427 | if (exp_if->if_id == cpu_to_le16(IF_ID_ISL39000)) | ||
428 | synth = le16_to_cpu(exp_if->variant); | ||
429 | tmp += sizeof(*exp_if); | ||
430 | } | ||
431 | break; | ||
432 | case PDR_HARDWARE_PLATFORM_COMPONENT_ID: | ||
433 | if (data_len < 2) | ||
434 | break; | ||
435 | priv->version = *(u8 *)(entry->data + 1); | ||
436 | break; | ||
437 | case PDR_RSSI_LINEAR_APPROXIMATION: | ||
438 | case PDR_RSSI_LINEAR_APPROXIMATION_DUAL_BAND: | ||
439 | case PDR_RSSI_LINEAR_APPROXIMATION_EXTENDED: | ||
440 | p54_parse_rssical(dev, entry->data, data_len, | ||
441 | le16_to_cpu(entry->code)); | ||
442 | break; | ||
443 | case PDR_RSSI_LINEAR_APPROXIMATION_CUSTOM: { | ||
444 | __le16 *src = (void *) entry->data; | ||
445 | s16 *dst = (void *) &priv->rssical_db; | ||
446 | int i; | ||
447 | |||
448 | if (data_len != sizeof(priv->rssical_db)) { | ||
449 | err = -EINVAL; | ||
450 | goto err; | ||
451 | } | ||
452 | for (i = 0; i < sizeof(priv->rssical_db) / | ||
453 | sizeof(*src); i++) | ||
454 | *(dst++) = (s16) le16_to_cpu(*(src++)); | ||
455 | } | ||
456 | break; | ||
457 | case PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS_CUSTOM: { | ||
458 | struct pda_custom_wrapper *pda = (void *) entry->data; | ||
459 | if (priv->output_limit || data_len < sizeof(*pda)) | ||
460 | break; | ||
461 | priv->output_limit = p54_convert_db(pda, data_len); | ||
462 | } | ||
463 | break; | ||
464 | case PDR_PRISM_PA_CAL_CURVE_DATA_CUSTOM: { | ||
465 | struct pda_custom_wrapper *pda = (void *) entry->data; | ||
466 | if (priv->curve_data || data_len < sizeof(*pda)) | ||
467 | break; | ||
468 | priv->curve_data = p54_convert_db(pda, data_len); | ||
469 | } | ||
470 | break; | ||
471 | case PDR_END: | ||
472 | /* make it overrun */ | ||
473 | entry_len = len; | ||
474 | break; | ||
475 | default: | ||
476 | break; | ||
477 | } | ||
478 | |||
479 | entry = (void *)entry + (entry_len + 1)*2; | ||
480 | } | ||
481 | |||
482 | if (!synth || !priv->iq_autocal || !priv->output_limit || | ||
483 | !priv->curve_data) { | ||
484 | printk(KERN_ERR "%s: not all required entries found in eeprom!\n", | ||
485 | wiphy_name(dev->wiphy)); | ||
486 | err = -EINVAL; | ||
487 | goto err; | ||
488 | } | ||
489 | |||
490 | priv->rxhw = synth & PDR_SYNTH_FRONTEND_MASK; | ||
491 | if (priv->rxhw == PDR_SYNTH_FRONTEND_XBOW) | ||
492 | p54_init_xbow_synth(priv); | ||
493 | if (!(synth & PDR_SYNTH_24_GHZ_DISABLED)) | ||
494 | dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz; | ||
495 | if (!(synth & PDR_SYNTH_5_GHZ_DISABLED)) | ||
496 | dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz; | ||
497 | if ((synth & PDR_SYNTH_RX_DIV_MASK) == PDR_SYNTH_RX_DIV_SUPPORTED) | ||
498 | priv->rx_diversity_mask = 3; | ||
499 | if ((synth & PDR_SYNTH_TX_DIV_MASK) == PDR_SYNTH_TX_DIV_SUPPORTED) | ||
500 | priv->tx_diversity_mask = 3; | ||
501 | |||
502 | if (!is_valid_ether_addr(dev->wiphy->perm_addr)) { | ||
503 | u8 perm_addr[ETH_ALEN]; | ||
504 | |||
505 | printk(KERN_WARNING "%s: Invalid hwaddr! Using randomly generated MAC addr\n", | ||
506 | wiphy_name(dev->wiphy)); | ||
507 | random_ether_addr(perm_addr); | ||
508 | SET_IEEE80211_PERM_ADDR(dev, perm_addr); | ||
509 | } | ||
510 | |||
511 | printk(KERN_INFO "%s: hwaddr %pM, MAC:isl38%02x RF:%s\n", | ||
512 | wiphy_name(dev->wiphy), dev->wiphy->perm_addr, priv->version, | ||
513 | p54_rf_chips[priv->rxhw]); | ||
514 | |||
515 | return 0; | ||
516 | |||
517 | err: | ||
518 | kfree(priv->iq_autocal); | ||
519 | kfree(priv->output_limit); | ||
520 | kfree(priv->curve_data); | ||
521 | priv->iq_autocal = NULL; | ||
522 | priv->output_limit = NULL; | ||
523 | priv->curve_data = NULL; | ||
524 | |||
525 | printk(KERN_ERR "%s: eeprom parse failed!\n", | ||
526 | wiphy_name(dev->wiphy)); | ||
527 | return err; | ||
528 | } | ||
529 | EXPORT_SYMBOL_GPL(p54_parse_eeprom); | ||
530 | |||
531 | int p54_read_eeprom(struct ieee80211_hw *dev) | ||
532 | { | ||
533 | struct p54_common *priv = dev->priv; | ||
534 | size_t eeprom_size = 0x2020, offset = 0, blocksize, maxblocksize; | ||
535 | int ret = -ENOMEM; | ||
536 | void *eeprom = NULL; | ||
537 | |||
538 | maxblocksize = EEPROM_READBACK_LEN; | ||
539 | if (priv->fw_var >= 0x509) | ||
540 | maxblocksize -= 0xc; | ||
541 | else | ||
542 | maxblocksize -= 0x4; | ||
543 | |||
544 | eeprom = kzalloc(eeprom_size, GFP_KERNEL); | ||
545 | if (unlikely(!eeprom)) | ||
546 | goto free; | ||
547 | |||
548 | while (eeprom_size) { | ||
549 | blocksize = min(eeprom_size, maxblocksize); | ||
550 | ret = p54_download_eeprom(priv, (void *) (eeprom + offset), | ||
551 | offset, blocksize); | ||
552 | if (unlikely(ret)) | ||
553 | goto free; | ||
554 | |||
555 | offset += blocksize; | ||
556 | eeprom_size -= blocksize; | ||
557 | } | ||
558 | |||
559 | ret = p54_parse_eeprom(dev, eeprom, offset); | ||
560 | free: | ||
561 | kfree(eeprom); | ||
562 | return ret; | ||
563 | } | ||
564 | EXPORT_SYMBOL_GPL(p54_read_eeprom); | ||
diff --git a/drivers/net/wireless/p54/eeprom.h b/drivers/net/wireless/p54/eeprom.h new file mode 100644 index 000000000000..9051aef11249 --- /dev/null +++ b/drivers/net/wireless/p54/eeprom.h | |||
@@ -0,0 +1,226 @@ | |||
1 | /* | ||
2 | * eeprom specific definitions for mac80211 Prism54 drivers | ||
3 | * | ||
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
5 | * Copyright (c) 2007-2009, Christian Lamparter <chunkeey@web.de> | ||
6 | * | ||
7 | * Based on: | ||
8 | * - the islsm (softmac prism54) driver, which is: | ||
9 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
10 | * | ||
11 | * - LMAC API interface header file for STLC4560 (lmac_longbow.h) | ||
12 | * Copyright (C) 2007 Conexant Systems, Inc. | ||
13 | * | ||
14 | * - islmvc driver | ||
15 | * Copyright (C) 2001 Intersil Americas Inc. | ||
16 | * | ||
17 | * This program is free software; you can redistribute it and/or modify | ||
18 | * it under the terms of the GNU General Public License version 2 as | ||
19 | * published by the Free Software Foundation. | ||
20 | */ | ||
21 | |||
22 | #ifndef EEPROM_H | ||
23 | #define EEPROM_H | ||
24 | |||
25 | /* PDA defines are Copyright (C) 2005 Nokia Corporation (taken from islsm_pda.h) */ | ||
26 | |||
27 | struct pda_entry { | ||
28 | __le16 len; /* includes both code and data */ | ||
29 | __le16 code; | ||
30 | u8 data[0]; | ||
31 | } __packed; | ||
32 | |||
33 | struct eeprom_pda_wrap { | ||
34 | __le32 magic; | ||
35 | __le16 pad; | ||
36 | __le16 len; | ||
37 | __le32 arm_opcode; | ||
38 | u8 data[0]; | ||
39 | } __packed; | ||
40 | |||
41 | struct p54_iq_autocal_entry { | ||
42 | __le16 iq_param[4]; | ||
43 | } __packed; | ||
44 | |||
45 | struct pda_iq_autocal_entry { | ||
46 | __le16 freq; | ||
47 | struct p54_iq_autocal_entry params; | ||
48 | } __packed; | ||
49 | |||
50 | struct pda_channel_output_limit { | ||
51 | __le16 freq; | ||
52 | u8 val_bpsk; | ||
53 | u8 val_qpsk; | ||
54 | u8 val_16qam; | ||
55 | u8 val_64qam; | ||
56 | u8 rate_set_mask; | ||
57 | u8 rate_set_size; | ||
58 | } __packed; | ||
59 | |||
60 | struct pda_pa_curve_data_sample_rev0 { | ||
61 | u8 rf_power; | ||
62 | u8 pa_detector; | ||
63 | u8 pcv; | ||
64 | } __packed; | ||
65 | |||
66 | struct pda_pa_curve_data_sample_rev1 { | ||
67 | u8 rf_power; | ||
68 | u8 pa_detector; | ||
69 | u8 data_barker; | ||
70 | u8 data_bpsk; | ||
71 | u8 data_qpsk; | ||
72 | u8 data_16qam; | ||
73 | u8 data_64qam; | ||
74 | } __packed; | ||
75 | |||
76 | struct pda_pa_curve_data { | ||
77 | u8 cal_method_rev; | ||
78 | u8 channels; | ||
79 | u8 points_per_channel; | ||
80 | u8 padding; | ||
81 | u8 data[0]; | ||
82 | } __packed; | ||
83 | |||
84 | struct pda_rssi_cal_entry { | ||
85 | __le16 mul; | ||
86 | __le16 add; | ||
87 | } __packed; | ||
88 | |||
89 | struct pda_country { | ||
90 | u8 regdomain; | ||
91 | u8 alpha2[2]; | ||
92 | u8 flags; | ||
93 | } __packed; | ||
94 | |||
95 | struct pda_antenna_gain { | ||
96 | struct { | ||
97 | u8 gain_5GHz; /* 0.25 dBi units */ | ||
98 | u8 gain_2GHz; /* 0.25 dBi units */ | ||
99 | } __packed antenna[0]; | ||
100 | } __packed; | ||
101 | |||
102 | struct pda_custom_wrapper { | ||
103 | __le16 entries; | ||
104 | __le16 entry_size; | ||
105 | __le16 offset; | ||
106 | __le16 len; | ||
107 | u8 data[0]; | ||
108 | } __packed; | ||
109 | |||
110 | /* | ||
111 | * this defines the PDR codes used to build PDAs as defined in document | ||
112 | * number 553155. The current implementation mirrors version 1.1 of the | ||
113 | * document and lists only PDRs supported by the ARM platform. | ||
114 | */ | ||
115 | |||
116 | /* common and choice range (0x0000 - 0x0fff) */ | ||
117 | #define PDR_END 0x0000 | ||
118 | #define PDR_MANUFACTURING_PART_NUMBER 0x0001 | ||
119 | #define PDR_PDA_VERSION 0x0002 | ||
120 | #define PDR_NIC_SERIAL_NUMBER 0x0003 | ||
121 | #define PDR_NIC_RAM_SIZE 0x0005 | ||
122 | #define PDR_RFMODEM_SUP_RANGE 0x0006 | ||
123 | #define PDR_PRISM_MAC_SUP_RANGE 0x0007 | ||
124 | #define PDR_NIC_ID 0x0008 | ||
125 | |||
126 | #define PDR_MAC_ADDRESS 0x0101 | ||
127 | #define PDR_REGULATORY_DOMAIN_LIST 0x0103 /* obsolete */ | ||
128 | #define PDR_ALLOWED_CHAN_SET 0x0104 | ||
129 | #define PDR_DEFAULT_CHAN 0x0105 | ||
130 | #define PDR_TEMPERATURE_TYPE 0x0107 | ||
131 | |||
132 | #define PDR_IFR_SETTING 0x0200 | ||
133 | #define PDR_RFR_SETTING 0x0201 | ||
134 | #define PDR_3861_BASELINE_REG_SETTINGS 0x0202 | ||
135 | #define PDR_3861_SHADOW_REG_SETTINGS 0x0203 | ||
136 | #define PDR_3861_IFRF_REG_SETTINGS 0x0204 | ||
137 | |||
138 | #define PDR_3861_CHAN_CALIB_SET_POINTS 0x0300 | ||
139 | #define PDR_3861_CHAN_CALIB_INTEGRATOR 0x0301 | ||
140 | |||
141 | #define PDR_3842_PRISM_II_NIC_CONFIG 0x0400 | ||
142 | #define PDR_PRISM_USB_ID 0x0401 | ||
143 | #define PDR_PRISM_PCI_ID 0x0402 | ||
144 | #define PDR_PRISM_PCI_IF_CONFIG 0x0403 | ||
145 | #define PDR_PRISM_PCI_PM_CONFIG 0x0404 | ||
146 | |||
147 | #define PDR_3861_MF_TEST_CHAN_SET_POINTS 0x0900 | ||
148 | #define PDR_3861_MF_TEST_CHAN_INTEGRATORS 0x0901 | ||
149 | |||
150 | /* ARM range (0x1000 - 0x1fff) */ | ||
151 | #define PDR_COUNTRY_INFORMATION 0x1000 /* obsolete */ | ||
152 | #define PDR_INTERFACE_LIST 0x1001 | ||
153 | #define PDR_HARDWARE_PLATFORM_COMPONENT_ID 0x1002 | ||
154 | #define PDR_OEM_NAME 0x1003 | ||
155 | #define PDR_PRODUCT_NAME 0x1004 | ||
156 | #define PDR_UTF8_OEM_NAME 0x1005 | ||
157 | #define PDR_UTF8_PRODUCT_NAME 0x1006 | ||
158 | #define PDR_COUNTRY_LIST 0x1007 | ||
159 | #define PDR_DEFAULT_COUNTRY 0x1008 | ||
160 | |||
161 | #define PDR_ANTENNA_GAIN 0x1100 | ||
162 | |||
163 | #define PDR_PRISM_INDIGO_PA_CALIBRATION_DATA 0x1901 | ||
164 | #define PDR_RSSI_LINEAR_APPROXIMATION 0x1902 | ||
165 | #define PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS 0x1903 | ||
166 | #define PDR_PRISM_PA_CAL_CURVE_DATA 0x1904 | ||
167 | #define PDR_RSSI_LINEAR_APPROXIMATION_DUAL_BAND 0x1905 | ||
168 | #define PDR_PRISM_ZIF_TX_IQ_CALIBRATION 0x1906 | ||
169 | #define PDR_REGULATORY_POWER_LIMITS 0x1907 | ||
170 | #define PDR_RSSI_LINEAR_APPROXIMATION_EXTENDED 0x1908 | ||
171 | #define PDR_RADIATED_TRANSMISSION_CORRECTION 0x1909 | ||
172 | #define PDR_PRISM_TX_IQ_CALIBRATION 0x190a | ||
173 | |||
174 | /* reserved range (0x2000 - 0x7fff) */ | ||
175 | |||
176 | /* customer range (0x8000 - 0xffff) */ | ||
177 | #define PDR_BASEBAND_REGISTERS 0x8000 | ||
178 | #define PDR_PER_CHANNEL_BASEBAND_REGISTERS 0x8001 | ||
179 | |||
180 | /* used by our modificated eeprom image */ | ||
181 | #define PDR_RSSI_LINEAR_APPROXIMATION_CUSTOM 0xDEAD | ||
182 | #define PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS_CUSTOM 0xBEEF | ||
183 | #define PDR_PRISM_PA_CAL_CURVE_DATA_CUSTOM 0xB05D | ||
184 | |||
185 | /* Interface Definitions */ | ||
186 | #define PDR_INTERFACE_ROLE_SERVER 0x0000 | ||
187 | #define PDR_INTERFACE_ROLE_CLIENT 0x0001 | ||
188 | |||
189 | /* PDR definitions for default country & country list */ | ||
190 | #define PDR_COUNTRY_CERT_CODE 0x80 | ||
191 | #define PDR_COUNTRY_CERT_CODE_REAL 0x00 | ||
192 | #define PDR_COUNTRY_CERT_CODE_PSEUDO 0x80 | ||
193 | #define PDR_COUNTRY_CERT_BAND 0x40 | ||
194 | #define PDR_COUNTRY_CERT_BAND_2GHZ 0x00 | ||
195 | #define PDR_COUNTRY_CERT_BAND_5GHZ 0x40 | ||
196 | #define PDR_COUNTRY_CERT_IODOOR 0x30 | ||
197 | #define PDR_COUNTRY_CERT_IODOOR_BOTH 0x00 | ||
198 | #define PDR_COUNTRY_CERT_IODOOR_INDOOR 0x20 | ||
199 | #define PDR_COUNTRY_CERT_IODOOR_OUTDOOR 0x30 | ||
200 | #define PDR_COUNTRY_CERT_INDEX 0x0f | ||
201 | |||
202 | /* Specific LMAC FW/HW variant definitions */ | ||
203 | #define PDR_SYNTH_FRONTEND_MASK 0x0007 | ||
204 | #define PDR_SYNTH_FRONTEND_DUETTE3 0x0001 | ||
205 | #define PDR_SYNTH_FRONTEND_DUETTE2 0x0002 | ||
206 | #define PDR_SYNTH_FRONTEND_FRISBEE 0x0003 | ||
207 | #define PDR_SYNTH_FRONTEND_XBOW 0x0004 | ||
208 | #define PDR_SYNTH_FRONTEND_LONGBOW 0x0005 | ||
209 | #define PDR_SYNTH_IQ_CAL_MASK 0x0018 | ||
210 | #define PDR_SYNTH_IQ_CAL_PA_DETECTOR 0x0000 | ||
211 | #define PDR_SYNTH_IQ_CAL_DISABLED 0x0008 | ||
212 | #define PDR_SYNTH_IQ_CAL_ZIF 0x0010 | ||
213 | #define PDR_SYNTH_FAA_SWITCH_MASK 0x0020 | ||
214 | #define PDR_SYNTH_FAA_SWITCH_ENABLED 0x0020 | ||
215 | #define PDR_SYNTH_24_GHZ_MASK 0x0040 | ||
216 | #define PDR_SYNTH_24_GHZ_DISABLED 0x0040 | ||
217 | #define PDR_SYNTH_5_GHZ_MASK 0x0080 | ||
218 | #define PDR_SYNTH_5_GHZ_DISABLED 0x0080 | ||
219 | #define PDR_SYNTH_RX_DIV_MASK 0x0100 | ||
220 | #define PDR_SYNTH_RX_DIV_SUPPORTED 0x0100 | ||
221 | #define PDR_SYNTH_TX_DIV_MASK 0x0200 | ||
222 | #define PDR_SYNTH_TX_DIV_SUPPORTED 0x0200 | ||
223 | #define PDR_SYNTH_ASM_MASK 0x0400 | ||
224 | #define PDR_SYNTH_ASM_XSWON 0x0400 | ||
225 | |||
226 | #endif /* EEPROM_H */ | ||
diff --git a/drivers/net/wireless/p54/fwio.c b/drivers/net/wireless/p54/fwio.c new file mode 100644 index 000000000000..dc4f3f5ee0c8 --- /dev/null +++ b/drivers/net/wireless/p54/fwio.c | |||
@@ -0,0 +1,698 @@ | |||
1 | /* | ||
2 | * Firmware I/O code for mac80211 Prism54 drivers | ||
3 | * | ||
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
5 | * Copyright (c) 2007-2009, Christian Lamparter <chunkeey@web.de> | ||
6 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> | ||
7 | * | ||
8 | * Based on: | ||
9 | * - the islsm (softmac prism54) driver, which is: | ||
10 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
11 | * - stlc45xx driver | ||
12 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | |||
19 | #include <linux/init.h> | ||
20 | #include <linux/firmware.h> | ||
21 | #include <linux/etherdevice.h> | ||
22 | |||
23 | #include <net/mac80211.h> | ||
24 | |||
25 | #include "p54.h" | ||
26 | #include "eeprom.h" | ||
27 | #include "lmac.h" | ||
28 | |||
29 | int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) | ||
30 | { | ||
31 | struct p54_common *priv = dev->priv; | ||
32 | struct exp_if *exp_if; | ||
33 | struct bootrec *bootrec; | ||
34 | u32 *data = (u32 *)fw->data; | ||
35 | u32 *end_data = (u32 *)fw->data + (fw->size >> 2); | ||
36 | u8 *fw_version = NULL; | ||
37 | size_t len; | ||
38 | int i; | ||
39 | int maxlen; | ||
40 | |||
41 | if (priv->rx_start) | ||
42 | return 0; | ||
43 | |||
44 | while (data < end_data && *data) | ||
45 | data++; | ||
46 | |||
47 | while (data < end_data && !*data) | ||
48 | data++; | ||
49 | |||
50 | bootrec = (struct bootrec *) data; | ||
51 | |||
52 | while (bootrec->data <= end_data && (bootrec->data + | ||
53 | (len = le32_to_cpu(bootrec->len))) <= end_data) { | ||
54 | u32 code = le32_to_cpu(bootrec->code); | ||
55 | switch (code) { | ||
56 | case BR_CODE_COMPONENT_ID: | ||
57 | priv->fw_interface = be32_to_cpup((__be32 *) | ||
58 | bootrec->data); | ||
59 | switch (priv->fw_interface) { | ||
60 | case FW_LM86: | ||
61 | case FW_LM20: | ||
62 | case FW_LM87: { | ||
63 | char *iftype = (char *)bootrec->data; | ||
64 | printk(KERN_INFO "%s: p54 detected a LM%c%c " | ||
65 | "firmware\n", | ||
66 | wiphy_name(priv->hw->wiphy), | ||
67 | iftype[2], iftype[3]); | ||
68 | break; | ||
69 | } | ||
70 | case FW_FMAC: | ||
71 | default: | ||
72 | printk(KERN_ERR "%s: unsupported firmware\n", | ||
73 | wiphy_name(priv->hw->wiphy)); | ||
74 | return -ENODEV; | ||
75 | } | ||
76 | break; | ||
77 | case BR_CODE_COMPONENT_VERSION: | ||
78 | /* 24 bytes should be enough for all firmwares */ | ||
79 | if (strnlen((unsigned char *) bootrec->data, 24) < 24) | ||
80 | fw_version = (unsigned char *) bootrec->data; | ||
81 | break; | ||
82 | case BR_CODE_DESCR: { | ||
83 | struct bootrec_desc *desc = | ||
84 | (struct bootrec_desc *)bootrec->data; | ||
85 | priv->rx_start = le32_to_cpu(desc->rx_start); | ||
86 | /* FIXME add sanity checking */ | ||
87 | priv->rx_end = le32_to_cpu(desc->rx_end) - 0x3500; | ||
88 | priv->headroom = desc->headroom; | ||
89 | priv->tailroom = desc->tailroom; | ||
90 | priv->privacy_caps = desc->privacy_caps; | ||
91 | priv->rx_keycache_size = desc->rx_keycache_size; | ||
92 | if (le32_to_cpu(bootrec->len) == 11) | ||
93 | priv->rx_mtu = le16_to_cpu(desc->rx_mtu); | ||
94 | else | ||
95 | priv->rx_mtu = (size_t) | ||
96 | 0x620 - priv->tx_hdr_len; | ||
97 | maxlen = priv->tx_hdr_len + /* USB devices */ | ||
98 | sizeof(struct p54_rx_data) + | ||
99 | 4 + /* rx alignment */ | ||
100 | IEEE80211_MAX_FRAG_THRESHOLD; | ||
101 | if (priv->rx_mtu > maxlen && PAGE_SIZE == 4096) { | ||
102 | printk(KERN_INFO "p54: rx_mtu reduced from %d " | ||
103 | "to %d\n", priv->rx_mtu, maxlen); | ||
104 | priv->rx_mtu = maxlen; | ||
105 | } | ||
106 | break; | ||
107 | } | ||
108 | case BR_CODE_EXPOSED_IF: | ||
109 | exp_if = (struct exp_if *) bootrec->data; | ||
110 | for (i = 0; i < (len * sizeof(*exp_if) / 4); i++) | ||
111 | if (exp_if[i].if_id == cpu_to_le16(IF_ID_LMAC)) | ||
112 | priv->fw_var = le16_to_cpu(exp_if[i].variant); | ||
113 | break; | ||
114 | case BR_CODE_DEPENDENT_IF: | ||
115 | break; | ||
116 | case BR_CODE_END_OF_BRA: | ||
117 | case LEGACY_BR_CODE_END_OF_BRA: | ||
118 | end_data = NULL; | ||
119 | break; | ||
120 | default: | ||
121 | break; | ||
122 | } | ||
123 | bootrec = (struct bootrec *)&bootrec->data[len]; | ||
124 | } | ||
125 | |||
126 | if (fw_version) | ||
127 | printk(KERN_INFO "%s: FW rev %s - Softmac protocol %x.%x\n", | ||
128 | wiphy_name(priv->hw->wiphy), fw_version, | ||
129 | priv->fw_var >> 8, priv->fw_var & 0xff); | ||
130 | |||
131 | if (priv->fw_var < 0x500) | ||
132 | printk(KERN_INFO "%s: you are using an obsolete firmware. " | ||
133 | "visit http://wireless.kernel.org/en/users/Drivers/p54 " | ||
134 | "and grab one for \"kernel >= 2.6.28\"!\n", | ||
135 | wiphy_name(priv->hw->wiphy)); | ||
136 | |||
137 | if (priv->fw_var >= 0x300) { | ||
138 | /* Firmware supports QoS, use it! */ | ||
139 | |||
140 | if (priv->fw_var >= 0x500) { | ||
141 | priv->tx_stats[P54_QUEUE_AC_VO].limit = 16; | ||
142 | priv->tx_stats[P54_QUEUE_AC_VI].limit = 16; | ||
143 | priv->tx_stats[P54_QUEUE_AC_BE].limit = 16; | ||
144 | priv->tx_stats[P54_QUEUE_AC_BK].limit = 16; | ||
145 | } else { | ||
146 | priv->tx_stats[P54_QUEUE_AC_VO].limit = 3; | ||
147 | priv->tx_stats[P54_QUEUE_AC_VI].limit = 4; | ||
148 | priv->tx_stats[P54_QUEUE_AC_BE].limit = 3; | ||
149 | priv->tx_stats[P54_QUEUE_AC_BK].limit = 2; | ||
150 | } | ||
151 | priv->hw->queues = P54_QUEUE_AC_NUM; | ||
152 | } | ||
153 | |||
154 | printk(KERN_INFO "%s: cryptographic accelerator " | ||
155 | "WEP:%s, TKIP:%s, CCMP:%s\n", wiphy_name(priv->hw->wiphy), | ||
156 | (priv->privacy_caps & BR_DESC_PRIV_CAP_WEP) ? "YES" : | ||
157 | "no", (priv->privacy_caps & (BR_DESC_PRIV_CAP_TKIP | | ||
158 | BR_DESC_PRIV_CAP_MICHAEL)) ? "YES" : "no", | ||
159 | (priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP) ? | ||
160 | "YES" : "no"); | ||
161 | |||
162 | if (priv->rx_keycache_size) { | ||
163 | /* | ||
164 | * NOTE: | ||
165 | * | ||
166 | * The firmware provides at most 255 (0 - 254) slots | ||
167 | * for keys which are then used to offload decryption. | ||
168 | * As a result the 255 entry (aka 0xff) can be used | ||
169 | * safely by the driver to mark keys that didn't fit | ||
170 | * into the full cache. This trick saves us from | ||
171 | * keeping a extra list for uploaded keys. | ||
172 | */ | ||
173 | |||
174 | priv->used_rxkeys = kzalloc(BITS_TO_LONGS( | ||
175 | priv->rx_keycache_size), GFP_KERNEL); | ||
176 | |||
177 | if (!priv->used_rxkeys) | ||
178 | return -ENOMEM; | ||
179 | } | ||
180 | |||
181 | return 0; | ||
182 | } | ||
183 | EXPORT_SYMBOL_GPL(p54_parse_firmware); | ||
184 | |||
185 | static struct sk_buff *p54_alloc_skb(struct p54_common *priv, u16 hdr_flags, | ||
186 | u16 payload_len, u16 type, gfp_t memflags) | ||
187 | { | ||
188 | struct p54_hdr *hdr; | ||
189 | struct sk_buff *skb; | ||
190 | size_t frame_len = sizeof(*hdr) + payload_len; | ||
191 | |||
192 | if (frame_len > P54_MAX_CTRL_FRAME_LEN) | ||
193 | return NULL; | ||
194 | |||
195 | if (unlikely(skb_queue_len(&priv->tx_pending) > 64)) | ||
196 | return NULL; | ||
197 | |||
198 | skb = __dev_alloc_skb(priv->tx_hdr_len + frame_len, memflags); | ||
199 | if (!skb) | ||
200 | return NULL; | ||
201 | skb_reserve(skb, priv->tx_hdr_len); | ||
202 | |||
203 | hdr = (struct p54_hdr *) skb_put(skb, sizeof(*hdr)); | ||
204 | hdr->flags = cpu_to_le16(hdr_flags); | ||
205 | hdr->len = cpu_to_le16(payload_len); | ||
206 | hdr->type = cpu_to_le16(type); | ||
207 | hdr->tries = hdr->rts_tries = 0; | ||
208 | return skb; | ||
209 | } | ||
210 | |||
211 | int p54_download_eeprom(struct p54_common *priv, void *buf, | ||
212 | u16 offset, u16 len) | ||
213 | { | ||
214 | struct p54_eeprom_lm86 *eeprom_hdr; | ||
215 | struct sk_buff *skb; | ||
216 | size_t eeprom_hdr_size; | ||
217 | int ret = 0; | ||
218 | |||
219 | if (priv->fw_var >= 0x509) | ||
220 | eeprom_hdr_size = sizeof(*eeprom_hdr); | ||
221 | else | ||
222 | eeprom_hdr_size = 0x4; | ||
223 | |||
224 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL, eeprom_hdr_size + | ||
225 | len, P54_CONTROL_TYPE_EEPROM_READBACK, | ||
226 | GFP_KERNEL); | ||
227 | if (unlikely(!skb)) | ||
228 | return -ENOMEM; | ||
229 | |||
230 | mutex_lock(&priv->eeprom_mutex); | ||
231 | priv->eeprom = buf; | ||
232 | eeprom_hdr = (struct p54_eeprom_lm86 *) skb_put(skb, | ||
233 | eeprom_hdr_size + len); | ||
234 | |||
235 | if (priv->fw_var < 0x509) { | ||
236 | eeprom_hdr->v1.offset = cpu_to_le16(offset); | ||
237 | eeprom_hdr->v1.len = cpu_to_le16(len); | ||
238 | } else { | ||
239 | eeprom_hdr->v2.offset = cpu_to_le32(offset); | ||
240 | eeprom_hdr->v2.len = cpu_to_le16(len); | ||
241 | eeprom_hdr->v2.magic2 = 0xf; | ||
242 | memcpy(eeprom_hdr->v2.magic, (const char *)"LOCK", 4); | ||
243 | } | ||
244 | |||
245 | p54_tx(priv, skb); | ||
246 | |||
247 | if (!wait_for_completion_interruptible_timeout( | ||
248 | &priv->eeprom_comp, HZ)) { | ||
249 | printk(KERN_ERR "%s: device does not respond!\n", | ||
250 | wiphy_name(priv->hw->wiphy)); | ||
251 | ret = -EBUSY; | ||
252 | } | ||
253 | priv->eeprom = NULL; | ||
254 | mutex_unlock(&priv->eeprom_mutex); | ||
255 | return ret; | ||
256 | } | ||
257 | |||
258 | int p54_update_beacon_tim(struct p54_common *priv, u16 aid, bool set) | ||
259 | { | ||
260 | struct sk_buff *skb; | ||
261 | struct p54_tim *tim; | ||
262 | |||
263 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*tim), | ||
264 | P54_CONTROL_TYPE_TIM, GFP_ATOMIC); | ||
265 | if (unlikely(!skb)) | ||
266 | return -ENOMEM; | ||
267 | |||
268 | tim = (struct p54_tim *) skb_put(skb, sizeof(*tim)); | ||
269 | tim->count = 1; | ||
270 | tim->entry[0] = cpu_to_le16(set ? (aid | 0x8000) : aid); | ||
271 | p54_tx(priv, skb); | ||
272 | return 0; | ||
273 | } | ||
274 | |||
275 | int p54_sta_unlock(struct p54_common *priv, u8 *addr) | ||
276 | { | ||
277 | struct sk_buff *skb; | ||
278 | struct p54_sta_unlock *sta; | ||
279 | |||
280 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*sta), | ||
281 | P54_CONTROL_TYPE_PSM_STA_UNLOCK, GFP_ATOMIC); | ||
282 | if (unlikely(!skb)) | ||
283 | return -ENOMEM; | ||
284 | |||
285 | sta = (struct p54_sta_unlock *)skb_put(skb, sizeof(*sta)); | ||
286 | memcpy(sta->addr, addr, ETH_ALEN); | ||
287 | p54_tx(priv, skb); | ||
288 | return 0; | ||
289 | } | ||
290 | |||
291 | int p54_tx_cancel(struct p54_common *priv, __le32 req_id) | ||
292 | { | ||
293 | struct sk_buff *skb; | ||
294 | struct p54_txcancel *cancel; | ||
295 | u32 _req_id = le32_to_cpu(req_id); | ||
296 | |||
297 | if (unlikely(_req_id < priv->rx_start || _req_id > priv->rx_end)) | ||
298 | return -EINVAL; | ||
299 | |||
300 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*cancel), | ||
301 | P54_CONTROL_TYPE_TXCANCEL, GFP_ATOMIC); | ||
302 | if (unlikely(!skb)) | ||
303 | return -ENOMEM; | ||
304 | |||
305 | cancel = (struct p54_txcancel *)skb_put(skb, sizeof(*cancel)); | ||
306 | cancel->req_id = req_id; | ||
307 | p54_tx(priv, skb); | ||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | int p54_setup_mac(struct p54_common *priv) | ||
312 | { | ||
313 | struct sk_buff *skb; | ||
314 | struct p54_setup_mac *setup; | ||
315 | u16 mode; | ||
316 | |||
317 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*setup), | ||
318 | P54_CONTROL_TYPE_SETUP, GFP_ATOMIC); | ||
319 | if (!skb) | ||
320 | return -ENOMEM; | ||
321 | |||
322 | setup = (struct p54_setup_mac *) skb_put(skb, sizeof(*setup)); | ||
323 | if (priv->hw->conf.radio_enabled) { | ||
324 | switch (priv->mode) { | ||
325 | case NL80211_IFTYPE_STATION: | ||
326 | mode = P54_FILTER_TYPE_STATION; | ||
327 | break; | ||
328 | case NL80211_IFTYPE_AP: | ||
329 | mode = P54_FILTER_TYPE_AP; | ||
330 | break; | ||
331 | case NL80211_IFTYPE_ADHOC: | ||
332 | case NL80211_IFTYPE_MESH_POINT: | ||
333 | mode = P54_FILTER_TYPE_IBSS; | ||
334 | break; | ||
335 | case NL80211_IFTYPE_MONITOR: | ||
336 | mode = P54_FILTER_TYPE_PROMISCUOUS; | ||
337 | break; | ||
338 | default: | ||
339 | mode = P54_FILTER_TYPE_HIBERNATE; | ||
340 | break; | ||
341 | } | ||
342 | |||
343 | /* | ||
344 | * "TRANSPARENT and PROMISCUOUS are mutually exclusive" | ||
345 | * STSW45X0C LMAC API - page 12 | ||
346 | */ | ||
347 | if (((priv->filter_flags & FIF_PROMISC_IN_BSS) || | ||
348 | (priv->filter_flags & FIF_OTHER_BSS)) && | ||
349 | (mode != P54_FILTER_TYPE_PROMISCUOUS)) | ||
350 | mode |= P54_FILTER_TYPE_TRANSPARENT; | ||
351 | } else | ||
352 | mode = P54_FILTER_TYPE_HIBERNATE; | ||
353 | |||
354 | setup->mac_mode = cpu_to_le16(mode); | ||
355 | memcpy(setup->mac_addr, priv->mac_addr, ETH_ALEN); | ||
356 | memcpy(setup->bssid, priv->bssid, ETH_ALEN); | ||
357 | setup->rx_antenna = 2 & priv->rx_diversity_mask; /* automatic */ | ||
358 | setup->rx_align = 0; | ||
359 | if (priv->fw_var < 0x500) { | ||
360 | setup->v1.basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); | ||
361 | memset(setup->v1.rts_rates, 0, 8); | ||
362 | setup->v1.rx_addr = cpu_to_le32(priv->rx_end); | ||
363 | setup->v1.max_rx = cpu_to_le16(priv->rx_mtu); | ||
364 | setup->v1.rxhw = cpu_to_le16(priv->rxhw); | ||
365 | setup->v1.wakeup_timer = cpu_to_le16(priv->wakeup_timer); | ||
366 | setup->v1.unalloc0 = cpu_to_le16(0); | ||
367 | } else { | ||
368 | setup->v2.rx_addr = cpu_to_le32(priv->rx_end); | ||
369 | setup->v2.max_rx = cpu_to_le16(priv->rx_mtu); | ||
370 | setup->v2.rxhw = cpu_to_le16(priv->rxhw); | ||
371 | setup->v2.timer = cpu_to_le16(priv->wakeup_timer); | ||
372 | setup->v2.truncate = cpu_to_le16(48896); | ||
373 | setup->v2.basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); | ||
374 | setup->v2.sbss_offset = 0; | ||
375 | setup->v2.mcast_window = 0; | ||
376 | setup->v2.rx_rssi_threshold = 0; | ||
377 | setup->v2.rx_ed_threshold = 0; | ||
378 | setup->v2.ref_clock = cpu_to_le32(644245094); | ||
379 | setup->v2.lpf_bandwidth = cpu_to_le16(65535); | ||
380 | setup->v2.osc_start_delay = cpu_to_le16(65535); | ||
381 | } | ||
382 | p54_tx(priv, skb); | ||
383 | return 0; | ||
384 | } | ||
385 | |||
386 | int p54_scan(struct p54_common *priv, u16 mode, u16 dwell) | ||
387 | { | ||
388 | struct sk_buff *skb; | ||
389 | struct p54_hdr *hdr; | ||
390 | struct p54_scan_head *head; | ||
391 | struct p54_iq_autocal_entry *iq_autocal; | ||
392 | union p54_scan_body_union *body; | ||
393 | struct p54_scan_tail_rate *rate; | ||
394 | struct pda_rssi_cal_entry *rssi; | ||
395 | unsigned int i; | ||
396 | void *entry; | ||
397 | int band = priv->hw->conf.channel->band; | ||
398 | __le16 freq = cpu_to_le16(priv->hw->conf.channel->center_freq); | ||
399 | |||
400 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*head) + | ||
401 | 2 + sizeof(*iq_autocal) + sizeof(*body) + | ||
402 | sizeof(*rate) + 2 * sizeof(*rssi), | ||
403 | P54_CONTROL_TYPE_SCAN, GFP_ATOMIC); | ||
404 | if (!skb) | ||
405 | return -ENOMEM; | ||
406 | |||
407 | head = (struct p54_scan_head *) skb_put(skb, sizeof(*head)); | ||
408 | memset(head->scan_params, 0, sizeof(head->scan_params)); | ||
409 | head->mode = cpu_to_le16(mode); | ||
410 | head->dwell = cpu_to_le16(dwell); | ||
411 | head->freq = freq; | ||
412 | |||
413 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
414 | __le16 *pa_power_points = (__le16 *) skb_put(skb, 2); | ||
415 | *pa_power_points = cpu_to_le16(0x0c); | ||
416 | } | ||
417 | |||
418 | iq_autocal = (void *) skb_put(skb, sizeof(*iq_autocal)); | ||
419 | for (i = 0; i < priv->iq_autocal_len; i++) { | ||
420 | if (priv->iq_autocal[i].freq != freq) | ||
421 | continue; | ||
422 | |||
423 | memcpy(iq_autocal, &priv->iq_autocal[i].params, | ||
424 | sizeof(struct p54_iq_autocal_entry)); | ||
425 | break; | ||
426 | } | ||
427 | if (i == priv->iq_autocal_len) | ||
428 | goto err; | ||
429 | |||
430 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) | ||
431 | body = (void *) skb_put(skb, sizeof(body->longbow)); | ||
432 | else | ||
433 | body = (void *) skb_put(skb, sizeof(body->normal)); | ||
434 | |||
435 | for (i = 0; i < priv->output_limit->entries; i++) { | ||
436 | __le16 *entry_freq = (void *) (priv->output_limit->data + | ||
437 | priv->output_limit->entry_size * i); | ||
438 | |||
439 | if (*entry_freq != freq) | ||
440 | continue; | ||
441 | |||
442 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
443 | memcpy(&body->longbow.power_limits, | ||
444 | (void *) entry_freq + sizeof(__le16), | ||
445 | priv->output_limit->entry_size); | ||
446 | } else { | ||
447 | struct pda_channel_output_limit *limits = | ||
448 | (void *) entry_freq; | ||
449 | |||
450 | body->normal.val_barker = 0x38; | ||
451 | body->normal.val_bpsk = body->normal.dup_bpsk = | ||
452 | limits->val_bpsk; | ||
453 | body->normal.val_qpsk = body->normal.dup_qpsk = | ||
454 | limits->val_qpsk; | ||
455 | body->normal.val_16qam = body->normal.dup_16qam = | ||
456 | limits->val_16qam; | ||
457 | body->normal.val_64qam = body->normal.dup_64qam = | ||
458 | limits->val_64qam; | ||
459 | } | ||
460 | break; | ||
461 | } | ||
462 | if (i == priv->output_limit->entries) | ||
463 | goto err; | ||
464 | |||
465 | entry = (void *)(priv->curve_data->data + priv->curve_data->offset); | ||
466 | for (i = 0; i < priv->curve_data->entries; i++) { | ||
467 | if (*((__le16 *)entry) != freq) { | ||
468 | entry += priv->curve_data->entry_size; | ||
469 | continue; | ||
470 | } | ||
471 | |||
472 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
473 | memcpy(&body->longbow.curve_data, | ||
474 | (void *) entry + sizeof(__le16), | ||
475 | priv->curve_data->entry_size); | ||
476 | } else { | ||
477 | struct p54_scan_body *chan = &body->normal; | ||
478 | struct pda_pa_curve_data *curve_data = | ||
479 | (void *) priv->curve_data->data; | ||
480 | |||
481 | entry += sizeof(__le16); | ||
482 | chan->pa_points_per_curve = 8; | ||
483 | memset(chan->curve_data, 0, sizeof(*chan->curve_data)); | ||
484 | memcpy(chan->curve_data, entry, | ||
485 | sizeof(struct p54_pa_curve_data_sample) * | ||
486 | min((u8)8, curve_data->points_per_channel)); | ||
487 | } | ||
488 | break; | ||
489 | } | ||
490 | if (i == priv->curve_data->entries) | ||
491 | goto err; | ||
492 | |||
493 | if ((priv->fw_var >= 0x500) && (priv->fw_var < 0x509)) { | ||
494 | rate = (void *) skb_put(skb, sizeof(*rate)); | ||
495 | rate->basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); | ||
496 | for (i = 0; i < sizeof(rate->rts_rates); i++) | ||
497 | rate->rts_rates[i] = i; | ||
498 | } | ||
499 | |||
500 | rssi = (struct pda_rssi_cal_entry *) skb_put(skb, sizeof(*rssi)); | ||
501 | rssi->mul = cpu_to_le16(priv->rssical_db[band].mul); | ||
502 | rssi->add = cpu_to_le16(priv->rssical_db[band].add); | ||
503 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
504 | /* Longbow frontend needs ever more */ | ||
505 | rssi = (void *) skb_put(skb, sizeof(*rssi)); | ||
506 | rssi->mul = cpu_to_le16(priv->rssical_db[band].longbow_unkn); | ||
507 | rssi->add = cpu_to_le16(priv->rssical_db[band].longbow_unk2); | ||
508 | } | ||
509 | |||
510 | if (priv->fw_var >= 0x509) { | ||
511 | rate = (void *) skb_put(skb, sizeof(*rate)); | ||
512 | rate->basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); | ||
513 | for (i = 0; i < sizeof(rate->rts_rates); i++) | ||
514 | rate->rts_rates[i] = i; | ||
515 | } | ||
516 | |||
517 | hdr = (struct p54_hdr *) skb->data; | ||
518 | hdr->len = cpu_to_le16(skb->len - sizeof(*hdr)); | ||
519 | |||
520 | p54_tx(priv, skb); | ||
521 | return 0; | ||
522 | |||
523 | err: | ||
524 | printk(KERN_ERR "%s: frequency change to channel %d failed.\n", | ||
525 | wiphy_name(priv->hw->wiphy), ieee80211_frequency_to_channel( | ||
526 | priv->hw->conf.channel->center_freq)); | ||
527 | |||
528 | dev_kfree_skb_any(skb); | ||
529 | return -EINVAL; | ||
530 | } | ||
531 | |||
532 | int p54_set_leds(struct p54_common *priv) | ||
533 | { | ||
534 | struct sk_buff *skb; | ||
535 | struct p54_led *led; | ||
536 | |||
537 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*led), | ||
538 | P54_CONTROL_TYPE_LED, GFP_ATOMIC); | ||
539 | if (unlikely(!skb)) | ||
540 | return -ENOMEM; | ||
541 | |||
542 | led = (struct p54_led *) skb_put(skb, sizeof(*led)); | ||
543 | led->flags = cpu_to_le16(0x0003); | ||
544 | led->mask[0] = led->mask[1] = cpu_to_le16(priv->softled_state); | ||
545 | led->delay[0] = cpu_to_le16(1); | ||
546 | led->delay[1] = cpu_to_le16(0); | ||
547 | p54_tx(priv, skb); | ||
548 | return 0; | ||
549 | } | ||
550 | |||
551 | int p54_set_edcf(struct p54_common *priv) | ||
552 | { | ||
553 | struct sk_buff *skb; | ||
554 | struct p54_edcf *edcf; | ||
555 | |||
556 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*edcf), | ||
557 | P54_CONTROL_TYPE_DCFINIT, GFP_ATOMIC); | ||
558 | if (unlikely(!skb)) | ||
559 | return -ENOMEM; | ||
560 | |||
561 | edcf = (struct p54_edcf *)skb_put(skb, sizeof(*edcf)); | ||
562 | if (priv->use_short_slot) { | ||
563 | edcf->slottime = 9; | ||
564 | edcf->sifs = 0x10; | ||
565 | edcf->eofpad = 0x00; | ||
566 | } else { | ||
567 | edcf->slottime = 20; | ||
568 | edcf->sifs = 0x0a; | ||
569 | edcf->eofpad = 0x06; | ||
570 | } | ||
571 | /* (see prism54/isl_oid.h for further details) */ | ||
572 | edcf->frameburst = cpu_to_le16(0); | ||
573 | edcf->round_trip_delay = cpu_to_le16(0); | ||
574 | edcf->flags = 0; | ||
575 | memset(edcf->mapping, 0, sizeof(edcf->mapping)); | ||
576 | memcpy(edcf->queue, priv->qos_params, sizeof(edcf->queue)); | ||
577 | p54_tx(priv, skb); | ||
578 | return 0; | ||
579 | } | ||
580 | |||
581 | int p54_set_ps(struct p54_common *priv) | ||
582 | { | ||
583 | struct sk_buff *skb; | ||
584 | struct p54_psm *psm; | ||
585 | unsigned int i; | ||
586 | u16 mode; | ||
587 | |||
588 | if (priv->hw->conf.flags & IEEE80211_CONF_PS) | ||
589 | mode = P54_PSM | P54_PSM_BEACON_TIMEOUT | P54_PSM_DTIM | | ||
590 | P54_PSM_CHECKSUM | P54_PSM_MCBC; | ||
591 | else | ||
592 | mode = P54_PSM_CAM; | ||
593 | |||
594 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*psm), | ||
595 | P54_CONTROL_TYPE_PSM, GFP_ATOMIC); | ||
596 | if (!skb) | ||
597 | return -ENOMEM; | ||
598 | |||
599 | psm = (struct p54_psm *)skb_put(skb, sizeof(*psm)); | ||
600 | psm->mode = cpu_to_le16(mode); | ||
601 | psm->aid = cpu_to_le16(priv->aid); | ||
602 | for (i = 0; i < ARRAY_SIZE(psm->intervals); i++) { | ||
603 | psm->intervals[i].interval = | ||
604 | cpu_to_le16(priv->hw->conf.listen_interval); | ||
605 | psm->intervals[i].periods = cpu_to_le16(1); | ||
606 | } | ||
607 | |||
608 | psm->beacon_rssi_skip_max = 200; | ||
609 | psm->rssi_delta_threshold = 0; | ||
610 | psm->nr = 10; | ||
611 | psm->exclude[0] = 0; | ||
612 | |||
613 | p54_tx(priv, skb); | ||
614 | return 0; | ||
615 | } | ||
616 | |||
617 | int p54_init_xbow_synth(struct p54_common *priv) | ||
618 | { | ||
619 | struct sk_buff *skb; | ||
620 | struct p54_xbow_synth *xbow; | ||
621 | |||
622 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*xbow), | ||
623 | P54_CONTROL_TYPE_XBOW_SYNTH_CFG, GFP_KERNEL); | ||
624 | if (unlikely(!skb)) | ||
625 | return -ENOMEM; | ||
626 | |||
627 | xbow = (struct p54_xbow_synth *)skb_put(skb, sizeof(*xbow)); | ||
628 | xbow->magic1 = cpu_to_le16(0x1); | ||
629 | xbow->magic2 = cpu_to_le16(0x2); | ||
630 | xbow->freq = cpu_to_le16(5390); | ||
631 | memset(xbow->padding, 0, sizeof(xbow->padding)); | ||
632 | p54_tx(priv, skb); | ||
633 | return 0; | ||
634 | } | ||
635 | |||
636 | int p54_upload_key(struct p54_common *priv, u8 algo, int slot, u8 idx, u8 len, | ||
637 | u8 *addr, u8* key) | ||
638 | { | ||
639 | struct sk_buff *skb; | ||
640 | struct p54_keycache *rxkey; | ||
641 | |||
642 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*rxkey), | ||
643 | P54_CONTROL_TYPE_RX_KEYCACHE, GFP_KERNEL); | ||
644 | if (unlikely(!skb)) | ||
645 | return -ENOMEM; | ||
646 | |||
647 | rxkey = (struct p54_keycache *)skb_put(skb, sizeof(*rxkey)); | ||
648 | rxkey->entry = slot; | ||
649 | rxkey->key_id = idx; | ||
650 | rxkey->key_type = algo; | ||
651 | if (addr) | ||
652 | memcpy(rxkey->mac, addr, ETH_ALEN); | ||
653 | else | ||
654 | memset(rxkey->mac, ~0, ETH_ALEN); | ||
655 | |||
656 | switch (algo) { | ||
657 | case P54_CRYPTO_WEP: | ||
658 | case P54_CRYPTO_AESCCMP: | ||
659 | rxkey->key_len = min_t(u8, 16, len); | ||
660 | memcpy(rxkey->key, key, rxkey->key_len); | ||
661 | break; | ||
662 | |||
663 | case P54_CRYPTO_TKIPMICHAEL: | ||
664 | rxkey->key_len = 24; | ||
665 | memcpy(rxkey->key, key, 16); | ||
666 | memcpy(&(rxkey->key[16]), &(key | ||
667 | [NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY]), 8); | ||
668 | break; | ||
669 | |||
670 | case P54_CRYPTO_NONE: | ||
671 | rxkey->key_len = 0; | ||
672 | memset(rxkey->key, 0, sizeof(rxkey->key)); | ||
673 | break; | ||
674 | |||
675 | default: | ||
676 | printk(KERN_ERR "%s: invalid cryptographic algorithm: %d\n", | ||
677 | wiphy_name(priv->hw->wiphy), algo); | ||
678 | dev_kfree_skb(skb); | ||
679 | return -EINVAL; | ||
680 | } | ||
681 | |||
682 | p54_tx(priv, skb); | ||
683 | return 0; | ||
684 | } | ||
685 | |||
686 | int p54_fetch_statistics(struct p54_common *priv) | ||
687 | { | ||
688 | struct sk_buff *skb; | ||
689 | |||
690 | skb = p54_alloc_skb(priv, P54_HDR_FLAG_CONTROL, | ||
691 | sizeof(struct p54_statistics), | ||
692 | P54_CONTROL_TYPE_STAT_READBACK, GFP_KERNEL); | ||
693 | if (!skb) | ||
694 | return -ENOMEM; | ||
695 | |||
696 | p54_tx(priv, skb); | ||
697 | return 0; | ||
698 | } | ||
diff --git a/drivers/net/wireless/p54/led.c b/drivers/net/wireless/p54/led.c new file mode 100644 index 000000000000..c00115b206d4 --- /dev/null +++ b/drivers/net/wireless/p54/led.c | |||
@@ -0,0 +1,163 @@ | |||
1 | /* | ||
2 | * Common code for mac80211 Prism54 drivers | ||
3 | * | ||
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
5 | * Copyright (c) 2007-2009, Christian Lamparter <chunkeey@web.de> | ||
6 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> | ||
7 | * | ||
8 | * Based on: | ||
9 | * - the islsm (softmac prism54) driver, which is: | ||
10 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
11 | * - stlc45xx driver | ||
12 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | |||
19 | #include <linux/init.h> | ||
20 | #include <linux/firmware.h> | ||
21 | #include <linux/etherdevice.h> | ||
22 | |||
23 | #include <net/mac80211.h> | ||
24 | #ifdef CONFIG_P54_LEDS | ||
25 | #include <linux/leds.h> | ||
26 | #endif /* CONFIG_P54_LEDS */ | ||
27 | |||
28 | #include "p54.h" | ||
29 | #include "lmac.h" | ||
30 | |||
31 | static void p54_update_leds(struct work_struct *work) | ||
32 | { | ||
33 | struct p54_common *priv = container_of(work, struct p54_common, | ||
34 | led_work.work); | ||
35 | int err, i, tmp, blink_delay = 400; | ||
36 | bool rerun = false; | ||
37 | |||
38 | /* Don't toggle the LED, when the device is down. */ | ||
39 | if (priv->mode == NL80211_IFTYPE_UNSPECIFIED) | ||
40 | return ; | ||
41 | |||
42 | for (i = 0; i < ARRAY_SIZE(priv->leds); i++) | ||
43 | if (priv->leds[i].toggled) { | ||
44 | priv->softled_state |= BIT(i); | ||
45 | |||
46 | tmp = 70 + 200 / (priv->leds[i].toggled); | ||
47 | if (tmp < blink_delay) | ||
48 | blink_delay = tmp; | ||
49 | |||
50 | if (priv->leds[i].led_dev.brightness == LED_OFF) | ||
51 | rerun = true; | ||
52 | |||
53 | priv->leds[i].toggled = | ||
54 | !!priv->leds[i].led_dev.brightness; | ||
55 | } else | ||
56 | priv->softled_state &= ~BIT(i); | ||
57 | |||
58 | err = p54_set_leds(priv); | ||
59 | if (err && net_ratelimit()) | ||
60 | printk(KERN_ERR "%s: failed to update LEDs (%d).\n", | ||
61 | wiphy_name(priv->hw->wiphy), err); | ||
62 | |||
63 | if (rerun) | ||
64 | queue_delayed_work(priv->hw->workqueue, &priv->led_work, | ||
65 | msecs_to_jiffies(blink_delay)); | ||
66 | } | ||
67 | |||
68 | static void p54_led_brightness_set(struct led_classdev *led_dev, | ||
69 | enum led_brightness brightness) | ||
70 | { | ||
71 | struct p54_led_dev *led = container_of(led_dev, struct p54_led_dev, | ||
72 | led_dev); | ||
73 | struct ieee80211_hw *dev = led->hw_dev; | ||
74 | struct p54_common *priv = dev->priv; | ||
75 | |||
76 | if (priv->mode == NL80211_IFTYPE_UNSPECIFIED) | ||
77 | return ; | ||
78 | |||
79 | if ((brightness) && (led->registered)) { | ||
80 | led->toggled++; | ||
81 | queue_delayed_work(priv->hw->workqueue, &priv->led_work, | ||
82 | HZ/10); | ||
83 | } | ||
84 | } | ||
85 | |||
86 | static int p54_register_led(struct p54_common *priv, | ||
87 | unsigned int led_index, | ||
88 | char *name, char *trigger) | ||
89 | { | ||
90 | struct p54_led_dev *led = &priv->leds[led_index]; | ||
91 | int err; | ||
92 | |||
93 | if (led->registered) | ||
94 | return -EEXIST; | ||
95 | |||
96 | snprintf(led->name, sizeof(led->name), "p54-%s::%s", | ||
97 | wiphy_name(priv->hw->wiphy), name); | ||
98 | led->hw_dev = priv->hw; | ||
99 | led->index = led_index; | ||
100 | led->led_dev.name = led->name; | ||
101 | led->led_dev.default_trigger = trigger; | ||
102 | led->led_dev.brightness_set = p54_led_brightness_set; | ||
103 | |||
104 | err = led_classdev_register(wiphy_dev(priv->hw->wiphy), &led->led_dev); | ||
105 | if (err) | ||
106 | printk(KERN_ERR "%s: Failed to register %s LED.\n", | ||
107 | wiphy_name(priv->hw->wiphy), name); | ||
108 | else | ||
109 | led->registered = 1; | ||
110 | |||
111 | return err; | ||
112 | } | ||
113 | |||
114 | int p54_init_leds(struct p54_common *priv) | ||
115 | { | ||
116 | int err; | ||
117 | |||
118 | /* | ||
119 | * TODO: | ||
120 | * Figure out if the EEPROM contains some hints about the number | ||
121 | * of available/programmable LEDs of the device. | ||
122 | */ | ||
123 | |||
124 | INIT_DELAYED_WORK(&priv->led_work, p54_update_leds); | ||
125 | |||
126 | err = p54_register_led(priv, 0, "assoc", | ||
127 | ieee80211_get_assoc_led_name(priv->hw)); | ||
128 | if (err) | ||
129 | return err; | ||
130 | |||
131 | err = p54_register_led(priv, 1, "tx", | ||
132 | ieee80211_get_tx_led_name(priv->hw)); | ||
133 | if (err) | ||
134 | return err; | ||
135 | |||
136 | err = p54_register_led(priv, 2, "rx", | ||
137 | ieee80211_get_rx_led_name(priv->hw)); | ||
138 | if (err) | ||
139 | return err; | ||
140 | |||
141 | err = p54_register_led(priv, 3, "radio", | ||
142 | ieee80211_get_radio_led_name(priv->hw)); | ||
143 | if (err) | ||
144 | return err; | ||
145 | |||
146 | err = p54_set_leds(priv); | ||
147 | return err; | ||
148 | } | ||
149 | |||
150 | void p54_unregister_leds(struct p54_common *priv) | ||
151 | { | ||
152 | int i; | ||
153 | |||
154 | for (i = 0; i < ARRAY_SIZE(priv->leds); i++) { | ||
155 | if (priv->leds[i].registered) { | ||
156 | priv->leds[i].registered = false; | ||
157 | priv->leds[i].toggled = 0; | ||
158 | led_classdev_unregister(&priv->leds[i].led_dev); | ||
159 | } | ||
160 | } | ||
161 | |||
162 | cancel_delayed_work_sync(&priv->led_work); | ||
163 | } | ||
diff --git a/drivers/net/wireless/p54/lmac.h b/drivers/net/wireless/p54/lmac.h new file mode 100644 index 000000000000..0496cff26b35 --- /dev/null +++ b/drivers/net/wireless/p54/lmac.h | |||
@@ -0,0 +1,551 @@ | |||
1 | /* | ||
2 | * LMAC Interface specific definitions for mac80211 Prism54 drivers | ||
3 | * | ||
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
5 | * Copyright (c) 2007 - 2009, Christian Lamparter <chunkeey@web.de> | ||
6 | * | ||
7 | * Based on: | ||
8 | * - the islsm (softmac prism54) driver, which is: | ||
9 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
10 | * | ||
11 | * - LMAC API interface header file for STLC4560 (lmac_longbow.h) | ||
12 | * Copyright (C) 2007 Conexant Systems, Inc. | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | |||
19 | #ifndef LMAC_H | ||
20 | #define LMAC_H | ||
21 | |||
22 | enum p54_control_frame_types { | ||
23 | P54_CONTROL_TYPE_SETUP = 0, | ||
24 | P54_CONTROL_TYPE_SCAN, | ||
25 | P54_CONTROL_TYPE_TRAP, | ||
26 | P54_CONTROL_TYPE_DCFINIT, | ||
27 | P54_CONTROL_TYPE_RX_KEYCACHE, | ||
28 | P54_CONTROL_TYPE_TIM, | ||
29 | P54_CONTROL_TYPE_PSM, | ||
30 | P54_CONTROL_TYPE_TXCANCEL, | ||
31 | P54_CONTROL_TYPE_TXDONE, | ||
32 | P54_CONTROL_TYPE_BURST, | ||
33 | P54_CONTROL_TYPE_STAT_READBACK, | ||
34 | P54_CONTROL_TYPE_BBP, | ||
35 | P54_CONTROL_TYPE_EEPROM_READBACK, | ||
36 | P54_CONTROL_TYPE_LED, | ||
37 | P54_CONTROL_TYPE_GPIO, | ||
38 | P54_CONTROL_TYPE_TIMER, | ||
39 | P54_CONTROL_TYPE_MODULATION, | ||
40 | P54_CONTROL_TYPE_SYNTH_CONFIG, | ||
41 | P54_CONTROL_TYPE_DETECTOR_VALUE, | ||
42 | P54_CONTROL_TYPE_XBOW_SYNTH_CFG, | ||
43 | P54_CONTROL_TYPE_CCE_QUIET, | ||
44 | P54_CONTROL_TYPE_PSM_STA_UNLOCK, | ||
45 | P54_CONTROL_TYPE_PCS, | ||
46 | P54_CONTROL_TYPE_BT_BALANCER = 28, | ||
47 | P54_CONTROL_TYPE_GROUP_ADDRESS_TABLE = 30, | ||
48 | P54_CONTROL_TYPE_ARPTABLE = 31, | ||
49 | P54_CONTROL_TYPE_BT_OPTIONS = 35, | ||
50 | }; | ||
51 | |||
52 | #define P54_HDR_FLAG_CONTROL BIT(15) | ||
53 | #define P54_HDR_FLAG_CONTROL_OPSET (BIT(15) + BIT(0)) | ||
54 | #define P54_HDR_FLAG_DATA_ALIGN BIT(14) | ||
55 | |||
56 | #define P54_HDR_FLAG_DATA_OUT_PROMISC BIT(0) | ||
57 | #define P54_HDR_FLAG_DATA_OUT_TIMESTAMP BIT(1) | ||
58 | #define P54_HDR_FLAG_DATA_OUT_SEQNR BIT(2) | ||
59 | #define P54_HDR_FLAG_DATA_OUT_BIT3 BIT(3) | ||
60 | #define P54_HDR_FLAG_DATA_OUT_BURST BIT(4) | ||
61 | #define P54_HDR_FLAG_DATA_OUT_NOCANCEL BIT(5) | ||
62 | #define P54_HDR_FLAG_DATA_OUT_CLEARTIM BIT(6) | ||
63 | #define P54_HDR_FLAG_DATA_OUT_HITCHHIKE BIT(7) | ||
64 | #define P54_HDR_FLAG_DATA_OUT_COMPRESS BIT(8) | ||
65 | #define P54_HDR_FLAG_DATA_OUT_CONCAT BIT(9) | ||
66 | #define P54_HDR_FLAG_DATA_OUT_PCS_ACCEPT BIT(10) | ||
67 | #define P54_HDR_FLAG_DATA_OUT_WAITEOSP BIT(11) | ||
68 | |||
69 | #define P54_HDR_FLAG_DATA_IN_FCS_GOOD BIT(0) | ||
70 | #define P54_HDR_FLAG_DATA_IN_MATCH_MAC BIT(1) | ||
71 | #define P54_HDR_FLAG_DATA_IN_MCBC BIT(2) | ||
72 | #define P54_HDR_FLAG_DATA_IN_BEACON BIT(3) | ||
73 | #define P54_HDR_FLAG_DATA_IN_MATCH_BSS BIT(4) | ||
74 | #define P54_HDR_FLAG_DATA_IN_BCAST_BSS BIT(5) | ||
75 | #define P54_HDR_FLAG_DATA_IN_DATA BIT(6) | ||
76 | #define P54_HDR_FLAG_DATA_IN_TRUNCATED BIT(7) | ||
77 | #define P54_HDR_FLAG_DATA_IN_BIT8 BIT(8) | ||
78 | #define P54_HDR_FLAG_DATA_IN_TRANSPARENT BIT(9) | ||
79 | |||
80 | struct p54_hdr { | ||
81 | __le16 flags; | ||
82 | __le16 len; | ||
83 | __le32 req_id; | ||
84 | __le16 type; /* enum p54_control_frame_types */ | ||
85 | u8 rts_tries; | ||
86 | u8 tries; | ||
87 | u8 data[0]; | ||
88 | } __packed; | ||
89 | |||
90 | #define GET_REQ_ID(skb) \ | ||
91 | (((struct p54_hdr *) ((struct sk_buff *) skb)->data)->req_id) \ | ||
92 | |||
93 | #define FREE_AFTER_TX(skb) \ | ||
94 | ((((struct p54_hdr *) ((struct sk_buff *) skb)->data)-> \ | ||
95 | flags) == cpu_to_le16(P54_HDR_FLAG_CONTROL_OPSET)) | ||
96 | |||
97 | #define IS_DATA_FRAME(skb) \ | ||
98 | (!((((struct p54_hdr *) ((struct sk_buff *) skb)->data)-> \ | ||
99 | flags) & cpu_to_le16(P54_HDR_FLAG_CONTROL))) | ||
100 | |||
101 | /* | ||
102 | * shared interface ID definitions | ||
103 | * The interface ID is a unique identification of a specific interface. | ||
104 | * The following values are reserved: 0x0000, 0x0002, 0x0012, 0x0014, 0x0015 | ||
105 | */ | ||
106 | #define IF_ID_ISL36356A 0x0001 /* ISL36356A <-> Firmware */ | ||
107 | #define IF_ID_MVC 0x0003 /* MAC Virtual Coprocessor */ | ||
108 | #define IF_ID_DEBUG 0x0008 /* PolDebug Interface */ | ||
109 | #define IF_ID_PRODUCT 0x0009 | ||
110 | #define IF_ID_OEM 0x000a | ||
111 | #define IF_ID_PCI3877 0x000b /* 3877 <-> Host PCI */ | ||
112 | #define IF_ID_ISL37704C 0x000c /* ISL37704C <-> Fw */ | ||
113 | #define IF_ID_ISL39000 0x000f /* ISL39000 <-> Fw */ | ||
114 | #define IF_ID_ISL39300A 0x0010 /* ISL39300A <-> Fw */ | ||
115 | #define IF_ID_ISL37700_UAP 0x0016 /* ISL37700 uAP Fw <-> Fw */ | ||
116 | #define IF_ID_ISL39000_UAP 0x0017 /* ISL39000 uAP Fw <-> Fw */ | ||
117 | #define IF_ID_LMAC 0x001a /* Interface exposed by LMAC */ | ||
118 | |||
119 | struct exp_if { | ||
120 | __le16 role; | ||
121 | __le16 if_id; | ||
122 | __le16 variant; | ||
123 | __le16 btm_compat; | ||
124 | __le16 top_compat; | ||
125 | } __packed; | ||
126 | |||
127 | struct dep_if { | ||
128 | __le16 role; | ||
129 | __le16 if_id; | ||
130 | __le16 variant; | ||
131 | } __packed; | ||
132 | |||
133 | /* driver <-> lmac definitions */ | ||
134 | struct p54_eeprom_lm86 { | ||
135 | union { | ||
136 | struct { | ||
137 | __le16 offset; | ||
138 | __le16 len; | ||
139 | u8 data[0]; | ||
140 | } __packed v1; | ||
141 | struct { | ||
142 | __le32 offset; | ||
143 | __le16 len; | ||
144 | u8 magic2; | ||
145 | u8 pad; | ||
146 | u8 magic[4]; | ||
147 | u8 data[0]; | ||
148 | } __packed v2; | ||
149 | } __packed; | ||
150 | } __packed; | ||
151 | |||
152 | enum p54_rx_decrypt_status { | ||
153 | P54_DECRYPT_NONE = 0, | ||
154 | P54_DECRYPT_OK, | ||
155 | P54_DECRYPT_NOKEY, | ||
156 | P54_DECRYPT_NOMICHAEL, | ||
157 | P54_DECRYPT_NOCKIPMIC, | ||
158 | P54_DECRYPT_FAIL_WEP, | ||
159 | P54_DECRYPT_FAIL_TKIP, | ||
160 | P54_DECRYPT_FAIL_MICHAEL, | ||
161 | P54_DECRYPT_FAIL_CKIPKP, | ||
162 | P54_DECRYPT_FAIL_CKIPMIC, | ||
163 | P54_DECRYPT_FAIL_AESCCMP | ||
164 | }; | ||
165 | |||
166 | struct p54_rx_data { | ||
167 | __le16 flags; | ||
168 | __le16 len; | ||
169 | __le16 freq; | ||
170 | u8 antenna; | ||
171 | u8 rate; | ||
172 | u8 rssi; | ||
173 | u8 quality; | ||
174 | u8 decrypt_status; | ||
175 | u8 rssi_raw; | ||
176 | __le32 tsf32; | ||
177 | __le32 unalloc0; | ||
178 | u8 align[0]; | ||
179 | } __packed; | ||
180 | |||
181 | enum p54_trap_type { | ||
182 | P54_TRAP_SCAN = 0, | ||
183 | P54_TRAP_TIMER, | ||
184 | P54_TRAP_BEACON_TX, | ||
185 | P54_TRAP_FAA_RADIO_ON, | ||
186 | P54_TRAP_FAA_RADIO_OFF, | ||
187 | P54_TRAP_RADAR, | ||
188 | P54_TRAP_NO_BEACON, | ||
189 | P54_TRAP_TBTT, | ||
190 | P54_TRAP_SCO_ENTER, | ||
191 | P54_TRAP_SCO_EXIT | ||
192 | }; | ||
193 | |||
194 | struct p54_trap { | ||
195 | __le16 event; | ||
196 | __le16 frequency; | ||
197 | } __packed; | ||
198 | |||
199 | enum p54_frame_sent_status { | ||
200 | P54_TX_OK = 0, | ||
201 | P54_TX_FAILED, | ||
202 | P54_TX_PSM, | ||
203 | P54_TX_PSM_CANCELLED = 4 | ||
204 | }; | ||
205 | |||
206 | struct p54_frame_sent { | ||
207 | u8 status; | ||
208 | u8 tries; | ||
209 | u8 ack_rssi; | ||
210 | u8 quality; | ||
211 | __le16 seq; | ||
212 | u8 antenna; | ||
213 | u8 padding; | ||
214 | } __packed; | ||
215 | |||
216 | enum p54_tx_data_crypt { | ||
217 | P54_CRYPTO_NONE = 0, | ||
218 | P54_CRYPTO_WEP, | ||
219 | P54_CRYPTO_TKIP, | ||
220 | P54_CRYPTO_TKIPMICHAEL, | ||
221 | P54_CRYPTO_CCX_WEPMIC, | ||
222 | P54_CRYPTO_CCX_KPMIC, | ||
223 | P54_CRYPTO_CCX_KP, | ||
224 | P54_CRYPTO_AESCCMP | ||
225 | }; | ||
226 | |||
227 | enum p54_tx_data_queue { | ||
228 | P54_QUEUE_BEACON = 0, | ||
229 | P54_QUEUE_FWSCAN = 1, | ||
230 | P54_QUEUE_MGMT = 2, | ||
231 | P54_QUEUE_CAB = 3, | ||
232 | P54_QUEUE_DATA = 4, | ||
233 | |||
234 | P54_QUEUE_AC_NUM = 4, | ||
235 | P54_QUEUE_AC_VO = 4, | ||
236 | P54_QUEUE_AC_VI = 5, | ||
237 | P54_QUEUE_AC_BE = 6, | ||
238 | P54_QUEUE_AC_BK = 7, | ||
239 | |||
240 | /* keep last */ | ||
241 | P54_QUEUE_NUM = 8, | ||
242 | }; | ||
243 | |||
244 | #define IS_QOS_QUEUE(n) (n >= P54_QUEUE_DATA) | ||
245 | |||
246 | struct p54_tx_data { | ||
247 | u8 rateset[8]; | ||
248 | u8 rts_rate_idx; | ||
249 | u8 crypt_offset; | ||
250 | u8 key_type; | ||
251 | u8 key_len; | ||
252 | u8 key[16]; | ||
253 | u8 hw_queue; | ||
254 | u8 backlog; | ||
255 | __le16 durations[4]; | ||
256 | u8 tx_antenna; | ||
257 | union { | ||
258 | struct { | ||
259 | u8 cts_rate; | ||
260 | __le16 output_power; | ||
261 | } __packed longbow; | ||
262 | struct { | ||
263 | u8 output_power; | ||
264 | u8 cts_rate; | ||
265 | u8 unalloc; | ||
266 | } __packed normal; | ||
267 | } __packed; | ||
268 | u8 unalloc2[2]; | ||
269 | u8 align[0]; | ||
270 | } __packed; | ||
271 | |||
272 | /* unit is ms */ | ||
273 | #define P54_TX_FRAME_LIFETIME 2000 | ||
274 | #define P54_TX_TIMEOUT 4000 | ||
275 | #define P54_STATISTICS_UPDATE 5000 | ||
276 | |||
277 | #define P54_FILTER_TYPE_NONE 0 | ||
278 | #define P54_FILTER_TYPE_STATION BIT(0) | ||
279 | #define P54_FILTER_TYPE_IBSS BIT(1) | ||
280 | #define P54_FILTER_TYPE_AP BIT(2) | ||
281 | #define P54_FILTER_TYPE_TRANSPARENT BIT(3) | ||
282 | #define P54_FILTER_TYPE_PROMISCUOUS BIT(4) | ||
283 | #define P54_FILTER_TYPE_HIBERNATE BIT(5) | ||
284 | #define P54_FILTER_TYPE_NOACK BIT(6) | ||
285 | #define P54_FILTER_TYPE_RX_DISABLED BIT(7) | ||
286 | |||
287 | struct p54_setup_mac { | ||
288 | __le16 mac_mode; | ||
289 | u8 mac_addr[ETH_ALEN]; | ||
290 | u8 bssid[ETH_ALEN]; | ||
291 | u8 rx_antenna; | ||
292 | u8 rx_align; | ||
293 | union { | ||
294 | struct { | ||
295 | __le32 basic_rate_mask; | ||
296 | u8 rts_rates[8]; | ||
297 | __le32 rx_addr; | ||
298 | __le16 max_rx; | ||
299 | __le16 rxhw; | ||
300 | __le16 wakeup_timer; | ||
301 | __le16 unalloc0; | ||
302 | } __packed v1; | ||
303 | struct { | ||
304 | __le32 rx_addr; | ||
305 | __le16 max_rx; | ||
306 | __le16 rxhw; | ||
307 | __le16 timer; | ||
308 | __le16 truncate; | ||
309 | __le32 basic_rate_mask; | ||
310 | u8 sbss_offset; | ||
311 | u8 mcast_window; | ||
312 | u8 rx_rssi_threshold; | ||
313 | u8 rx_ed_threshold; | ||
314 | __le32 ref_clock; | ||
315 | __le16 lpf_bandwidth; | ||
316 | __le16 osc_start_delay; | ||
317 | } __packed v2; | ||
318 | } __packed; | ||
319 | } __packed; | ||
320 | |||
321 | #define P54_SETUP_V1_LEN 40 | ||
322 | #define P54_SETUP_V2_LEN (sizeof(struct p54_setup_mac)) | ||
323 | |||
324 | #define P54_SCAN_EXIT BIT(0) | ||
325 | #define P54_SCAN_TRAP BIT(1) | ||
326 | #define P54_SCAN_ACTIVE BIT(2) | ||
327 | #define P54_SCAN_FILTER BIT(3) | ||
328 | |||
329 | struct p54_scan_head { | ||
330 | __le16 mode; | ||
331 | __le16 dwell; | ||
332 | u8 scan_params[20]; | ||
333 | __le16 freq; | ||
334 | } __packed; | ||
335 | |||
336 | struct p54_pa_curve_data_sample { | ||
337 | u8 rf_power; | ||
338 | u8 pa_detector; | ||
339 | u8 data_barker; | ||
340 | u8 data_bpsk; | ||
341 | u8 data_qpsk; | ||
342 | u8 data_16qam; | ||
343 | u8 data_64qam; | ||
344 | u8 padding; | ||
345 | } __packed; | ||
346 | |||
347 | struct p54_scan_body { | ||
348 | u8 pa_points_per_curve; | ||
349 | u8 val_barker; | ||
350 | u8 val_bpsk; | ||
351 | u8 val_qpsk; | ||
352 | u8 val_16qam; | ||
353 | u8 val_64qam; | ||
354 | struct p54_pa_curve_data_sample curve_data[8]; | ||
355 | u8 dup_bpsk; | ||
356 | u8 dup_qpsk; | ||
357 | u8 dup_16qam; | ||
358 | u8 dup_64qam; | ||
359 | } __packed; | ||
360 | |||
361 | /* | ||
362 | * Warning: Longbow's structures are bogus. | ||
363 | */ | ||
364 | struct p54_channel_output_limit_longbow { | ||
365 | __le16 rf_power_points[12]; | ||
366 | } __packed; | ||
367 | |||
368 | struct p54_pa_curve_data_sample_longbow { | ||
369 | __le16 rf_power; | ||
370 | __le16 pa_detector; | ||
371 | struct { | ||
372 | __le16 data[4]; | ||
373 | } points[3] __packed; | ||
374 | } __packed; | ||
375 | |||
376 | struct p54_scan_body_longbow { | ||
377 | struct p54_channel_output_limit_longbow power_limits; | ||
378 | struct p54_pa_curve_data_sample_longbow curve_data[8]; | ||
379 | __le16 unkn[6]; /* maybe more power_limits or rate_mask */ | ||
380 | } __packed; | ||
381 | |||
382 | union p54_scan_body_union { | ||
383 | struct p54_scan_body normal; | ||
384 | struct p54_scan_body_longbow longbow; | ||
385 | } __packed; | ||
386 | |||
387 | struct p54_scan_tail_rate { | ||
388 | __le32 basic_rate_mask; | ||
389 | u8 rts_rates[8]; | ||
390 | } __packed; | ||
391 | |||
392 | struct p54_led { | ||
393 | __le16 flags; | ||
394 | __le16 mask[2]; | ||
395 | __le16 delay[2]; | ||
396 | } __packed; | ||
397 | |||
398 | struct p54_edcf { | ||
399 | u8 flags; | ||
400 | u8 slottime; | ||
401 | u8 sifs; | ||
402 | u8 eofpad; | ||
403 | struct p54_edcf_queue_param queue[8]; | ||
404 | u8 mapping[4]; | ||
405 | __le16 frameburst; | ||
406 | __le16 round_trip_delay; | ||
407 | } __packed; | ||
408 | |||
409 | struct p54_statistics { | ||
410 | __le32 rx_success; | ||
411 | __le32 rx_bad_fcs; | ||
412 | __le32 rx_abort; | ||
413 | __le32 rx_abort_phy; | ||
414 | __le32 rts_success; | ||
415 | __le32 rts_fail; | ||
416 | __le32 tsf32; | ||
417 | __le32 airtime; | ||
418 | __le32 noise; | ||
419 | __le32 sample_noise[8]; | ||
420 | __le32 sample_cca; | ||
421 | __le32 sample_tx; | ||
422 | } __packed; | ||
423 | |||
424 | struct p54_xbow_synth { | ||
425 | __le16 magic1; | ||
426 | __le16 magic2; | ||
427 | __le16 freq; | ||
428 | u32 padding[5]; | ||
429 | } __packed; | ||
430 | |||
431 | struct p54_timer { | ||
432 | __le32 interval; | ||
433 | } __packed; | ||
434 | |||
435 | struct p54_keycache { | ||
436 | u8 entry; | ||
437 | u8 key_id; | ||
438 | u8 mac[ETH_ALEN]; | ||
439 | u8 padding[2]; | ||
440 | u8 key_type; | ||
441 | u8 key_len; | ||
442 | u8 key[24]; | ||
443 | } __packed; | ||
444 | |||
445 | struct p54_burst { | ||
446 | u8 flags; | ||
447 | u8 queue; | ||
448 | u8 backlog; | ||
449 | u8 pad; | ||
450 | __le16 durations[32]; | ||
451 | } __packed; | ||
452 | |||
453 | struct p54_psm_interval { | ||
454 | __le16 interval; | ||
455 | __le16 periods; | ||
456 | } __packed; | ||
457 | |||
458 | #define P54_PSM_CAM 0 | ||
459 | #define P54_PSM BIT(0) | ||
460 | #define P54_PSM_DTIM BIT(1) | ||
461 | #define P54_PSM_MCBC BIT(2) | ||
462 | #define P54_PSM_CHECKSUM BIT(3) | ||
463 | #define P54_PSM_SKIP_MORE_DATA BIT(4) | ||
464 | #define P54_PSM_BEACON_TIMEOUT BIT(5) | ||
465 | #define P54_PSM_HFOSLEEP BIT(6) | ||
466 | #define P54_PSM_AUTOSWITCH_SLEEP BIT(7) | ||
467 | #define P54_PSM_LPIT BIT(8) | ||
468 | #define P54_PSM_BF_UCAST_SKIP BIT(9) | ||
469 | #define P54_PSM_BF_MCAST_SKIP BIT(10) | ||
470 | |||
471 | struct p54_psm { | ||
472 | __le16 mode; | ||
473 | __le16 aid; | ||
474 | struct p54_psm_interval intervals[4]; | ||
475 | u8 beacon_rssi_skip_max; | ||
476 | u8 rssi_delta_threshold; | ||
477 | u8 nr; | ||
478 | u8 exclude[1]; | ||
479 | } __packed; | ||
480 | |||
481 | #define MC_FILTER_ADDRESS_NUM 4 | ||
482 | |||
483 | struct p54_group_address_table { | ||
484 | __le16 filter_enable; | ||
485 | __le16 num_address; | ||
486 | u8 mac_list[MC_FILTER_ADDRESS_NUM][ETH_ALEN]; | ||
487 | } __packed; | ||
488 | |||
489 | struct p54_txcancel { | ||
490 | __le32 req_id; | ||
491 | } __packed; | ||
492 | |||
493 | struct p54_sta_unlock { | ||
494 | u8 addr[ETH_ALEN]; | ||
495 | u16 padding; | ||
496 | } __packed; | ||
497 | |||
498 | #define P54_TIM_CLEAR BIT(15) | ||
499 | struct p54_tim { | ||
500 | u8 count; | ||
501 | u8 padding[3]; | ||
502 | __le16 entry[8]; | ||
503 | } __packed; | ||
504 | |||
505 | struct p54_cce_quiet { | ||
506 | __le32 period; | ||
507 | } __packed; | ||
508 | |||
509 | struct p54_bt_balancer { | ||
510 | __le16 prio_thresh; | ||
511 | __le16 acl_thresh; | ||
512 | } __packed; | ||
513 | |||
514 | struct p54_arp_table { | ||
515 | __le16 filter_enable; | ||
516 | u8 ipv4_addr[4]; | ||
517 | } __packed; | ||
518 | |||
519 | /* LED control */ | ||
520 | int p54_set_leds(struct p54_common *priv); | ||
521 | int p54_init_leds(struct p54_common *priv); | ||
522 | void p54_unregister_leds(struct p54_common *priv); | ||
523 | |||
524 | /* xmit functions */ | ||
525 | int p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb); | ||
526 | int p54_tx_cancel(struct p54_common *priv, __le32 req_id); | ||
527 | void p54_tx(struct p54_common *priv, struct sk_buff *skb); | ||
528 | |||
529 | /* synth/phy configuration */ | ||
530 | int p54_init_xbow_synth(struct p54_common *priv); | ||
531 | int p54_scan(struct p54_common *priv, u16 mode, u16 dwell); | ||
532 | |||
533 | /* MAC */ | ||
534 | int p54_sta_unlock(struct p54_common *priv, u8 *addr); | ||
535 | int p54_update_beacon_tim(struct p54_common *priv, u16 aid, bool set); | ||
536 | int p54_setup_mac(struct p54_common *priv); | ||
537 | int p54_set_ps(struct p54_common *priv); | ||
538 | int p54_fetch_statistics(struct p54_common *priv); | ||
539 | |||
540 | /* e/v DCF setup */ | ||
541 | int p54_set_edcf(struct p54_common *priv); | ||
542 | |||
543 | /* cryptographic engine */ | ||
544 | int p54_upload_key(struct p54_common *priv, u8 algo, int slot, | ||
545 | u8 idx, u8 len, u8 *addr, u8* key); | ||
546 | |||
547 | /* eeprom */ | ||
548 | int p54_download_eeprom(struct p54_common *priv, void *buf, | ||
549 | u16 offset, u16 len); | ||
550 | |||
551 | #endif /* LMAC_H */ | ||
diff --git a/drivers/net/wireless/p54/main.c b/drivers/net/wireless/p54/main.c new file mode 100644 index 000000000000..f9b4f6a238ea --- /dev/null +++ b/drivers/net/wireless/p54/main.c | |||
@@ -0,0 +1,607 @@ | |||
1 | /* | ||
2 | * mac80211 glue code for mac80211 Prism54 drivers | ||
3 | * | ||
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
5 | * Copyright (c) 2007-2009, Christian Lamparter <chunkeey@web.de> | ||
6 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> | ||
7 | * | ||
8 | * Based on: | ||
9 | * - the islsm (softmac prism54) driver, which is: | ||
10 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
11 | * - stlc45xx driver | ||
12 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | |||
19 | #include <linux/init.h> | ||
20 | #include <linux/firmware.h> | ||
21 | #include <linux/etherdevice.h> | ||
22 | |||
23 | #include <net/mac80211.h> | ||
24 | |||
25 | #include "p54.h" | ||
26 | #include "lmac.h" | ||
27 | |||
28 | static int modparam_nohwcrypt; | ||
29 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); | ||
30 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); | ||
31 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); | ||
32 | MODULE_DESCRIPTION("Softmac Prism54 common code"); | ||
33 | MODULE_LICENSE("GPL"); | ||
34 | MODULE_ALIAS("prism54common"); | ||
35 | |||
36 | static void p54_sta_notify(struct ieee80211_hw *dev, struct ieee80211_vif *vif, | ||
37 | enum sta_notify_cmd notify_cmd, | ||
38 | struct ieee80211_sta *sta) | ||
39 | { | ||
40 | struct p54_common *priv = dev->priv; | ||
41 | switch (notify_cmd) { | ||
42 | case STA_NOTIFY_ADD: | ||
43 | case STA_NOTIFY_REMOVE: | ||
44 | /* | ||
45 | * Notify the firmware that we don't want or we don't | ||
46 | * need to buffer frames for this station anymore. | ||
47 | */ | ||
48 | |||
49 | p54_sta_unlock(priv, sta->addr); | ||
50 | break; | ||
51 | case STA_NOTIFY_AWAKE: | ||
52 | /* update the firmware's filter table */ | ||
53 | p54_sta_unlock(priv, sta->addr); | ||
54 | break; | ||
55 | default: | ||
56 | break; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | static int p54_set_tim(struct ieee80211_hw *dev, struct ieee80211_sta *sta, | ||
61 | bool set) | ||
62 | { | ||
63 | struct p54_common *priv = dev->priv; | ||
64 | |||
65 | return p54_update_beacon_tim(priv, sta->aid, set); | ||
66 | } | ||
67 | |||
68 | static int p54_beacon_format_ie_tim(struct sk_buff *skb) | ||
69 | { | ||
70 | /* | ||
71 | * the good excuse for this mess is ... the firmware. | ||
72 | * The dummy TIM MUST be at the end of the beacon frame, | ||
73 | * because it'll be overwritten! | ||
74 | */ | ||
75 | |||
76 | struct ieee80211_mgmt *mgmt = (void *)skb->data; | ||
77 | u8 *pos, *end; | ||
78 | |||
79 | if (skb->len <= sizeof(mgmt)) | ||
80 | return -EINVAL; | ||
81 | |||
82 | pos = (u8 *)mgmt->u.beacon.variable; | ||
83 | end = skb->data + skb->len; | ||
84 | while (pos < end) { | ||
85 | if (pos + 2 + pos[1] > end) | ||
86 | return -EINVAL; | ||
87 | |||
88 | if (pos[0] == WLAN_EID_TIM) { | ||
89 | u8 dtim_len = pos[1]; | ||
90 | u8 dtim_period = pos[3]; | ||
91 | u8 *next = pos + 2 + dtim_len; | ||
92 | |||
93 | if (dtim_len < 3) | ||
94 | return -EINVAL; | ||
95 | |||
96 | memmove(pos, next, end - next); | ||
97 | |||
98 | if (dtim_len > 3) | ||
99 | skb_trim(skb, skb->len - (dtim_len - 3)); | ||
100 | |||
101 | pos = end - (dtim_len + 2); | ||
102 | |||
103 | /* add the dummy at the end */ | ||
104 | pos[0] = WLAN_EID_TIM; | ||
105 | pos[1] = 3; | ||
106 | pos[2] = 0; | ||
107 | pos[3] = dtim_period; | ||
108 | pos[4] = 0; | ||
109 | return 0; | ||
110 | } | ||
111 | pos += 2 + pos[1]; | ||
112 | } | ||
113 | return 0; | ||
114 | } | ||
115 | |||
116 | static int p54_beacon_update(struct p54_common *priv, | ||
117 | struct ieee80211_vif *vif) | ||
118 | { | ||
119 | struct sk_buff *beacon; | ||
120 | __le32 old_beacon_req_id; | ||
121 | int ret; | ||
122 | |||
123 | beacon = ieee80211_beacon_get(priv->hw, vif); | ||
124 | if (!beacon) | ||
125 | return -ENOMEM; | ||
126 | ret = p54_beacon_format_ie_tim(beacon); | ||
127 | if (ret) | ||
128 | return ret; | ||
129 | |||
130 | old_beacon_req_id = priv->beacon_req_id; | ||
131 | priv->beacon_req_id = GET_REQ_ID(beacon); | ||
132 | |||
133 | ret = p54_tx_80211(priv->hw, beacon); | ||
134 | if (ret) { | ||
135 | priv->beacon_req_id = old_beacon_req_id; | ||
136 | return -ENOSPC; | ||
137 | } | ||
138 | |||
139 | priv->tsf_high32 = 0; | ||
140 | priv->tsf_low32 = 0; | ||
141 | |||
142 | return 0; | ||
143 | } | ||
144 | |||
145 | static int p54_start(struct ieee80211_hw *dev) | ||
146 | { | ||
147 | struct p54_common *priv = dev->priv; | ||
148 | int err; | ||
149 | |||
150 | mutex_lock(&priv->conf_mutex); | ||
151 | err = priv->open(dev); | ||
152 | if (err) | ||
153 | goto out; | ||
154 | P54_SET_QUEUE(priv->qos_params[0], 0x0002, 0x0003, 0x0007, 47); | ||
155 | P54_SET_QUEUE(priv->qos_params[1], 0x0002, 0x0007, 0x000f, 94); | ||
156 | P54_SET_QUEUE(priv->qos_params[2], 0x0003, 0x000f, 0x03ff, 0); | ||
157 | P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0); | ||
158 | err = p54_set_edcf(priv); | ||
159 | if (err) | ||
160 | goto out; | ||
161 | |||
162 | memset(priv->bssid, ~0, ETH_ALEN); | ||
163 | priv->mode = NL80211_IFTYPE_MONITOR; | ||
164 | err = p54_setup_mac(priv); | ||
165 | if (err) { | ||
166 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | ||
167 | goto out; | ||
168 | } | ||
169 | |||
170 | queue_delayed_work(dev->workqueue, &priv->work, 0); | ||
171 | |||
172 | priv->softled_state = 0; | ||
173 | err = p54_set_leds(priv); | ||
174 | |||
175 | out: | ||
176 | mutex_unlock(&priv->conf_mutex); | ||
177 | return err; | ||
178 | } | ||
179 | |||
180 | static void p54_stop(struct ieee80211_hw *dev) | ||
181 | { | ||
182 | struct p54_common *priv = dev->priv; | ||
183 | int i; | ||
184 | |||
185 | mutex_lock(&priv->conf_mutex); | ||
186 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | ||
187 | priv->softled_state = 0; | ||
188 | p54_set_leds(priv); | ||
189 | |||
190 | cancel_delayed_work_sync(&priv->work); | ||
191 | |||
192 | priv->stop(dev); | ||
193 | skb_queue_purge(&priv->tx_pending); | ||
194 | skb_queue_purge(&priv->tx_queue); | ||
195 | for (i = 0; i < P54_QUEUE_NUM; i++) { | ||
196 | priv->tx_stats[i].count = 0; | ||
197 | priv->tx_stats[i].len = 0; | ||
198 | } | ||
199 | |||
200 | priv->beacon_req_id = cpu_to_le32(0); | ||
201 | priv->tsf_high32 = priv->tsf_low32 = 0; | ||
202 | mutex_unlock(&priv->conf_mutex); | ||
203 | } | ||
204 | |||
205 | static int p54_add_interface(struct ieee80211_hw *dev, | ||
206 | struct ieee80211_if_init_conf *conf) | ||
207 | { | ||
208 | struct p54_common *priv = dev->priv; | ||
209 | |||
210 | mutex_lock(&priv->conf_mutex); | ||
211 | if (priv->mode != NL80211_IFTYPE_MONITOR) { | ||
212 | mutex_unlock(&priv->conf_mutex); | ||
213 | return -EOPNOTSUPP; | ||
214 | } | ||
215 | |||
216 | priv->vif = conf->vif; | ||
217 | |||
218 | switch (conf->type) { | ||
219 | case NL80211_IFTYPE_STATION: | ||
220 | case NL80211_IFTYPE_ADHOC: | ||
221 | case NL80211_IFTYPE_AP: | ||
222 | case NL80211_IFTYPE_MESH_POINT: | ||
223 | priv->mode = conf->type; | ||
224 | break; | ||
225 | default: | ||
226 | mutex_unlock(&priv->conf_mutex); | ||
227 | return -EOPNOTSUPP; | ||
228 | } | ||
229 | |||
230 | memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); | ||
231 | p54_setup_mac(priv); | ||
232 | mutex_unlock(&priv->conf_mutex); | ||
233 | return 0; | ||
234 | } | ||
235 | |||
236 | static void p54_remove_interface(struct ieee80211_hw *dev, | ||
237 | struct ieee80211_if_init_conf *conf) | ||
238 | { | ||
239 | struct p54_common *priv = dev->priv; | ||
240 | |||
241 | mutex_lock(&priv->conf_mutex); | ||
242 | priv->vif = NULL; | ||
243 | if (priv->beacon_req_id) { | ||
244 | p54_tx_cancel(priv, priv->beacon_req_id); | ||
245 | priv->beacon_req_id = cpu_to_le32(0); | ||
246 | } | ||
247 | priv->mode = NL80211_IFTYPE_MONITOR; | ||
248 | memset(priv->mac_addr, 0, ETH_ALEN); | ||
249 | memset(priv->bssid, 0, ETH_ALEN); | ||
250 | p54_setup_mac(priv); | ||
251 | mutex_unlock(&priv->conf_mutex); | ||
252 | } | ||
253 | |||
254 | static int p54_config(struct ieee80211_hw *dev, u32 changed) | ||
255 | { | ||
256 | int ret = 0; | ||
257 | struct p54_common *priv = dev->priv; | ||
258 | struct ieee80211_conf *conf = &dev->conf; | ||
259 | |||
260 | mutex_lock(&priv->conf_mutex); | ||
261 | if (changed & IEEE80211_CONF_CHANGE_POWER) | ||
262 | priv->output_power = conf->power_level << 2; | ||
263 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { | ||
264 | ret = p54_scan(priv, P54_SCAN_EXIT, 0); | ||
265 | if (ret) | ||
266 | goto out; | ||
267 | } | ||
268 | if (changed & IEEE80211_CONF_CHANGE_PS) { | ||
269 | ret = p54_set_ps(priv); | ||
270 | if (ret) | ||
271 | goto out; | ||
272 | } | ||
273 | |||
274 | out: | ||
275 | mutex_unlock(&priv->conf_mutex); | ||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | static void p54_configure_filter(struct ieee80211_hw *dev, | ||
280 | unsigned int changed_flags, | ||
281 | unsigned int *total_flags, | ||
282 | int mc_count, struct dev_mc_list *mclist) | ||
283 | { | ||
284 | struct p54_common *priv = dev->priv; | ||
285 | |||
286 | *total_flags &= FIF_PROMISC_IN_BSS | | ||
287 | FIF_OTHER_BSS; | ||
288 | |||
289 | priv->filter_flags = *total_flags; | ||
290 | |||
291 | if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) | ||
292 | p54_setup_mac(priv); | ||
293 | } | ||
294 | |||
295 | static int p54_conf_tx(struct ieee80211_hw *dev, u16 queue, | ||
296 | const struct ieee80211_tx_queue_params *params) | ||
297 | { | ||
298 | struct p54_common *priv = dev->priv; | ||
299 | int ret; | ||
300 | |||
301 | mutex_lock(&priv->conf_mutex); | ||
302 | if ((params) && !(queue > 4)) { | ||
303 | P54_SET_QUEUE(priv->qos_params[queue], params->aifs, | ||
304 | params->cw_min, params->cw_max, params->txop); | ||
305 | ret = p54_set_edcf(priv); | ||
306 | } else | ||
307 | ret = -EINVAL; | ||
308 | mutex_unlock(&priv->conf_mutex); | ||
309 | return ret; | ||
310 | } | ||
311 | |||
312 | static void p54_work(struct work_struct *work) | ||
313 | { | ||
314 | struct p54_common *priv = container_of(work, struct p54_common, | ||
315 | work.work); | ||
316 | |||
317 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | ||
318 | return ; | ||
319 | |||
320 | /* | ||
321 | * TODO: walk through tx_queue and do the following tasks | ||
322 | * 1. initiate bursts. | ||
323 | * 2. cancel stuck frames / reset the device if necessary. | ||
324 | */ | ||
325 | |||
326 | p54_fetch_statistics(priv); | ||
327 | } | ||
328 | |||
329 | static int p54_get_stats(struct ieee80211_hw *dev, | ||
330 | struct ieee80211_low_level_stats *stats) | ||
331 | { | ||
332 | struct p54_common *priv = dev->priv; | ||
333 | |||
334 | memcpy(stats, &priv->stats, sizeof(*stats)); | ||
335 | return 0; | ||
336 | } | ||
337 | |||
338 | static int p54_get_tx_stats(struct ieee80211_hw *dev, | ||
339 | struct ieee80211_tx_queue_stats *stats) | ||
340 | { | ||
341 | struct p54_common *priv = dev->priv; | ||
342 | |||
343 | memcpy(stats, &priv->tx_stats[P54_QUEUE_DATA], | ||
344 | sizeof(stats[0]) * dev->queues); | ||
345 | return 0; | ||
346 | } | ||
347 | |||
348 | static void p54_bss_info_changed(struct ieee80211_hw *dev, | ||
349 | struct ieee80211_vif *vif, | ||
350 | struct ieee80211_bss_conf *info, | ||
351 | u32 changed) | ||
352 | { | ||
353 | struct p54_common *priv = dev->priv; | ||
354 | |||
355 | mutex_lock(&priv->conf_mutex); | ||
356 | if (changed & BSS_CHANGED_BSSID) { | ||
357 | memcpy(priv->bssid, info->bssid, ETH_ALEN); | ||
358 | p54_setup_mac(priv); | ||
359 | } | ||
360 | |||
361 | if (changed & BSS_CHANGED_BEACON) { | ||
362 | p54_scan(priv, P54_SCAN_EXIT, 0); | ||
363 | p54_setup_mac(priv); | ||
364 | p54_beacon_update(priv, vif); | ||
365 | p54_set_edcf(priv); | ||
366 | } | ||
367 | |||
368 | if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_BEACON)) { | ||
369 | priv->use_short_slot = info->use_short_slot; | ||
370 | p54_set_edcf(priv); | ||
371 | } | ||
372 | if (changed & BSS_CHANGED_BASIC_RATES) { | ||
373 | if (dev->conf.channel->band == IEEE80211_BAND_5GHZ) | ||
374 | priv->basic_rate_mask = (info->basic_rates << 4); | ||
375 | else | ||
376 | priv->basic_rate_mask = info->basic_rates; | ||
377 | p54_setup_mac(priv); | ||
378 | if (priv->fw_var >= 0x500) | ||
379 | p54_scan(priv, P54_SCAN_EXIT, 0); | ||
380 | } | ||
381 | if (changed & BSS_CHANGED_ASSOC) { | ||
382 | if (info->assoc) { | ||
383 | priv->aid = info->aid; | ||
384 | priv->wakeup_timer = info->beacon_int * | ||
385 | info->dtim_period * 5; | ||
386 | p54_setup_mac(priv); | ||
387 | } | ||
388 | } | ||
389 | |||
390 | mutex_unlock(&priv->conf_mutex); | ||
391 | } | ||
392 | |||
393 | static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, | ||
394 | struct ieee80211_vif *vif, struct ieee80211_sta *sta, | ||
395 | struct ieee80211_key_conf *key) | ||
396 | { | ||
397 | struct p54_common *priv = dev->priv; | ||
398 | int slot, ret = 0; | ||
399 | u8 algo = 0; | ||
400 | u8 *addr = NULL; | ||
401 | |||
402 | if (modparam_nohwcrypt) | ||
403 | return -EOPNOTSUPP; | ||
404 | |||
405 | mutex_lock(&priv->conf_mutex); | ||
406 | if (cmd == SET_KEY) { | ||
407 | switch (key->alg) { | ||
408 | case ALG_TKIP: | ||
409 | if (!(priv->privacy_caps & (BR_DESC_PRIV_CAP_MICHAEL | | ||
410 | BR_DESC_PRIV_CAP_TKIP))) { | ||
411 | ret = -EOPNOTSUPP; | ||
412 | goto out_unlock; | ||
413 | } | ||
414 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | ||
415 | algo = P54_CRYPTO_TKIPMICHAEL; | ||
416 | break; | ||
417 | case ALG_WEP: | ||
418 | if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_WEP)) { | ||
419 | ret = -EOPNOTSUPP; | ||
420 | goto out_unlock; | ||
421 | } | ||
422 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | ||
423 | algo = P54_CRYPTO_WEP; | ||
424 | break; | ||
425 | case ALG_CCMP: | ||
426 | if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP)) { | ||
427 | ret = -EOPNOTSUPP; | ||
428 | goto out_unlock; | ||
429 | } | ||
430 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | ||
431 | algo = P54_CRYPTO_AESCCMP; | ||
432 | break; | ||
433 | default: | ||
434 | ret = -EOPNOTSUPP; | ||
435 | goto out_unlock; | ||
436 | } | ||
437 | slot = bitmap_find_free_region(priv->used_rxkeys, | ||
438 | priv->rx_keycache_size, 0); | ||
439 | |||
440 | if (slot < 0) { | ||
441 | /* | ||
442 | * The device supports the choosen algorithm, but the | ||
443 | * firmware does not provide enough key slots to store | ||
444 | * all of them. | ||
445 | * But encryption offload for outgoing frames is always | ||
446 | * possible, so we just pretend that the upload was | ||
447 | * successful and do the decryption in software. | ||
448 | */ | ||
449 | |||
450 | /* mark the key as invalid. */ | ||
451 | key->hw_key_idx = 0xff; | ||
452 | goto out_unlock; | ||
453 | } | ||
454 | } else { | ||
455 | slot = key->hw_key_idx; | ||
456 | |||
457 | if (slot == 0xff) { | ||
458 | /* This key was not uploaded into the rx key cache. */ | ||
459 | |||
460 | goto out_unlock; | ||
461 | } | ||
462 | |||
463 | bitmap_release_region(priv->used_rxkeys, slot, 0); | ||
464 | algo = 0; | ||
465 | } | ||
466 | |||
467 | if (sta) | ||
468 | addr = sta->addr; | ||
469 | |||
470 | ret = p54_upload_key(priv, algo, slot, key->keyidx, | ||
471 | key->keylen, addr, key->key); | ||
472 | if (ret) { | ||
473 | bitmap_release_region(priv->used_rxkeys, slot, 0); | ||
474 | ret = -EOPNOTSUPP; | ||
475 | goto out_unlock; | ||
476 | } | ||
477 | |||
478 | key->hw_key_idx = slot; | ||
479 | |||
480 | out_unlock: | ||
481 | mutex_unlock(&priv->conf_mutex); | ||
482 | return ret; | ||
483 | } | ||
484 | |||
485 | static const struct ieee80211_ops p54_ops = { | ||
486 | .tx = p54_tx_80211, | ||
487 | .start = p54_start, | ||
488 | .stop = p54_stop, | ||
489 | .add_interface = p54_add_interface, | ||
490 | .remove_interface = p54_remove_interface, | ||
491 | .set_tim = p54_set_tim, | ||
492 | .sta_notify = p54_sta_notify, | ||
493 | .set_key = p54_set_key, | ||
494 | .config = p54_config, | ||
495 | .bss_info_changed = p54_bss_info_changed, | ||
496 | .configure_filter = p54_configure_filter, | ||
497 | .conf_tx = p54_conf_tx, | ||
498 | .get_stats = p54_get_stats, | ||
499 | .get_tx_stats = p54_get_tx_stats | ||
500 | }; | ||
501 | |||
502 | struct ieee80211_hw *p54_init_common(size_t priv_data_len) | ||
503 | { | ||
504 | struct ieee80211_hw *dev; | ||
505 | struct p54_common *priv; | ||
506 | |||
507 | dev = ieee80211_alloc_hw(priv_data_len, &p54_ops); | ||
508 | if (!dev) | ||
509 | return NULL; | ||
510 | |||
511 | priv = dev->priv; | ||
512 | priv->hw = dev; | ||
513 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | ||
514 | priv->basic_rate_mask = 0x15f; | ||
515 | spin_lock_init(&priv->tx_stats_lock); | ||
516 | skb_queue_head_init(&priv->tx_queue); | ||
517 | skb_queue_head_init(&priv->tx_pending); | ||
518 | dev->flags = IEEE80211_HW_RX_INCLUDES_FCS | | ||
519 | IEEE80211_HW_SIGNAL_DBM | | ||
520 | IEEE80211_HW_NOISE_DBM; | ||
521 | |||
522 | dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | ||
523 | BIT(NL80211_IFTYPE_ADHOC) | | ||
524 | BIT(NL80211_IFTYPE_AP) | | ||
525 | BIT(NL80211_IFTYPE_MESH_POINT); | ||
526 | |||
527 | dev->channel_change_time = 1000; /* TODO: find actual value */ | ||
528 | priv->tx_stats[P54_QUEUE_BEACON].limit = 1; | ||
529 | priv->tx_stats[P54_QUEUE_FWSCAN].limit = 1; | ||
530 | priv->tx_stats[P54_QUEUE_MGMT].limit = 3; | ||
531 | priv->tx_stats[P54_QUEUE_CAB].limit = 3; | ||
532 | priv->tx_stats[P54_QUEUE_DATA].limit = 5; | ||
533 | dev->queues = 1; | ||
534 | priv->noise = -94; | ||
535 | /* | ||
536 | * We support at most 8 tries no matter which rate they're at, | ||
537 | * we cannot support max_rates * max_rate_tries as we set it | ||
538 | * here, but setting it correctly to 4/2 or so would limit us | ||
539 | * artificially if the RC algorithm wants just two rates, so | ||
540 | * let's say 4/7, we'll redistribute it at TX time, see the | ||
541 | * comments there. | ||
542 | */ | ||
543 | dev->max_rates = 4; | ||
544 | dev->max_rate_tries = 7; | ||
545 | dev->extra_tx_headroom = sizeof(struct p54_hdr) + 4 + | ||
546 | sizeof(struct p54_tx_data); | ||
547 | |||
548 | mutex_init(&priv->conf_mutex); | ||
549 | mutex_init(&priv->eeprom_mutex); | ||
550 | init_completion(&priv->eeprom_comp); | ||
551 | INIT_DELAYED_WORK(&priv->work, p54_work); | ||
552 | |||
553 | return dev; | ||
554 | } | ||
555 | EXPORT_SYMBOL_GPL(p54_init_common); | ||
556 | |||
557 | int p54_register_common(struct ieee80211_hw *dev, struct device *pdev) | ||
558 | { | ||
559 | struct p54_common *priv = dev->priv; | ||
560 | int err; | ||
561 | |||
562 | err = ieee80211_register_hw(dev); | ||
563 | if (err) { | ||
564 | dev_err(pdev, "Cannot register device (%d).\n", err); | ||
565 | return err; | ||
566 | } | ||
567 | |||
568 | #ifdef CONFIG_P54_LEDS | ||
569 | err = p54_init_leds(priv); | ||
570 | if (err) | ||
571 | return err; | ||
572 | #endif /* CONFIG_P54_LEDS */ | ||
573 | |||
574 | dev_info(pdev, "is registered as '%s'\n", wiphy_name(dev->wiphy)); | ||
575 | return 0; | ||
576 | } | ||
577 | EXPORT_SYMBOL_GPL(p54_register_common); | ||
578 | |||
579 | void p54_free_common(struct ieee80211_hw *dev) | ||
580 | { | ||
581 | struct p54_common *priv = dev->priv; | ||
582 | |||
583 | kfree(priv->iq_autocal); | ||
584 | kfree(priv->output_limit); | ||
585 | kfree(priv->curve_data); | ||
586 | kfree(priv->used_rxkeys); | ||
587 | priv->iq_autocal = NULL; | ||
588 | priv->output_limit = NULL; | ||
589 | priv->curve_data = NULL; | ||
590 | priv->used_rxkeys = NULL; | ||
591 | ieee80211_free_hw(dev); | ||
592 | } | ||
593 | EXPORT_SYMBOL_GPL(p54_free_common); | ||
594 | |||
595 | void p54_unregister_common(struct ieee80211_hw *dev) | ||
596 | { | ||
597 | struct p54_common *priv = dev->priv; | ||
598 | |||
599 | #ifdef CONFIG_P54_LEDS | ||
600 | p54_unregister_leds(priv); | ||
601 | #endif /* CONFIG_P54_LEDS */ | ||
602 | |||
603 | ieee80211_unregister_hw(dev); | ||
604 | mutex_destroy(&priv->conf_mutex); | ||
605 | mutex_destroy(&priv->eeprom_mutex); | ||
606 | } | ||
607 | EXPORT_SYMBOL_GPL(p54_unregister_common); | ||
diff --git a/drivers/net/wireless/p54/p54.h b/drivers/net/wireless/p54/p54.h index db3df947d8ed..19d085c73d7d 100644 --- a/drivers/net/wireless/p54/p54.h +++ b/drivers/net/wireless/p54/p54.h | |||
@@ -1,6 +1,3 @@ | |||
1 | #ifndef P54_H | ||
2 | #define P54_H | ||
3 | |||
4 | /* | 1 | /* |
5 | * Shared defines for all mac80211 Prism54 code | 2 | * Shared defines for all mac80211 Prism54 code |
6 | * | 3 | * |
@@ -14,39 +11,78 @@ | |||
14 | * published by the Free Software Foundation. | 11 | * published by the Free Software Foundation. |
15 | */ | 12 | */ |
16 | 13 | ||
14 | #ifndef P54_H | ||
15 | #define P54_H | ||
16 | |||
17 | #ifdef CONFIG_P54_LEDS | 17 | #ifdef CONFIG_P54_LEDS |
18 | #include <linux/leds.h> | 18 | #include <linux/leds.h> |
19 | #endif /* CONFIG_P54_LEDS */ | 19 | #endif /* CONFIG_P54_LEDS */ |
20 | 20 | ||
21 | enum p54_control_frame_types { | 21 | #define ISL38XX_DEV_FIRMWARE_ADDR 0x20000 |
22 | P54_CONTROL_TYPE_SETUP = 0, | 22 | |
23 | P54_CONTROL_TYPE_SCAN, | 23 | #define BR_CODE_MIN 0x80000000 |
24 | P54_CONTROL_TYPE_TRAP, | 24 | #define BR_CODE_COMPONENT_ID 0x80000001 |
25 | P54_CONTROL_TYPE_DCFINIT, | 25 | #define BR_CODE_COMPONENT_VERSION 0x80000002 |
26 | P54_CONTROL_TYPE_RX_KEYCACHE, | 26 | #define BR_CODE_DEPENDENT_IF 0x80000003 |
27 | P54_CONTROL_TYPE_TIM, | 27 | #define BR_CODE_EXPOSED_IF 0x80000004 |
28 | P54_CONTROL_TYPE_PSM, | 28 | #define BR_CODE_DESCR 0x80000101 |
29 | P54_CONTROL_TYPE_TXCANCEL, | 29 | #define BR_CODE_MAX 0x8FFFFFFF |
30 | P54_CONTROL_TYPE_TXDONE, | 30 | #define BR_CODE_END_OF_BRA 0xFF0000FF |
31 | P54_CONTROL_TYPE_BURST, | 31 | #define LEGACY_BR_CODE_END_OF_BRA 0xFFFFFFFF |
32 | P54_CONTROL_TYPE_STAT_READBACK, | 32 | |
33 | P54_CONTROL_TYPE_BBP, | 33 | struct bootrec { |
34 | P54_CONTROL_TYPE_EEPROM_READBACK, | 34 | __le32 code; |
35 | P54_CONTROL_TYPE_LED, | 35 | __le32 len; |
36 | P54_CONTROL_TYPE_GPIO, | 36 | u32 data[10]; |
37 | P54_CONTROL_TYPE_TIMER, | 37 | } __packed; |
38 | P54_CONTROL_TYPE_MODULATION, | 38 | |
39 | P54_CONTROL_TYPE_SYNTH_CONFIG, | 39 | /* Interface role definitions */ |
40 | P54_CONTROL_TYPE_DETECTOR_VALUE, | 40 | #define BR_INTERFACE_ROLE_SERVER 0x0000 |
41 | P54_CONTROL_TYPE_XBOW_SYNTH_CFG, | 41 | #define BR_INTERFACE_ROLE_CLIENT 0x8000 |
42 | P54_CONTROL_TYPE_CCE_QUIET, | 42 | |
43 | P54_CONTROL_TYPE_PSM_STA_UNLOCK, | 43 | #define BR_DESC_PRIV_CAP_WEP BIT(0) |
44 | P54_CONTROL_TYPE_PCS, | 44 | #define BR_DESC_PRIV_CAP_TKIP BIT(1) |
45 | P54_CONTROL_TYPE_BT_BALANCER = 28, | 45 | #define BR_DESC_PRIV_CAP_MICHAEL BIT(2) |
46 | P54_CONTROL_TYPE_GROUP_ADDRESS_TABLE = 30, | 46 | #define BR_DESC_PRIV_CAP_CCX_CP BIT(3) |
47 | P54_CONTROL_TYPE_ARPTABLE = 31, | 47 | #define BR_DESC_PRIV_CAP_CCX_MIC BIT(4) |
48 | P54_CONTROL_TYPE_BT_OPTIONS = 35 | 48 | #define BR_DESC_PRIV_CAP_AESCCMP BIT(5) |
49 | }; | 49 | |
50 | struct bootrec_desc { | ||
51 | __le16 modes; | ||
52 | __le16 flags; | ||
53 | __le32 rx_start; | ||
54 | __le32 rx_end; | ||
55 | u8 headroom; | ||
56 | u8 tailroom; | ||
57 | u8 tx_queues; | ||
58 | u8 tx_depth; | ||
59 | u8 privacy_caps; | ||
60 | u8 rx_keycache_size; | ||
61 | u8 time_size; | ||
62 | u8 padding; | ||
63 | u8 rates[16]; | ||
64 | u8 padding2[4]; | ||
65 | __le16 rx_mtu; | ||
66 | } __packed; | ||
67 | |||
68 | #define FW_FMAC 0x464d4143 | ||
69 | #define FW_LM86 0x4c4d3836 | ||
70 | #define FW_LM87 0x4c4d3837 | ||
71 | #define FW_LM20 0x4c4d3230 | ||
72 | |||
73 | struct bootrec_comp_id { | ||
74 | __le32 fw_variant; | ||
75 | } __packed; | ||
76 | |||
77 | struct bootrec_comp_ver { | ||
78 | char fw_version[24]; | ||
79 | } __packed; | ||
80 | |||
81 | struct bootrec_end { | ||
82 | __le16 crc; | ||
83 | u8 padding[2]; | ||
84 | u8 md5[16]; | ||
85 | } __packed; | ||
50 | 86 | ||
51 | /* provide 16 bytes for the transport back-end */ | 87 | /* provide 16 bytes for the transport back-end */ |
52 | #define P54_TX_INFO_DATA_SIZE 16 | 88 | #define P54_TX_INFO_DATA_SIZE 16 |
@@ -55,34 +91,30 @@ enum p54_control_frame_types { | |||
55 | struct p54_tx_info { | 91 | struct p54_tx_info { |
56 | u32 start_addr; | 92 | u32 start_addr; |
57 | u32 end_addr; | 93 | u32 end_addr; |
58 | void *data[P54_TX_INFO_DATA_SIZE / sizeof(void *)]; | 94 | union { |
95 | void *data[P54_TX_INFO_DATA_SIZE / sizeof(void *)]; | ||
96 | struct { | ||
97 | u32 extra_len; | ||
98 | }; | ||
99 | }; | ||
59 | }; | 100 | }; |
60 | 101 | ||
61 | #define P54_MAX_CTRL_FRAME_LEN 0x1000 | 102 | #define P54_MAX_CTRL_FRAME_LEN 0x1000 |
62 | 103 | ||
63 | #define P54_HDR_FLAG_CONTROL BIT(15) | 104 | #define P54_SET_QUEUE(queue, ai_fs, cw_min, cw_max, _txop) \ |
64 | #define P54_HDR_FLAG_CONTROL_OPSET (BIT(15) + BIT(0)) | 105 | do { \ |
65 | 106 | queue.aifs = cpu_to_le16(ai_fs); \ | |
66 | struct p54_hdr { | 107 | queue.cwmin = cpu_to_le16(cw_min); \ |
67 | __le16 flags; | 108 | queue.cwmax = cpu_to_le16(cw_max); \ |
68 | __le16 len; | 109 | queue.txop = cpu_to_le16(_txop); \ |
69 | __le32 req_id; | 110 | } while (0) |
70 | __le16 type; /* enum p54_control_frame_types */ | ||
71 | u8 rts_tries; | ||
72 | u8 tries; | ||
73 | u8 data[0]; | ||
74 | } __attribute__ ((packed)); | ||
75 | |||
76 | #define FREE_AFTER_TX(skb) \ | ||
77 | ((((struct p54_hdr *) ((struct sk_buff *) skb)->data)-> \ | ||
78 | flags) == cpu_to_le16(P54_HDR_FLAG_CONTROL_OPSET)) | ||
79 | 111 | ||
80 | struct p54_edcf_queue_param { | 112 | struct p54_edcf_queue_param { |
81 | __le16 aifs; | 113 | __le16 aifs; |
82 | __le16 cwmin; | 114 | __le16 cwmin; |
83 | __le16 cwmax; | 115 | __le16 cwmax; |
84 | __le16 txop; | 116 | __le16 txop; |
85 | } __attribute__ ((packed)); | 117 | } __packed; |
86 | 118 | ||
87 | struct p54_rssi_linear_approximation { | 119 | struct p54_rssi_linear_approximation { |
88 | s16 mul; | 120 | s16 mul; |
@@ -101,13 +133,6 @@ struct p54_cal_database { | |||
101 | 133 | ||
102 | #define EEPROM_READBACK_LEN 0x3fc | 134 | #define EEPROM_READBACK_LEN 0x3fc |
103 | 135 | ||
104 | #define ISL38XX_DEV_FIRMWARE_ADDR 0x20000 | ||
105 | |||
106 | #define FW_FMAC 0x464d4143 | ||
107 | #define FW_LM86 0x4c4d3836 | ||
108 | #define FW_LM87 0x4c4d3837 | ||
109 | #define FW_LM20 0x4c4d3230 | ||
110 | |||
111 | enum fw_state { | 136 | enum fw_state { |
112 | FW_STATE_OFF, | 137 | FW_STATE_OFF, |
113 | FW_STATE_BOOTING, | 138 | FW_STATE_BOOTING, |
@@ -138,6 +163,7 @@ struct p54_common { | |||
138 | void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb); | 163 | void (*tx)(struct ieee80211_hw *dev, struct sk_buff *skb); |
139 | int (*open)(struct ieee80211_hw *dev); | 164 | int (*open)(struct ieee80211_hw *dev); |
140 | void (*stop)(struct ieee80211_hw *dev); | 165 | void (*stop)(struct ieee80211_hw *dev); |
166 | struct sk_buff_head tx_pending; | ||
141 | struct sk_buff_head tx_queue; | 167 | struct sk_buff_head tx_queue; |
142 | struct mutex conf_mutex; | 168 | struct mutex conf_mutex; |
143 | 169 | ||
@@ -156,6 +182,7 @@ struct p54_common { | |||
156 | 182 | ||
157 | /* (e)DCF / QOS state */ | 183 | /* (e)DCF / QOS state */ |
158 | bool use_short_slot; | 184 | bool use_short_slot; |
185 | spinlock_t tx_stats_lock; | ||
159 | struct ieee80211_tx_queue_stats tx_stats[8]; | 186 | struct ieee80211_tx_queue_stats tx_stats[8]; |
160 | struct p54_edcf_queue_param qos_params[8]; | 187 | struct p54_edcf_queue_param qos_params[8]; |
161 | 188 | ||
@@ -181,7 +208,7 @@ struct p54_common { | |||
181 | u32 tsf_low32, tsf_high32; | 208 | u32 tsf_low32, tsf_high32; |
182 | u32 basic_rate_mask; | 209 | u32 basic_rate_mask; |
183 | u16 aid; | 210 | u16 aid; |
184 | struct sk_buff *cached_beacon; | 211 | __le32 beacon_req_id; |
185 | 212 | ||
186 | /* cryptographic engine information */ | 213 | /* cryptographic engine information */ |
187 | u8 privacy_caps; | 214 | u8 privacy_caps; |
@@ -202,15 +229,20 @@ struct p54_common { | |||
202 | /* eeprom handling */ | 229 | /* eeprom handling */ |
203 | void *eeprom; | 230 | void *eeprom; |
204 | struct completion eeprom_comp; | 231 | struct completion eeprom_comp; |
232 | struct mutex eeprom_mutex; | ||
205 | }; | 233 | }; |
206 | 234 | ||
235 | /* interfaces for the drivers */ | ||
207 | int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb); | 236 | int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb); |
208 | void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb); | 237 | void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb); |
209 | int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw); | 238 | int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw); |
210 | int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len); | 239 | int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len); |
211 | int p54_read_eeprom(struct ieee80211_hw *dev); | 240 | int p54_read_eeprom(struct ieee80211_hw *dev); |
241 | |||
212 | struct ieee80211_hw *p54_init_common(size_t priv_data_len); | 242 | struct ieee80211_hw *p54_init_common(size_t priv_data_len); |
213 | int p54_register_common(struct ieee80211_hw *dev, struct device *pdev); | 243 | int p54_register_common(struct ieee80211_hw *dev, struct device *pdev); |
214 | void p54_free_common(struct ieee80211_hw *dev); | 244 | void p54_free_common(struct ieee80211_hw *dev); |
215 | 245 | ||
246 | void p54_unregister_common(struct ieee80211_hw *dev); | ||
247 | |||
216 | #endif /* P54_H */ | 248 | #endif /* P54_H */ |
diff --git a/drivers/net/wireless/p54/p54common.c b/drivers/net/wireless/p54/p54common.c deleted file mode 100644 index 22ca122bd798..000000000000 --- a/drivers/net/wireless/p54/p54common.c +++ /dev/null | |||
@@ -1,2688 +0,0 @@ | |||
1 | /* | ||
2 | * Common code for mac80211 Prism54 drivers | ||
3 | * | ||
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
5 | * Copyright (c) 2007, Christian Lamparter <chunkeey@web.de> | ||
6 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> | ||
7 | * | ||
8 | * Based on: | ||
9 | * - the islsm (softmac prism54) driver, which is: | ||
10 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
11 | * - stlc45xx driver | ||
12 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | |||
19 | #include <linux/init.h> | ||
20 | #include <linux/firmware.h> | ||
21 | #include <linux/etherdevice.h> | ||
22 | |||
23 | #include <net/mac80211.h> | ||
24 | #ifdef CONFIG_P54_LEDS | ||
25 | #include <linux/leds.h> | ||
26 | #endif /* CONFIG_P54_LEDS */ | ||
27 | |||
28 | #include "p54.h" | ||
29 | #include "p54common.h" | ||
30 | |||
31 | static int modparam_nohwcrypt; | ||
32 | module_param_named(nohwcrypt, modparam_nohwcrypt, bool, S_IRUGO); | ||
33 | MODULE_PARM_DESC(nohwcrypt, "Disable hardware encryption."); | ||
34 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); | ||
35 | MODULE_DESCRIPTION("Softmac Prism54 common code"); | ||
36 | MODULE_LICENSE("GPL"); | ||
37 | MODULE_ALIAS("prism54common"); | ||
38 | |||
39 | static struct ieee80211_rate p54_bgrates[] = { | ||
40 | { .bitrate = 10, .hw_value = 0, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
41 | { .bitrate = 20, .hw_value = 1, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
42 | { .bitrate = 55, .hw_value = 2, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
43 | { .bitrate = 110, .hw_value = 3, .flags = IEEE80211_RATE_SHORT_PREAMBLE }, | ||
44 | { .bitrate = 60, .hw_value = 4, }, | ||
45 | { .bitrate = 90, .hw_value = 5, }, | ||
46 | { .bitrate = 120, .hw_value = 6, }, | ||
47 | { .bitrate = 180, .hw_value = 7, }, | ||
48 | { .bitrate = 240, .hw_value = 8, }, | ||
49 | { .bitrate = 360, .hw_value = 9, }, | ||
50 | { .bitrate = 480, .hw_value = 10, }, | ||
51 | { .bitrate = 540, .hw_value = 11, }, | ||
52 | }; | ||
53 | |||
54 | static struct ieee80211_channel p54_bgchannels[] = { | ||
55 | { .center_freq = 2412, .hw_value = 1, }, | ||
56 | { .center_freq = 2417, .hw_value = 2, }, | ||
57 | { .center_freq = 2422, .hw_value = 3, }, | ||
58 | { .center_freq = 2427, .hw_value = 4, }, | ||
59 | { .center_freq = 2432, .hw_value = 5, }, | ||
60 | { .center_freq = 2437, .hw_value = 6, }, | ||
61 | { .center_freq = 2442, .hw_value = 7, }, | ||
62 | { .center_freq = 2447, .hw_value = 8, }, | ||
63 | { .center_freq = 2452, .hw_value = 9, }, | ||
64 | { .center_freq = 2457, .hw_value = 10, }, | ||
65 | { .center_freq = 2462, .hw_value = 11, }, | ||
66 | { .center_freq = 2467, .hw_value = 12, }, | ||
67 | { .center_freq = 2472, .hw_value = 13, }, | ||
68 | { .center_freq = 2484, .hw_value = 14, }, | ||
69 | }; | ||
70 | |||
71 | static struct ieee80211_supported_band band_2GHz = { | ||
72 | .channels = p54_bgchannels, | ||
73 | .n_channels = ARRAY_SIZE(p54_bgchannels), | ||
74 | .bitrates = p54_bgrates, | ||
75 | .n_bitrates = ARRAY_SIZE(p54_bgrates), | ||
76 | }; | ||
77 | |||
78 | static struct ieee80211_rate p54_arates[] = { | ||
79 | { .bitrate = 60, .hw_value = 4, }, | ||
80 | { .bitrate = 90, .hw_value = 5, }, | ||
81 | { .bitrate = 120, .hw_value = 6, }, | ||
82 | { .bitrate = 180, .hw_value = 7, }, | ||
83 | { .bitrate = 240, .hw_value = 8, }, | ||
84 | { .bitrate = 360, .hw_value = 9, }, | ||
85 | { .bitrate = 480, .hw_value = 10, }, | ||
86 | { .bitrate = 540, .hw_value = 11, }, | ||
87 | }; | ||
88 | |||
89 | static struct ieee80211_channel p54_achannels[] = { | ||
90 | { .center_freq = 4920 }, | ||
91 | { .center_freq = 4940 }, | ||
92 | { .center_freq = 4960 }, | ||
93 | { .center_freq = 4980 }, | ||
94 | { .center_freq = 5040 }, | ||
95 | { .center_freq = 5060 }, | ||
96 | { .center_freq = 5080 }, | ||
97 | { .center_freq = 5170 }, | ||
98 | { .center_freq = 5180 }, | ||
99 | { .center_freq = 5190 }, | ||
100 | { .center_freq = 5200 }, | ||
101 | { .center_freq = 5210 }, | ||
102 | { .center_freq = 5220 }, | ||
103 | { .center_freq = 5230 }, | ||
104 | { .center_freq = 5240 }, | ||
105 | { .center_freq = 5260 }, | ||
106 | { .center_freq = 5280 }, | ||
107 | { .center_freq = 5300 }, | ||
108 | { .center_freq = 5320 }, | ||
109 | { .center_freq = 5500 }, | ||
110 | { .center_freq = 5520 }, | ||
111 | { .center_freq = 5540 }, | ||
112 | { .center_freq = 5560 }, | ||
113 | { .center_freq = 5580 }, | ||
114 | { .center_freq = 5600 }, | ||
115 | { .center_freq = 5620 }, | ||
116 | { .center_freq = 5640 }, | ||
117 | { .center_freq = 5660 }, | ||
118 | { .center_freq = 5680 }, | ||
119 | { .center_freq = 5700 }, | ||
120 | { .center_freq = 5745 }, | ||
121 | { .center_freq = 5765 }, | ||
122 | { .center_freq = 5785 }, | ||
123 | { .center_freq = 5805 }, | ||
124 | { .center_freq = 5825 }, | ||
125 | }; | ||
126 | |||
127 | static struct ieee80211_supported_band band_5GHz = { | ||
128 | .channels = p54_achannels, | ||
129 | .n_channels = ARRAY_SIZE(p54_achannels), | ||
130 | .bitrates = p54_arates, | ||
131 | .n_bitrates = ARRAY_SIZE(p54_arates), | ||
132 | }; | ||
133 | |||
134 | int p54_parse_firmware(struct ieee80211_hw *dev, const struct firmware *fw) | ||
135 | { | ||
136 | struct p54_common *priv = dev->priv; | ||
137 | struct bootrec_exp_if *exp_if; | ||
138 | struct bootrec *bootrec; | ||
139 | u32 *data = (u32 *)fw->data; | ||
140 | u32 *end_data = (u32 *)fw->data + (fw->size >> 2); | ||
141 | u8 *fw_version = NULL; | ||
142 | size_t len; | ||
143 | int i; | ||
144 | int maxlen; | ||
145 | |||
146 | if (priv->rx_start) | ||
147 | return 0; | ||
148 | |||
149 | while (data < end_data && *data) | ||
150 | data++; | ||
151 | |||
152 | while (data < end_data && !*data) | ||
153 | data++; | ||
154 | |||
155 | bootrec = (struct bootrec *) data; | ||
156 | |||
157 | while (bootrec->data <= end_data && | ||
158 | (bootrec->data + (len = le32_to_cpu(bootrec->len))) <= end_data) { | ||
159 | u32 code = le32_to_cpu(bootrec->code); | ||
160 | switch (code) { | ||
161 | case BR_CODE_COMPONENT_ID: | ||
162 | priv->fw_interface = be32_to_cpup((__be32 *) | ||
163 | bootrec->data); | ||
164 | switch (priv->fw_interface) { | ||
165 | case FW_LM86: | ||
166 | case FW_LM20: | ||
167 | case FW_LM87: { | ||
168 | char *iftype = (char *)bootrec->data; | ||
169 | printk(KERN_INFO "%s: p54 detected a LM%c%c " | ||
170 | "firmware\n", | ||
171 | wiphy_name(dev->wiphy), | ||
172 | iftype[2], iftype[3]); | ||
173 | break; | ||
174 | } | ||
175 | case FW_FMAC: | ||
176 | default: | ||
177 | printk(KERN_ERR "%s: unsupported firmware\n", | ||
178 | wiphy_name(dev->wiphy)); | ||
179 | return -ENODEV; | ||
180 | } | ||
181 | break; | ||
182 | case BR_CODE_COMPONENT_VERSION: | ||
183 | /* 24 bytes should be enough for all firmwares */ | ||
184 | if (strnlen((unsigned char*)bootrec->data, 24) < 24) | ||
185 | fw_version = (unsigned char*)bootrec->data; | ||
186 | break; | ||
187 | case BR_CODE_DESCR: { | ||
188 | struct bootrec_desc *desc = | ||
189 | (struct bootrec_desc *)bootrec->data; | ||
190 | priv->rx_start = le32_to_cpu(desc->rx_start); | ||
191 | /* FIXME add sanity checking */ | ||
192 | priv->rx_end = le32_to_cpu(desc->rx_end) - 0x3500; | ||
193 | priv->headroom = desc->headroom; | ||
194 | priv->tailroom = desc->tailroom; | ||
195 | priv->privacy_caps = desc->privacy_caps; | ||
196 | priv->rx_keycache_size = desc->rx_keycache_size; | ||
197 | if (le32_to_cpu(bootrec->len) == 11) | ||
198 | priv->rx_mtu = le16_to_cpu(desc->rx_mtu); | ||
199 | else | ||
200 | priv->rx_mtu = (size_t) | ||
201 | 0x620 - priv->tx_hdr_len; | ||
202 | maxlen = priv->tx_hdr_len + /* USB devices */ | ||
203 | sizeof(struct p54_rx_data) + | ||
204 | 4 + /* rx alignment */ | ||
205 | IEEE80211_MAX_FRAG_THRESHOLD; | ||
206 | if (priv->rx_mtu > maxlen && PAGE_SIZE == 4096) { | ||
207 | printk(KERN_INFO "p54: rx_mtu reduced from %d " | ||
208 | "to %d\n", priv->rx_mtu, | ||
209 | maxlen); | ||
210 | priv->rx_mtu = maxlen; | ||
211 | } | ||
212 | break; | ||
213 | } | ||
214 | case BR_CODE_EXPOSED_IF: | ||
215 | exp_if = (struct bootrec_exp_if *) bootrec->data; | ||
216 | for (i = 0; i < (len * sizeof(*exp_if) / 4); i++) | ||
217 | if (exp_if[i].if_id == cpu_to_le16(0x1a)) | ||
218 | priv->fw_var = le16_to_cpu(exp_if[i].variant); | ||
219 | break; | ||
220 | case BR_CODE_DEPENDENT_IF: | ||
221 | break; | ||
222 | case BR_CODE_END_OF_BRA: | ||
223 | case LEGACY_BR_CODE_END_OF_BRA: | ||
224 | end_data = NULL; | ||
225 | break; | ||
226 | default: | ||
227 | break; | ||
228 | } | ||
229 | bootrec = (struct bootrec *)&bootrec->data[len]; | ||
230 | } | ||
231 | |||
232 | if (fw_version) | ||
233 | printk(KERN_INFO "%s: FW rev %s - Softmac protocol %x.%x\n", | ||
234 | wiphy_name(dev->wiphy), fw_version, | ||
235 | priv->fw_var >> 8, priv->fw_var & 0xff); | ||
236 | |||
237 | if (priv->fw_var < 0x500) | ||
238 | printk(KERN_INFO "%s: you are using an obsolete firmware. " | ||
239 | "visit http://wireless.kernel.org/en/users/Drivers/p54 " | ||
240 | "and grab one for \"kernel >= 2.6.28\"!\n", | ||
241 | wiphy_name(dev->wiphy)); | ||
242 | |||
243 | if (priv->fw_var >= 0x300) { | ||
244 | /* Firmware supports QoS, use it! */ | ||
245 | priv->tx_stats[P54_QUEUE_AC_VO].limit = 3; | ||
246 | priv->tx_stats[P54_QUEUE_AC_VI].limit = 4; | ||
247 | priv->tx_stats[P54_QUEUE_AC_BE].limit = 3; | ||
248 | priv->tx_stats[P54_QUEUE_AC_BK].limit = 2; | ||
249 | dev->queues = P54_QUEUE_AC_NUM; | ||
250 | } | ||
251 | |||
252 | if (!modparam_nohwcrypt) { | ||
253 | printk(KERN_INFO "%s: cryptographic accelerator " | ||
254 | "WEP:%s, TKIP:%s, CCMP:%s\n", | ||
255 | wiphy_name(dev->wiphy), | ||
256 | (priv->privacy_caps & BR_DESC_PRIV_CAP_WEP) ? "YES" : | ||
257 | "no", (priv->privacy_caps & (BR_DESC_PRIV_CAP_TKIP | | ||
258 | BR_DESC_PRIV_CAP_MICHAEL)) ? "YES" : "no", | ||
259 | (priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP) ? | ||
260 | "YES" : "no"); | ||
261 | |||
262 | if (priv->rx_keycache_size) { | ||
263 | /* | ||
264 | * NOTE: | ||
265 | * | ||
266 | * The firmware provides at most 255 (0 - 254) slots | ||
267 | * for keys which are then used to offload decryption. | ||
268 | * As a result the 255 entry (aka 0xff) can be used | ||
269 | * safely by the driver to mark keys that didn't fit | ||
270 | * into the full cache. This trick saves us from | ||
271 | * keeping a extra list for uploaded keys. | ||
272 | */ | ||
273 | |||
274 | priv->used_rxkeys = kzalloc(BITS_TO_LONGS( | ||
275 | priv->rx_keycache_size), GFP_KERNEL); | ||
276 | |||
277 | if (!priv->used_rxkeys) | ||
278 | return -ENOMEM; | ||
279 | } | ||
280 | } | ||
281 | |||
282 | return 0; | ||
283 | } | ||
284 | EXPORT_SYMBOL_GPL(p54_parse_firmware); | ||
285 | |||
286 | static int p54_convert_rev0(struct ieee80211_hw *dev, | ||
287 | struct pda_pa_curve_data *curve_data) | ||
288 | { | ||
289 | struct p54_common *priv = dev->priv; | ||
290 | struct p54_pa_curve_data_sample *dst; | ||
291 | struct pda_pa_curve_data_sample_rev0 *src; | ||
292 | size_t cd_len = sizeof(*curve_data) + | ||
293 | (curve_data->points_per_channel*sizeof(*dst) + 2) * | ||
294 | curve_data->channels; | ||
295 | unsigned int i, j; | ||
296 | void *source, *target; | ||
297 | |||
298 | priv->curve_data = kmalloc(sizeof(*priv->curve_data) + cd_len, | ||
299 | GFP_KERNEL); | ||
300 | if (!priv->curve_data) | ||
301 | return -ENOMEM; | ||
302 | |||
303 | priv->curve_data->entries = curve_data->channels; | ||
304 | priv->curve_data->entry_size = sizeof(__le16) + | ||
305 | sizeof(*dst) * curve_data->points_per_channel; | ||
306 | priv->curve_data->offset = offsetof(struct pda_pa_curve_data, data); | ||
307 | priv->curve_data->len = cd_len; | ||
308 | memcpy(priv->curve_data->data, curve_data, sizeof(*curve_data)); | ||
309 | source = curve_data->data; | ||
310 | target = ((struct pda_pa_curve_data *) priv->curve_data->data)->data; | ||
311 | for (i = 0; i < curve_data->channels; i++) { | ||
312 | __le16 *freq = source; | ||
313 | source += sizeof(__le16); | ||
314 | *((__le16 *)target) = *freq; | ||
315 | target += sizeof(__le16); | ||
316 | for (j = 0; j < curve_data->points_per_channel; j++) { | ||
317 | dst = target; | ||
318 | src = source; | ||
319 | |||
320 | dst->rf_power = src->rf_power; | ||
321 | dst->pa_detector = src->pa_detector; | ||
322 | dst->data_64qam = src->pcv; | ||
323 | /* "invent" the points for the other modulations */ | ||
324 | #define SUB(x,y) (u8)((x) - (y)) > (x) ? 0 : (x) - (y) | ||
325 | dst->data_16qam = SUB(src->pcv, 12); | ||
326 | dst->data_qpsk = SUB(dst->data_16qam, 12); | ||
327 | dst->data_bpsk = SUB(dst->data_qpsk, 12); | ||
328 | dst->data_barker = SUB(dst->data_bpsk, 14); | ||
329 | #undef SUB | ||
330 | target += sizeof(*dst); | ||
331 | source += sizeof(*src); | ||
332 | } | ||
333 | } | ||
334 | |||
335 | return 0; | ||
336 | } | ||
337 | |||
338 | static int p54_convert_rev1(struct ieee80211_hw *dev, | ||
339 | struct pda_pa_curve_data *curve_data) | ||
340 | { | ||
341 | struct p54_common *priv = dev->priv; | ||
342 | struct p54_pa_curve_data_sample *dst; | ||
343 | struct pda_pa_curve_data_sample_rev1 *src; | ||
344 | size_t cd_len = sizeof(*curve_data) + | ||
345 | (curve_data->points_per_channel*sizeof(*dst) + 2) * | ||
346 | curve_data->channels; | ||
347 | unsigned int i, j; | ||
348 | void *source, *target; | ||
349 | |||
350 | priv->curve_data = kzalloc(cd_len + sizeof(*priv->curve_data), | ||
351 | GFP_KERNEL); | ||
352 | if (!priv->curve_data) | ||
353 | return -ENOMEM; | ||
354 | |||
355 | priv->curve_data->entries = curve_data->channels; | ||
356 | priv->curve_data->entry_size = sizeof(__le16) + | ||
357 | sizeof(*dst) * curve_data->points_per_channel; | ||
358 | priv->curve_data->offset = offsetof(struct pda_pa_curve_data, data); | ||
359 | priv->curve_data->len = cd_len; | ||
360 | memcpy(priv->curve_data->data, curve_data, sizeof(*curve_data)); | ||
361 | source = curve_data->data; | ||
362 | target = ((struct pda_pa_curve_data *) priv->curve_data->data)->data; | ||
363 | for (i = 0; i < curve_data->channels; i++) { | ||
364 | __le16 *freq = source; | ||
365 | source += sizeof(__le16); | ||
366 | *((__le16 *)target) = *freq; | ||
367 | target += sizeof(__le16); | ||
368 | for (j = 0; j < curve_data->points_per_channel; j++) { | ||
369 | memcpy(target, source, sizeof(*src)); | ||
370 | |||
371 | target += sizeof(*dst); | ||
372 | source += sizeof(*src); | ||
373 | } | ||
374 | source++; | ||
375 | } | ||
376 | |||
377 | return 0; | ||
378 | } | ||
379 | |||
380 | static const char *p54_rf_chips[] = { "NULL", "Duette3", "Duette2", | ||
381 | "Frisbee", "Xbow", "Longbow", "NULL", "NULL" }; | ||
382 | static int p54_init_xbow_synth(struct ieee80211_hw *dev); | ||
383 | |||
384 | static void p54_parse_rssical(struct ieee80211_hw *dev, void *data, int len, | ||
385 | u16 type) | ||
386 | { | ||
387 | struct p54_common *priv = dev->priv; | ||
388 | int offset = (type == PDR_RSSI_LINEAR_APPROXIMATION_EXTENDED) ? 2 : 0; | ||
389 | int entry_size = sizeof(struct pda_rssi_cal_entry) + offset; | ||
390 | int num_entries = (type == PDR_RSSI_LINEAR_APPROXIMATION) ? 1 : 2; | ||
391 | int i; | ||
392 | |||
393 | if (len != (entry_size * num_entries)) { | ||
394 | printk(KERN_ERR "%s: unknown rssi calibration data packing " | ||
395 | " type:(%x) len:%d.\n", | ||
396 | wiphy_name(dev->wiphy), type, len); | ||
397 | |||
398 | print_hex_dump_bytes("rssical:", DUMP_PREFIX_NONE, | ||
399 | data, len); | ||
400 | |||
401 | printk(KERN_ERR "%s: please report this issue.\n", | ||
402 | wiphy_name(dev->wiphy)); | ||
403 | return; | ||
404 | } | ||
405 | |||
406 | for (i = 0; i < num_entries; i++) { | ||
407 | struct pda_rssi_cal_entry *cal = data + | ||
408 | (offset + i * entry_size); | ||
409 | priv->rssical_db[i].mul = (s16) le16_to_cpu(cal->mul); | ||
410 | priv->rssical_db[i].add = (s16) le16_to_cpu(cal->add); | ||
411 | } | ||
412 | } | ||
413 | |||
414 | static void p54_parse_default_country(struct ieee80211_hw *dev, | ||
415 | void *data, int len) | ||
416 | { | ||
417 | struct pda_country *country; | ||
418 | |||
419 | if (len != sizeof(*country)) { | ||
420 | printk(KERN_ERR "%s: found possible invalid default country " | ||
421 | "eeprom entry. (entry size: %d)\n", | ||
422 | wiphy_name(dev->wiphy), len); | ||
423 | |||
424 | print_hex_dump_bytes("country:", DUMP_PREFIX_NONE, | ||
425 | data, len); | ||
426 | |||
427 | printk(KERN_ERR "%s: please report this issue.\n", | ||
428 | wiphy_name(dev->wiphy)); | ||
429 | return; | ||
430 | } | ||
431 | |||
432 | country = (struct pda_country *) data; | ||
433 | if (country->flags == PDR_COUNTRY_CERT_CODE_PSEUDO) | ||
434 | regulatory_hint(dev->wiphy, country->alpha2); | ||
435 | else { | ||
436 | /* TODO: | ||
437 | * write a shared/common function that converts | ||
438 | * "Regulatory domain codes" (802.11-2007 14.8.2.2) | ||
439 | * into ISO/IEC 3166-1 alpha2 for regulatory_hint. | ||
440 | */ | ||
441 | } | ||
442 | } | ||
443 | |||
444 | static int p54_convert_output_limits(struct ieee80211_hw *dev, | ||
445 | u8 *data, size_t len) | ||
446 | { | ||
447 | struct p54_common *priv = dev->priv; | ||
448 | |||
449 | if (len < 2) | ||
450 | return -EINVAL; | ||
451 | |||
452 | if (data[0] != 0) { | ||
453 | printk(KERN_ERR "%s: unknown output power db revision:%x\n", | ||
454 | wiphy_name(dev->wiphy), data[0]); | ||
455 | return -EINVAL; | ||
456 | } | ||
457 | |||
458 | if (2 + data[1] * sizeof(struct pda_channel_output_limit) > len) | ||
459 | return -EINVAL; | ||
460 | |||
461 | priv->output_limit = kmalloc(data[1] * | ||
462 | sizeof(struct pda_channel_output_limit) + | ||
463 | sizeof(*priv->output_limit), GFP_KERNEL); | ||
464 | |||
465 | if (!priv->output_limit) | ||
466 | return -ENOMEM; | ||
467 | |||
468 | priv->output_limit->offset = 0; | ||
469 | priv->output_limit->entries = data[1]; | ||
470 | priv->output_limit->entry_size = | ||
471 | sizeof(struct pda_channel_output_limit); | ||
472 | priv->output_limit->len = priv->output_limit->entry_size * | ||
473 | priv->output_limit->entries + | ||
474 | priv->output_limit->offset; | ||
475 | |||
476 | memcpy(priv->output_limit->data, &data[2], | ||
477 | data[1] * sizeof(struct pda_channel_output_limit)); | ||
478 | |||
479 | return 0; | ||
480 | } | ||
481 | |||
482 | static struct p54_cal_database *p54_convert_db(struct pda_custom_wrapper *src, | ||
483 | size_t total_len) | ||
484 | { | ||
485 | struct p54_cal_database *dst; | ||
486 | size_t payload_len, entries, entry_size, offset; | ||
487 | |||
488 | payload_len = le16_to_cpu(src->len); | ||
489 | entries = le16_to_cpu(src->entries); | ||
490 | entry_size = le16_to_cpu(src->entry_size); | ||
491 | offset = le16_to_cpu(src->offset); | ||
492 | if (((entries * entry_size + offset) != payload_len) || | ||
493 | (payload_len + sizeof(*src) != total_len)) | ||
494 | return NULL; | ||
495 | |||
496 | dst = kmalloc(sizeof(*dst) + payload_len, GFP_KERNEL); | ||
497 | if (!dst) | ||
498 | return NULL; | ||
499 | |||
500 | dst->entries = entries; | ||
501 | dst->entry_size = entry_size; | ||
502 | dst->offset = offset; | ||
503 | dst->len = payload_len; | ||
504 | |||
505 | memcpy(dst->data, src->data, payload_len); | ||
506 | return dst; | ||
507 | } | ||
508 | |||
509 | int p54_parse_eeprom(struct ieee80211_hw *dev, void *eeprom, int len) | ||
510 | { | ||
511 | struct p54_common *priv = dev->priv; | ||
512 | struct eeprom_pda_wrap *wrap = NULL; | ||
513 | struct pda_entry *entry; | ||
514 | unsigned int data_len, entry_len; | ||
515 | void *tmp; | ||
516 | int err; | ||
517 | u8 *end = (u8 *)eeprom + len; | ||
518 | u16 synth = 0; | ||
519 | |||
520 | wrap = (struct eeprom_pda_wrap *) eeprom; | ||
521 | entry = (void *)wrap->data + le16_to_cpu(wrap->len); | ||
522 | |||
523 | /* verify that at least the entry length/code fits */ | ||
524 | while ((u8 *)entry <= end - sizeof(*entry)) { | ||
525 | entry_len = le16_to_cpu(entry->len); | ||
526 | data_len = ((entry_len - 1) << 1); | ||
527 | |||
528 | /* abort if entry exceeds whole structure */ | ||
529 | if ((u8 *)entry + sizeof(*entry) + data_len > end) | ||
530 | break; | ||
531 | |||
532 | switch (le16_to_cpu(entry->code)) { | ||
533 | case PDR_MAC_ADDRESS: | ||
534 | if (data_len != ETH_ALEN) | ||
535 | break; | ||
536 | SET_IEEE80211_PERM_ADDR(dev, entry->data); | ||
537 | break; | ||
538 | case PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS: | ||
539 | if (priv->output_limit) | ||
540 | break; | ||
541 | err = p54_convert_output_limits(dev, entry->data, | ||
542 | data_len); | ||
543 | if (err) | ||
544 | goto err; | ||
545 | break; | ||
546 | case PDR_PRISM_PA_CAL_CURVE_DATA: { | ||
547 | struct pda_pa_curve_data *curve_data = | ||
548 | (struct pda_pa_curve_data *)entry->data; | ||
549 | if (data_len < sizeof(*curve_data)) { | ||
550 | err = -EINVAL; | ||
551 | goto err; | ||
552 | } | ||
553 | |||
554 | switch (curve_data->cal_method_rev) { | ||
555 | case 0: | ||
556 | err = p54_convert_rev0(dev, curve_data); | ||
557 | break; | ||
558 | case 1: | ||
559 | err = p54_convert_rev1(dev, curve_data); | ||
560 | break; | ||
561 | default: | ||
562 | printk(KERN_ERR "%s: unknown curve data " | ||
563 | "revision %d\n", | ||
564 | wiphy_name(dev->wiphy), | ||
565 | curve_data->cal_method_rev); | ||
566 | err = -ENODEV; | ||
567 | break; | ||
568 | } | ||
569 | if (err) | ||
570 | goto err; | ||
571 | } | ||
572 | break; | ||
573 | case PDR_PRISM_ZIF_TX_IQ_CALIBRATION: | ||
574 | priv->iq_autocal = kmalloc(data_len, GFP_KERNEL); | ||
575 | if (!priv->iq_autocal) { | ||
576 | err = -ENOMEM; | ||
577 | goto err; | ||
578 | } | ||
579 | |||
580 | memcpy(priv->iq_autocal, entry->data, data_len); | ||
581 | priv->iq_autocal_len = data_len / sizeof(struct pda_iq_autocal_entry); | ||
582 | break; | ||
583 | case PDR_DEFAULT_COUNTRY: | ||
584 | p54_parse_default_country(dev, entry->data, data_len); | ||
585 | break; | ||
586 | case PDR_INTERFACE_LIST: | ||
587 | tmp = entry->data; | ||
588 | while ((u8 *)tmp < entry->data + data_len) { | ||
589 | struct bootrec_exp_if *exp_if = tmp; | ||
590 | if (le16_to_cpu(exp_if->if_id) == 0xf) | ||
591 | synth = le16_to_cpu(exp_if->variant); | ||
592 | tmp += sizeof(struct bootrec_exp_if); | ||
593 | } | ||
594 | break; | ||
595 | case PDR_HARDWARE_PLATFORM_COMPONENT_ID: | ||
596 | if (data_len < 2) | ||
597 | break; | ||
598 | priv->version = *(u8 *)(entry->data + 1); | ||
599 | break; | ||
600 | case PDR_RSSI_LINEAR_APPROXIMATION: | ||
601 | case PDR_RSSI_LINEAR_APPROXIMATION_DUAL_BAND: | ||
602 | case PDR_RSSI_LINEAR_APPROXIMATION_EXTENDED: | ||
603 | p54_parse_rssical(dev, entry->data, data_len, | ||
604 | le16_to_cpu(entry->code)); | ||
605 | break; | ||
606 | case PDR_RSSI_LINEAR_APPROXIMATION_CUSTOM: { | ||
607 | __le16 *src = (void *) entry->data; | ||
608 | s16 *dst = (void *) &priv->rssical_db; | ||
609 | int i; | ||
610 | |||
611 | if (data_len != sizeof(priv->rssical_db)) { | ||
612 | err = -EINVAL; | ||
613 | goto err; | ||
614 | } | ||
615 | for (i = 0; i < sizeof(priv->rssical_db) / | ||
616 | sizeof(*src); i++) | ||
617 | *(dst++) = (s16) le16_to_cpu(*(src++)); | ||
618 | } | ||
619 | break; | ||
620 | case PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS_CUSTOM: { | ||
621 | struct pda_custom_wrapper *pda = (void *) entry->data; | ||
622 | if (priv->output_limit || data_len < sizeof(*pda)) | ||
623 | break; | ||
624 | priv->output_limit = p54_convert_db(pda, data_len); | ||
625 | } | ||
626 | break; | ||
627 | case PDR_PRISM_PA_CAL_CURVE_DATA_CUSTOM: { | ||
628 | struct pda_custom_wrapper *pda = (void *) entry->data; | ||
629 | if (priv->curve_data || data_len < sizeof(*pda)) | ||
630 | break; | ||
631 | priv->curve_data = p54_convert_db(pda, data_len); | ||
632 | } | ||
633 | break; | ||
634 | case PDR_END: | ||
635 | /* make it overrun */ | ||
636 | entry_len = len; | ||
637 | break; | ||
638 | case PDR_MANUFACTURING_PART_NUMBER: | ||
639 | case PDR_PDA_VERSION: | ||
640 | case PDR_NIC_SERIAL_NUMBER: | ||
641 | case PDR_REGULATORY_DOMAIN_LIST: | ||
642 | case PDR_TEMPERATURE_TYPE: | ||
643 | case PDR_PRISM_PCI_IDENTIFIER: | ||
644 | case PDR_COUNTRY_INFORMATION: | ||
645 | case PDR_OEM_NAME: | ||
646 | case PDR_PRODUCT_NAME: | ||
647 | case PDR_UTF8_OEM_NAME: | ||
648 | case PDR_UTF8_PRODUCT_NAME: | ||
649 | case PDR_COUNTRY_LIST: | ||
650 | case PDR_ANTENNA_GAIN: | ||
651 | case PDR_PRISM_INDIGO_PA_CALIBRATION_DATA: | ||
652 | case PDR_REGULATORY_POWER_LIMITS: | ||
653 | case PDR_RADIATED_TRANSMISSION_CORRECTION: | ||
654 | case PDR_PRISM_TX_IQ_CALIBRATION: | ||
655 | case PDR_BASEBAND_REGISTERS: | ||
656 | case PDR_PER_CHANNEL_BASEBAND_REGISTERS: | ||
657 | break; | ||
658 | default: | ||
659 | printk(KERN_INFO "%s: unknown eeprom code : 0x%x\n", | ||
660 | wiphy_name(dev->wiphy), | ||
661 | le16_to_cpu(entry->code)); | ||
662 | break; | ||
663 | } | ||
664 | |||
665 | entry = (void *)entry + (entry_len + 1)*2; | ||
666 | } | ||
667 | |||
668 | if (!synth || !priv->iq_autocal || !priv->output_limit || | ||
669 | !priv->curve_data) { | ||
670 | printk(KERN_ERR "%s: not all required entries found in eeprom!\n", | ||
671 | wiphy_name(dev->wiphy)); | ||
672 | err = -EINVAL; | ||
673 | goto err; | ||
674 | } | ||
675 | |||
676 | priv->rxhw = synth & PDR_SYNTH_FRONTEND_MASK; | ||
677 | if (priv->rxhw == PDR_SYNTH_FRONTEND_XBOW) | ||
678 | p54_init_xbow_synth(dev); | ||
679 | if (!(synth & PDR_SYNTH_24_GHZ_DISABLED)) | ||
680 | dev->wiphy->bands[IEEE80211_BAND_2GHZ] = &band_2GHz; | ||
681 | if (!(synth & PDR_SYNTH_5_GHZ_DISABLED)) | ||
682 | dev->wiphy->bands[IEEE80211_BAND_5GHZ] = &band_5GHz; | ||
683 | if ((synth & PDR_SYNTH_RX_DIV_MASK) == PDR_SYNTH_RX_DIV_SUPPORTED) | ||
684 | priv->rx_diversity_mask = 3; | ||
685 | if ((synth & PDR_SYNTH_TX_DIV_MASK) == PDR_SYNTH_TX_DIV_SUPPORTED) | ||
686 | priv->tx_diversity_mask = 3; | ||
687 | |||
688 | if (!is_valid_ether_addr(dev->wiphy->perm_addr)) { | ||
689 | u8 perm_addr[ETH_ALEN]; | ||
690 | |||
691 | printk(KERN_WARNING "%s: Invalid hwaddr! Using randomly generated MAC addr\n", | ||
692 | wiphy_name(dev->wiphy)); | ||
693 | random_ether_addr(perm_addr); | ||
694 | SET_IEEE80211_PERM_ADDR(dev, perm_addr); | ||
695 | } | ||
696 | |||
697 | printk(KERN_INFO "%s: hwaddr %pM, MAC:isl38%02x RF:%s\n", | ||
698 | wiphy_name(dev->wiphy), | ||
699 | dev->wiphy->perm_addr, | ||
700 | priv->version, p54_rf_chips[priv->rxhw]); | ||
701 | |||
702 | return 0; | ||
703 | |||
704 | err: | ||
705 | if (priv->iq_autocal) { | ||
706 | kfree(priv->iq_autocal); | ||
707 | priv->iq_autocal = NULL; | ||
708 | } | ||
709 | |||
710 | if (priv->output_limit) { | ||
711 | kfree(priv->output_limit); | ||
712 | priv->output_limit = NULL; | ||
713 | } | ||
714 | |||
715 | if (priv->curve_data) { | ||
716 | kfree(priv->curve_data); | ||
717 | priv->curve_data = NULL; | ||
718 | } | ||
719 | |||
720 | printk(KERN_ERR "%s: eeprom parse failed!\n", | ||
721 | wiphy_name(dev->wiphy)); | ||
722 | return err; | ||
723 | } | ||
724 | EXPORT_SYMBOL_GPL(p54_parse_eeprom); | ||
725 | |||
726 | static int p54_rssi_to_dbm(struct ieee80211_hw *dev, int rssi) | ||
727 | { | ||
728 | struct p54_common *priv = dev->priv; | ||
729 | int band = dev->conf.channel->band; | ||
730 | |||
731 | if (priv->rxhw != PDR_SYNTH_FRONTEND_LONGBOW) | ||
732 | return ((rssi * priv->rssical_db[band].mul) / 64 + | ||
733 | priv->rssical_db[band].add) / 4; | ||
734 | else | ||
735 | /* | ||
736 | * TODO: find the correct formula | ||
737 | */ | ||
738 | return ((rssi * priv->rssical_db[band].mul) / 64 + | ||
739 | priv->rssical_db[band].add) / 4; | ||
740 | } | ||
741 | |||
742 | static int p54_rx_data(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
743 | { | ||
744 | struct p54_common *priv = dev->priv; | ||
745 | struct p54_rx_data *hdr = (struct p54_rx_data *) skb->data; | ||
746 | struct ieee80211_rx_status rx_status = {0}; | ||
747 | u16 freq = le16_to_cpu(hdr->freq); | ||
748 | size_t header_len = sizeof(*hdr); | ||
749 | u32 tsf32; | ||
750 | u8 rate = hdr->rate & 0xf; | ||
751 | |||
752 | /* | ||
753 | * If the device is in a unspecified state we have to | ||
754 | * ignore all data frames. Else we could end up with a | ||
755 | * nasty crash. | ||
756 | */ | ||
757 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | ||
758 | return 0; | ||
759 | |||
760 | if (!(hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_IN_FCS_GOOD))) { | ||
761 | return 0; | ||
762 | } | ||
763 | |||
764 | if (hdr->decrypt_status == P54_DECRYPT_OK) | ||
765 | rx_status.flag |= RX_FLAG_DECRYPTED; | ||
766 | if ((hdr->decrypt_status == P54_DECRYPT_FAIL_MICHAEL) || | ||
767 | (hdr->decrypt_status == P54_DECRYPT_FAIL_TKIP)) | ||
768 | rx_status.flag |= RX_FLAG_MMIC_ERROR; | ||
769 | |||
770 | rx_status.signal = p54_rssi_to_dbm(dev, hdr->rssi); | ||
771 | rx_status.noise = priv->noise; | ||
772 | if (hdr->rate & 0x10) | ||
773 | rx_status.flag |= RX_FLAG_SHORTPRE; | ||
774 | if (dev->conf.channel->band == IEEE80211_BAND_5GHZ) | ||
775 | rx_status.rate_idx = (rate < 4) ? 0 : rate - 4; | ||
776 | else | ||
777 | rx_status.rate_idx = rate; | ||
778 | |||
779 | rx_status.freq = freq; | ||
780 | rx_status.band = dev->conf.channel->band; | ||
781 | rx_status.antenna = hdr->antenna; | ||
782 | |||
783 | tsf32 = le32_to_cpu(hdr->tsf32); | ||
784 | if (tsf32 < priv->tsf_low32) | ||
785 | priv->tsf_high32++; | ||
786 | rx_status.mactime = ((u64)priv->tsf_high32) << 32 | tsf32; | ||
787 | priv->tsf_low32 = tsf32; | ||
788 | |||
789 | rx_status.flag |= RX_FLAG_TSFT; | ||
790 | |||
791 | if (hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN)) | ||
792 | header_len += hdr->align[0]; | ||
793 | |||
794 | skb_pull(skb, header_len); | ||
795 | skb_trim(skb, le16_to_cpu(hdr->len)); | ||
796 | |||
797 | ieee80211_rx_irqsafe(dev, skb, &rx_status); | ||
798 | |||
799 | queue_delayed_work(dev->workqueue, &priv->work, | ||
800 | msecs_to_jiffies(P54_STATISTICS_UPDATE)); | ||
801 | |||
802 | return -1; | ||
803 | } | ||
804 | |||
805 | static void inline p54_wake_free_queues(struct ieee80211_hw *dev) | ||
806 | { | ||
807 | struct p54_common *priv = dev->priv; | ||
808 | int i; | ||
809 | |||
810 | if (priv->mode == NL80211_IFTYPE_UNSPECIFIED) | ||
811 | return ; | ||
812 | |||
813 | for (i = 0; i < dev->queues; i++) | ||
814 | if (priv->tx_stats[i + P54_QUEUE_DATA].len < | ||
815 | priv->tx_stats[i + P54_QUEUE_DATA].limit) | ||
816 | ieee80211_wake_queue(dev, i); | ||
817 | } | ||
818 | |||
819 | void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
820 | { | ||
821 | struct p54_common *priv = dev->priv; | ||
822 | struct ieee80211_tx_info *info; | ||
823 | struct p54_tx_info *range; | ||
824 | unsigned long flags; | ||
825 | |||
826 | if (unlikely(!skb || !dev || !skb_queue_len(&priv->tx_queue))) | ||
827 | return; | ||
828 | |||
829 | /* | ||
830 | * don't try to free an already unlinked skb | ||
831 | */ | ||
832 | if (unlikely((!skb->next) || (!skb->prev))) | ||
833 | return; | ||
834 | |||
835 | spin_lock_irqsave(&priv->tx_queue.lock, flags); | ||
836 | info = IEEE80211_SKB_CB(skb); | ||
837 | range = (void *)info->rate_driver_data; | ||
838 | if (skb->prev != (struct sk_buff *)&priv->tx_queue) { | ||
839 | struct ieee80211_tx_info *ni; | ||
840 | struct p54_tx_info *mr; | ||
841 | |||
842 | ni = IEEE80211_SKB_CB(skb->prev); | ||
843 | mr = (struct p54_tx_info *)ni->rate_driver_data; | ||
844 | } | ||
845 | if (skb->next != (struct sk_buff *)&priv->tx_queue) { | ||
846 | struct ieee80211_tx_info *ni; | ||
847 | struct p54_tx_info *mr; | ||
848 | |||
849 | ni = IEEE80211_SKB_CB(skb->next); | ||
850 | mr = (struct p54_tx_info *)ni->rate_driver_data; | ||
851 | } | ||
852 | __skb_unlink(skb, &priv->tx_queue); | ||
853 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
854 | dev_kfree_skb_any(skb); | ||
855 | p54_wake_free_queues(dev); | ||
856 | } | ||
857 | EXPORT_SYMBOL_GPL(p54_free_skb); | ||
858 | |||
859 | static struct sk_buff *p54_find_tx_entry(struct ieee80211_hw *dev, | ||
860 | __le32 req_id) | ||
861 | { | ||
862 | struct p54_common *priv = dev->priv; | ||
863 | struct sk_buff *entry; | ||
864 | unsigned long flags; | ||
865 | |||
866 | spin_lock_irqsave(&priv->tx_queue.lock, flags); | ||
867 | entry = priv->tx_queue.next; | ||
868 | while (entry != (struct sk_buff *)&priv->tx_queue) { | ||
869 | struct p54_hdr *hdr = (struct p54_hdr *) entry->data; | ||
870 | |||
871 | if (hdr->req_id == req_id) { | ||
872 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
873 | return entry; | ||
874 | } | ||
875 | entry = entry->next; | ||
876 | } | ||
877 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
878 | return NULL; | ||
879 | } | ||
880 | |||
881 | static void p54_rx_frame_sent(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
882 | { | ||
883 | struct p54_common *priv = dev->priv; | ||
884 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
885 | struct p54_frame_sent *payload = (struct p54_frame_sent *) hdr->data; | ||
886 | struct sk_buff *entry; | ||
887 | u32 addr = le32_to_cpu(hdr->req_id) - priv->headroom; | ||
888 | struct p54_tx_info *range = NULL; | ||
889 | unsigned long flags; | ||
890 | int count, idx; | ||
891 | |||
892 | spin_lock_irqsave(&priv->tx_queue.lock, flags); | ||
893 | entry = (struct sk_buff *) priv->tx_queue.next; | ||
894 | while (entry != (struct sk_buff *)&priv->tx_queue) { | ||
895 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(entry); | ||
896 | struct p54_hdr *entry_hdr; | ||
897 | struct p54_tx_data *entry_data; | ||
898 | unsigned int pad = 0, frame_len; | ||
899 | |||
900 | range = (void *)info->rate_driver_data; | ||
901 | if (range->start_addr != addr) { | ||
902 | entry = entry->next; | ||
903 | continue; | ||
904 | } | ||
905 | |||
906 | if (entry->next != (struct sk_buff *)&priv->tx_queue) { | ||
907 | struct ieee80211_tx_info *ni; | ||
908 | struct p54_tx_info *mr; | ||
909 | |||
910 | ni = IEEE80211_SKB_CB(entry->next); | ||
911 | mr = (struct p54_tx_info *)ni->rate_driver_data; | ||
912 | } | ||
913 | |||
914 | __skb_unlink(entry, &priv->tx_queue); | ||
915 | |||
916 | frame_len = entry->len; | ||
917 | entry_hdr = (struct p54_hdr *) entry->data; | ||
918 | entry_data = (struct p54_tx_data *) entry_hdr->data; | ||
919 | if (priv->tx_stats[entry_data->hw_queue].len) | ||
920 | priv->tx_stats[entry_data->hw_queue].len--; | ||
921 | priv->stats.dot11ACKFailureCount += payload->tries - 1; | ||
922 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
923 | |||
924 | /* | ||
925 | * Frames in P54_QUEUE_FWSCAN and P54_QUEUE_BEACON are | ||
926 | * generated by the driver. Therefore tx_status is bogus | ||
927 | * and we don't want to confuse the mac80211 stack. | ||
928 | */ | ||
929 | if (unlikely(entry_data->hw_queue < P54_QUEUE_FWSCAN)) { | ||
930 | if (entry_data->hw_queue == P54_QUEUE_BEACON) | ||
931 | priv->cached_beacon = NULL; | ||
932 | |||
933 | kfree_skb(entry); | ||
934 | goto out; | ||
935 | } | ||
936 | |||
937 | /* | ||
938 | * Clear manually, ieee80211_tx_info_clear_status would | ||
939 | * clear the counts too and we need them. | ||
940 | */ | ||
941 | memset(&info->status.ampdu_ack_len, 0, | ||
942 | sizeof(struct ieee80211_tx_info) - | ||
943 | offsetof(struct ieee80211_tx_info, status.ampdu_ack_len)); | ||
944 | BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, | ||
945 | status.ampdu_ack_len) != 23); | ||
946 | |||
947 | if (entry_hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN)) | ||
948 | pad = entry_data->align[0]; | ||
949 | |||
950 | /* walk through the rates array and adjust the counts */ | ||
951 | count = payload->tries; | ||
952 | for (idx = 0; idx < 4; idx++) { | ||
953 | if (count >= info->status.rates[idx].count) { | ||
954 | count -= info->status.rates[idx].count; | ||
955 | } else if (count > 0) { | ||
956 | info->status.rates[idx].count = count; | ||
957 | count = 0; | ||
958 | } else { | ||
959 | info->status.rates[idx].idx = -1; | ||
960 | info->status.rates[idx].count = 0; | ||
961 | } | ||
962 | } | ||
963 | |||
964 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && | ||
965 | (!payload->status)) | ||
966 | info->flags |= IEEE80211_TX_STAT_ACK; | ||
967 | if (payload->status & P54_TX_PSM_CANCELLED) | ||
968 | info->flags |= IEEE80211_TX_STAT_TX_FILTERED; | ||
969 | info->status.ack_signal = p54_rssi_to_dbm(dev, | ||
970 | (int)payload->ack_rssi); | ||
971 | |||
972 | /* Undo all changes to the frame. */ | ||
973 | switch (entry_data->key_type) { | ||
974 | case P54_CRYPTO_TKIPMICHAEL: { | ||
975 | u8 *iv = (u8 *)(entry_data->align + pad + | ||
976 | entry_data->crypt_offset); | ||
977 | |||
978 | /* Restore the original TKIP IV. */ | ||
979 | iv[2] = iv[0]; | ||
980 | iv[0] = iv[1]; | ||
981 | iv[1] = (iv[0] | 0x20) & 0x7f; /* WEPSeed - 8.3.2.2 */ | ||
982 | |||
983 | frame_len -= 12; /* remove TKIP_MMIC + TKIP_ICV */ | ||
984 | break; | ||
985 | } | ||
986 | case P54_CRYPTO_AESCCMP: | ||
987 | frame_len -= 8; /* remove CCMP_MIC */ | ||
988 | break; | ||
989 | case P54_CRYPTO_WEP: | ||
990 | frame_len -= 4; /* remove WEP_ICV */ | ||
991 | break; | ||
992 | } | ||
993 | skb_trim(entry, frame_len); | ||
994 | skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data)); | ||
995 | ieee80211_tx_status_irqsafe(dev, entry); | ||
996 | goto out; | ||
997 | } | ||
998 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
999 | |||
1000 | out: | ||
1001 | p54_wake_free_queues(dev); | ||
1002 | } | ||
1003 | |||
1004 | static void p54_rx_eeprom_readback(struct ieee80211_hw *dev, | ||
1005 | struct sk_buff *skb) | ||
1006 | { | ||
1007 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
1008 | struct p54_eeprom_lm86 *eeprom = (struct p54_eeprom_lm86 *) hdr->data; | ||
1009 | struct p54_common *priv = dev->priv; | ||
1010 | |||
1011 | if (!priv->eeprom) | ||
1012 | return ; | ||
1013 | |||
1014 | if (priv->fw_var >= 0x509) { | ||
1015 | memcpy(priv->eeprom, eeprom->v2.data, | ||
1016 | le16_to_cpu(eeprom->v2.len)); | ||
1017 | } else { | ||
1018 | memcpy(priv->eeprom, eeprom->v1.data, | ||
1019 | le16_to_cpu(eeprom->v1.len)); | ||
1020 | } | ||
1021 | |||
1022 | complete(&priv->eeprom_comp); | ||
1023 | } | ||
1024 | |||
1025 | static void p54_rx_stats(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
1026 | { | ||
1027 | struct p54_common *priv = dev->priv; | ||
1028 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
1029 | struct p54_statistics *stats = (struct p54_statistics *) hdr->data; | ||
1030 | u32 tsf32; | ||
1031 | |||
1032 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | ||
1033 | return ; | ||
1034 | |||
1035 | tsf32 = le32_to_cpu(stats->tsf32); | ||
1036 | if (tsf32 < priv->tsf_low32) | ||
1037 | priv->tsf_high32++; | ||
1038 | priv->tsf_low32 = tsf32; | ||
1039 | |||
1040 | priv->stats.dot11RTSFailureCount = le32_to_cpu(stats->rts_fail); | ||
1041 | priv->stats.dot11RTSSuccessCount = le32_to_cpu(stats->rts_success); | ||
1042 | priv->stats.dot11FCSErrorCount = le32_to_cpu(stats->rx_bad_fcs); | ||
1043 | |||
1044 | priv->noise = p54_rssi_to_dbm(dev, le32_to_cpu(stats->noise)); | ||
1045 | |||
1046 | p54_free_skb(dev, p54_find_tx_entry(dev, hdr->req_id)); | ||
1047 | } | ||
1048 | |||
1049 | static void p54_rx_trap(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
1050 | { | ||
1051 | struct p54_common *priv = dev->priv; | ||
1052 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
1053 | struct p54_trap *trap = (struct p54_trap *) hdr->data; | ||
1054 | u16 event = le16_to_cpu(trap->event); | ||
1055 | u16 freq = le16_to_cpu(trap->frequency); | ||
1056 | |||
1057 | switch (event) { | ||
1058 | case P54_TRAP_BEACON_TX: | ||
1059 | break; | ||
1060 | case P54_TRAP_RADAR: | ||
1061 | printk(KERN_INFO "%s: radar (freq:%d MHz)\n", | ||
1062 | wiphy_name(dev->wiphy), freq); | ||
1063 | break; | ||
1064 | case P54_TRAP_NO_BEACON: | ||
1065 | if (priv->vif) | ||
1066 | ieee80211_beacon_loss(priv->vif); | ||
1067 | break; | ||
1068 | case P54_TRAP_SCAN: | ||
1069 | break; | ||
1070 | case P54_TRAP_TBTT: | ||
1071 | break; | ||
1072 | case P54_TRAP_TIMER: | ||
1073 | break; | ||
1074 | default: | ||
1075 | printk(KERN_INFO "%s: received event:%x freq:%d\n", | ||
1076 | wiphy_name(dev->wiphy), event, freq); | ||
1077 | break; | ||
1078 | } | ||
1079 | } | ||
1080 | |||
1081 | static int p54_rx_control(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
1082 | { | ||
1083 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
1084 | |||
1085 | switch (le16_to_cpu(hdr->type)) { | ||
1086 | case P54_CONTROL_TYPE_TXDONE: | ||
1087 | p54_rx_frame_sent(dev, skb); | ||
1088 | break; | ||
1089 | case P54_CONTROL_TYPE_TRAP: | ||
1090 | p54_rx_trap(dev, skb); | ||
1091 | break; | ||
1092 | case P54_CONTROL_TYPE_BBP: | ||
1093 | break; | ||
1094 | case P54_CONTROL_TYPE_STAT_READBACK: | ||
1095 | p54_rx_stats(dev, skb); | ||
1096 | break; | ||
1097 | case P54_CONTROL_TYPE_EEPROM_READBACK: | ||
1098 | p54_rx_eeprom_readback(dev, skb); | ||
1099 | break; | ||
1100 | default: | ||
1101 | printk(KERN_DEBUG "%s: not handling 0x%02x type control frame\n", | ||
1102 | wiphy_name(dev->wiphy), le16_to_cpu(hdr->type)); | ||
1103 | break; | ||
1104 | } | ||
1105 | |||
1106 | return 0; | ||
1107 | } | ||
1108 | |||
1109 | /* returns zero if skb can be reused */ | ||
1110 | int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
1111 | { | ||
1112 | u16 type = le16_to_cpu(*((__le16 *)skb->data)); | ||
1113 | |||
1114 | if (type & P54_HDR_FLAG_CONTROL) | ||
1115 | return p54_rx_control(dev, skb); | ||
1116 | else | ||
1117 | return p54_rx_data(dev, skb); | ||
1118 | } | ||
1119 | EXPORT_SYMBOL_GPL(p54_rx); | ||
1120 | |||
1121 | /* | ||
1122 | * So, the firmware is somewhat stupid and doesn't know what places in its | ||
1123 | * memory incoming data should go to. By poking around in the firmware, we | ||
1124 | * can find some unused memory to upload our packets to. However, data that we | ||
1125 | * want the card to TX needs to stay intact until the card has told us that | ||
1126 | * it is done with it. This function finds empty places we can upload to and | ||
1127 | * marks allocated areas as reserved if necessary. p54_rx_frame_sent or | ||
1128 | * p54_free_skb frees allocated areas. | ||
1129 | */ | ||
1130 | static int p54_assign_address(struct ieee80211_hw *dev, struct sk_buff *skb, | ||
1131 | struct p54_hdr *data, u32 len) | ||
1132 | { | ||
1133 | struct p54_common *priv = dev->priv; | ||
1134 | struct sk_buff *entry; | ||
1135 | struct sk_buff *target_skb = NULL; | ||
1136 | struct ieee80211_tx_info *info; | ||
1137 | struct p54_tx_info *range; | ||
1138 | u32 last_addr = priv->rx_start; | ||
1139 | u32 largest_hole = 0; | ||
1140 | u32 target_addr = priv->rx_start; | ||
1141 | unsigned long flags; | ||
1142 | unsigned int left; | ||
1143 | len = (len + priv->headroom + priv->tailroom + 3) & ~0x3; | ||
1144 | |||
1145 | if (!skb) | ||
1146 | return -EINVAL; | ||
1147 | |||
1148 | spin_lock_irqsave(&priv->tx_queue.lock, flags); | ||
1149 | |||
1150 | left = skb_queue_len(&priv->tx_queue); | ||
1151 | if (unlikely(left >= 28)) { | ||
1152 | /* | ||
1153 | * The tx_queue is nearly full! | ||
1154 | * We have throttle normal data traffic, because we must | ||
1155 | * have a few spare slots for control frames left. | ||
1156 | */ | ||
1157 | ieee80211_stop_queues(dev); | ||
1158 | queue_delayed_work(dev->workqueue, &priv->work, | ||
1159 | msecs_to_jiffies(P54_TX_TIMEOUT)); | ||
1160 | |||
1161 | if (unlikely(left == 32)) { | ||
1162 | /* | ||
1163 | * The tx_queue is now really full. | ||
1164 | * | ||
1165 | * TODO: check if the device has crashed and reset it. | ||
1166 | */ | ||
1167 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
1168 | return -ENOSPC; | ||
1169 | } | ||
1170 | } | ||
1171 | |||
1172 | entry = priv->tx_queue.next; | ||
1173 | while (left--) { | ||
1174 | u32 hole_size; | ||
1175 | info = IEEE80211_SKB_CB(entry); | ||
1176 | range = (void *)info->rate_driver_data; | ||
1177 | hole_size = range->start_addr - last_addr; | ||
1178 | if (!target_skb && hole_size >= len) { | ||
1179 | target_skb = entry->prev; | ||
1180 | hole_size -= len; | ||
1181 | target_addr = last_addr; | ||
1182 | } | ||
1183 | largest_hole = max(largest_hole, hole_size); | ||
1184 | last_addr = range->end_addr; | ||
1185 | entry = entry->next; | ||
1186 | } | ||
1187 | if (!target_skb && priv->rx_end - last_addr >= len) { | ||
1188 | target_skb = priv->tx_queue.prev; | ||
1189 | largest_hole = max(largest_hole, priv->rx_end - last_addr - len); | ||
1190 | if (!skb_queue_empty(&priv->tx_queue)) { | ||
1191 | info = IEEE80211_SKB_CB(target_skb); | ||
1192 | range = (void *)info->rate_driver_data; | ||
1193 | target_addr = range->end_addr; | ||
1194 | } | ||
1195 | } else | ||
1196 | largest_hole = max(largest_hole, priv->rx_end - last_addr); | ||
1197 | |||
1198 | if (!target_skb) { | ||
1199 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
1200 | ieee80211_stop_queues(dev); | ||
1201 | return -ENOSPC; | ||
1202 | } | ||
1203 | |||
1204 | info = IEEE80211_SKB_CB(skb); | ||
1205 | range = (void *)info->rate_driver_data; | ||
1206 | range->start_addr = target_addr; | ||
1207 | range->end_addr = target_addr + len; | ||
1208 | __skb_queue_after(&priv->tx_queue, target_skb, skb); | ||
1209 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
1210 | |||
1211 | if (largest_hole < priv->headroom + sizeof(struct p54_hdr) + | ||
1212 | 48 + IEEE80211_MAX_RTS_THRESHOLD + priv->tailroom) | ||
1213 | ieee80211_stop_queues(dev); | ||
1214 | |||
1215 | data->req_id = cpu_to_le32(target_addr + priv->headroom); | ||
1216 | return 0; | ||
1217 | } | ||
1218 | |||
1219 | static struct sk_buff *p54_alloc_skb(struct ieee80211_hw *dev, u16 hdr_flags, | ||
1220 | u16 payload_len, u16 type, gfp_t memflags) | ||
1221 | { | ||
1222 | struct p54_common *priv = dev->priv; | ||
1223 | struct p54_hdr *hdr; | ||
1224 | struct sk_buff *skb; | ||
1225 | size_t frame_len = sizeof(*hdr) + payload_len; | ||
1226 | |||
1227 | if (frame_len > P54_MAX_CTRL_FRAME_LEN) | ||
1228 | return NULL; | ||
1229 | |||
1230 | skb = __dev_alloc_skb(priv->tx_hdr_len + frame_len, memflags); | ||
1231 | if (!skb) | ||
1232 | return NULL; | ||
1233 | skb_reserve(skb, priv->tx_hdr_len); | ||
1234 | |||
1235 | hdr = (struct p54_hdr *) skb_put(skb, sizeof(*hdr)); | ||
1236 | hdr->flags = cpu_to_le16(hdr_flags); | ||
1237 | hdr->len = cpu_to_le16(payload_len); | ||
1238 | hdr->type = cpu_to_le16(type); | ||
1239 | hdr->tries = hdr->rts_tries = 0; | ||
1240 | |||
1241 | if (p54_assign_address(dev, skb, hdr, frame_len)) { | ||
1242 | kfree_skb(skb); | ||
1243 | return NULL; | ||
1244 | } | ||
1245 | return skb; | ||
1246 | } | ||
1247 | |||
1248 | int p54_read_eeprom(struct ieee80211_hw *dev) | ||
1249 | { | ||
1250 | struct p54_common *priv = dev->priv; | ||
1251 | struct p54_eeprom_lm86 *eeprom_hdr; | ||
1252 | struct sk_buff *skb; | ||
1253 | size_t eeprom_size = 0x2020, offset = 0, blocksize, maxblocksize; | ||
1254 | int ret = -ENOMEM; | ||
1255 | void *eeprom = NULL; | ||
1256 | |||
1257 | maxblocksize = EEPROM_READBACK_LEN; | ||
1258 | if (priv->fw_var >= 0x509) | ||
1259 | maxblocksize -= 0xc; | ||
1260 | else | ||
1261 | maxblocksize -= 0x4; | ||
1262 | |||
1263 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL, sizeof(*eeprom_hdr) + | ||
1264 | maxblocksize, P54_CONTROL_TYPE_EEPROM_READBACK, | ||
1265 | GFP_KERNEL); | ||
1266 | if (!skb) | ||
1267 | goto free; | ||
1268 | priv->eeprom = kzalloc(EEPROM_READBACK_LEN, GFP_KERNEL); | ||
1269 | if (!priv->eeprom) | ||
1270 | goto free; | ||
1271 | eeprom = kzalloc(eeprom_size, GFP_KERNEL); | ||
1272 | if (!eeprom) | ||
1273 | goto free; | ||
1274 | |||
1275 | eeprom_hdr = (struct p54_eeprom_lm86 *) skb_put(skb, | ||
1276 | sizeof(*eeprom_hdr) + maxblocksize); | ||
1277 | |||
1278 | while (eeprom_size) { | ||
1279 | blocksize = min(eeprom_size, maxblocksize); | ||
1280 | if (priv->fw_var < 0x509) { | ||
1281 | eeprom_hdr->v1.offset = cpu_to_le16(offset); | ||
1282 | eeprom_hdr->v1.len = cpu_to_le16(blocksize); | ||
1283 | } else { | ||
1284 | eeprom_hdr->v2.offset = cpu_to_le32(offset); | ||
1285 | eeprom_hdr->v2.len = cpu_to_le16(blocksize); | ||
1286 | eeprom_hdr->v2.magic2 = 0xf; | ||
1287 | memcpy(eeprom_hdr->v2.magic, (const char *)"LOCK", 4); | ||
1288 | } | ||
1289 | priv->tx(dev, skb); | ||
1290 | |||
1291 | if (!wait_for_completion_interruptible_timeout(&priv->eeprom_comp, HZ)) { | ||
1292 | printk(KERN_ERR "%s: device does not respond!\n", | ||
1293 | wiphy_name(dev->wiphy)); | ||
1294 | ret = -EBUSY; | ||
1295 | goto free; | ||
1296 | } | ||
1297 | |||
1298 | memcpy(eeprom + offset, priv->eeprom, blocksize); | ||
1299 | offset += blocksize; | ||
1300 | eeprom_size -= blocksize; | ||
1301 | } | ||
1302 | |||
1303 | ret = p54_parse_eeprom(dev, eeprom, offset); | ||
1304 | free: | ||
1305 | kfree(priv->eeprom); | ||
1306 | priv->eeprom = NULL; | ||
1307 | p54_free_skb(dev, skb); | ||
1308 | kfree(eeprom); | ||
1309 | |||
1310 | return ret; | ||
1311 | } | ||
1312 | EXPORT_SYMBOL_GPL(p54_read_eeprom); | ||
1313 | |||
1314 | static int p54_set_tim(struct ieee80211_hw *dev, struct ieee80211_sta *sta, | ||
1315 | bool set) | ||
1316 | { | ||
1317 | struct p54_common *priv = dev->priv; | ||
1318 | struct sk_buff *skb; | ||
1319 | struct p54_tim *tim; | ||
1320 | |||
1321 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*tim), | ||
1322 | P54_CONTROL_TYPE_TIM, GFP_ATOMIC); | ||
1323 | if (!skb) | ||
1324 | return -ENOMEM; | ||
1325 | |||
1326 | tim = (struct p54_tim *) skb_put(skb, sizeof(*tim)); | ||
1327 | tim->count = 1; | ||
1328 | tim->entry[0] = cpu_to_le16(set ? (sta->aid | 0x8000) : sta->aid); | ||
1329 | priv->tx(dev, skb); | ||
1330 | return 0; | ||
1331 | } | ||
1332 | |||
1333 | static int p54_sta_unlock(struct ieee80211_hw *dev, u8 *addr) | ||
1334 | { | ||
1335 | struct p54_common *priv = dev->priv; | ||
1336 | struct sk_buff *skb; | ||
1337 | struct p54_sta_unlock *sta; | ||
1338 | |||
1339 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*sta), | ||
1340 | P54_CONTROL_TYPE_PSM_STA_UNLOCK, GFP_ATOMIC); | ||
1341 | if (!skb) | ||
1342 | return -ENOMEM; | ||
1343 | |||
1344 | sta = (struct p54_sta_unlock *)skb_put(skb, sizeof(*sta)); | ||
1345 | memcpy(sta->addr, addr, ETH_ALEN); | ||
1346 | priv->tx(dev, skb); | ||
1347 | return 0; | ||
1348 | } | ||
1349 | |||
1350 | static void p54_sta_notify(struct ieee80211_hw *dev, struct ieee80211_vif *vif, | ||
1351 | enum sta_notify_cmd notify_cmd, | ||
1352 | struct ieee80211_sta *sta) | ||
1353 | { | ||
1354 | switch (notify_cmd) { | ||
1355 | case STA_NOTIFY_ADD: | ||
1356 | case STA_NOTIFY_REMOVE: | ||
1357 | /* | ||
1358 | * Notify the firmware that we don't want or we don't | ||
1359 | * need to buffer frames for this station anymore. | ||
1360 | */ | ||
1361 | |||
1362 | p54_sta_unlock(dev, sta->addr); | ||
1363 | break; | ||
1364 | case STA_NOTIFY_AWAKE: | ||
1365 | /* update the firmware's filter table */ | ||
1366 | p54_sta_unlock(dev, sta->addr); | ||
1367 | break; | ||
1368 | default: | ||
1369 | break; | ||
1370 | } | ||
1371 | } | ||
1372 | |||
1373 | static int p54_tx_cancel(struct ieee80211_hw *dev, struct sk_buff *entry) | ||
1374 | { | ||
1375 | struct p54_common *priv = dev->priv; | ||
1376 | struct sk_buff *skb; | ||
1377 | struct p54_hdr *hdr; | ||
1378 | struct p54_txcancel *cancel; | ||
1379 | |||
1380 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*cancel), | ||
1381 | P54_CONTROL_TYPE_TXCANCEL, GFP_ATOMIC); | ||
1382 | if (!skb) | ||
1383 | return -ENOMEM; | ||
1384 | |||
1385 | hdr = (void *)entry->data; | ||
1386 | cancel = (struct p54_txcancel *)skb_put(skb, sizeof(*cancel)); | ||
1387 | cancel->req_id = hdr->req_id; | ||
1388 | priv->tx(dev, skb); | ||
1389 | return 0; | ||
1390 | } | ||
1391 | |||
1392 | static int p54_tx_fill(struct ieee80211_hw *dev, struct sk_buff *skb, | ||
1393 | struct ieee80211_tx_info *info, u8 *queue, size_t *extra_len, | ||
1394 | u16 *flags, u16 *aid) | ||
1395 | { | ||
1396 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
1397 | struct p54_common *priv = dev->priv; | ||
1398 | int ret = 1; | ||
1399 | |||
1400 | switch (priv->mode) { | ||
1401 | case NL80211_IFTYPE_MONITOR: | ||
1402 | /* | ||
1403 | * We have to set P54_HDR_FLAG_DATA_OUT_PROMISC for | ||
1404 | * every frame in promiscuous/monitor mode. | ||
1405 | * see STSW45x0C LMAC API - page 12. | ||
1406 | */ | ||
1407 | *aid = 0; | ||
1408 | *flags = P54_HDR_FLAG_DATA_OUT_PROMISC; | ||
1409 | *queue += P54_QUEUE_DATA; | ||
1410 | break; | ||
1411 | case NL80211_IFTYPE_STATION: | ||
1412 | *aid = 1; | ||
1413 | if (unlikely(ieee80211_is_mgmt(hdr->frame_control))) { | ||
1414 | *queue = P54_QUEUE_MGMT; | ||
1415 | ret = 0; | ||
1416 | } else | ||
1417 | *queue += P54_QUEUE_DATA; | ||
1418 | break; | ||
1419 | case NL80211_IFTYPE_AP: | ||
1420 | case NL80211_IFTYPE_ADHOC: | ||
1421 | case NL80211_IFTYPE_MESH_POINT: | ||
1422 | if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { | ||
1423 | *aid = 0; | ||
1424 | *queue = P54_QUEUE_CAB; | ||
1425 | return 0; | ||
1426 | } | ||
1427 | |||
1428 | if (unlikely(ieee80211_is_mgmt(hdr->frame_control))) { | ||
1429 | if (ieee80211_is_probe_resp(hdr->frame_control)) { | ||
1430 | *aid = 0; | ||
1431 | *queue = P54_QUEUE_MGMT; | ||
1432 | *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP | | ||
1433 | P54_HDR_FLAG_DATA_OUT_NOCANCEL; | ||
1434 | return 0; | ||
1435 | } else if (ieee80211_is_beacon(hdr->frame_control)) { | ||
1436 | *aid = 0; | ||
1437 | |||
1438 | if (info->flags & IEEE80211_TX_CTL_INJECTED) { | ||
1439 | /* | ||
1440 | * Injecting beacons on top of a AP is | ||
1441 | * not a good idea... nevertheless, | ||
1442 | * it should be doable. | ||
1443 | */ | ||
1444 | |||
1445 | *queue += P54_QUEUE_DATA; | ||
1446 | return 1; | ||
1447 | } | ||
1448 | |||
1449 | *flags = P54_HDR_FLAG_DATA_OUT_TIMESTAMP; | ||
1450 | *queue = P54_QUEUE_BEACON; | ||
1451 | *extra_len = IEEE80211_MAX_TIM_LEN; | ||
1452 | return 0; | ||
1453 | } else { | ||
1454 | *queue = P54_QUEUE_MGMT; | ||
1455 | ret = 0; | ||
1456 | } | ||
1457 | } else | ||
1458 | *queue += P54_QUEUE_DATA; | ||
1459 | |||
1460 | if (info->control.sta) | ||
1461 | *aid = info->control.sta->aid; | ||
1462 | |||
1463 | if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) | ||
1464 | *flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL; | ||
1465 | break; | ||
1466 | } | ||
1467 | return ret; | ||
1468 | } | ||
1469 | |||
1470 | static u8 p54_convert_algo(enum ieee80211_key_alg alg) | ||
1471 | { | ||
1472 | switch (alg) { | ||
1473 | case ALG_WEP: | ||
1474 | return P54_CRYPTO_WEP; | ||
1475 | case ALG_TKIP: | ||
1476 | return P54_CRYPTO_TKIPMICHAEL; | ||
1477 | case ALG_CCMP: | ||
1478 | return P54_CRYPTO_AESCCMP; | ||
1479 | default: | ||
1480 | return 0; | ||
1481 | } | ||
1482 | } | ||
1483 | |||
1484 | static int p54_tx(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
1485 | { | ||
1486 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
1487 | struct ieee80211_tx_queue_stats *current_queue; | ||
1488 | struct p54_common *priv = dev->priv; | ||
1489 | struct p54_hdr *hdr; | ||
1490 | struct p54_tx_data *txhdr; | ||
1491 | size_t padding, len, tim_len = 0; | ||
1492 | int i, j, ridx, ret; | ||
1493 | u16 hdr_flags = 0, aid = 0; | ||
1494 | u8 rate, queue, crypt_offset = 0; | ||
1495 | u8 cts_rate = 0x20; | ||
1496 | u8 rc_flags; | ||
1497 | u8 calculated_tries[4]; | ||
1498 | u8 nrates = 0, nremaining = 8; | ||
1499 | |||
1500 | queue = skb_get_queue_mapping(skb); | ||
1501 | |||
1502 | ret = p54_tx_fill(dev, skb, info, &queue, &tim_len, &hdr_flags, &aid); | ||
1503 | current_queue = &priv->tx_stats[queue]; | ||
1504 | if (unlikely((current_queue->len > current_queue->limit) && ret)) | ||
1505 | return NETDEV_TX_BUSY; | ||
1506 | current_queue->len++; | ||
1507 | current_queue->count++; | ||
1508 | if ((current_queue->len == current_queue->limit) && ret) | ||
1509 | ieee80211_stop_queue(dev, skb_get_queue_mapping(skb)); | ||
1510 | |||
1511 | padding = (unsigned long)(skb->data - (sizeof(*hdr) + sizeof(*txhdr))) & 3; | ||
1512 | len = skb->len; | ||
1513 | |||
1514 | if (info->control.hw_key) { | ||
1515 | crypt_offset = ieee80211_get_hdrlen_from_skb(skb); | ||
1516 | if (info->control.hw_key->alg == ALG_TKIP) { | ||
1517 | u8 *iv = (u8 *)(skb->data + crypt_offset); | ||
1518 | /* | ||
1519 | * The firmware excepts that the IV has to have | ||
1520 | * this special format | ||
1521 | */ | ||
1522 | iv[1] = iv[0]; | ||
1523 | iv[0] = iv[2]; | ||
1524 | iv[2] = 0; | ||
1525 | } | ||
1526 | } | ||
1527 | |||
1528 | txhdr = (struct p54_tx_data *) skb_push(skb, sizeof(*txhdr) + padding); | ||
1529 | hdr = (struct p54_hdr *) skb_push(skb, sizeof(*hdr)); | ||
1530 | |||
1531 | if (padding) | ||
1532 | hdr_flags |= P54_HDR_FLAG_DATA_ALIGN; | ||
1533 | hdr->type = cpu_to_le16(aid); | ||
1534 | hdr->rts_tries = info->control.rates[0].count; | ||
1535 | |||
1536 | /* | ||
1537 | * we register the rates in perfect order, and | ||
1538 | * RTS/CTS won't happen on 5 GHz | ||
1539 | */ | ||
1540 | cts_rate = info->control.rts_cts_rate_idx; | ||
1541 | |||
1542 | memset(&txhdr->rateset, 0, sizeof(txhdr->rateset)); | ||
1543 | |||
1544 | /* see how many rates got used */ | ||
1545 | for (i = 0; i < 4; i++) { | ||
1546 | if (info->control.rates[i].idx < 0) | ||
1547 | break; | ||
1548 | nrates++; | ||
1549 | } | ||
1550 | |||
1551 | /* limit tries to 8/nrates per rate */ | ||
1552 | for (i = 0; i < nrates; i++) { | ||
1553 | /* | ||
1554 | * The magic expression here is equivalent to 8/nrates for | ||
1555 | * all values that matter, but avoids division and jumps. | ||
1556 | * Note that nrates can only take the values 1 through 4. | ||
1557 | */ | ||
1558 | calculated_tries[i] = min_t(int, ((15 >> nrates) | 1) + 1, | ||
1559 | info->control.rates[i].count); | ||
1560 | nremaining -= calculated_tries[i]; | ||
1561 | } | ||
1562 | |||
1563 | /* if there are tries left, distribute from back to front */ | ||
1564 | for (i = nrates - 1; nremaining > 0 && i >= 0; i--) { | ||
1565 | int tmp = info->control.rates[i].count - calculated_tries[i]; | ||
1566 | |||
1567 | if (tmp <= 0) | ||
1568 | continue; | ||
1569 | /* RC requested more tries at this rate */ | ||
1570 | |||
1571 | tmp = min_t(int, tmp, nremaining); | ||
1572 | calculated_tries[i] += tmp; | ||
1573 | nremaining -= tmp; | ||
1574 | } | ||
1575 | |||
1576 | ridx = 0; | ||
1577 | for (i = 0; i < nrates && ridx < 8; i++) { | ||
1578 | /* we register the rates in perfect order */ | ||
1579 | rate = info->control.rates[i].idx; | ||
1580 | if (info->band == IEEE80211_BAND_5GHZ) | ||
1581 | rate += 4; | ||
1582 | |||
1583 | /* store the count we actually calculated for TX status */ | ||
1584 | info->control.rates[i].count = calculated_tries[i]; | ||
1585 | |||
1586 | rc_flags = info->control.rates[i].flags; | ||
1587 | if (rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) { | ||
1588 | rate |= 0x10; | ||
1589 | cts_rate |= 0x10; | ||
1590 | } | ||
1591 | if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) | ||
1592 | rate |= 0x40; | ||
1593 | else if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) | ||
1594 | rate |= 0x20; | ||
1595 | for (j = 0; j < calculated_tries[i] && ridx < 8; j++) { | ||
1596 | txhdr->rateset[ridx] = rate; | ||
1597 | ridx++; | ||
1598 | } | ||
1599 | } | ||
1600 | |||
1601 | if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) | ||
1602 | hdr_flags |= P54_HDR_FLAG_DATA_OUT_SEQNR; | ||
1603 | |||
1604 | /* TODO: enable bursting */ | ||
1605 | hdr->flags = cpu_to_le16(hdr_flags); | ||
1606 | hdr->tries = ridx; | ||
1607 | txhdr->rts_rate_idx = 0; | ||
1608 | if (info->control.hw_key) { | ||
1609 | txhdr->key_type = p54_convert_algo(info->control.hw_key->alg); | ||
1610 | txhdr->key_len = min((u8)16, info->control.hw_key->keylen); | ||
1611 | memcpy(txhdr->key, info->control.hw_key->key, txhdr->key_len); | ||
1612 | if (info->control.hw_key->alg == ALG_TKIP) { | ||
1613 | if (unlikely(skb_tailroom(skb) < 12)) | ||
1614 | goto err; | ||
1615 | /* reserve space for the MIC key */ | ||
1616 | len += 8; | ||
1617 | memcpy(skb_put(skb, 8), &(info->control.hw_key->key | ||
1618 | [NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY]), 8); | ||
1619 | } | ||
1620 | /* reserve some space for ICV */ | ||
1621 | len += info->control.hw_key->icv_len; | ||
1622 | memset(skb_put(skb, info->control.hw_key->icv_len), 0, | ||
1623 | info->control.hw_key->icv_len); | ||
1624 | } else { | ||
1625 | txhdr->key_type = 0; | ||
1626 | txhdr->key_len = 0; | ||
1627 | } | ||
1628 | txhdr->crypt_offset = crypt_offset; | ||
1629 | txhdr->hw_queue = queue; | ||
1630 | txhdr->backlog = current_queue->len; | ||
1631 | memset(txhdr->durations, 0, sizeof(txhdr->durations)); | ||
1632 | txhdr->tx_antenna = ((info->antenna_sel_tx == 0) ? | ||
1633 | 2 : info->antenna_sel_tx - 1) & priv->tx_diversity_mask; | ||
1634 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
1635 | txhdr->longbow.cts_rate = cts_rate; | ||
1636 | txhdr->longbow.output_power = cpu_to_le16(priv->output_power); | ||
1637 | } else { | ||
1638 | txhdr->normal.output_power = priv->output_power; | ||
1639 | txhdr->normal.cts_rate = cts_rate; | ||
1640 | } | ||
1641 | if (padding) | ||
1642 | txhdr->align[0] = padding; | ||
1643 | |||
1644 | hdr->len = cpu_to_le16(len); | ||
1645 | /* modifies skb->cb and with it info, so must be last! */ | ||
1646 | if (unlikely(p54_assign_address(dev, skb, hdr, skb->len + tim_len))) | ||
1647 | goto err; | ||
1648 | priv->tx(dev, skb); | ||
1649 | |||
1650 | queue_delayed_work(dev->workqueue, &priv->work, | ||
1651 | msecs_to_jiffies(P54_TX_FRAME_LIFETIME)); | ||
1652 | |||
1653 | return NETDEV_TX_OK; | ||
1654 | |||
1655 | err: | ||
1656 | skb_pull(skb, sizeof(*hdr) + sizeof(*txhdr) + padding); | ||
1657 | current_queue->len--; | ||
1658 | current_queue->count--; | ||
1659 | return NETDEV_TX_BUSY; | ||
1660 | } | ||
1661 | |||
1662 | static int p54_setup_mac(struct ieee80211_hw *dev) | ||
1663 | { | ||
1664 | struct p54_common *priv = dev->priv; | ||
1665 | struct sk_buff *skb; | ||
1666 | struct p54_setup_mac *setup; | ||
1667 | u16 mode; | ||
1668 | |||
1669 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*setup), | ||
1670 | P54_CONTROL_TYPE_SETUP, GFP_ATOMIC); | ||
1671 | if (!skb) | ||
1672 | return -ENOMEM; | ||
1673 | |||
1674 | setup = (struct p54_setup_mac *) skb_put(skb, sizeof(*setup)); | ||
1675 | if (dev->conf.radio_enabled) { | ||
1676 | switch (priv->mode) { | ||
1677 | case NL80211_IFTYPE_STATION: | ||
1678 | mode = P54_FILTER_TYPE_STATION; | ||
1679 | break; | ||
1680 | case NL80211_IFTYPE_AP: | ||
1681 | mode = P54_FILTER_TYPE_AP; | ||
1682 | break; | ||
1683 | case NL80211_IFTYPE_ADHOC: | ||
1684 | case NL80211_IFTYPE_MESH_POINT: | ||
1685 | mode = P54_FILTER_TYPE_IBSS; | ||
1686 | break; | ||
1687 | case NL80211_IFTYPE_MONITOR: | ||
1688 | mode = P54_FILTER_TYPE_PROMISCUOUS; | ||
1689 | break; | ||
1690 | default: | ||
1691 | mode = P54_FILTER_TYPE_HIBERNATE; | ||
1692 | break; | ||
1693 | } | ||
1694 | |||
1695 | /* | ||
1696 | * "TRANSPARENT and PROMISCUOUS are mutually exclusive" | ||
1697 | * STSW45X0C LMAC API - page 12 | ||
1698 | */ | ||
1699 | if (((priv->filter_flags & FIF_PROMISC_IN_BSS) || | ||
1700 | (priv->filter_flags & FIF_OTHER_BSS)) && | ||
1701 | (mode != P54_FILTER_TYPE_PROMISCUOUS)) | ||
1702 | mode |= P54_FILTER_TYPE_TRANSPARENT; | ||
1703 | } else | ||
1704 | mode = P54_FILTER_TYPE_HIBERNATE; | ||
1705 | |||
1706 | setup->mac_mode = cpu_to_le16(mode); | ||
1707 | memcpy(setup->mac_addr, priv->mac_addr, ETH_ALEN); | ||
1708 | memcpy(setup->bssid, priv->bssid, ETH_ALEN); | ||
1709 | setup->rx_antenna = 2 & priv->rx_diversity_mask; /* automatic */ | ||
1710 | setup->rx_align = 0; | ||
1711 | if (priv->fw_var < 0x500) { | ||
1712 | setup->v1.basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); | ||
1713 | memset(setup->v1.rts_rates, 0, 8); | ||
1714 | setup->v1.rx_addr = cpu_to_le32(priv->rx_end); | ||
1715 | setup->v1.max_rx = cpu_to_le16(priv->rx_mtu); | ||
1716 | setup->v1.rxhw = cpu_to_le16(priv->rxhw); | ||
1717 | setup->v1.wakeup_timer = cpu_to_le16(priv->wakeup_timer); | ||
1718 | setup->v1.unalloc0 = cpu_to_le16(0); | ||
1719 | } else { | ||
1720 | setup->v2.rx_addr = cpu_to_le32(priv->rx_end); | ||
1721 | setup->v2.max_rx = cpu_to_le16(priv->rx_mtu); | ||
1722 | setup->v2.rxhw = cpu_to_le16(priv->rxhw); | ||
1723 | setup->v2.timer = cpu_to_le16(priv->wakeup_timer); | ||
1724 | setup->v2.truncate = cpu_to_le16(48896); | ||
1725 | setup->v2.basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); | ||
1726 | setup->v2.sbss_offset = 0; | ||
1727 | setup->v2.mcast_window = 0; | ||
1728 | setup->v2.rx_rssi_threshold = 0; | ||
1729 | setup->v2.rx_ed_threshold = 0; | ||
1730 | setup->v2.ref_clock = cpu_to_le32(644245094); | ||
1731 | setup->v2.lpf_bandwidth = cpu_to_le16(65535); | ||
1732 | setup->v2.osc_start_delay = cpu_to_le16(65535); | ||
1733 | } | ||
1734 | priv->tx(dev, skb); | ||
1735 | return 0; | ||
1736 | } | ||
1737 | |||
1738 | static int p54_scan(struct ieee80211_hw *dev, u16 mode, u16 dwell) | ||
1739 | { | ||
1740 | struct p54_common *priv = dev->priv; | ||
1741 | struct sk_buff *skb; | ||
1742 | struct p54_hdr *hdr; | ||
1743 | struct p54_scan_head *head; | ||
1744 | struct p54_iq_autocal_entry *iq_autocal; | ||
1745 | union p54_scan_body_union *body; | ||
1746 | struct p54_scan_tail_rate *rate; | ||
1747 | struct pda_rssi_cal_entry *rssi; | ||
1748 | unsigned int i; | ||
1749 | void *entry; | ||
1750 | int band = dev->conf.channel->band; | ||
1751 | __le16 freq = cpu_to_le16(dev->conf.channel->center_freq); | ||
1752 | |||
1753 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*head) + | ||
1754 | 2 + sizeof(*iq_autocal) + sizeof(*body) + | ||
1755 | sizeof(*rate) + 2 * sizeof(*rssi), | ||
1756 | P54_CONTROL_TYPE_SCAN, GFP_ATOMIC); | ||
1757 | if (!skb) | ||
1758 | return -ENOMEM; | ||
1759 | |||
1760 | head = (struct p54_scan_head *) skb_put(skb, sizeof(*head)); | ||
1761 | memset(head->scan_params, 0, sizeof(head->scan_params)); | ||
1762 | head->mode = cpu_to_le16(mode); | ||
1763 | head->dwell = cpu_to_le16(dwell); | ||
1764 | head->freq = freq; | ||
1765 | |||
1766 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
1767 | __le16 *pa_power_points = (__le16 *) skb_put(skb, 2); | ||
1768 | *pa_power_points = cpu_to_le16(0x0c); | ||
1769 | } | ||
1770 | |||
1771 | iq_autocal = (void *) skb_put(skb, sizeof(*iq_autocal)); | ||
1772 | for (i = 0; i < priv->iq_autocal_len; i++) { | ||
1773 | if (priv->iq_autocal[i].freq != freq) | ||
1774 | continue; | ||
1775 | |||
1776 | memcpy(iq_autocal, &priv->iq_autocal[i].params, | ||
1777 | sizeof(struct p54_iq_autocal_entry)); | ||
1778 | break; | ||
1779 | } | ||
1780 | if (i == priv->iq_autocal_len) | ||
1781 | goto err; | ||
1782 | |||
1783 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) | ||
1784 | body = (void *) skb_put(skb, sizeof(body->longbow)); | ||
1785 | else | ||
1786 | body = (void *) skb_put(skb, sizeof(body->normal)); | ||
1787 | |||
1788 | for (i = 0; i < priv->output_limit->entries; i++) { | ||
1789 | __le16 *entry_freq = (void *) (priv->output_limit->data + | ||
1790 | priv->output_limit->entry_size * i); | ||
1791 | |||
1792 | if (*entry_freq != freq) | ||
1793 | continue; | ||
1794 | |||
1795 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
1796 | memcpy(&body->longbow.power_limits, | ||
1797 | (void *) entry_freq + sizeof(__le16), | ||
1798 | priv->output_limit->entry_size); | ||
1799 | } else { | ||
1800 | struct pda_channel_output_limit *limits = | ||
1801 | (void *) entry_freq; | ||
1802 | |||
1803 | body->normal.val_barker = 0x38; | ||
1804 | body->normal.val_bpsk = body->normal.dup_bpsk = | ||
1805 | limits->val_bpsk; | ||
1806 | body->normal.val_qpsk = body->normal.dup_qpsk = | ||
1807 | limits->val_qpsk; | ||
1808 | body->normal.val_16qam = body->normal.dup_16qam = | ||
1809 | limits->val_16qam; | ||
1810 | body->normal.val_64qam = body->normal.dup_64qam = | ||
1811 | limits->val_64qam; | ||
1812 | } | ||
1813 | break; | ||
1814 | } | ||
1815 | if (i == priv->output_limit->entries) | ||
1816 | goto err; | ||
1817 | |||
1818 | entry = (void *)(priv->curve_data->data + priv->curve_data->offset); | ||
1819 | for (i = 0; i < priv->curve_data->entries; i++) { | ||
1820 | if (*((__le16 *)entry) != freq) { | ||
1821 | entry += priv->curve_data->entry_size; | ||
1822 | continue; | ||
1823 | } | ||
1824 | |||
1825 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
1826 | memcpy(&body->longbow.curve_data, | ||
1827 | (void *) entry + sizeof(__le16), | ||
1828 | priv->curve_data->entry_size); | ||
1829 | } else { | ||
1830 | struct p54_scan_body *chan = &body->normal; | ||
1831 | struct pda_pa_curve_data *curve_data = | ||
1832 | (void *) priv->curve_data->data; | ||
1833 | |||
1834 | entry += sizeof(__le16); | ||
1835 | chan->pa_points_per_curve = 8; | ||
1836 | memset(chan->curve_data, 0, sizeof(*chan->curve_data)); | ||
1837 | memcpy(chan->curve_data, entry, | ||
1838 | sizeof(struct p54_pa_curve_data_sample) * | ||
1839 | min((u8)8, curve_data->points_per_channel)); | ||
1840 | } | ||
1841 | break; | ||
1842 | } | ||
1843 | if (i == priv->curve_data->entries) | ||
1844 | goto err; | ||
1845 | |||
1846 | if ((priv->fw_var >= 0x500) && (priv->fw_var < 0x509)) { | ||
1847 | rate = (void *) skb_put(skb, sizeof(*rate)); | ||
1848 | rate->basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); | ||
1849 | for (i = 0; i < sizeof(rate->rts_rates); i++) | ||
1850 | rate->rts_rates[i] = i; | ||
1851 | } | ||
1852 | |||
1853 | rssi = (struct pda_rssi_cal_entry *) skb_put(skb, sizeof(*rssi)); | ||
1854 | rssi->mul = cpu_to_le16(priv->rssical_db[band].mul); | ||
1855 | rssi->add = cpu_to_le16(priv->rssical_db[band].add); | ||
1856 | if (priv->rxhw == PDR_SYNTH_FRONTEND_LONGBOW) { | ||
1857 | /* Longbow frontend needs ever more */ | ||
1858 | rssi = (void *) skb_put(skb, sizeof(*rssi)); | ||
1859 | rssi->mul = cpu_to_le16(priv->rssical_db[band].longbow_unkn); | ||
1860 | rssi->add = cpu_to_le16(priv->rssical_db[band].longbow_unk2); | ||
1861 | } | ||
1862 | |||
1863 | if (priv->fw_var >= 0x509) { | ||
1864 | rate = (void *) skb_put(skb, sizeof(*rate)); | ||
1865 | rate->basic_rate_mask = cpu_to_le32(priv->basic_rate_mask); | ||
1866 | for (i = 0; i < sizeof(rate->rts_rates); i++) | ||
1867 | rate->rts_rates[i] = i; | ||
1868 | } | ||
1869 | |||
1870 | hdr = (struct p54_hdr *) skb->data; | ||
1871 | hdr->len = cpu_to_le16(skb->len - sizeof(*hdr)); | ||
1872 | |||
1873 | priv->tx(dev, skb); | ||
1874 | return 0; | ||
1875 | |||
1876 | err: | ||
1877 | printk(KERN_ERR "%s: frequency change failed\n", wiphy_name(dev->wiphy)); | ||
1878 | p54_free_skb(dev, skb); | ||
1879 | return -EINVAL; | ||
1880 | } | ||
1881 | |||
1882 | static int p54_set_leds(struct ieee80211_hw *dev) | ||
1883 | { | ||
1884 | struct p54_common *priv = dev->priv; | ||
1885 | struct sk_buff *skb; | ||
1886 | struct p54_led *led; | ||
1887 | |||
1888 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*led), | ||
1889 | P54_CONTROL_TYPE_LED, GFP_ATOMIC); | ||
1890 | if (!skb) | ||
1891 | return -ENOMEM; | ||
1892 | |||
1893 | led = (struct p54_led *) skb_put(skb, sizeof(*led)); | ||
1894 | led->flags = cpu_to_le16(0x0003); | ||
1895 | led->mask[0] = led->mask[1] = cpu_to_le16(priv->softled_state); | ||
1896 | led->delay[0] = cpu_to_le16(1); | ||
1897 | led->delay[1] = cpu_to_le16(0); | ||
1898 | priv->tx(dev, skb); | ||
1899 | return 0; | ||
1900 | } | ||
1901 | |||
1902 | #define P54_SET_QUEUE(queue, ai_fs, cw_min, cw_max, _txop) \ | ||
1903 | do { \ | ||
1904 | queue.aifs = cpu_to_le16(ai_fs); \ | ||
1905 | queue.cwmin = cpu_to_le16(cw_min); \ | ||
1906 | queue.cwmax = cpu_to_le16(cw_max); \ | ||
1907 | queue.txop = cpu_to_le16(_txop); \ | ||
1908 | } while(0) | ||
1909 | |||
1910 | static int p54_set_edcf(struct ieee80211_hw *dev) | ||
1911 | { | ||
1912 | struct p54_common *priv = dev->priv; | ||
1913 | struct sk_buff *skb; | ||
1914 | struct p54_edcf *edcf; | ||
1915 | |||
1916 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*edcf), | ||
1917 | P54_CONTROL_TYPE_DCFINIT, GFP_ATOMIC); | ||
1918 | if (!skb) | ||
1919 | return -ENOMEM; | ||
1920 | |||
1921 | edcf = (struct p54_edcf *)skb_put(skb, sizeof(*edcf)); | ||
1922 | if (priv->use_short_slot) { | ||
1923 | edcf->slottime = 9; | ||
1924 | edcf->sifs = 0x10; | ||
1925 | edcf->eofpad = 0x00; | ||
1926 | } else { | ||
1927 | edcf->slottime = 20; | ||
1928 | edcf->sifs = 0x0a; | ||
1929 | edcf->eofpad = 0x06; | ||
1930 | } | ||
1931 | /* (see prism54/isl_oid.h for further details) */ | ||
1932 | edcf->frameburst = cpu_to_le16(0); | ||
1933 | edcf->round_trip_delay = cpu_to_le16(0); | ||
1934 | edcf->flags = 0; | ||
1935 | memset(edcf->mapping, 0, sizeof(edcf->mapping)); | ||
1936 | memcpy(edcf->queue, priv->qos_params, sizeof(edcf->queue)); | ||
1937 | priv->tx(dev, skb); | ||
1938 | return 0; | ||
1939 | } | ||
1940 | |||
1941 | static int p54_set_ps(struct ieee80211_hw *dev) | ||
1942 | { | ||
1943 | struct p54_common *priv = dev->priv; | ||
1944 | struct sk_buff *skb; | ||
1945 | struct p54_psm *psm; | ||
1946 | u16 mode; | ||
1947 | int i; | ||
1948 | |||
1949 | if (dev->conf.flags & IEEE80211_CONF_PS) | ||
1950 | mode = P54_PSM | P54_PSM_BEACON_TIMEOUT | P54_PSM_DTIM | | ||
1951 | P54_PSM_CHECKSUM | P54_PSM_MCBC; | ||
1952 | else | ||
1953 | mode = P54_PSM_CAM; | ||
1954 | |||
1955 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*psm), | ||
1956 | P54_CONTROL_TYPE_PSM, GFP_ATOMIC); | ||
1957 | if (!skb) | ||
1958 | return -ENOMEM; | ||
1959 | |||
1960 | psm = (struct p54_psm *)skb_put(skb, sizeof(*psm)); | ||
1961 | psm->mode = cpu_to_le16(mode); | ||
1962 | psm->aid = cpu_to_le16(priv->aid); | ||
1963 | for (i = 0; i < ARRAY_SIZE(psm->intervals); i++) { | ||
1964 | psm->intervals[i].interval = | ||
1965 | cpu_to_le16(dev->conf.listen_interval); | ||
1966 | psm->intervals[i].periods = cpu_to_le16(1); | ||
1967 | } | ||
1968 | |||
1969 | psm->beacon_rssi_skip_max = 200; | ||
1970 | psm->rssi_delta_threshold = 0; | ||
1971 | psm->nr = 10; | ||
1972 | psm->exclude[0] = 0; | ||
1973 | |||
1974 | priv->tx(dev, skb); | ||
1975 | |||
1976 | return 0; | ||
1977 | } | ||
1978 | |||
1979 | static int p54_beacon_tim(struct sk_buff *skb) | ||
1980 | { | ||
1981 | /* | ||
1982 | * the good excuse for this mess is ... the firmware. | ||
1983 | * The dummy TIM MUST be at the end of the beacon frame, | ||
1984 | * because it'll be overwritten! | ||
1985 | */ | ||
1986 | |||
1987 | struct ieee80211_mgmt *mgmt = (void *)skb->data; | ||
1988 | u8 *pos, *end; | ||
1989 | |||
1990 | if (skb->len <= sizeof(mgmt)) | ||
1991 | return -EINVAL; | ||
1992 | |||
1993 | pos = (u8 *)mgmt->u.beacon.variable; | ||
1994 | end = skb->data + skb->len; | ||
1995 | while (pos < end) { | ||
1996 | if (pos + 2 + pos[1] > end) | ||
1997 | return -EINVAL; | ||
1998 | |||
1999 | if (pos[0] == WLAN_EID_TIM) { | ||
2000 | u8 dtim_len = pos[1]; | ||
2001 | u8 dtim_period = pos[3]; | ||
2002 | u8 *next = pos + 2 + dtim_len; | ||
2003 | |||
2004 | if (dtim_len < 3) | ||
2005 | return -EINVAL; | ||
2006 | |||
2007 | memmove(pos, next, end - next); | ||
2008 | |||
2009 | if (dtim_len > 3) | ||
2010 | skb_trim(skb, skb->len - (dtim_len - 3)); | ||
2011 | |||
2012 | pos = end - (dtim_len + 2); | ||
2013 | |||
2014 | /* add the dummy at the end */ | ||
2015 | pos[0] = WLAN_EID_TIM; | ||
2016 | pos[1] = 3; | ||
2017 | pos[2] = 0; | ||
2018 | pos[3] = dtim_period; | ||
2019 | pos[4] = 0; | ||
2020 | return 0; | ||
2021 | } | ||
2022 | pos += 2 + pos[1]; | ||
2023 | } | ||
2024 | return 0; | ||
2025 | } | ||
2026 | |||
2027 | static int p54_beacon_update(struct ieee80211_hw *dev, | ||
2028 | struct ieee80211_vif *vif) | ||
2029 | { | ||
2030 | struct p54_common *priv = dev->priv; | ||
2031 | struct sk_buff *beacon; | ||
2032 | int ret; | ||
2033 | |||
2034 | if (priv->cached_beacon) { | ||
2035 | p54_tx_cancel(dev, priv->cached_beacon); | ||
2036 | /* wait for the last beacon the be freed */ | ||
2037 | msleep(10); | ||
2038 | } | ||
2039 | |||
2040 | beacon = ieee80211_beacon_get(dev, vif); | ||
2041 | if (!beacon) | ||
2042 | return -ENOMEM; | ||
2043 | ret = p54_beacon_tim(beacon); | ||
2044 | if (ret) | ||
2045 | return ret; | ||
2046 | ret = p54_tx(dev, beacon); | ||
2047 | if (ret) | ||
2048 | return ret; | ||
2049 | priv->cached_beacon = beacon; | ||
2050 | priv->tsf_high32 = 0; | ||
2051 | priv->tsf_low32 = 0; | ||
2052 | |||
2053 | return 0; | ||
2054 | } | ||
2055 | |||
2056 | static int p54_start(struct ieee80211_hw *dev) | ||
2057 | { | ||
2058 | struct p54_common *priv = dev->priv; | ||
2059 | int err; | ||
2060 | |||
2061 | mutex_lock(&priv->conf_mutex); | ||
2062 | err = priv->open(dev); | ||
2063 | if (err) | ||
2064 | goto out; | ||
2065 | P54_SET_QUEUE(priv->qos_params[0], 0x0002, 0x0003, 0x0007, 47); | ||
2066 | P54_SET_QUEUE(priv->qos_params[1], 0x0002, 0x0007, 0x000f, 94); | ||
2067 | P54_SET_QUEUE(priv->qos_params[2], 0x0003, 0x000f, 0x03ff, 0); | ||
2068 | P54_SET_QUEUE(priv->qos_params[3], 0x0007, 0x000f, 0x03ff, 0); | ||
2069 | err = p54_set_edcf(dev); | ||
2070 | if (err) | ||
2071 | goto out; | ||
2072 | |||
2073 | memset(priv->bssid, ~0, ETH_ALEN); | ||
2074 | priv->mode = NL80211_IFTYPE_MONITOR; | ||
2075 | err = p54_setup_mac(dev); | ||
2076 | if (err) { | ||
2077 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | ||
2078 | goto out; | ||
2079 | } | ||
2080 | |||
2081 | queue_delayed_work(dev->workqueue, &priv->work, 0); | ||
2082 | |||
2083 | priv->softled_state = 0; | ||
2084 | err = p54_set_leds(dev); | ||
2085 | |||
2086 | out: | ||
2087 | mutex_unlock(&priv->conf_mutex); | ||
2088 | return err; | ||
2089 | } | ||
2090 | |||
2091 | static void p54_stop(struct ieee80211_hw *dev) | ||
2092 | { | ||
2093 | struct p54_common *priv = dev->priv; | ||
2094 | struct sk_buff *skb; | ||
2095 | |||
2096 | mutex_lock(&priv->conf_mutex); | ||
2097 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | ||
2098 | priv->softled_state = 0; | ||
2099 | p54_set_leds(dev); | ||
2100 | |||
2101 | #ifdef CONFIG_P54_LEDS | ||
2102 | cancel_delayed_work_sync(&priv->led_work); | ||
2103 | #endif /* CONFIG_P54_LEDS */ | ||
2104 | cancel_delayed_work_sync(&priv->work); | ||
2105 | if (priv->cached_beacon) | ||
2106 | p54_tx_cancel(dev, priv->cached_beacon); | ||
2107 | |||
2108 | priv->stop(dev); | ||
2109 | while ((skb = skb_dequeue(&priv->tx_queue))) | ||
2110 | kfree_skb(skb); | ||
2111 | priv->cached_beacon = NULL; | ||
2112 | priv->tsf_high32 = priv->tsf_low32 = 0; | ||
2113 | mutex_unlock(&priv->conf_mutex); | ||
2114 | } | ||
2115 | |||
2116 | static int p54_add_interface(struct ieee80211_hw *dev, | ||
2117 | struct ieee80211_if_init_conf *conf) | ||
2118 | { | ||
2119 | struct p54_common *priv = dev->priv; | ||
2120 | |||
2121 | mutex_lock(&priv->conf_mutex); | ||
2122 | if (priv->mode != NL80211_IFTYPE_MONITOR) { | ||
2123 | mutex_unlock(&priv->conf_mutex); | ||
2124 | return -EOPNOTSUPP; | ||
2125 | } | ||
2126 | |||
2127 | priv->vif = conf->vif; | ||
2128 | |||
2129 | switch (conf->type) { | ||
2130 | case NL80211_IFTYPE_STATION: | ||
2131 | case NL80211_IFTYPE_ADHOC: | ||
2132 | case NL80211_IFTYPE_AP: | ||
2133 | case NL80211_IFTYPE_MESH_POINT: | ||
2134 | priv->mode = conf->type; | ||
2135 | break; | ||
2136 | default: | ||
2137 | mutex_unlock(&priv->conf_mutex); | ||
2138 | return -EOPNOTSUPP; | ||
2139 | } | ||
2140 | |||
2141 | memcpy(priv->mac_addr, conf->mac_addr, ETH_ALEN); | ||
2142 | p54_setup_mac(dev); | ||
2143 | mutex_unlock(&priv->conf_mutex); | ||
2144 | return 0; | ||
2145 | } | ||
2146 | |||
2147 | static void p54_remove_interface(struct ieee80211_hw *dev, | ||
2148 | struct ieee80211_if_init_conf *conf) | ||
2149 | { | ||
2150 | struct p54_common *priv = dev->priv; | ||
2151 | |||
2152 | mutex_lock(&priv->conf_mutex); | ||
2153 | priv->vif = NULL; | ||
2154 | if (priv->cached_beacon) | ||
2155 | p54_tx_cancel(dev, priv->cached_beacon); | ||
2156 | priv->mode = NL80211_IFTYPE_MONITOR; | ||
2157 | memset(priv->mac_addr, 0, ETH_ALEN); | ||
2158 | memset(priv->bssid, 0, ETH_ALEN); | ||
2159 | p54_setup_mac(dev); | ||
2160 | mutex_unlock(&priv->conf_mutex); | ||
2161 | } | ||
2162 | |||
2163 | static int p54_config(struct ieee80211_hw *dev, u32 changed) | ||
2164 | { | ||
2165 | int ret = 0; | ||
2166 | struct p54_common *priv = dev->priv; | ||
2167 | struct ieee80211_conf *conf = &dev->conf; | ||
2168 | |||
2169 | mutex_lock(&priv->conf_mutex); | ||
2170 | if (changed & IEEE80211_CONF_CHANGE_POWER) | ||
2171 | priv->output_power = conf->power_level << 2; | ||
2172 | if (changed & IEEE80211_CONF_CHANGE_RADIO_ENABLED) { | ||
2173 | ret = p54_setup_mac(dev); | ||
2174 | if (ret) | ||
2175 | goto out; | ||
2176 | } | ||
2177 | if (changed & IEEE80211_CONF_CHANGE_CHANNEL) { | ||
2178 | ret = p54_scan(dev, P54_SCAN_EXIT, 0); | ||
2179 | if (ret) | ||
2180 | goto out; | ||
2181 | } | ||
2182 | if (changed & IEEE80211_CONF_CHANGE_PS) { | ||
2183 | ret = p54_set_ps(dev); | ||
2184 | if (ret) | ||
2185 | goto out; | ||
2186 | } | ||
2187 | |||
2188 | out: | ||
2189 | mutex_unlock(&priv->conf_mutex); | ||
2190 | return ret; | ||
2191 | } | ||
2192 | |||
2193 | static void p54_configure_filter(struct ieee80211_hw *dev, | ||
2194 | unsigned int changed_flags, | ||
2195 | unsigned int *total_flags, | ||
2196 | int mc_count, struct dev_mc_list *mclist) | ||
2197 | { | ||
2198 | struct p54_common *priv = dev->priv; | ||
2199 | |||
2200 | *total_flags &= FIF_PROMISC_IN_BSS | | ||
2201 | FIF_OTHER_BSS; | ||
2202 | |||
2203 | priv->filter_flags = *total_flags; | ||
2204 | |||
2205 | if (changed_flags & (FIF_PROMISC_IN_BSS | FIF_OTHER_BSS)) | ||
2206 | p54_setup_mac(dev); | ||
2207 | } | ||
2208 | |||
2209 | static int p54_conf_tx(struct ieee80211_hw *dev, u16 queue, | ||
2210 | const struct ieee80211_tx_queue_params *params) | ||
2211 | { | ||
2212 | struct p54_common *priv = dev->priv; | ||
2213 | int ret; | ||
2214 | |||
2215 | mutex_lock(&priv->conf_mutex); | ||
2216 | if ((params) && !(queue > 4)) { | ||
2217 | P54_SET_QUEUE(priv->qos_params[queue], params->aifs, | ||
2218 | params->cw_min, params->cw_max, params->txop); | ||
2219 | ret = p54_set_edcf(dev); | ||
2220 | } else | ||
2221 | ret = -EINVAL; | ||
2222 | mutex_unlock(&priv->conf_mutex); | ||
2223 | return ret; | ||
2224 | } | ||
2225 | |||
2226 | static int p54_init_xbow_synth(struct ieee80211_hw *dev) | ||
2227 | { | ||
2228 | struct p54_common *priv = dev->priv; | ||
2229 | struct sk_buff *skb; | ||
2230 | struct p54_xbow_synth *xbow; | ||
2231 | |||
2232 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*xbow), | ||
2233 | P54_CONTROL_TYPE_XBOW_SYNTH_CFG, GFP_KERNEL); | ||
2234 | if (!skb) | ||
2235 | return -ENOMEM; | ||
2236 | |||
2237 | xbow = (struct p54_xbow_synth *)skb_put(skb, sizeof(*xbow)); | ||
2238 | xbow->magic1 = cpu_to_le16(0x1); | ||
2239 | xbow->magic2 = cpu_to_le16(0x2); | ||
2240 | xbow->freq = cpu_to_le16(5390); | ||
2241 | memset(xbow->padding, 0, sizeof(xbow->padding)); | ||
2242 | priv->tx(dev, skb); | ||
2243 | return 0; | ||
2244 | } | ||
2245 | |||
2246 | static void p54_work(struct work_struct *work) | ||
2247 | { | ||
2248 | struct p54_common *priv = container_of(work, struct p54_common, | ||
2249 | work.work); | ||
2250 | struct ieee80211_hw *dev = priv->hw; | ||
2251 | struct sk_buff *skb; | ||
2252 | |||
2253 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | ||
2254 | return ; | ||
2255 | |||
2256 | /* | ||
2257 | * TODO: walk through tx_queue and do the following tasks | ||
2258 | * 1. initiate bursts. | ||
2259 | * 2. cancel stuck frames / reset the device if necessary. | ||
2260 | */ | ||
2261 | |||
2262 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL, | ||
2263 | sizeof(struct p54_statistics), | ||
2264 | P54_CONTROL_TYPE_STAT_READBACK, GFP_KERNEL); | ||
2265 | if (!skb) | ||
2266 | return ; | ||
2267 | |||
2268 | priv->tx(dev, skb); | ||
2269 | } | ||
2270 | |||
2271 | static int p54_get_stats(struct ieee80211_hw *dev, | ||
2272 | struct ieee80211_low_level_stats *stats) | ||
2273 | { | ||
2274 | struct p54_common *priv = dev->priv; | ||
2275 | |||
2276 | memcpy(stats, &priv->stats, sizeof(*stats)); | ||
2277 | return 0; | ||
2278 | } | ||
2279 | |||
2280 | static int p54_get_tx_stats(struct ieee80211_hw *dev, | ||
2281 | struct ieee80211_tx_queue_stats *stats) | ||
2282 | { | ||
2283 | struct p54_common *priv = dev->priv; | ||
2284 | |||
2285 | memcpy(stats, &priv->tx_stats[P54_QUEUE_DATA], | ||
2286 | sizeof(stats[0]) * dev->queues); | ||
2287 | return 0; | ||
2288 | } | ||
2289 | |||
2290 | static void p54_bss_info_changed(struct ieee80211_hw *dev, | ||
2291 | struct ieee80211_vif *vif, | ||
2292 | struct ieee80211_bss_conf *info, | ||
2293 | u32 changed) | ||
2294 | { | ||
2295 | struct p54_common *priv = dev->priv; | ||
2296 | int ret; | ||
2297 | |||
2298 | mutex_lock(&priv->conf_mutex); | ||
2299 | if (changed & BSS_CHANGED_BSSID) { | ||
2300 | memcpy(priv->bssid, info->bssid, ETH_ALEN); | ||
2301 | ret = p54_setup_mac(dev); | ||
2302 | if (ret) | ||
2303 | goto out; | ||
2304 | } | ||
2305 | |||
2306 | if (changed & BSS_CHANGED_BEACON) { | ||
2307 | ret = p54_scan(dev, P54_SCAN_EXIT, 0); | ||
2308 | if (ret) | ||
2309 | goto out; | ||
2310 | ret = p54_setup_mac(dev); | ||
2311 | if (ret) | ||
2312 | goto out; | ||
2313 | ret = p54_beacon_update(dev, vif); | ||
2314 | if (ret) | ||
2315 | goto out; | ||
2316 | } | ||
2317 | /* XXX: this mimics having two callbacks... clean up */ | ||
2318 | out: | ||
2319 | mutex_unlock(&priv->conf_mutex); | ||
2320 | |||
2321 | if (changed & (BSS_CHANGED_ERP_SLOT | BSS_CHANGED_BEACON)) { | ||
2322 | priv->use_short_slot = info->use_short_slot; | ||
2323 | p54_set_edcf(dev); | ||
2324 | } | ||
2325 | if (changed & BSS_CHANGED_BASIC_RATES) { | ||
2326 | if (dev->conf.channel->band == IEEE80211_BAND_5GHZ) | ||
2327 | priv->basic_rate_mask = (info->basic_rates << 4); | ||
2328 | else | ||
2329 | priv->basic_rate_mask = info->basic_rates; | ||
2330 | p54_setup_mac(dev); | ||
2331 | if (priv->fw_var >= 0x500) | ||
2332 | p54_scan(dev, P54_SCAN_EXIT, 0); | ||
2333 | } | ||
2334 | if (changed & BSS_CHANGED_ASSOC) { | ||
2335 | if (info->assoc) { | ||
2336 | priv->aid = info->aid; | ||
2337 | priv->wakeup_timer = info->beacon_int * | ||
2338 | info->dtim_period * 5; | ||
2339 | p54_setup_mac(dev); | ||
2340 | } | ||
2341 | } | ||
2342 | } | ||
2343 | |||
2344 | static int p54_set_key(struct ieee80211_hw *dev, enum set_key_cmd cmd, | ||
2345 | struct ieee80211_vif *vif, struct ieee80211_sta *sta, | ||
2346 | struct ieee80211_key_conf *key) | ||
2347 | { | ||
2348 | struct p54_common *priv = dev->priv; | ||
2349 | struct sk_buff *skb; | ||
2350 | struct p54_keycache *rxkey; | ||
2351 | int slot, ret = 0; | ||
2352 | u8 algo = 0; | ||
2353 | |||
2354 | if (modparam_nohwcrypt) | ||
2355 | return -EOPNOTSUPP; | ||
2356 | |||
2357 | mutex_lock(&priv->conf_mutex); | ||
2358 | if (cmd == SET_KEY) { | ||
2359 | switch (key->alg) { | ||
2360 | case ALG_TKIP: | ||
2361 | if (!(priv->privacy_caps & (BR_DESC_PRIV_CAP_MICHAEL | | ||
2362 | BR_DESC_PRIV_CAP_TKIP))) { | ||
2363 | ret = -EOPNOTSUPP; | ||
2364 | goto out_unlock; | ||
2365 | } | ||
2366 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | ||
2367 | algo = P54_CRYPTO_TKIPMICHAEL; | ||
2368 | break; | ||
2369 | case ALG_WEP: | ||
2370 | if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_WEP)) { | ||
2371 | ret = -EOPNOTSUPP; | ||
2372 | goto out_unlock; | ||
2373 | } | ||
2374 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | ||
2375 | algo = P54_CRYPTO_WEP; | ||
2376 | break; | ||
2377 | case ALG_CCMP: | ||
2378 | if (!(priv->privacy_caps & BR_DESC_PRIV_CAP_AESCCMP)) { | ||
2379 | ret = -EOPNOTSUPP; | ||
2380 | goto out_unlock; | ||
2381 | } | ||
2382 | key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | ||
2383 | algo = P54_CRYPTO_AESCCMP; | ||
2384 | break; | ||
2385 | default: | ||
2386 | ret = -EOPNOTSUPP; | ||
2387 | goto out_unlock; | ||
2388 | } | ||
2389 | slot = bitmap_find_free_region(priv->used_rxkeys, | ||
2390 | priv->rx_keycache_size, 0); | ||
2391 | |||
2392 | if (slot < 0) { | ||
2393 | /* | ||
2394 | * The device supports the choosen algorithm, but the | ||
2395 | * firmware does not provide enough key slots to store | ||
2396 | * all of them. | ||
2397 | * But encryption offload for outgoing frames is always | ||
2398 | * possible, so we just pretend that the upload was | ||
2399 | * successful and do the decryption in software. | ||
2400 | */ | ||
2401 | |||
2402 | /* mark the key as invalid. */ | ||
2403 | key->hw_key_idx = 0xff; | ||
2404 | goto out_unlock; | ||
2405 | } | ||
2406 | } else { | ||
2407 | slot = key->hw_key_idx; | ||
2408 | |||
2409 | if (slot == 0xff) { | ||
2410 | /* This key was not uploaded into the rx key cache. */ | ||
2411 | |||
2412 | goto out_unlock; | ||
2413 | } | ||
2414 | |||
2415 | bitmap_release_region(priv->used_rxkeys, slot, 0); | ||
2416 | algo = 0; | ||
2417 | } | ||
2418 | |||
2419 | skb = p54_alloc_skb(dev, P54_HDR_FLAG_CONTROL_OPSET, sizeof(*rxkey), | ||
2420 | P54_CONTROL_TYPE_RX_KEYCACHE, GFP_KERNEL); | ||
2421 | if (!skb) { | ||
2422 | bitmap_release_region(priv->used_rxkeys, slot, 0); | ||
2423 | ret = -ENOSPC; | ||
2424 | goto out_unlock; | ||
2425 | } | ||
2426 | |||
2427 | rxkey = (struct p54_keycache *)skb_put(skb, sizeof(*rxkey)); | ||
2428 | rxkey->entry = slot; | ||
2429 | rxkey->key_id = key->keyidx; | ||
2430 | rxkey->key_type = algo; | ||
2431 | if (sta) | ||
2432 | memcpy(rxkey->mac, sta->addr, ETH_ALEN); | ||
2433 | else | ||
2434 | memset(rxkey->mac, ~0, ETH_ALEN); | ||
2435 | if (key->alg != ALG_TKIP) { | ||
2436 | rxkey->key_len = min((u8)16, key->keylen); | ||
2437 | memcpy(rxkey->key, key->key, rxkey->key_len); | ||
2438 | } else { | ||
2439 | rxkey->key_len = 24; | ||
2440 | memcpy(rxkey->key, key->key, 16); | ||
2441 | memcpy(&(rxkey->key[16]), &(key->key | ||
2442 | [NL80211_TKIP_DATA_OFFSET_RX_MIC_KEY]), 8); | ||
2443 | } | ||
2444 | |||
2445 | priv->tx(dev, skb); | ||
2446 | key->hw_key_idx = slot; | ||
2447 | |||
2448 | out_unlock: | ||
2449 | mutex_unlock(&priv->conf_mutex); | ||
2450 | return ret; | ||
2451 | } | ||
2452 | |||
2453 | #ifdef CONFIG_P54_LEDS | ||
2454 | static void p54_update_leds(struct work_struct *work) | ||
2455 | { | ||
2456 | struct p54_common *priv = container_of(work, struct p54_common, | ||
2457 | led_work.work); | ||
2458 | int err, i, tmp, blink_delay = 400; | ||
2459 | bool rerun = false; | ||
2460 | |||
2461 | /* Don't toggle the LED, when the device is down. */ | ||
2462 | if (priv->mode == NL80211_IFTYPE_UNSPECIFIED) | ||
2463 | return ; | ||
2464 | |||
2465 | for (i = 0; i < ARRAY_SIZE(priv->leds); i++) | ||
2466 | if (priv->leds[i].toggled) { | ||
2467 | priv->softled_state |= BIT(i); | ||
2468 | |||
2469 | tmp = 70 + 200 / (priv->leds[i].toggled); | ||
2470 | if (tmp < blink_delay) | ||
2471 | blink_delay = tmp; | ||
2472 | |||
2473 | if (priv->leds[i].led_dev.brightness == LED_OFF) | ||
2474 | rerun = true; | ||
2475 | |||
2476 | priv->leds[i].toggled = | ||
2477 | !!priv->leds[i].led_dev.brightness; | ||
2478 | } else | ||
2479 | priv->softled_state &= ~BIT(i); | ||
2480 | |||
2481 | err = p54_set_leds(priv->hw); | ||
2482 | if (err && net_ratelimit()) | ||
2483 | printk(KERN_ERR "%s: failed to update LEDs.\n", | ||
2484 | wiphy_name(priv->hw->wiphy)); | ||
2485 | |||
2486 | if (rerun) | ||
2487 | queue_delayed_work(priv->hw->workqueue, &priv->led_work, | ||
2488 | msecs_to_jiffies(blink_delay)); | ||
2489 | } | ||
2490 | |||
2491 | static void p54_led_brightness_set(struct led_classdev *led_dev, | ||
2492 | enum led_brightness brightness) | ||
2493 | { | ||
2494 | struct p54_led_dev *led = container_of(led_dev, struct p54_led_dev, | ||
2495 | led_dev); | ||
2496 | struct ieee80211_hw *dev = led->hw_dev; | ||
2497 | struct p54_common *priv = dev->priv; | ||
2498 | |||
2499 | if (priv->mode == NL80211_IFTYPE_UNSPECIFIED) | ||
2500 | return ; | ||
2501 | |||
2502 | if (brightness) { | ||
2503 | led->toggled++; | ||
2504 | queue_delayed_work(priv->hw->workqueue, &priv->led_work, | ||
2505 | HZ/10); | ||
2506 | } | ||
2507 | } | ||
2508 | |||
2509 | static int p54_register_led(struct ieee80211_hw *dev, | ||
2510 | unsigned int led_index, | ||
2511 | char *name, char *trigger) | ||
2512 | { | ||
2513 | struct p54_common *priv = dev->priv; | ||
2514 | struct p54_led_dev *led = &priv->leds[led_index]; | ||
2515 | int err; | ||
2516 | |||
2517 | if (led->registered) | ||
2518 | return -EEXIST; | ||
2519 | |||
2520 | snprintf(led->name, sizeof(led->name), "p54-%s::%s", | ||
2521 | wiphy_name(dev->wiphy), name); | ||
2522 | led->hw_dev = dev; | ||
2523 | led->index = led_index; | ||
2524 | led->led_dev.name = led->name; | ||
2525 | led->led_dev.default_trigger = trigger; | ||
2526 | led->led_dev.brightness_set = p54_led_brightness_set; | ||
2527 | |||
2528 | err = led_classdev_register(wiphy_dev(dev->wiphy), &led->led_dev); | ||
2529 | if (err) | ||
2530 | printk(KERN_ERR "%s: Failed to register %s LED.\n", | ||
2531 | wiphy_name(dev->wiphy), name); | ||
2532 | else | ||
2533 | led->registered = 1; | ||
2534 | |||
2535 | return err; | ||
2536 | } | ||
2537 | |||
2538 | static int p54_init_leds(struct ieee80211_hw *dev) | ||
2539 | { | ||
2540 | struct p54_common *priv = dev->priv; | ||
2541 | int err; | ||
2542 | |||
2543 | /* | ||
2544 | * TODO: | ||
2545 | * Figure out if the EEPROM contains some hints about the number | ||
2546 | * of available/programmable LEDs of the device. | ||
2547 | */ | ||
2548 | |||
2549 | INIT_DELAYED_WORK(&priv->led_work, p54_update_leds); | ||
2550 | |||
2551 | err = p54_register_led(dev, 0, "assoc", | ||
2552 | ieee80211_get_assoc_led_name(dev)); | ||
2553 | if (err) | ||
2554 | return err; | ||
2555 | |||
2556 | err = p54_register_led(dev, 1, "tx", | ||
2557 | ieee80211_get_tx_led_name(dev)); | ||
2558 | if (err) | ||
2559 | return err; | ||
2560 | |||
2561 | err = p54_register_led(dev, 2, "rx", | ||
2562 | ieee80211_get_rx_led_name(dev)); | ||
2563 | if (err) | ||
2564 | return err; | ||
2565 | |||
2566 | err = p54_register_led(dev, 3, "radio", | ||
2567 | ieee80211_get_radio_led_name(dev)); | ||
2568 | if (err) | ||
2569 | return err; | ||
2570 | |||
2571 | err = p54_set_leds(dev); | ||
2572 | return err; | ||
2573 | } | ||
2574 | |||
2575 | static void p54_unregister_leds(struct ieee80211_hw *dev) | ||
2576 | { | ||
2577 | struct p54_common *priv = dev->priv; | ||
2578 | int i; | ||
2579 | |||
2580 | for (i = 0; i < ARRAY_SIZE(priv->leds); i++) | ||
2581 | if (priv->leds[i].registered) | ||
2582 | led_classdev_unregister(&priv->leds[i].led_dev); | ||
2583 | } | ||
2584 | #endif /* CONFIG_P54_LEDS */ | ||
2585 | |||
2586 | static const struct ieee80211_ops p54_ops = { | ||
2587 | .tx = p54_tx, | ||
2588 | .start = p54_start, | ||
2589 | .stop = p54_stop, | ||
2590 | .add_interface = p54_add_interface, | ||
2591 | .remove_interface = p54_remove_interface, | ||
2592 | .set_tim = p54_set_tim, | ||
2593 | .sta_notify = p54_sta_notify, | ||
2594 | .set_key = p54_set_key, | ||
2595 | .config = p54_config, | ||
2596 | .bss_info_changed = p54_bss_info_changed, | ||
2597 | .configure_filter = p54_configure_filter, | ||
2598 | .conf_tx = p54_conf_tx, | ||
2599 | .get_stats = p54_get_stats, | ||
2600 | .get_tx_stats = p54_get_tx_stats | ||
2601 | }; | ||
2602 | |||
2603 | struct ieee80211_hw *p54_init_common(size_t priv_data_len) | ||
2604 | { | ||
2605 | struct ieee80211_hw *dev; | ||
2606 | struct p54_common *priv; | ||
2607 | |||
2608 | dev = ieee80211_alloc_hw(priv_data_len, &p54_ops); | ||
2609 | if (!dev) | ||
2610 | return NULL; | ||
2611 | |||
2612 | priv = dev->priv; | ||
2613 | priv->hw = dev; | ||
2614 | priv->mode = NL80211_IFTYPE_UNSPECIFIED; | ||
2615 | priv->basic_rate_mask = 0x15f; | ||
2616 | skb_queue_head_init(&priv->tx_queue); | ||
2617 | dev->flags = IEEE80211_HW_RX_INCLUDES_FCS | | ||
2618 | IEEE80211_HW_SIGNAL_DBM | | ||
2619 | IEEE80211_HW_NOISE_DBM; | ||
2620 | |||
2621 | dev->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION) | | ||
2622 | BIT(NL80211_IFTYPE_ADHOC) | | ||
2623 | BIT(NL80211_IFTYPE_AP) | | ||
2624 | BIT(NL80211_IFTYPE_MESH_POINT); | ||
2625 | |||
2626 | dev->channel_change_time = 1000; /* TODO: find actual value */ | ||
2627 | priv->tx_stats[P54_QUEUE_BEACON].limit = 1; | ||
2628 | priv->tx_stats[P54_QUEUE_FWSCAN].limit = 1; | ||
2629 | priv->tx_stats[P54_QUEUE_MGMT].limit = 3; | ||
2630 | priv->tx_stats[P54_QUEUE_CAB].limit = 3; | ||
2631 | priv->tx_stats[P54_QUEUE_DATA].limit = 5; | ||
2632 | dev->queues = 1; | ||
2633 | priv->noise = -94; | ||
2634 | /* | ||
2635 | * We support at most 8 tries no matter which rate they're at, | ||
2636 | * we cannot support max_rates * max_rate_tries as we set it | ||
2637 | * here, but setting it correctly to 4/2 or so would limit us | ||
2638 | * artificially if the RC algorithm wants just two rates, so | ||
2639 | * let's say 4/7, we'll redistribute it at TX time, see the | ||
2640 | * comments there. | ||
2641 | */ | ||
2642 | dev->max_rates = 4; | ||
2643 | dev->max_rate_tries = 7; | ||
2644 | dev->extra_tx_headroom = sizeof(struct p54_hdr) + 4 + | ||
2645 | sizeof(struct p54_tx_data); | ||
2646 | |||
2647 | mutex_init(&priv->conf_mutex); | ||
2648 | init_completion(&priv->eeprom_comp); | ||
2649 | INIT_DELAYED_WORK(&priv->work, p54_work); | ||
2650 | |||
2651 | return dev; | ||
2652 | } | ||
2653 | EXPORT_SYMBOL_GPL(p54_init_common); | ||
2654 | |||
2655 | int p54_register_common(struct ieee80211_hw *dev, struct device *pdev) | ||
2656 | { | ||
2657 | int err; | ||
2658 | |||
2659 | err = ieee80211_register_hw(dev); | ||
2660 | if (err) { | ||
2661 | dev_err(pdev, "Cannot register device (%d).\n", err); | ||
2662 | return err; | ||
2663 | } | ||
2664 | |||
2665 | #ifdef CONFIG_P54_LEDS | ||
2666 | err = p54_init_leds(dev); | ||
2667 | if (err) | ||
2668 | return err; | ||
2669 | #endif /* CONFIG_P54_LEDS */ | ||
2670 | |||
2671 | dev_info(pdev, "is registered as '%s'\n", wiphy_name(dev->wiphy)); | ||
2672 | return 0; | ||
2673 | } | ||
2674 | EXPORT_SYMBOL_GPL(p54_register_common); | ||
2675 | |||
2676 | void p54_free_common(struct ieee80211_hw *dev) | ||
2677 | { | ||
2678 | struct p54_common *priv = dev->priv; | ||
2679 | kfree(priv->iq_autocal); | ||
2680 | kfree(priv->output_limit); | ||
2681 | kfree(priv->curve_data); | ||
2682 | kfree(priv->used_rxkeys); | ||
2683 | |||
2684 | #ifdef CONFIG_P54_LEDS | ||
2685 | p54_unregister_leds(dev); | ||
2686 | #endif /* CONFIG_P54_LEDS */ | ||
2687 | } | ||
2688 | EXPORT_SYMBOL_GPL(p54_free_common); | ||
diff --git a/drivers/net/wireless/p54/p54common.h b/drivers/net/wireless/p54/p54common.h deleted file mode 100644 index 75ead7a150fc..000000000000 --- a/drivers/net/wireless/p54/p54common.h +++ /dev/null | |||
@@ -1,644 +0,0 @@ | |||
1 | #ifndef P54COMMON_H | ||
2 | #define P54COMMON_H | ||
3 | |||
4 | /* | ||
5 | * Common code specific definitions for mac80211 Prism54 drivers | ||
6 | * | ||
7 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
8 | * Copyright (c) 2007, Christian Lamparter <chunkeey@web.de> | ||
9 | * | ||
10 | * Based on: | ||
11 | * - the islsm (softmac prism54) driver, which is: | ||
12 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
13 | * | ||
14 | * - LMAC API interface header file for STLC4560 (lmac_longbow.h) | ||
15 | * Copyright (C) 2007 Conexant Systems, Inc. | ||
16 | * | ||
17 | * This program is free software; you can redistribute it and/or modify | ||
18 | * it under the terms of the GNU General Public License version 2 as | ||
19 | * published by the Free Software Foundation. | ||
20 | */ | ||
21 | |||
22 | struct bootrec { | ||
23 | __le32 code; | ||
24 | __le32 len; | ||
25 | u32 data[10]; | ||
26 | } __attribute__((packed)); | ||
27 | |||
28 | #define PDR_SYNTH_FRONTEND_MASK 0x0007 | ||
29 | #define PDR_SYNTH_FRONTEND_DUETTE3 0x0001 | ||
30 | #define PDR_SYNTH_FRONTEND_DUETTE2 0x0002 | ||
31 | #define PDR_SYNTH_FRONTEND_FRISBEE 0x0003 | ||
32 | #define PDR_SYNTH_FRONTEND_XBOW 0x0004 | ||
33 | #define PDR_SYNTH_FRONTEND_LONGBOW 0x0005 | ||
34 | #define PDR_SYNTH_IQ_CAL_MASK 0x0018 | ||
35 | #define PDR_SYNTH_IQ_CAL_PA_DETECTOR 0x0000 | ||
36 | #define PDR_SYNTH_IQ_CAL_DISABLED 0x0008 | ||
37 | #define PDR_SYNTH_IQ_CAL_ZIF 0x0010 | ||
38 | #define PDR_SYNTH_FAA_SWITCH_MASK 0x0020 | ||
39 | #define PDR_SYNTH_FAA_SWITCH_ENABLED 0x0020 | ||
40 | #define PDR_SYNTH_24_GHZ_MASK 0x0040 | ||
41 | #define PDR_SYNTH_24_GHZ_DISABLED 0x0040 | ||
42 | #define PDR_SYNTH_5_GHZ_MASK 0x0080 | ||
43 | #define PDR_SYNTH_5_GHZ_DISABLED 0x0080 | ||
44 | #define PDR_SYNTH_RX_DIV_MASK 0x0100 | ||
45 | #define PDR_SYNTH_RX_DIV_SUPPORTED 0x0100 | ||
46 | #define PDR_SYNTH_TX_DIV_MASK 0x0200 | ||
47 | #define PDR_SYNTH_TX_DIV_SUPPORTED 0x0200 | ||
48 | |||
49 | struct bootrec_exp_if { | ||
50 | __le16 role; | ||
51 | __le16 if_id; | ||
52 | __le16 variant; | ||
53 | __le16 btm_compat; | ||
54 | __le16 top_compat; | ||
55 | } __attribute__((packed)); | ||
56 | |||
57 | #define BR_DESC_PRIV_CAP_WEP BIT(0) | ||
58 | #define BR_DESC_PRIV_CAP_TKIP BIT(1) | ||
59 | #define BR_DESC_PRIV_CAP_MICHAEL BIT(2) | ||
60 | #define BR_DESC_PRIV_CAP_CCX_CP BIT(3) | ||
61 | #define BR_DESC_PRIV_CAP_CCX_MIC BIT(4) | ||
62 | #define BR_DESC_PRIV_CAP_AESCCMP BIT(5) | ||
63 | |||
64 | struct bootrec_desc { | ||
65 | __le16 modes; | ||
66 | __le16 flags; | ||
67 | __le32 rx_start; | ||
68 | __le32 rx_end; | ||
69 | u8 headroom; | ||
70 | u8 tailroom; | ||
71 | u8 tx_queues; | ||
72 | u8 tx_depth; | ||
73 | u8 privacy_caps; | ||
74 | u8 rx_keycache_size; | ||
75 | u8 time_size; | ||
76 | u8 padding; | ||
77 | u8 rates[16]; | ||
78 | u8 padding2[4]; | ||
79 | __le16 rx_mtu; | ||
80 | } __attribute__((packed)); | ||
81 | |||
82 | #define BR_CODE_MIN 0x80000000 | ||
83 | #define BR_CODE_COMPONENT_ID 0x80000001 | ||
84 | #define BR_CODE_COMPONENT_VERSION 0x80000002 | ||
85 | #define BR_CODE_DEPENDENT_IF 0x80000003 | ||
86 | #define BR_CODE_EXPOSED_IF 0x80000004 | ||
87 | #define BR_CODE_DESCR 0x80000101 | ||
88 | #define BR_CODE_MAX 0x8FFFFFFF | ||
89 | #define BR_CODE_END_OF_BRA 0xFF0000FF | ||
90 | #define LEGACY_BR_CODE_END_OF_BRA 0xFFFFFFFF | ||
91 | |||
92 | #define P54_HDR_FLAG_DATA_ALIGN BIT(14) | ||
93 | #define P54_HDR_FLAG_DATA_OUT_PROMISC BIT(0) | ||
94 | #define P54_HDR_FLAG_DATA_OUT_TIMESTAMP BIT(1) | ||
95 | #define P54_HDR_FLAG_DATA_OUT_SEQNR BIT(2) | ||
96 | #define P54_HDR_FLAG_DATA_OUT_BIT3 BIT(3) | ||
97 | #define P54_HDR_FLAG_DATA_OUT_BURST BIT(4) | ||
98 | #define P54_HDR_FLAG_DATA_OUT_NOCANCEL BIT(5) | ||
99 | #define P54_HDR_FLAG_DATA_OUT_CLEARTIM BIT(6) | ||
100 | #define P54_HDR_FLAG_DATA_OUT_HITCHHIKE BIT(7) | ||
101 | #define P54_HDR_FLAG_DATA_OUT_COMPRESS BIT(8) | ||
102 | #define P54_HDR_FLAG_DATA_OUT_CONCAT BIT(9) | ||
103 | #define P54_HDR_FLAG_DATA_OUT_PCS_ACCEPT BIT(10) | ||
104 | #define P54_HDR_FLAG_DATA_OUT_WAITEOSP BIT(11) | ||
105 | |||
106 | #define P54_HDR_FLAG_DATA_IN_FCS_GOOD BIT(0) | ||
107 | #define P54_HDR_FLAG_DATA_IN_MATCH_MAC BIT(1) | ||
108 | #define P54_HDR_FLAG_DATA_IN_MCBC BIT(2) | ||
109 | #define P54_HDR_FLAG_DATA_IN_BEACON BIT(3) | ||
110 | #define P54_HDR_FLAG_DATA_IN_MATCH_BSS BIT(4) | ||
111 | #define P54_HDR_FLAG_DATA_IN_BCAST_BSS BIT(5) | ||
112 | #define P54_HDR_FLAG_DATA_IN_DATA BIT(6) | ||
113 | #define P54_HDR_FLAG_DATA_IN_TRUNCATED BIT(7) | ||
114 | #define P54_HDR_FLAG_DATA_IN_BIT8 BIT(8) | ||
115 | #define P54_HDR_FLAG_DATA_IN_TRANSPARENT BIT(9) | ||
116 | |||
117 | /* PDA defines are Copyright (C) 2005 Nokia Corporation (taken from islsm_pda.h) */ | ||
118 | |||
119 | struct pda_entry { | ||
120 | __le16 len; /* includes both code and data */ | ||
121 | __le16 code; | ||
122 | u8 data[0]; | ||
123 | } __attribute__ ((packed)); | ||
124 | |||
125 | struct eeprom_pda_wrap { | ||
126 | __le32 magic; | ||
127 | __le16 pad; | ||
128 | __le16 len; | ||
129 | __le32 arm_opcode; | ||
130 | u8 data[0]; | ||
131 | } __attribute__ ((packed)); | ||
132 | |||
133 | struct p54_iq_autocal_entry { | ||
134 | __le16 iq_param[4]; | ||
135 | } __attribute__ ((packed)); | ||
136 | |||
137 | struct pda_iq_autocal_entry { | ||
138 | __le16 freq; | ||
139 | struct p54_iq_autocal_entry params; | ||
140 | } __attribute__ ((packed)); | ||
141 | |||
142 | struct pda_channel_output_limit { | ||
143 | __le16 freq; | ||
144 | u8 val_bpsk; | ||
145 | u8 val_qpsk; | ||
146 | u8 val_16qam; | ||
147 | u8 val_64qam; | ||
148 | u8 rate_set_mask; | ||
149 | u8 rate_set_size; | ||
150 | } __attribute__ ((packed)); | ||
151 | |||
152 | struct pda_pa_curve_data_sample_rev0 { | ||
153 | u8 rf_power; | ||
154 | u8 pa_detector; | ||
155 | u8 pcv; | ||
156 | } __attribute__ ((packed)); | ||
157 | |||
158 | struct pda_pa_curve_data_sample_rev1 { | ||
159 | u8 rf_power; | ||
160 | u8 pa_detector; | ||
161 | u8 data_barker; | ||
162 | u8 data_bpsk; | ||
163 | u8 data_qpsk; | ||
164 | u8 data_16qam; | ||
165 | u8 data_64qam; | ||
166 | } __attribute__ ((packed)); | ||
167 | |||
168 | struct p54_pa_curve_data_sample { | ||
169 | u8 rf_power; | ||
170 | u8 pa_detector; | ||
171 | u8 data_barker; | ||
172 | u8 data_bpsk; | ||
173 | u8 data_qpsk; | ||
174 | u8 data_16qam; | ||
175 | u8 data_64qam; | ||
176 | u8 padding; | ||
177 | } __attribute__ ((packed)); | ||
178 | |||
179 | struct pda_pa_curve_data { | ||
180 | u8 cal_method_rev; | ||
181 | u8 channels; | ||
182 | u8 points_per_channel; | ||
183 | u8 padding; | ||
184 | u8 data[0]; | ||
185 | } __attribute__ ((packed)); | ||
186 | |||
187 | struct pda_rssi_cal_entry { | ||
188 | __le16 mul; | ||
189 | __le16 add; | ||
190 | } __attribute__ ((packed)); | ||
191 | |||
192 | struct pda_country { | ||
193 | u8 regdomain; | ||
194 | u8 alpha2[2]; | ||
195 | u8 flags; | ||
196 | } __attribute__ ((packed)); | ||
197 | |||
198 | /* | ||
199 | * Warning: Longbow's structures are bogus. | ||
200 | */ | ||
201 | struct p54_channel_output_limit_longbow { | ||
202 | __le16 rf_power_points[12]; | ||
203 | } __attribute__ ((packed)); | ||
204 | |||
205 | struct p54_pa_curve_data_sample_longbow { | ||
206 | __le16 rf_power; | ||
207 | __le16 pa_detector; | ||
208 | struct { | ||
209 | __le16 data[4]; | ||
210 | } points[3] __attribute__ ((packed)); | ||
211 | } __attribute__ ((packed)); | ||
212 | |||
213 | struct pda_custom_wrapper { | ||
214 | __le16 entries; | ||
215 | __le16 entry_size; | ||
216 | __le16 offset; | ||
217 | __le16 len; | ||
218 | u8 data[0]; | ||
219 | } __attribute__ ((packed)); | ||
220 | |||
221 | /* | ||
222 | * this defines the PDR codes used to build PDAs as defined in document | ||
223 | * number 553155. The current implementation mirrors version 1.1 of the | ||
224 | * document and lists only PDRs supported by the ARM platform. | ||
225 | */ | ||
226 | |||
227 | /* common and choice range (0x0000 - 0x0fff) */ | ||
228 | #define PDR_END 0x0000 | ||
229 | #define PDR_MANUFACTURING_PART_NUMBER 0x0001 | ||
230 | #define PDR_PDA_VERSION 0x0002 | ||
231 | #define PDR_NIC_SERIAL_NUMBER 0x0003 | ||
232 | |||
233 | #define PDR_MAC_ADDRESS 0x0101 | ||
234 | #define PDR_REGULATORY_DOMAIN_LIST 0x0103 | ||
235 | #define PDR_TEMPERATURE_TYPE 0x0107 | ||
236 | |||
237 | #define PDR_PRISM_PCI_IDENTIFIER 0x0402 | ||
238 | |||
239 | /* ARM range (0x1000 - 0x1fff) */ | ||
240 | #define PDR_COUNTRY_INFORMATION 0x1000 | ||
241 | #define PDR_INTERFACE_LIST 0x1001 | ||
242 | #define PDR_HARDWARE_PLATFORM_COMPONENT_ID 0x1002 | ||
243 | #define PDR_OEM_NAME 0x1003 | ||
244 | #define PDR_PRODUCT_NAME 0x1004 | ||
245 | #define PDR_UTF8_OEM_NAME 0x1005 | ||
246 | #define PDR_UTF8_PRODUCT_NAME 0x1006 | ||
247 | #define PDR_COUNTRY_LIST 0x1007 | ||
248 | #define PDR_DEFAULT_COUNTRY 0x1008 | ||
249 | |||
250 | #define PDR_ANTENNA_GAIN 0x1100 | ||
251 | |||
252 | #define PDR_PRISM_INDIGO_PA_CALIBRATION_DATA 0x1901 | ||
253 | #define PDR_RSSI_LINEAR_APPROXIMATION 0x1902 | ||
254 | #define PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS 0x1903 | ||
255 | #define PDR_PRISM_PA_CAL_CURVE_DATA 0x1904 | ||
256 | #define PDR_RSSI_LINEAR_APPROXIMATION_DUAL_BAND 0x1905 | ||
257 | #define PDR_PRISM_ZIF_TX_IQ_CALIBRATION 0x1906 | ||
258 | #define PDR_REGULATORY_POWER_LIMITS 0x1907 | ||
259 | #define PDR_RSSI_LINEAR_APPROXIMATION_EXTENDED 0x1908 | ||
260 | #define PDR_RADIATED_TRANSMISSION_CORRECTION 0x1909 | ||
261 | #define PDR_PRISM_TX_IQ_CALIBRATION 0x190a | ||
262 | |||
263 | /* reserved range (0x2000 - 0x7fff) */ | ||
264 | |||
265 | /* customer range (0x8000 - 0xffff) */ | ||
266 | #define PDR_BASEBAND_REGISTERS 0x8000 | ||
267 | #define PDR_PER_CHANNEL_BASEBAND_REGISTERS 0x8001 | ||
268 | |||
269 | /* used by our modificated eeprom image */ | ||
270 | #define PDR_RSSI_LINEAR_APPROXIMATION_CUSTOM 0xDEAD | ||
271 | #define PDR_PRISM_PA_CAL_OUTPUT_POWER_LIMITS_CUSTOM 0xBEEF | ||
272 | #define PDR_PRISM_PA_CAL_CURVE_DATA_CUSTOM 0xB05D | ||
273 | |||
274 | /* PDR definitions for default country & country list */ | ||
275 | #define PDR_COUNTRY_CERT_CODE 0x80 | ||
276 | #define PDR_COUNTRY_CERT_CODE_REAL 0x00 | ||
277 | #define PDR_COUNTRY_CERT_CODE_PSEUDO 0x80 | ||
278 | #define PDR_COUNTRY_CERT_BAND 0x40 | ||
279 | #define PDR_COUNTRY_CERT_BAND_2GHZ 0x00 | ||
280 | #define PDR_COUNTRY_CERT_BAND_5GHZ 0x40 | ||
281 | #define PDR_COUNTRY_CERT_IODOOR 0x30 | ||
282 | #define PDR_COUNTRY_CERT_IODOOR_BOTH 0x00 | ||
283 | #define PDR_COUNTRY_CERT_IODOOR_INDOOR 0x20 | ||
284 | #define PDR_COUNTRY_CERT_IODOOR_OUTDOOR 0x30 | ||
285 | #define PDR_COUNTRY_CERT_INDEX 0x0F | ||
286 | |||
287 | struct p54_eeprom_lm86 { | ||
288 | union { | ||
289 | struct { | ||
290 | __le16 offset; | ||
291 | __le16 len; | ||
292 | u8 data[0]; | ||
293 | } v1; | ||
294 | struct { | ||
295 | __le32 offset; | ||
296 | __le16 len; | ||
297 | u8 magic2; | ||
298 | u8 pad; | ||
299 | u8 magic[4]; | ||
300 | u8 data[0]; | ||
301 | } v2; | ||
302 | } __attribute__ ((packed)); | ||
303 | } __attribute__ ((packed)); | ||
304 | |||
305 | enum p54_rx_decrypt_status { | ||
306 | P54_DECRYPT_NONE = 0, | ||
307 | P54_DECRYPT_OK, | ||
308 | P54_DECRYPT_NOKEY, | ||
309 | P54_DECRYPT_NOMICHAEL, | ||
310 | P54_DECRYPT_NOCKIPMIC, | ||
311 | P54_DECRYPT_FAIL_WEP, | ||
312 | P54_DECRYPT_FAIL_TKIP, | ||
313 | P54_DECRYPT_FAIL_MICHAEL, | ||
314 | P54_DECRYPT_FAIL_CKIPKP, | ||
315 | P54_DECRYPT_FAIL_CKIPMIC, | ||
316 | P54_DECRYPT_FAIL_AESCCMP | ||
317 | }; | ||
318 | |||
319 | struct p54_rx_data { | ||
320 | __le16 flags; | ||
321 | __le16 len; | ||
322 | __le16 freq; | ||
323 | u8 antenna; | ||
324 | u8 rate; | ||
325 | u8 rssi; | ||
326 | u8 quality; | ||
327 | u8 decrypt_status; | ||
328 | u8 rssi_raw; | ||
329 | __le32 tsf32; | ||
330 | __le32 unalloc0; | ||
331 | u8 align[0]; | ||
332 | } __attribute__ ((packed)); | ||
333 | |||
334 | enum p54_trap_type { | ||
335 | P54_TRAP_SCAN = 0, | ||
336 | P54_TRAP_TIMER, | ||
337 | P54_TRAP_BEACON_TX, | ||
338 | P54_TRAP_FAA_RADIO_ON, | ||
339 | P54_TRAP_FAA_RADIO_OFF, | ||
340 | P54_TRAP_RADAR, | ||
341 | P54_TRAP_NO_BEACON, | ||
342 | P54_TRAP_TBTT, | ||
343 | P54_TRAP_SCO_ENTER, | ||
344 | P54_TRAP_SCO_EXIT | ||
345 | }; | ||
346 | |||
347 | struct p54_trap { | ||
348 | __le16 event; | ||
349 | __le16 frequency; | ||
350 | } __attribute__ ((packed)); | ||
351 | |||
352 | enum p54_frame_sent_status { | ||
353 | P54_TX_OK = 0, | ||
354 | P54_TX_FAILED, | ||
355 | P54_TX_PSM, | ||
356 | P54_TX_PSM_CANCELLED = 4 | ||
357 | }; | ||
358 | |||
359 | struct p54_frame_sent { | ||
360 | u8 status; | ||
361 | u8 tries; | ||
362 | u8 ack_rssi; | ||
363 | u8 quality; | ||
364 | __le16 seq; | ||
365 | u8 antenna; | ||
366 | u8 padding; | ||
367 | } __attribute__ ((packed)); | ||
368 | |||
369 | enum p54_tx_data_crypt { | ||
370 | P54_CRYPTO_NONE = 0, | ||
371 | P54_CRYPTO_WEP, | ||
372 | P54_CRYPTO_TKIP, | ||
373 | P54_CRYPTO_TKIPMICHAEL, | ||
374 | P54_CRYPTO_CCX_WEPMIC, | ||
375 | P54_CRYPTO_CCX_KPMIC, | ||
376 | P54_CRYPTO_CCX_KP, | ||
377 | P54_CRYPTO_AESCCMP | ||
378 | }; | ||
379 | |||
380 | enum p54_tx_data_queue { | ||
381 | P54_QUEUE_BEACON = 0, | ||
382 | P54_QUEUE_FWSCAN = 1, | ||
383 | P54_QUEUE_MGMT = 2, | ||
384 | P54_QUEUE_CAB = 3, | ||
385 | P54_QUEUE_DATA = 4, | ||
386 | |||
387 | P54_QUEUE_AC_NUM = 4, | ||
388 | P54_QUEUE_AC_VO = 4, | ||
389 | P54_QUEUE_AC_VI = 5, | ||
390 | P54_QUEUE_AC_BE = 6, | ||
391 | P54_QUEUE_AC_BK = 7, | ||
392 | |||
393 | /* keep last */ | ||
394 | P54_QUEUE_NUM = 8, | ||
395 | }; | ||
396 | |||
397 | struct p54_tx_data { | ||
398 | u8 rateset[8]; | ||
399 | u8 rts_rate_idx; | ||
400 | u8 crypt_offset; | ||
401 | u8 key_type; | ||
402 | u8 key_len; | ||
403 | u8 key[16]; | ||
404 | u8 hw_queue; | ||
405 | u8 backlog; | ||
406 | __le16 durations[4]; | ||
407 | u8 tx_antenna; | ||
408 | union { | ||
409 | struct { | ||
410 | u8 cts_rate; | ||
411 | __le16 output_power; | ||
412 | } __attribute__((packed)) longbow; | ||
413 | struct { | ||
414 | u8 output_power; | ||
415 | u8 cts_rate; | ||
416 | u8 unalloc; | ||
417 | } __attribute__ ((packed)) normal; | ||
418 | } __attribute__ ((packed)); | ||
419 | u8 unalloc2[2]; | ||
420 | u8 align[0]; | ||
421 | } __attribute__ ((packed)); | ||
422 | |||
423 | /* unit is ms */ | ||
424 | #define P54_TX_FRAME_LIFETIME 2000 | ||
425 | #define P54_TX_TIMEOUT 4000 | ||
426 | #define P54_STATISTICS_UPDATE 5000 | ||
427 | |||
428 | #define P54_FILTER_TYPE_NONE 0 | ||
429 | #define P54_FILTER_TYPE_STATION BIT(0) | ||
430 | #define P54_FILTER_TYPE_IBSS BIT(1) | ||
431 | #define P54_FILTER_TYPE_AP BIT(2) | ||
432 | #define P54_FILTER_TYPE_TRANSPARENT BIT(3) | ||
433 | #define P54_FILTER_TYPE_PROMISCUOUS BIT(4) | ||
434 | #define P54_FILTER_TYPE_HIBERNATE BIT(5) | ||
435 | #define P54_FILTER_TYPE_NOACK BIT(6) | ||
436 | #define P54_FILTER_TYPE_RX_DISABLED BIT(7) | ||
437 | |||
438 | struct p54_setup_mac { | ||
439 | __le16 mac_mode; | ||
440 | u8 mac_addr[ETH_ALEN]; | ||
441 | u8 bssid[ETH_ALEN]; | ||
442 | u8 rx_antenna; | ||
443 | u8 rx_align; | ||
444 | union { | ||
445 | struct { | ||
446 | __le32 basic_rate_mask; | ||
447 | u8 rts_rates[8]; | ||
448 | __le32 rx_addr; | ||
449 | __le16 max_rx; | ||
450 | __le16 rxhw; | ||
451 | __le16 wakeup_timer; | ||
452 | __le16 unalloc0; | ||
453 | } v1 __attribute__ ((packed)); | ||
454 | struct { | ||
455 | __le32 rx_addr; | ||
456 | __le16 max_rx; | ||
457 | __le16 rxhw; | ||
458 | __le16 timer; | ||
459 | __le16 truncate; | ||
460 | __le32 basic_rate_mask; | ||
461 | u8 sbss_offset; | ||
462 | u8 mcast_window; | ||
463 | u8 rx_rssi_threshold; | ||
464 | u8 rx_ed_threshold; | ||
465 | __le32 ref_clock; | ||
466 | __le16 lpf_bandwidth; | ||
467 | __le16 osc_start_delay; | ||
468 | } v2 __attribute__ ((packed)); | ||
469 | } __attribute__ ((packed)); | ||
470 | } __attribute__ ((packed)); | ||
471 | |||
472 | #define P54_SETUP_V1_LEN 40 | ||
473 | #define P54_SETUP_V2_LEN (sizeof(struct p54_setup_mac)) | ||
474 | |||
475 | #define P54_SCAN_EXIT BIT(0) | ||
476 | #define P54_SCAN_TRAP BIT(1) | ||
477 | #define P54_SCAN_ACTIVE BIT(2) | ||
478 | #define P54_SCAN_FILTER BIT(3) | ||
479 | |||
480 | struct p54_scan_head { | ||
481 | __le16 mode; | ||
482 | __le16 dwell; | ||
483 | u8 scan_params[20]; | ||
484 | __le16 freq; | ||
485 | } __attribute__ ((packed)); | ||
486 | |||
487 | struct p54_scan_body { | ||
488 | u8 pa_points_per_curve; | ||
489 | u8 val_barker; | ||
490 | u8 val_bpsk; | ||
491 | u8 val_qpsk; | ||
492 | u8 val_16qam; | ||
493 | u8 val_64qam; | ||
494 | struct p54_pa_curve_data_sample curve_data[8]; | ||
495 | u8 dup_bpsk; | ||
496 | u8 dup_qpsk; | ||
497 | u8 dup_16qam; | ||
498 | u8 dup_64qam; | ||
499 | } __attribute__ ((packed)); | ||
500 | |||
501 | struct p54_scan_body_longbow { | ||
502 | struct p54_channel_output_limit_longbow power_limits; | ||
503 | struct p54_pa_curve_data_sample_longbow curve_data[8]; | ||
504 | __le16 unkn[6]; /* maybe more power_limits or rate_mask */ | ||
505 | } __attribute__ ((packed)); | ||
506 | |||
507 | union p54_scan_body_union { | ||
508 | struct p54_scan_body normal; | ||
509 | struct p54_scan_body_longbow longbow; | ||
510 | } __attribute__ ((packed)); | ||
511 | |||
512 | struct p54_scan_tail_rate { | ||
513 | __le32 basic_rate_mask; | ||
514 | u8 rts_rates[8]; | ||
515 | } __attribute__ ((packed)); | ||
516 | |||
517 | struct p54_led { | ||
518 | __le16 flags; | ||
519 | __le16 mask[2]; | ||
520 | __le16 delay[2]; | ||
521 | } __attribute__ ((packed)); | ||
522 | |||
523 | struct p54_edcf { | ||
524 | u8 flags; | ||
525 | u8 slottime; | ||
526 | u8 sifs; | ||
527 | u8 eofpad; | ||
528 | struct p54_edcf_queue_param queue[8]; | ||
529 | u8 mapping[4]; | ||
530 | __le16 frameburst; | ||
531 | __le16 round_trip_delay; | ||
532 | } __attribute__ ((packed)); | ||
533 | |||
534 | struct p54_statistics { | ||
535 | __le32 rx_success; | ||
536 | __le32 rx_bad_fcs; | ||
537 | __le32 rx_abort; | ||
538 | __le32 rx_abort_phy; | ||
539 | __le32 rts_success; | ||
540 | __le32 rts_fail; | ||
541 | __le32 tsf32; | ||
542 | __le32 airtime; | ||
543 | __le32 noise; | ||
544 | __le32 sample_noise[8]; | ||
545 | __le32 sample_cca; | ||
546 | __le32 sample_tx; | ||
547 | } __attribute__ ((packed)); | ||
548 | |||
549 | struct p54_xbow_synth { | ||
550 | __le16 magic1; | ||
551 | __le16 magic2; | ||
552 | __le16 freq; | ||
553 | u32 padding[5]; | ||
554 | } __attribute__ ((packed)); | ||
555 | |||
556 | struct p54_timer { | ||
557 | __le32 interval; | ||
558 | } __attribute__ ((packed)); | ||
559 | |||
560 | struct p54_keycache { | ||
561 | u8 entry; | ||
562 | u8 key_id; | ||
563 | u8 mac[ETH_ALEN]; | ||
564 | u8 padding[2]; | ||
565 | u8 key_type; | ||
566 | u8 key_len; | ||
567 | u8 key[24]; | ||
568 | } __attribute__ ((packed)); | ||
569 | |||
570 | struct p54_burst { | ||
571 | u8 flags; | ||
572 | u8 queue; | ||
573 | u8 backlog; | ||
574 | u8 pad; | ||
575 | __le16 durations[32]; | ||
576 | } __attribute__ ((packed)); | ||
577 | |||
578 | struct p54_psm_interval { | ||
579 | __le16 interval; | ||
580 | __le16 periods; | ||
581 | } __attribute__ ((packed)); | ||
582 | |||
583 | #define P54_PSM_CAM 0 | ||
584 | #define P54_PSM BIT(0) | ||
585 | #define P54_PSM_DTIM BIT(1) | ||
586 | #define P54_PSM_MCBC BIT(2) | ||
587 | #define P54_PSM_CHECKSUM BIT(3) | ||
588 | #define P54_PSM_SKIP_MORE_DATA BIT(4) | ||
589 | #define P54_PSM_BEACON_TIMEOUT BIT(5) | ||
590 | #define P54_PSM_HFOSLEEP BIT(6) | ||
591 | #define P54_PSM_AUTOSWITCH_SLEEP BIT(7) | ||
592 | #define P54_PSM_LPIT BIT(8) | ||
593 | #define P54_PSM_BF_UCAST_SKIP BIT(9) | ||
594 | #define P54_PSM_BF_MCAST_SKIP BIT(10) | ||
595 | |||
596 | struct p54_psm { | ||
597 | __le16 mode; | ||
598 | __le16 aid; | ||
599 | struct p54_psm_interval intervals[4]; | ||
600 | u8 beacon_rssi_skip_max; | ||
601 | u8 rssi_delta_threshold; | ||
602 | u8 nr; | ||
603 | u8 exclude[1]; | ||
604 | } __attribute__ ((packed)); | ||
605 | |||
606 | #define MC_FILTER_ADDRESS_NUM 4 | ||
607 | |||
608 | struct p54_group_address_table { | ||
609 | __le16 filter_enable; | ||
610 | __le16 num_address; | ||
611 | u8 mac_list[MC_FILTER_ADDRESS_NUM][ETH_ALEN]; | ||
612 | } __attribute__ ((packed)); | ||
613 | |||
614 | struct p54_txcancel { | ||
615 | __le32 req_id; | ||
616 | } __attribute__ ((packed)); | ||
617 | |||
618 | struct p54_sta_unlock { | ||
619 | u8 addr[ETH_ALEN]; | ||
620 | u16 padding; | ||
621 | } __attribute__ ((packed)); | ||
622 | |||
623 | #define P54_TIM_CLEAR BIT(15) | ||
624 | struct p54_tim { | ||
625 | u8 count; | ||
626 | u8 padding[3]; | ||
627 | __le16 entry[8]; | ||
628 | } __attribute__ ((packed)); | ||
629 | |||
630 | struct p54_cce_quiet { | ||
631 | __le32 period; | ||
632 | } __attribute__ ((packed)); | ||
633 | |||
634 | struct p54_bt_balancer { | ||
635 | __le16 prio_thresh; | ||
636 | __le16 acl_thresh; | ||
637 | } __attribute__ ((packed)); | ||
638 | |||
639 | struct p54_arp_table { | ||
640 | __le16 filter_enable; | ||
641 | u8 ipv4_addr[4]; | ||
642 | } __attribute__ ((packed)); | ||
643 | |||
644 | #endif /* P54COMMON_H */ | ||
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c index b1610ea4bb3d..d348c265e867 100644 --- a/drivers/net/wireless/p54/p54pci.c +++ b/drivers/net/wireless/p54/p54pci.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <net/mac80211.h> | 22 | #include <net/mac80211.h> |
23 | 23 | ||
24 | #include "p54.h" | 24 | #include "p54.h" |
25 | #include "lmac.h" | ||
25 | #include "p54pci.h" | 26 | #include "p54pci.h" |
26 | 27 | ||
27 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); | 28 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); |
@@ -564,7 +565,6 @@ static int __devinit p54p_probe(struct pci_dev *pdev, | |||
564 | 565 | ||
565 | err_free_common: | 566 | err_free_common: |
566 | release_firmware(priv->firmware); | 567 | release_firmware(priv->firmware); |
567 | p54_free_common(dev); | ||
568 | pci_free_consistent(pdev, sizeof(*priv->ring_control), | 568 | pci_free_consistent(pdev, sizeof(*priv->ring_control), |
569 | priv->ring_control, priv->ring_control_dma); | 569 | priv->ring_control, priv->ring_control_dma); |
570 | 570 | ||
@@ -573,7 +573,7 @@ static int __devinit p54p_probe(struct pci_dev *pdev, | |||
573 | 573 | ||
574 | err_free_dev: | 574 | err_free_dev: |
575 | pci_set_drvdata(pdev, NULL); | 575 | pci_set_drvdata(pdev, NULL); |
576 | ieee80211_free_hw(dev); | 576 | p54_free_common(dev); |
577 | 577 | ||
578 | err_free_reg: | 578 | err_free_reg: |
579 | pci_release_regions(pdev); | 579 | pci_release_regions(pdev); |
@@ -590,16 +590,15 @@ static void __devexit p54p_remove(struct pci_dev *pdev) | |||
590 | if (!dev) | 590 | if (!dev) |
591 | return; | 591 | return; |
592 | 592 | ||
593 | ieee80211_unregister_hw(dev); | 593 | p54_unregister_common(dev); |
594 | priv = dev->priv; | 594 | priv = dev->priv; |
595 | release_firmware(priv->firmware); | 595 | release_firmware(priv->firmware); |
596 | pci_free_consistent(pdev, sizeof(*priv->ring_control), | 596 | pci_free_consistent(pdev, sizeof(*priv->ring_control), |
597 | priv->ring_control, priv->ring_control_dma); | 597 | priv->ring_control, priv->ring_control_dma); |
598 | p54_free_common(dev); | ||
599 | iounmap(priv->map); | 598 | iounmap(priv->map); |
600 | pci_release_regions(pdev); | 599 | pci_release_regions(pdev); |
601 | pci_disable_device(pdev); | 600 | pci_disable_device(pdev); |
602 | ieee80211_free_hw(dev); | 601 | p54_free_common(dev); |
603 | } | 602 | } |
604 | 603 | ||
605 | #ifdef CONFIG_PM | 604 | #ifdef CONFIG_PM |
diff --git a/drivers/net/wireless/p54/p54spi.c b/drivers/net/wireless/p54/p54spi.c index 83116baeb110..d5f181ad37fc 100644 --- a/drivers/net/wireless/p54/p54spi.c +++ b/drivers/net/wireless/p54/p54spi.c | |||
@@ -34,7 +34,7 @@ | |||
34 | #include "p54spi_eeprom.h" | 34 | #include "p54spi_eeprom.h" |
35 | #include "p54.h" | 35 | #include "p54.h" |
36 | 36 | ||
37 | #include "p54common.h" | 37 | #include "lmac.h" |
38 | 38 | ||
39 | MODULE_FIRMWARE("3826.arm"); | 39 | MODULE_FIRMWARE("3826.arm"); |
40 | MODULE_ALIAS("stlc45xx"); | 40 | MODULE_ALIAS("stlc45xx"); |
@@ -111,15 +111,6 @@ static void p54spi_spi_write(struct p54s_priv *priv, u8 address, | |||
111 | spi_sync(priv->spi, &m); | 111 | spi_sync(priv->spi, &m); |
112 | } | 112 | } |
113 | 113 | ||
114 | static u16 p54spi_read16(struct p54s_priv *priv, u8 addr) | ||
115 | { | ||
116 | __le16 val; | ||
117 | |||
118 | p54spi_spi_read(priv, addr, &val, sizeof(val)); | ||
119 | |||
120 | return le16_to_cpu(val); | ||
121 | } | ||
122 | |||
123 | static u32 p54spi_read32(struct p54s_priv *priv, u8 addr) | 114 | static u32 p54spi_read32(struct p54s_priv *priv, u8 addr) |
124 | { | 115 | { |
125 | __le32 val; | 116 | __le32 val; |
@@ -139,37 +130,12 @@ static inline void p54spi_write32(struct p54s_priv *priv, u8 addr, __le32 val) | |||
139 | p54spi_spi_write(priv, addr, &val, sizeof(val)); | 130 | p54spi_spi_write(priv, addr, &val, sizeof(val)); |
140 | } | 131 | } |
141 | 132 | ||
142 | struct p54spi_spi_reg { | 133 | static int p54spi_wait_bit(struct p54s_priv *priv, u16 reg, u32 bits) |
143 | u16 address; /* __le16 ? */ | ||
144 | u16 length; | ||
145 | char *name; | ||
146 | }; | ||
147 | |||
148 | static const struct p54spi_spi_reg p54spi_registers_array[] = | ||
149 | { | ||
150 | { SPI_ADRS_ARM_INTERRUPTS, 32, "ARM_INT " }, | ||
151 | { SPI_ADRS_ARM_INT_EN, 32, "ARM_INT_ENA " }, | ||
152 | { SPI_ADRS_HOST_INTERRUPTS, 32, "HOST_INT " }, | ||
153 | { SPI_ADRS_HOST_INT_EN, 32, "HOST_INT_ENA" }, | ||
154 | { SPI_ADRS_HOST_INT_ACK, 32, "HOST_INT_ACK" }, | ||
155 | { SPI_ADRS_GEN_PURP_1, 32, "GP1_COMM " }, | ||
156 | { SPI_ADRS_GEN_PURP_2, 32, "GP2_COMM " }, | ||
157 | { SPI_ADRS_DEV_CTRL_STAT, 32, "DEV_CTRL_STA" }, | ||
158 | { SPI_ADRS_DMA_DATA, 16, "DMA_DATA " }, | ||
159 | { SPI_ADRS_DMA_WRITE_CTRL, 16, "DMA_WR_CTRL " }, | ||
160 | { SPI_ADRS_DMA_WRITE_LEN, 16, "DMA_WR_LEN " }, | ||
161 | { SPI_ADRS_DMA_WRITE_BASE, 32, "DMA_WR_BASE " }, | ||
162 | { SPI_ADRS_DMA_READ_CTRL, 16, "DMA_RD_CTRL " }, | ||
163 | { SPI_ADRS_DMA_READ_LEN, 16, "DMA_RD_LEN " }, | ||
164 | { SPI_ADRS_DMA_WRITE_BASE, 32, "DMA_RD_BASE " } | ||
165 | }; | ||
166 | |||
167 | static int p54spi_wait_bit(struct p54s_priv *priv, u16 reg, __le32 bits) | ||
168 | { | 134 | { |
169 | int i; | 135 | int i; |
170 | 136 | ||
171 | for (i = 0; i < 2000; i++) { | 137 | for (i = 0; i < 2000; i++) { |
172 | __le32 buffer = p54spi_read32(priv, reg); | 138 | u32 buffer = p54spi_read32(priv, reg); |
173 | if ((buffer & bits) == bits) | 139 | if ((buffer & bits) == bits) |
174 | return 1; | 140 | return 1; |
175 | } | 141 | } |
@@ -179,8 +145,7 @@ static int p54spi_wait_bit(struct p54s_priv *priv, u16 reg, __le32 bits) | |||
179 | static int p54spi_spi_write_dma(struct p54s_priv *priv, __le32 base, | 145 | static int p54spi_spi_write_dma(struct p54s_priv *priv, __le32 base, |
180 | const void *buf, size_t len) | 146 | const void *buf, size_t len) |
181 | { | 147 | { |
182 | if (!p54spi_wait_bit(priv, SPI_ADRS_DMA_WRITE_CTRL, | 148 | if (!p54spi_wait_bit(priv, SPI_ADRS_DMA_WRITE_CTRL, HOST_ALLOWED)) { |
183 | cpu_to_le32(HOST_ALLOWED))) { | ||
184 | dev_err(&priv->spi->dev, "spi_write_dma not allowed " | 149 | dev_err(&priv->spi->dev, "spi_write_dma not allowed " |
185 | "to DMA write.\n"); | 150 | "to DMA write.\n"); |
186 | return -EAGAIN; | 151 | return -EAGAIN; |
@@ -333,7 +298,7 @@ static int p54spi_wakeup(struct p54s_priv *priv) | |||
333 | 298 | ||
334 | /* And wait for the READY interrupt */ | 299 | /* And wait for the READY interrupt */ |
335 | if (!p54spi_wait_bit(priv, SPI_ADRS_HOST_INTERRUPTS, | 300 | if (!p54spi_wait_bit(priv, SPI_ADRS_HOST_INTERRUPTS, |
336 | cpu_to_le32(SPI_HOST_INT_READY))) { | 301 | SPI_HOST_INT_READY)) { |
337 | dev_err(&priv->spi->dev, "INT_READY timeout\n"); | 302 | dev_err(&priv->spi->dev, "INT_READY timeout\n"); |
338 | return -EBUSY; | 303 | return -EBUSY; |
339 | } | 304 | } |
@@ -444,7 +409,7 @@ static int p54spi_tx_frame(struct p54s_priv *priv, struct sk_buff *skb) | |||
444 | goto out; | 409 | goto out; |
445 | 410 | ||
446 | if (!p54spi_wait_bit(priv, SPI_ADRS_HOST_INTERRUPTS, | 411 | if (!p54spi_wait_bit(priv, SPI_ADRS_HOST_INTERRUPTS, |
447 | cpu_to_le32(SPI_HOST_INT_WR_READY))) { | 412 | SPI_HOST_INT_WR_READY)) { |
448 | dev_err(&priv->spi->dev, "WR_READY timeout\n"); | 413 | dev_err(&priv->spi->dev, "WR_READY timeout\n"); |
449 | ret = -EAGAIN; | 414 | ret = -EAGAIN; |
450 | goto out; | 415 | goto out; |
@@ -713,7 +678,7 @@ static int __devexit p54spi_remove(struct spi_device *spi) | |||
713 | { | 678 | { |
714 | struct p54s_priv *priv = dev_get_drvdata(&spi->dev); | 679 | struct p54s_priv *priv = dev_get_drvdata(&spi->dev); |
715 | 680 | ||
716 | ieee80211_unregister_hw(priv->hw); | 681 | p54_unregister_common(priv->hw); |
717 | 682 | ||
718 | free_irq(gpio_to_irq(p54spi_gpio_irq), spi); | 683 | free_irq(gpio_to_irq(p54spi_gpio_irq), spi); |
719 | 684 | ||
@@ -724,7 +689,6 @@ static int __devexit p54spi_remove(struct spi_device *spi) | |||
724 | mutex_destroy(&priv->mutex); | 689 | mutex_destroy(&priv->mutex); |
725 | 690 | ||
726 | p54_free_common(priv->hw); | 691 | p54_free_common(priv->hw); |
727 | ieee80211_free_hw(priv->hw); | ||
728 | 692 | ||
729 | return 0; | 693 | return 0; |
730 | } | 694 | } |
diff --git a/drivers/net/wireless/p54/p54usb.c b/drivers/net/wireless/p54/p54usb.c index 0e877a104a89..e44460ff149c 100644 --- a/drivers/net/wireless/p54/p54usb.c +++ b/drivers/net/wireless/p54/p54usb.c | |||
@@ -22,6 +22,7 @@ | |||
22 | #include <net/mac80211.h> | 22 | #include <net/mac80211.h> |
23 | 23 | ||
24 | #include "p54.h" | 24 | #include "p54.h" |
25 | #include "lmac.h" | ||
25 | #include "p54usb.h" | 26 | #include "p54usb.h" |
26 | 27 | ||
27 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); | 28 | MODULE_AUTHOR("Michael Wu <flamingice@sourmilk.net>"); |
@@ -245,8 +246,10 @@ static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb) | |||
245 | struct lm87_tx_hdr *hdr = (void *)skb->data - sizeof(*hdr); | 246 | struct lm87_tx_hdr *hdr = (void *)skb->data - sizeof(*hdr); |
246 | 247 | ||
247 | data_urb = usb_alloc_urb(0, GFP_ATOMIC); | 248 | data_urb = usb_alloc_urb(0, GFP_ATOMIC); |
248 | if (!data_urb) | 249 | if (!data_urb) { |
250 | p54_free_skb(dev, skb); | ||
249 | return; | 251 | return; |
252 | } | ||
250 | 253 | ||
251 | hdr->chksum = p54u_lm87_chksum((__le32 *)skb->data, skb->len); | 254 | hdr->chksum = p54u_lm87_chksum((__le32 *)skb->data, skb->len); |
252 | hdr->device_addr = ((struct p54_hdr *)skb->data)->req_id; | 255 | hdr->device_addr = ((struct p54_hdr *)skb->data)->req_id; |
@@ -268,27 +271,22 @@ static void p54u_tx_lm87(struct ieee80211_hw *dev, struct sk_buff *skb) | |||
268 | static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb) | 271 | static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb) |
269 | { | 272 | { |
270 | struct p54u_priv *priv = dev->priv; | 273 | struct p54u_priv *priv = dev->priv; |
271 | struct urb *int_urb, *data_urb; | 274 | struct urb *int_urb = NULL, *data_urb = NULL; |
272 | struct net2280_tx_hdr *hdr = (void *)skb->data - sizeof(*hdr); | 275 | struct net2280_tx_hdr *hdr = (void *)skb->data - sizeof(*hdr); |
273 | struct net2280_reg_write *reg; | 276 | struct net2280_reg_write *reg = NULL; |
274 | int err = 0; | 277 | int err = -ENOMEM; |
275 | 278 | ||
276 | reg = kmalloc(sizeof(*reg), GFP_ATOMIC); | 279 | reg = kmalloc(sizeof(*reg), GFP_ATOMIC); |
277 | if (!reg) | 280 | if (!reg) |
278 | return; | 281 | goto out; |
279 | 282 | ||
280 | int_urb = usb_alloc_urb(0, GFP_ATOMIC); | 283 | int_urb = usb_alloc_urb(0, GFP_ATOMIC); |
281 | if (!int_urb) { | 284 | if (!int_urb) |
282 | kfree(reg); | 285 | goto out; |
283 | return; | ||
284 | } | ||
285 | 286 | ||
286 | data_urb = usb_alloc_urb(0, GFP_ATOMIC); | 287 | data_urb = usb_alloc_urb(0, GFP_ATOMIC); |
287 | if (!data_urb) { | 288 | if (!data_urb) |
288 | kfree(reg); | 289 | goto out; |
289 | usb_free_urb(int_urb); | ||
290 | return; | ||
291 | } | ||
292 | 290 | ||
293 | reg->port = cpu_to_le16(NET2280_DEV_U32); | 291 | reg->port = cpu_to_le16(NET2280_DEV_U32); |
294 | reg->addr = cpu_to_le32(P54U_DEV_BASE); | 292 | reg->addr = cpu_to_le32(P54U_DEV_BASE); |
@@ -303,11 +301,12 @@ static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb) | |||
303 | p54u_tx_dummy_cb, dev); | 301 | p54u_tx_dummy_cb, dev); |
304 | 302 | ||
305 | /* | 303 | /* |
306 | * This flag triggers a code path in the USB subsystem that will | 304 | * URB_FREE_BUFFER triggers a code path in the USB subsystem that will |
307 | * free what's inside the transfer_buffer after the callback routine | 305 | * free what is inside the transfer_buffer after the last reference to |
308 | * has completed. | 306 | * the int_urb is dropped. |
309 | */ | 307 | */ |
310 | int_urb->transfer_flags |= URB_FREE_BUFFER | URB_ZERO_PACKET; | 308 | int_urb->transfer_flags |= URB_FREE_BUFFER | URB_ZERO_PACKET; |
309 | reg = NULL; | ||
311 | 310 | ||
312 | usb_fill_bulk_urb(data_urb, priv->udev, | 311 | usb_fill_bulk_urb(data_urb, priv->udev, |
313 | usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), | 312 | usb_sndbulkpipe(priv->udev, P54U_PIPE_DATA), |
@@ -328,12 +327,12 @@ static void p54u_tx_net2280(struct ieee80211_hw *dev, struct sk_buff *skb) | |||
328 | usb_unanchor_urb(data_urb); | 327 | usb_unanchor_urb(data_urb); |
329 | goto out; | 328 | goto out; |
330 | } | 329 | } |
331 | out: | 330 | out: |
332 | usb_free_urb(int_urb); | 331 | usb_free_urb(int_urb); |
333 | usb_free_urb(data_urb); | 332 | usb_free_urb(data_urb); |
334 | 333 | ||
335 | if (err) { | 334 | if (err) { |
336 | skb_pull(skb, sizeof(*hdr)); | 335 | kfree(reg); |
337 | p54_free_skb(dev, skb); | 336 | p54_free_skb(dev, skb); |
338 | } | 337 | } |
339 | } | 338 | } |
@@ -961,7 +960,7 @@ err_free_fw: | |||
961 | release_firmware(priv->fw); | 960 | release_firmware(priv->fw); |
962 | 961 | ||
963 | err_free_dev: | 962 | err_free_dev: |
964 | ieee80211_free_hw(dev); | 963 | p54_free_common(dev); |
965 | usb_set_intfdata(intf, NULL); | 964 | usb_set_intfdata(intf, NULL); |
966 | usb_put_dev(udev); | 965 | usb_put_dev(udev); |
967 | return err; | 966 | return err; |
@@ -975,13 +974,12 @@ static void __devexit p54u_disconnect(struct usb_interface *intf) | |||
975 | if (!dev) | 974 | if (!dev) |
976 | return; | 975 | return; |
977 | 976 | ||
978 | ieee80211_unregister_hw(dev); | 977 | p54_unregister_common(dev); |
979 | 978 | ||
980 | priv = dev->priv; | 979 | priv = dev->priv; |
981 | usb_put_dev(interface_to_usbdev(intf)); | 980 | usb_put_dev(interface_to_usbdev(intf)); |
982 | release_firmware(priv->fw); | 981 | release_firmware(priv->fw); |
983 | p54_free_common(dev); | 982 | p54_free_common(dev); |
984 | ieee80211_free_hw(dev); | ||
985 | } | 983 | } |
986 | 984 | ||
987 | static int p54u_pre_reset(struct usb_interface *intf) | 985 | static int p54u_pre_reset(struct usb_interface *intf) |
diff --git a/drivers/net/wireless/p54/txrx.c b/drivers/net/wireless/p54/txrx.c new file mode 100644 index 000000000000..6426d2cae6de --- /dev/null +++ b/drivers/net/wireless/p54/txrx.c | |||
@@ -0,0 +1,826 @@ | |||
1 | /* | ||
2 | * Common code for mac80211 Prism54 drivers | ||
3 | * | ||
4 | * Copyright (c) 2006, Michael Wu <flamingice@sourmilk.net> | ||
5 | * Copyright (c) 2007-2009, Christian Lamparter <chunkeey@web.de> | ||
6 | * Copyright 2008, Johannes Berg <johannes@sipsolutions.net> | ||
7 | * | ||
8 | * Based on: | ||
9 | * - the islsm (softmac prism54) driver, which is: | ||
10 | * Copyright 2004-2006 Jean-Baptiste Note <jbnote@gmail.com>, et al. | ||
11 | * - stlc45xx driver | ||
12 | * Copyright (C) 2008 Nokia Corporation and/or its subsidiary(-ies). | ||
13 | * | ||
14 | * This program is free software; you can redistribute it and/or modify | ||
15 | * it under the terms of the GNU General Public License version 2 as | ||
16 | * published by the Free Software Foundation. | ||
17 | */ | ||
18 | |||
19 | #include <linux/init.h> | ||
20 | #include <linux/firmware.h> | ||
21 | #include <linux/etherdevice.h> | ||
22 | |||
23 | #include <net/mac80211.h> | ||
24 | |||
25 | #include "p54.h" | ||
26 | #include "lmac.h" | ||
27 | |||
28 | #ifdef P54_MM_DEBUG | ||
29 | static void p54_dump_tx_queue(struct p54_common *priv) | ||
30 | { | ||
31 | unsigned long flags; | ||
32 | struct ieee80211_tx_info *info; | ||
33 | struct p54_tx_info *range; | ||
34 | struct sk_buff *skb; | ||
35 | struct p54_hdr *hdr; | ||
36 | unsigned int i = 0; | ||
37 | u32 prev_addr; | ||
38 | u32 largest_hole = 0, free; | ||
39 | |||
40 | spin_lock_irqsave(&priv->tx_queue.lock, flags); | ||
41 | printk(KERN_DEBUG "%s: / --- tx queue dump (%d entries) --- \n", | ||
42 | wiphy_name(priv->hw->wiphy), skb_queue_len(&priv->tx_queue)); | ||
43 | |||
44 | prev_addr = priv->rx_start; | ||
45 | skb_queue_walk(&priv->tx_queue, skb) { | ||
46 | info = IEEE80211_SKB_CB(skb); | ||
47 | range = (void *) info->rate_driver_data; | ||
48 | hdr = (void *) skb->data; | ||
49 | |||
50 | free = range->start_addr - prev_addr; | ||
51 | printk(KERN_DEBUG "%s: | [%02d] => [skb:%p skb_len:0x%04x " | ||
52 | "hdr:{flags:%02x len:%04x req_id:%04x type:%02x} " | ||
53 | "mem:{start:%04x end:%04x, free:%d}]\n", | ||
54 | wiphy_name(priv->hw->wiphy), i++, skb, skb->len, | ||
55 | le16_to_cpu(hdr->flags), le16_to_cpu(hdr->len), | ||
56 | le32_to_cpu(hdr->req_id), le16_to_cpu(hdr->type), | ||
57 | range->start_addr, range->end_addr, free); | ||
58 | |||
59 | prev_addr = range->end_addr; | ||
60 | largest_hole = max(largest_hole, free); | ||
61 | } | ||
62 | free = priv->rx_end - prev_addr; | ||
63 | largest_hole = max(largest_hole, free); | ||
64 | printk(KERN_DEBUG "%s: \\ --- [free: %d], largest free block: %d ---\n", | ||
65 | wiphy_name(priv->hw->wiphy), free, largest_hole); | ||
66 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
67 | } | ||
68 | #endif /* P54_MM_DEBUG */ | ||
69 | |||
70 | /* | ||
71 | * So, the firmware is somewhat stupid and doesn't know what places in its | ||
72 | * memory incoming data should go to. By poking around in the firmware, we | ||
73 | * can find some unused memory to upload our packets to. However, data that we | ||
74 | * want the card to TX needs to stay intact until the card has told us that | ||
75 | * it is done with it. This function finds empty places we can upload to and | ||
76 | * marks allocated areas as reserved if necessary. p54_find_and_unlink_skb or | ||
77 | * p54_free_skb frees allocated areas. | ||
78 | */ | ||
79 | static int p54_assign_address(struct p54_common *priv, struct sk_buff *skb) | ||
80 | { | ||
81 | struct sk_buff *entry, *target_skb = NULL; | ||
82 | struct ieee80211_tx_info *info; | ||
83 | struct p54_tx_info *range; | ||
84 | struct p54_hdr *data = (void *) skb->data; | ||
85 | unsigned long flags; | ||
86 | u32 last_addr = priv->rx_start; | ||
87 | u32 target_addr = priv->rx_start; | ||
88 | u16 len = priv->headroom + skb->len + priv->tailroom + 3; | ||
89 | |||
90 | if (unlikely(WARN_ON(!skb || !priv))) | ||
91 | return -EINVAL; | ||
92 | |||
93 | info = IEEE80211_SKB_CB(skb); | ||
94 | range = (void *) info->rate_driver_data; | ||
95 | len = (range->extra_len + len) & ~0x3; | ||
96 | |||
97 | spin_lock_irqsave(&priv->tx_queue.lock, flags); | ||
98 | if (unlikely(skb_queue_len(&priv->tx_queue) == 32)) { | ||
99 | /* | ||
100 | * The tx_queue is now really full. | ||
101 | * | ||
102 | * TODO: check if the device has crashed and reset it. | ||
103 | */ | ||
104 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
105 | return -EBUSY; | ||
106 | } | ||
107 | |||
108 | skb_queue_walk(&priv->tx_queue, entry) { | ||
109 | u32 hole_size; | ||
110 | info = IEEE80211_SKB_CB(entry); | ||
111 | range = (void *) info->rate_driver_data; | ||
112 | hole_size = range->start_addr - last_addr; | ||
113 | |||
114 | if (!entry->next) { | ||
115 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
116 | return -ENOSPC; | ||
117 | } | ||
118 | |||
119 | if (!target_skb && hole_size >= len) { | ||
120 | target_skb = entry->prev; | ||
121 | hole_size -= len; | ||
122 | target_addr = last_addr; | ||
123 | break; | ||
124 | } | ||
125 | last_addr = range->end_addr; | ||
126 | } | ||
127 | if (unlikely(!target_skb)) { | ||
128 | if (priv->rx_end - last_addr >= len) { | ||
129 | target_skb = priv->tx_queue.prev; | ||
130 | if (!skb_queue_empty(&priv->tx_queue)) { | ||
131 | info = IEEE80211_SKB_CB(target_skb); | ||
132 | range = (void *)info->rate_driver_data; | ||
133 | target_addr = range->end_addr; | ||
134 | } | ||
135 | } else { | ||
136 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
137 | return -ENOSPC; | ||
138 | } | ||
139 | } | ||
140 | |||
141 | info = IEEE80211_SKB_CB(skb); | ||
142 | range = (void *) info->rate_driver_data; | ||
143 | range->start_addr = target_addr; | ||
144 | range->end_addr = target_addr + len; | ||
145 | __skb_queue_after(&priv->tx_queue, target_skb, skb); | ||
146 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
147 | data->req_id = cpu_to_le32(target_addr + priv->headroom); | ||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static void p54_tx_pending(struct p54_common *priv) | ||
152 | { | ||
153 | struct sk_buff *skb; | ||
154 | int ret; | ||
155 | |||
156 | if (unlikely(WARN_ON(!priv))) | ||
157 | return ; | ||
158 | |||
159 | skb = skb_dequeue(&priv->tx_pending); | ||
160 | if (unlikely(!skb)) | ||
161 | return ; | ||
162 | |||
163 | ret = p54_assign_address(priv, skb); | ||
164 | if (unlikely(ret)) | ||
165 | skb_queue_head(&priv->tx_pending, skb); | ||
166 | else | ||
167 | priv->tx(priv->hw, skb); | ||
168 | } | ||
169 | |||
170 | static void p54_wake_queues(struct p54_common *priv) | ||
171 | { | ||
172 | unsigned long flags; | ||
173 | unsigned int i; | ||
174 | |||
175 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | ||
176 | return ; | ||
177 | |||
178 | p54_tx_pending(priv); | ||
179 | |||
180 | spin_lock_irqsave(&priv->tx_stats_lock, flags); | ||
181 | for (i = 0; i < priv->hw->queues; i++) { | ||
182 | if (priv->tx_stats[i + P54_QUEUE_DATA].len < | ||
183 | priv->tx_stats[i + P54_QUEUE_DATA].limit) | ||
184 | ieee80211_wake_queue(priv->hw, i); | ||
185 | } | ||
186 | spin_unlock_irqrestore(&priv->tx_stats_lock, flags); | ||
187 | } | ||
188 | |||
189 | static int p54_tx_qos_accounting_alloc(struct p54_common *priv, | ||
190 | struct sk_buff *skb, | ||
191 | const u16 p54_queue) | ||
192 | { | ||
193 | struct ieee80211_tx_queue_stats *queue; | ||
194 | unsigned long flags; | ||
195 | |||
196 | if (WARN_ON(p54_queue > P54_QUEUE_NUM)) | ||
197 | return -EINVAL; | ||
198 | |||
199 | queue = &priv->tx_stats[p54_queue]; | ||
200 | |||
201 | spin_lock_irqsave(&priv->tx_stats_lock, flags); | ||
202 | if (unlikely(queue->len >= queue->limit && IS_QOS_QUEUE(p54_queue))) { | ||
203 | spin_unlock_irqrestore(&priv->tx_stats_lock, flags); | ||
204 | return -ENOSPC; | ||
205 | } | ||
206 | |||
207 | queue->len++; | ||
208 | queue->count++; | ||
209 | |||
210 | if (unlikely(queue->len == queue->limit && IS_QOS_QUEUE(p54_queue))) { | ||
211 | u16 ac_queue = p54_queue - P54_QUEUE_DATA; | ||
212 | ieee80211_stop_queue(priv->hw, ac_queue); | ||
213 | } | ||
214 | |||
215 | spin_unlock_irqrestore(&priv->tx_stats_lock, flags); | ||
216 | return 0; | ||
217 | } | ||
218 | |||
219 | static void p54_tx_qos_accounting_free(struct p54_common *priv, | ||
220 | struct sk_buff *skb) | ||
221 | { | ||
222 | if (skb && IS_DATA_FRAME(skb)) { | ||
223 | struct p54_hdr *hdr = (void *) skb->data; | ||
224 | struct p54_tx_data *data = (void *) hdr->data; | ||
225 | unsigned long flags; | ||
226 | |||
227 | spin_lock_irqsave(&priv->tx_stats_lock, flags); | ||
228 | priv->tx_stats[data->hw_queue].len--; | ||
229 | spin_unlock_irqrestore(&priv->tx_stats_lock, flags); | ||
230 | } | ||
231 | p54_wake_queues(priv); | ||
232 | } | ||
233 | |||
234 | void p54_free_skb(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
235 | { | ||
236 | struct p54_common *priv = dev->priv; | ||
237 | if (unlikely(!skb)) | ||
238 | return ; | ||
239 | |||
240 | skb_unlink(skb, &priv->tx_queue); | ||
241 | p54_tx_qos_accounting_free(priv, skb); | ||
242 | dev_kfree_skb_any(skb); | ||
243 | } | ||
244 | EXPORT_SYMBOL_GPL(p54_free_skb); | ||
245 | |||
246 | static struct sk_buff *p54_find_and_unlink_skb(struct p54_common *priv, | ||
247 | const __le32 req_id) | ||
248 | { | ||
249 | struct sk_buff *entry; | ||
250 | unsigned long flags; | ||
251 | |||
252 | spin_lock_irqsave(&priv->tx_queue.lock, flags); | ||
253 | skb_queue_walk(&priv->tx_queue, entry) { | ||
254 | struct p54_hdr *hdr = (struct p54_hdr *) entry->data; | ||
255 | |||
256 | if (hdr->req_id == req_id) { | ||
257 | __skb_unlink(entry, &priv->tx_queue); | ||
258 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
259 | p54_tx_qos_accounting_free(priv, entry); | ||
260 | return entry; | ||
261 | } | ||
262 | } | ||
263 | spin_unlock_irqrestore(&priv->tx_queue.lock, flags); | ||
264 | return NULL; | ||
265 | } | ||
266 | |||
267 | void p54_tx(struct p54_common *priv, struct sk_buff *skb) | ||
268 | { | ||
269 | if (unlikely(WARN_ON(!priv))) | ||
270 | return ; | ||
271 | |||
272 | skb_queue_tail(&priv->tx_pending, skb); | ||
273 | p54_tx_pending(priv); | ||
274 | } | ||
275 | |||
276 | static int p54_rssi_to_dbm(struct p54_common *priv, int rssi) | ||
277 | { | ||
278 | int band = priv->hw->conf.channel->band; | ||
279 | |||
280 | if (priv->rxhw != 5) | ||
281 | return ((rssi * priv->rssical_db[band].mul) / 64 + | ||
282 | priv->rssical_db[band].add) / 4; | ||
283 | else | ||
284 | /* | ||
285 | * TODO: find the correct formula | ||
286 | */ | ||
287 | return ((rssi * priv->rssical_db[band].mul) / 64 + | ||
288 | priv->rssical_db[band].add) / 4; | ||
289 | } | ||
290 | |||
291 | static int p54_rx_data(struct p54_common *priv, struct sk_buff *skb) | ||
292 | { | ||
293 | struct p54_rx_data *hdr = (struct p54_rx_data *) skb->data; | ||
294 | struct ieee80211_rx_status *rx_status = IEEE80211_SKB_RXCB(skb); | ||
295 | u16 freq = le16_to_cpu(hdr->freq); | ||
296 | size_t header_len = sizeof(*hdr); | ||
297 | u32 tsf32; | ||
298 | u8 rate = hdr->rate & 0xf; | ||
299 | |||
300 | /* | ||
301 | * If the device is in a unspecified state we have to | ||
302 | * ignore all data frames. Else we could end up with a | ||
303 | * nasty crash. | ||
304 | */ | ||
305 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | ||
306 | return 0; | ||
307 | |||
308 | if (!(hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_IN_FCS_GOOD))) | ||
309 | return 0; | ||
310 | |||
311 | if (hdr->decrypt_status == P54_DECRYPT_OK) | ||
312 | rx_status->flag |= RX_FLAG_DECRYPTED; | ||
313 | if ((hdr->decrypt_status == P54_DECRYPT_FAIL_MICHAEL) || | ||
314 | (hdr->decrypt_status == P54_DECRYPT_FAIL_TKIP)) | ||
315 | rx_status->flag |= RX_FLAG_MMIC_ERROR; | ||
316 | |||
317 | rx_status->signal = p54_rssi_to_dbm(priv, hdr->rssi); | ||
318 | rx_status->noise = priv->noise; | ||
319 | if (hdr->rate & 0x10) | ||
320 | rx_status->flag |= RX_FLAG_SHORTPRE; | ||
321 | if (priv->hw->conf.channel->band == IEEE80211_BAND_5GHZ) | ||
322 | rx_status->rate_idx = (rate < 4) ? 0 : rate - 4; | ||
323 | else | ||
324 | rx_status->rate_idx = rate; | ||
325 | |||
326 | rx_status->freq = freq; | ||
327 | rx_status->band = priv->hw->conf.channel->band; | ||
328 | rx_status->antenna = hdr->antenna; | ||
329 | |||
330 | tsf32 = le32_to_cpu(hdr->tsf32); | ||
331 | if (tsf32 < priv->tsf_low32) | ||
332 | priv->tsf_high32++; | ||
333 | rx_status->mactime = ((u64)priv->tsf_high32) << 32 | tsf32; | ||
334 | priv->tsf_low32 = tsf32; | ||
335 | |||
336 | rx_status->flag |= RX_FLAG_TSFT; | ||
337 | |||
338 | if (hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN)) | ||
339 | header_len += hdr->align[0]; | ||
340 | |||
341 | skb_pull(skb, header_len); | ||
342 | skb_trim(skb, le16_to_cpu(hdr->len)); | ||
343 | ieee80211_rx_irqsafe(priv->hw, skb); | ||
344 | |||
345 | queue_delayed_work(priv->hw->workqueue, &priv->work, | ||
346 | msecs_to_jiffies(P54_STATISTICS_UPDATE)); | ||
347 | |||
348 | return -1; | ||
349 | } | ||
350 | |||
351 | static void p54_rx_frame_sent(struct p54_common *priv, struct sk_buff *skb) | ||
352 | { | ||
353 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
354 | struct p54_frame_sent *payload = (struct p54_frame_sent *) hdr->data; | ||
355 | struct ieee80211_tx_info *info; | ||
356 | struct p54_hdr *entry_hdr; | ||
357 | struct p54_tx_data *entry_data; | ||
358 | struct sk_buff *entry; | ||
359 | unsigned int pad = 0, frame_len; | ||
360 | int count, idx; | ||
361 | |||
362 | entry = p54_find_and_unlink_skb(priv, hdr->req_id); | ||
363 | if (unlikely(!entry)) | ||
364 | return ; | ||
365 | |||
366 | frame_len = entry->len; | ||
367 | info = IEEE80211_SKB_CB(entry); | ||
368 | entry_hdr = (struct p54_hdr *) entry->data; | ||
369 | entry_data = (struct p54_tx_data *) entry_hdr->data; | ||
370 | priv->stats.dot11ACKFailureCount += payload->tries - 1; | ||
371 | |||
372 | /* | ||
373 | * Frames in P54_QUEUE_FWSCAN and P54_QUEUE_BEACON are | ||
374 | * generated by the driver. Therefore tx_status is bogus | ||
375 | * and we don't want to confuse the mac80211 stack. | ||
376 | */ | ||
377 | if (unlikely(entry_data->hw_queue < P54_QUEUE_FWSCAN)) { | ||
378 | if (entry_data->hw_queue == P54_QUEUE_BEACON && | ||
379 | hdr->req_id == priv->beacon_req_id) | ||
380 | priv->beacon_req_id = cpu_to_le32(0); | ||
381 | |||
382 | dev_kfree_skb_any(entry); | ||
383 | return ; | ||
384 | } | ||
385 | |||
386 | /* | ||
387 | * Clear manually, ieee80211_tx_info_clear_status would | ||
388 | * clear the counts too and we need them. | ||
389 | */ | ||
390 | memset(&info->status.ampdu_ack_len, 0, | ||
391 | sizeof(struct ieee80211_tx_info) - | ||
392 | offsetof(struct ieee80211_tx_info, status.ampdu_ack_len)); | ||
393 | BUILD_BUG_ON(offsetof(struct ieee80211_tx_info, | ||
394 | status.ampdu_ack_len) != 23); | ||
395 | |||
396 | if (entry_hdr->flags & cpu_to_le16(P54_HDR_FLAG_DATA_ALIGN)) | ||
397 | pad = entry_data->align[0]; | ||
398 | |||
399 | /* walk through the rates array and adjust the counts */ | ||
400 | count = payload->tries; | ||
401 | for (idx = 0; idx < 4; idx++) { | ||
402 | if (count >= info->status.rates[idx].count) { | ||
403 | count -= info->status.rates[idx].count; | ||
404 | } else if (count > 0) { | ||
405 | info->status.rates[idx].count = count; | ||
406 | count = 0; | ||
407 | } else { | ||
408 | info->status.rates[idx].idx = -1; | ||
409 | info->status.rates[idx].count = 0; | ||
410 | } | ||
411 | } | ||
412 | |||
413 | if (!(info->flags & IEEE80211_TX_CTL_NO_ACK) && | ||
414 | (!payload->status)) | ||
415 | info->flags |= IEEE80211_TX_STAT_ACK; | ||
416 | if (payload->status & P54_TX_PSM_CANCELLED) | ||
417 | info->flags |= IEEE80211_TX_STAT_TX_FILTERED; | ||
418 | info->status.ack_signal = p54_rssi_to_dbm(priv, | ||
419 | (int)payload->ack_rssi); | ||
420 | |||
421 | /* Undo all changes to the frame. */ | ||
422 | switch (entry_data->key_type) { | ||
423 | case P54_CRYPTO_TKIPMICHAEL: { | ||
424 | u8 *iv = (u8 *)(entry_data->align + pad + | ||
425 | entry_data->crypt_offset); | ||
426 | |||
427 | /* Restore the original TKIP IV. */ | ||
428 | iv[2] = iv[0]; | ||
429 | iv[0] = iv[1]; | ||
430 | iv[1] = (iv[0] | 0x20) & 0x7f; /* WEPSeed - 8.3.2.2 */ | ||
431 | |||
432 | frame_len -= 12; /* remove TKIP_MMIC + TKIP_ICV */ | ||
433 | break; | ||
434 | } | ||
435 | case P54_CRYPTO_AESCCMP: | ||
436 | frame_len -= 8; /* remove CCMP_MIC */ | ||
437 | break; | ||
438 | case P54_CRYPTO_WEP: | ||
439 | frame_len -= 4; /* remove WEP_ICV */ | ||
440 | break; | ||
441 | } | ||
442 | |||
443 | skb_trim(entry, frame_len); | ||
444 | skb_pull(entry, sizeof(*hdr) + pad + sizeof(*entry_data)); | ||
445 | ieee80211_tx_status_irqsafe(priv->hw, entry); | ||
446 | } | ||
447 | |||
448 | static void p54_rx_eeprom_readback(struct p54_common *priv, | ||
449 | struct sk_buff *skb) | ||
450 | { | ||
451 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
452 | struct p54_eeprom_lm86 *eeprom = (struct p54_eeprom_lm86 *) hdr->data; | ||
453 | struct sk_buff *tmp; | ||
454 | |||
455 | if (!priv->eeprom) | ||
456 | return ; | ||
457 | |||
458 | if (priv->fw_var >= 0x509) { | ||
459 | memcpy(priv->eeprom, eeprom->v2.data, | ||
460 | le16_to_cpu(eeprom->v2.len)); | ||
461 | } else { | ||
462 | memcpy(priv->eeprom, eeprom->v1.data, | ||
463 | le16_to_cpu(eeprom->v1.len)); | ||
464 | } | ||
465 | |||
466 | priv->eeprom = NULL; | ||
467 | tmp = p54_find_and_unlink_skb(priv, hdr->req_id); | ||
468 | dev_kfree_skb_any(tmp); | ||
469 | complete(&priv->eeprom_comp); | ||
470 | } | ||
471 | |||
472 | static void p54_rx_stats(struct p54_common *priv, struct sk_buff *skb) | ||
473 | { | ||
474 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
475 | struct p54_statistics *stats = (struct p54_statistics *) hdr->data; | ||
476 | struct sk_buff *tmp; | ||
477 | u32 tsf32; | ||
478 | |||
479 | if (unlikely(priv->mode == NL80211_IFTYPE_UNSPECIFIED)) | ||
480 | return ; | ||
481 | |||
482 | tsf32 = le32_to_cpu(stats->tsf32); | ||
483 | if (tsf32 < priv->tsf_low32) | ||
484 | priv->tsf_high32++; | ||
485 | priv->tsf_low32 = tsf32; | ||
486 | |||
487 | priv->stats.dot11RTSFailureCount = le32_to_cpu(stats->rts_fail); | ||
488 | priv->stats.dot11RTSSuccessCount = le32_to_cpu(stats->rts_success); | ||
489 | priv->stats.dot11FCSErrorCount = le32_to_cpu(stats->rx_bad_fcs); | ||
490 | |||
491 | priv->noise = p54_rssi_to_dbm(priv, le32_to_cpu(stats->noise)); | ||
492 | |||
493 | tmp = p54_find_and_unlink_skb(priv, hdr->req_id); | ||
494 | dev_kfree_skb_any(tmp); | ||
495 | } | ||
496 | |||
497 | static void p54_rx_trap(struct p54_common *priv, struct sk_buff *skb) | ||
498 | { | ||
499 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
500 | struct p54_trap *trap = (struct p54_trap *) hdr->data; | ||
501 | u16 event = le16_to_cpu(trap->event); | ||
502 | u16 freq = le16_to_cpu(trap->frequency); | ||
503 | |||
504 | switch (event) { | ||
505 | case P54_TRAP_BEACON_TX: | ||
506 | break; | ||
507 | case P54_TRAP_RADAR: | ||
508 | printk(KERN_INFO "%s: radar (freq:%d MHz)\n", | ||
509 | wiphy_name(priv->hw->wiphy), freq); | ||
510 | break; | ||
511 | case P54_TRAP_NO_BEACON: | ||
512 | if (priv->vif) | ||
513 | ieee80211_beacon_loss(priv->vif); | ||
514 | break; | ||
515 | case P54_TRAP_SCAN: | ||
516 | break; | ||
517 | case P54_TRAP_TBTT: | ||
518 | break; | ||
519 | case P54_TRAP_TIMER: | ||
520 | break; | ||
521 | default: | ||
522 | printk(KERN_INFO "%s: received event:%x freq:%d\n", | ||
523 | wiphy_name(priv->hw->wiphy), event, freq); | ||
524 | break; | ||
525 | } | ||
526 | } | ||
527 | |||
528 | static int p54_rx_control(struct p54_common *priv, struct sk_buff *skb) | ||
529 | { | ||
530 | struct p54_hdr *hdr = (struct p54_hdr *) skb->data; | ||
531 | |||
532 | switch (le16_to_cpu(hdr->type)) { | ||
533 | case P54_CONTROL_TYPE_TXDONE: | ||
534 | p54_rx_frame_sent(priv, skb); | ||
535 | break; | ||
536 | case P54_CONTROL_TYPE_TRAP: | ||
537 | p54_rx_trap(priv, skb); | ||
538 | break; | ||
539 | case P54_CONTROL_TYPE_BBP: | ||
540 | break; | ||
541 | case P54_CONTROL_TYPE_STAT_READBACK: | ||
542 | p54_rx_stats(priv, skb); | ||
543 | break; | ||
544 | case P54_CONTROL_TYPE_EEPROM_READBACK: | ||
545 | p54_rx_eeprom_readback(priv, skb); | ||
546 | break; | ||
547 | default: | ||
548 | printk(KERN_DEBUG "%s: not handling 0x%02x type control frame\n", | ||
549 | wiphy_name(priv->hw->wiphy), le16_to_cpu(hdr->type)); | ||
550 | break; | ||
551 | } | ||
552 | return 0; | ||
553 | } | ||
554 | |||
555 | /* returns zero if skb can be reused */ | ||
556 | int p54_rx(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
557 | { | ||
558 | struct p54_common *priv = dev->priv; | ||
559 | u16 type = le16_to_cpu(*((__le16 *)skb->data)); | ||
560 | |||
561 | if (type & P54_HDR_FLAG_CONTROL) | ||
562 | return p54_rx_control(priv, skb); | ||
563 | else | ||
564 | return p54_rx_data(priv, skb); | ||
565 | } | ||
566 | EXPORT_SYMBOL_GPL(p54_rx); | ||
567 | |||
568 | static void p54_tx_80211_header(struct p54_common *priv, struct sk_buff *skb, | ||
569 | struct ieee80211_tx_info *info, u8 *queue, | ||
570 | u32 *extra_len, u16 *flags, u16 *aid, | ||
571 | bool *burst_possible) | ||
572 | { | ||
573 | struct ieee80211_hdr *hdr = (struct ieee80211_hdr *)skb->data; | ||
574 | |||
575 | if (ieee80211_is_data_qos(hdr->frame_control)) | ||
576 | *burst_possible = true; | ||
577 | else | ||
578 | *burst_possible = false; | ||
579 | |||
580 | if (info->flags & IEEE80211_TX_CTL_ASSIGN_SEQ) | ||
581 | *flags |= P54_HDR_FLAG_DATA_OUT_SEQNR; | ||
582 | |||
583 | if (info->flags & IEEE80211_TX_CTL_CLEAR_PS_FILT) | ||
584 | *flags |= P54_HDR_FLAG_DATA_OUT_NOCANCEL; | ||
585 | |||
586 | *queue = skb_get_queue_mapping(skb) + P54_QUEUE_DATA; | ||
587 | |||
588 | switch (priv->mode) { | ||
589 | case NL80211_IFTYPE_MONITOR: | ||
590 | /* | ||
591 | * We have to set P54_HDR_FLAG_DATA_OUT_PROMISC for | ||
592 | * every frame in promiscuous/monitor mode. | ||
593 | * see STSW45x0C LMAC API - page 12. | ||
594 | */ | ||
595 | *aid = 0; | ||
596 | *flags |= P54_HDR_FLAG_DATA_OUT_PROMISC; | ||
597 | break; | ||
598 | case NL80211_IFTYPE_STATION: | ||
599 | *aid = 1; | ||
600 | break; | ||
601 | case NL80211_IFTYPE_AP: | ||
602 | case NL80211_IFTYPE_ADHOC: | ||
603 | case NL80211_IFTYPE_MESH_POINT: | ||
604 | if (info->flags & IEEE80211_TX_CTL_SEND_AFTER_DTIM) { | ||
605 | *aid = 0; | ||
606 | *queue = P54_QUEUE_CAB; | ||
607 | return; | ||
608 | } | ||
609 | |||
610 | if (unlikely(ieee80211_is_mgmt(hdr->frame_control))) { | ||
611 | if (ieee80211_is_probe_resp(hdr->frame_control)) { | ||
612 | *aid = 0; | ||
613 | *flags |= P54_HDR_FLAG_DATA_OUT_TIMESTAMP | | ||
614 | P54_HDR_FLAG_DATA_OUT_NOCANCEL; | ||
615 | return; | ||
616 | } else if (ieee80211_is_beacon(hdr->frame_control)) { | ||
617 | *aid = 0; | ||
618 | |||
619 | if (info->flags & IEEE80211_TX_CTL_INJECTED) { | ||
620 | /* | ||
621 | * Injecting beacons on top of a AP is | ||
622 | * not a good idea... nevertheless, | ||
623 | * it should be doable. | ||
624 | */ | ||
625 | |||
626 | return; | ||
627 | } | ||
628 | |||
629 | *flags |= P54_HDR_FLAG_DATA_OUT_TIMESTAMP; | ||
630 | *queue = P54_QUEUE_BEACON; | ||
631 | *extra_len = IEEE80211_MAX_TIM_LEN; | ||
632 | return; | ||
633 | } | ||
634 | } | ||
635 | |||
636 | if (info->control.sta) | ||
637 | *aid = info->control.sta->aid; | ||
638 | break; | ||
639 | } | ||
640 | } | ||
641 | |||
642 | static u8 p54_convert_algo(enum ieee80211_key_alg alg) | ||
643 | { | ||
644 | switch (alg) { | ||
645 | case ALG_WEP: | ||
646 | return P54_CRYPTO_WEP; | ||
647 | case ALG_TKIP: | ||
648 | return P54_CRYPTO_TKIPMICHAEL; | ||
649 | case ALG_CCMP: | ||
650 | return P54_CRYPTO_AESCCMP; | ||
651 | default: | ||
652 | return 0; | ||
653 | } | ||
654 | } | ||
655 | |||
656 | int p54_tx_80211(struct ieee80211_hw *dev, struct sk_buff *skb) | ||
657 | { | ||
658 | struct p54_common *priv = dev->priv; | ||
659 | struct ieee80211_tx_info *info = IEEE80211_SKB_CB(skb); | ||
660 | struct p54_tx_info *p54info; | ||
661 | struct p54_hdr *hdr; | ||
662 | struct p54_tx_data *txhdr; | ||
663 | unsigned int padding, len, extra_len; | ||
664 | int i, j, ridx; | ||
665 | u16 hdr_flags = 0, aid = 0; | ||
666 | u8 rate, queue = 0, crypt_offset = 0; | ||
667 | u8 cts_rate = 0x20; | ||
668 | u8 rc_flags; | ||
669 | u8 calculated_tries[4]; | ||
670 | u8 nrates = 0, nremaining = 8; | ||
671 | bool burst_allowed = false; | ||
672 | |||
673 | p54_tx_80211_header(priv, skb, info, &queue, &extra_len, | ||
674 | &hdr_flags, &aid, &burst_allowed); | ||
675 | |||
676 | if (p54_tx_qos_accounting_alloc(priv, skb, queue)) { | ||
677 | if (!IS_QOS_QUEUE(queue)) { | ||
678 | dev_kfree_skb_any(skb); | ||
679 | return NETDEV_TX_OK; | ||
680 | } else { | ||
681 | return NETDEV_TX_BUSY; | ||
682 | } | ||
683 | } | ||
684 | |||
685 | padding = (unsigned long)(skb->data - (sizeof(*hdr) + sizeof(*txhdr))) & 3; | ||
686 | len = skb->len; | ||
687 | |||
688 | if (info->control.hw_key) { | ||
689 | crypt_offset = ieee80211_get_hdrlen_from_skb(skb); | ||
690 | if (info->control.hw_key->alg == ALG_TKIP) { | ||
691 | u8 *iv = (u8 *)(skb->data + crypt_offset); | ||
692 | /* | ||
693 | * The firmware excepts that the IV has to have | ||
694 | * this special format | ||
695 | */ | ||
696 | iv[1] = iv[0]; | ||
697 | iv[0] = iv[2]; | ||
698 | iv[2] = 0; | ||
699 | } | ||
700 | } | ||
701 | |||
702 | txhdr = (struct p54_tx_data *) skb_push(skb, sizeof(*txhdr) + padding); | ||
703 | hdr = (struct p54_hdr *) skb_push(skb, sizeof(*hdr)); | ||
704 | |||
705 | if (padding) | ||
706 | hdr_flags |= P54_HDR_FLAG_DATA_ALIGN; | ||
707 | hdr->type = cpu_to_le16(aid); | ||
708 | hdr->rts_tries = info->control.rates[0].count; | ||
709 | |||
710 | /* | ||
711 | * we register the rates in perfect order, and | ||
712 | * RTS/CTS won't happen on 5 GHz | ||
713 | */ | ||
714 | cts_rate = info->control.rts_cts_rate_idx; | ||
715 | |||
716 | memset(&txhdr->rateset, 0, sizeof(txhdr->rateset)); | ||
717 | |||
718 | /* see how many rates got used */ | ||
719 | for (i = 0; i < dev->max_rates; i++) { | ||
720 | if (info->control.rates[i].idx < 0) | ||
721 | break; | ||
722 | nrates++; | ||
723 | } | ||
724 | |||
725 | /* limit tries to 8/nrates per rate */ | ||
726 | for (i = 0; i < nrates; i++) { | ||
727 | /* | ||
728 | * The magic expression here is equivalent to 8/nrates for | ||
729 | * all values that matter, but avoids division and jumps. | ||
730 | * Note that nrates can only take the values 1 through 4. | ||
731 | */ | ||
732 | calculated_tries[i] = min_t(int, ((15 >> nrates) | 1) + 1, | ||
733 | info->control.rates[i].count); | ||
734 | nremaining -= calculated_tries[i]; | ||
735 | } | ||
736 | |||
737 | /* if there are tries left, distribute from back to front */ | ||
738 | for (i = nrates - 1; nremaining > 0 && i >= 0; i--) { | ||
739 | int tmp = info->control.rates[i].count - calculated_tries[i]; | ||
740 | |||
741 | if (tmp <= 0) | ||
742 | continue; | ||
743 | /* RC requested more tries at this rate */ | ||
744 | |||
745 | tmp = min_t(int, tmp, nremaining); | ||
746 | calculated_tries[i] += tmp; | ||
747 | nremaining -= tmp; | ||
748 | } | ||
749 | |||
750 | ridx = 0; | ||
751 | for (i = 0; i < nrates && ridx < 8; i++) { | ||
752 | /* we register the rates in perfect order */ | ||
753 | rate = info->control.rates[i].idx; | ||
754 | if (info->band == IEEE80211_BAND_5GHZ) | ||
755 | rate += 4; | ||
756 | |||
757 | /* store the count we actually calculated for TX status */ | ||
758 | info->control.rates[i].count = calculated_tries[i]; | ||
759 | |||
760 | rc_flags = info->control.rates[i].flags; | ||
761 | if (rc_flags & IEEE80211_TX_RC_USE_SHORT_PREAMBLE) { | ||
762 | rate |= 0x10; | ||
763 | cts_rate |= 0x10; | ||
764 | } | ||
765 | if (rc_flags & IEEE80211_TX_RC_USE_RTS_CTS) { | ||
766 | burst_allowed = false; | ||
767 | rate |= 0x40; | ||
768 | } else if (rc_flags & IEEE80211_TX_RC_USE_CTS_PROTECT) { | ||
769 | rate |= 0x20; | ||
770 | burst_allowed = false; | ||
771 | } | ||
772 | for (j = 0; j < calculated_tries[i] && ridx < 8; j++) { | ||
773 | txhdr->rateset[ridx] = rate; | ||
774 | ridx++; | ||
775 | } | ||
776 | } | ||
777 | |||
778 | if (burst_allowed) | ||
779 | hdr_flags |= P54_HDR_FLAG_DATA_OUT_BURST; | ||
780 | |||
781 | /* TODO: enable bursting */ | ||
782 | hdr->flags = cpu_to_le16(hdr_flags); | ||
783 | hdr->tries = ridx; | ||
784 | txhdr->rts_rate_idx = 0; | ||
785 | if (info->control.hw_key) { | ||
786 | txhdr->key_type = p54_convert_algo(info->control.hw_key->alg); | ||
787 | txhdr->key_len = min((u8)16, info->control.hw_key->keylen); | ||
788 | memcpy(txhdr->key, info->control.hw_key->key, txhdr->key_len); | ||
789 | if (info->control.hw_key->alg == ALG_TKIP) { | ||
790 | /* reserve space for the MIC key */ | ||
791 | len += 8; | ||
792 | memcpy(skb_put(skb, 8), &(info->control.hw_key->key | ||
793 | [NL80211_TKIP_DATA_OFFSET_TX_MIC_KEY]), 8); | ||
794 | } | ||
795 | /* reserve some space for ICV */ | ||
796 | len += info->control.hw_key->icv_len; | ||
797 | memset(skb_put(skb, info->control.hw_key->icv_len), 0, | ||
798 | info->control.hw_key->icv_len); | ||
799 | } else { | ||
800 | txhdr->key_type = 0; | ||
801 | txhdr->key_len = 0; | ||
802 | } | ||
803 | txhdr->crypt_offset = crypt_offset; | ||
804 | txhdr->hw_queue = queue; | ||
805 | txhdr->backlog = priv->tx_stats[queue].len - 1; | ||
806 | memset(txhdr->durations, 0, sizeof(txhdr->durations)); | ||
807 | txhdr->tx_antenna = ((info->antenna_sel_tx == 0) ? | ||
808 | 2 : info->antenna_sel_tx - 1) & priv->tx_diversity_mask; | ||
809 | if (priv->rxhw == 5) { | ||
810 | txhdr->longbow.cts_rate = cts_rate; | ||
811 | txhdr->longbow.output_power = cpu_to_le16(priv->output_power); | ||
812 | } else { | ||
813 | txhdr->normal.output_power = priv->output_power; | ||
814 | txhdr->normal.cts_rate = cts_rate; | ||
815 | } | ||
816 | if (padding) | ||
817 | txhdr->align[0] = padding; | ||
818 | |||
819 | hdr->len = cpu_to_le16(len); | ||
820 | /* modifies skb->cb and with it info, so must be last! */ | ||
821 | p54info = (void *) info->rate_driver_data; | ||
822 | p54info->extra_len = extra_len; | ||
823 | |||
824 | p54_tx(priv, skb); | ||
825 | return NETDEV_TX_OK; | ||
826 | } | ||
diff --git a/drivers/net/wireless/prism54/islpci_eth.c b/drivers/net/wireless/prism54/islpci_eth.c index 8f6210993448..c255d9c6a5f1 100644 --- a/drivers/net/wireless/prism54/islpci_eth.c +++ b/drivers/net/wireless/prism54/islpci_eth.c | |||
@@ -234,7 +234,7 @@ islpci_eth_transmit(struct sk_buff *skb, struct net_device *ndev) | |||
234 | /* unlock the driver code */ | 234 | /* unlock the driver code */ |
235 | spin_unlock_irqrestore(&priv->slock, flags); | 235 | spin_unlock_irqrestore(&priv->slock, flags); |
236 | 236 | ||
237 | return 0; | 237 | return NETDEV_TX_OK; |
238 | 238 | ||
239 | drop_free: | 239 | drop_free: |
240 | ndev->stats.tx_dropped++; | 240 | ndev->stats.tx_dropped++; |
diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c index 30876728d7e6..83d366258c81 100644 --- a/drivers/net/wireless/prism54/islpci_hotplug.c +++ b/drivers/net/wireless/prism54/islpci_hotplug.c | |||
@@ -49,9 +49,7 @@ static const struct pci_device_id prism54_id_tbl[] = { | |||
49 | 49 | ||
50 | /* 3COM 3CRWE154G72 Wireless LAN adapter */ | 50 | /* 3COM 3CRWE154G72 Wireless LAN adapter */ |
51 | { | 51 | { |
52 | 0x10b7, 0x6001, | 52 | PCI_VDEVICE(3COM, 0x6001), 0 |
53 | PCI_ANY_ID, PCI_ANY_ID, | ||
54 | 0, 0, 0 | ||
55 | }, | 53 | }, |
56 | 54 | ||
57 | /* Intersil PRISM Indigo Wireless LAN adapter */ | 55 | /* Intersil PRISM Indigo Wireless LAN adapter */ |
diff --git a/drivers/net/wireless/ray_cs.c b/drivers/net/wireless/ray_cs.c index b10b0383dfa5..64e574c3655c 100644 --- a/drivers/net/wireless/ray_cs.c +++ b/drivers/net/wireless/ray_cs.c | |||
@@ -937,7 +937,7 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
937 | 937 | ||
938 | if (length < ETH_ZLEN) { | 938 | if (length < ETH_ZLEN) { |
939 | if (skb_padto(skb, ETH_ZLEN)) | 939 | if (skb_padto(skb, ETH_ZLEN)) |
940 | return 0; | 940 | return NETDEV_TX_OK; |
941 | length = ETH_ZLEN; | 941 | length = ETH_ZLEN; |
942 | } | 942 | } |
943 | switch (ray_hw_xmit(skb->data, length, dev, DATA_TYPE)) { | 943 | switch (ray_hw_xmit(skb->data, length, dev, DATA_TYPE)) { |
@@ -951,9 +951,9 @@ static int ray_dev_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
951 | default: | 951 | default: |
952 | dev->trans_start = jiffies; | 952 | dev->trans_start = jiffies; |
953 | dev_kfree_skb(skb); | 953 | dev_kfree_skb(skb); |
954 | return 0; | 954 | return NETDEV_TX_OK; |
955 | } | 955 | } |
956 | return 0; | 956 | return NETDEV_TX_OK; |
957 | } /* ray_dev_start_xmit */ | 957 | } /* ray_dev_start_xmit */ |
958 | 958 | ||
959 | /*===========================================================================*/ | 959 | /*===========================================================================*/ |
diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 3bec3dbd3450..09c0702ae645 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c | |||
@@ -139,9 +139,15 @@ MODULE_PARM_DESC(workaround_interval, | |||
139 | /* Assume that Broadcom 4320 (only chipset at time of writing known to be | 139 | /* Assume that Broadcom 4320 (only chipset at time of writing known to be |
140 | * based on wireless rndis) has default txpower of 13dBm. | 140 | * based on wireless rndis) has default txpower of 13dBm. |
141 | * This value is from Linksys WUSB54GSC User Guide, Appendix F: Specifications. | 141 | * This value is from Linksys WUSB54GSC User Guide, Appendix F: Specifications. |
142 | * 13dBm == 19.9mW | 142 | * 100% : 20 mW ~ 13dBm |
143 | * 75% : 15 mW ~ 12dBm | ||
144 | * 50% : 10 mW ~ 10dBm | ||
145 | * 25% : 5 mW ~ 7dBm | ||
143 | */ | 146 | */ |
144 | #define BCM4320_DEFAULT_TXPOWER 20 | 147 | #define BCM4320_DEFAULT_TXPOWER_DBM_100 13 |
148 | #define BCM4320_DEFAULT_TXPOWER_DBM_75 12 | ||
149 | #define BCM4320_DEFAULT_TXPOWER_DBM_50 10 | ||
150 | #define BCM4320_DEFAULT_TXPOWER_DBM_25 7 | ||
145 | 151 | ||
146 | 152 | ||
147 | /* codes for "status" field of completion messages */ | 153 | /* codes for "status" field of completion messages */ |
@@ -420,21 +426,30 @@ struct rndis_wlan_private { | |||
420 | /* | 426 | /* |
421 | * cfg80211 ops | 427 | * cfg80211 ops |
422 | */ | 428 | */ |
423 | static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex, | 429 | static int rndis_change_virtual_intf(struct wiphy *wiphy, |
430 | struct net_device *dev, | ||
424 | enum nl80211_iftype type, u32 *flags, | 431 | enum nl80211_iftype type, u32 *flags, |
425 | struct vif_params *params); | 432 | struct vif_params *params); |
426 | 433 | ||
427 | static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, | 434 | static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, |
428 | struct cfg80211_scan_request *request); | 435 | struct cfg80211_scan_request *request); |
429 | 436 | ||
437 | static int rndis_set_wiphy_params(struct wiphy *wiphy, u32 changed); | ||
438 | |||
439 | static int rndis_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type, | ||
440 | int dbm); | ||
441 | static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm); | ||
442 | |||
430 | static struct cfg80211_ops rndis_config_ops = { | 443 | static struct cfg80211_ops rndis_config_ops = { |
431 | .change_virtual_intf = rndis_change_virtual_intf, | 444 | .change_virtual_intf = rndis_change_virtual_intf, |
432 | .scan = rndis_scan, | 445 | .scan = rndis_scan, |
446 | .set_wiphy_params = rndis_set_wiphy_params, | ||
447 | .set_tx_power = rndis_set_tx_power, | ||
448 | .get_tx_power = rndis_get_tx_power, | ||
433 | }; | 449 | }; |
434 | 450 | ||
435 | static void *rndis_wiphy_privid = &rndis_wiphy_privid; | 451 | static void *rndis_wiphy_privid = &rndis_wiphy_privid; |
436 | 452 | ||
437 | static const int bcm4320_power_output[4] = { 25, 50, 75, 100 }; | ||
438 | 453 | ||
439 | static const unsigned char zero_bssid[ETH_ALEN] = {0,}; | 454 | static const unsigned char zero_bssid[ETH_ALEN] = {0,}; |
440 | static const unsigned char ffff_bssid[ETH_ALEN] = { 0xff, 0xff, 0xff, | 455 | static const unsigned char ffff_bssid[ETH_ALEN] = { 0xff, 0xff, 0xff, |
@@ -447,10 +462,19 @@ static struct rndis_wlan_private *get_rndis_wlan_priv(struct usbnet *dev) | |||
447 | } | 462 | } |
448 | 463 | ||
449 | 464 | ||
450 | static u32 get_bcm4320_power(struct rndis_wlan_private *priv) | 465 | static u32 get_bcm4320_power_dbm(struct rndis_wlan_private *priv) |
451 | { | 466 | { |
452 | return BCM4320_DEFAULT_TXPOWER * | 467 | switch (priv->param_power_output) { |
453 | bcm4320_power_output[priv->param_power_output] / 100; | 468 | default: |
469 | case 3: | ||
470 | return BCM4320_DEFAULT_TXPOWER_DBM_100; | ||
471 | case 2: | ||
472 | return BCM4320_DEFAULT_TXPOWER_DBM_75; | ||
473 | case 1: | ||
474 | return BCM4320_DEFAULT_TXPOWER_DBM_50; | ||
475 | case 0: | ||
476 | return BCM4320_DEFAULT_TXPOWER_DBM_25; | ||
477 | } | ||
454 | } | 478 | } |
455 | 479 | ||
456 | 480 | ||
@@ -968,6 +992,36 @@ static int set_infra_mode(struct usbnet *usbdev, int mode) | |||
968 | } | 992 | } |
969 | 993 | ||
970 | 994 | ||
995 | static int set_rts_threshold(struct usbnet *usbdev, u32 rts_threshold) | ||
996 | { | ||
997 | __le32 tmp; | ||
998 | |||
999 | devdbg(usbdev, "set_rts_threshold %i", rts_threshold); | ||
1000 | |||
1001 | if (rts_threshold < 0 || rts_threshold > 2347) | ||
1002 | rts_threshold = 2347; | ||
1003 | |||
1004 | tmp = cpu_to_le32(rts_threshold); | ||
1005 | return rndis_set_oid(usbdev, OID_802_11_RTS_THRESHOLD, &tmp, | ||
1006 | sizeof(tmp)); | ||
1007 | } | ||
1008 | |||
1009 | |||
1010 | static int set_frag_threshold(struct usbnet *usbdev, u32 frag_threshold) | ||
1011 | { | ||
1012 | __le32 tmp; | ||
1013 | |||
1014 | devdbg(usbdev, "set_frag_threshold %i", frag_threshold); | ||
1015 | |||
1016 | if (frag_threshold < 256 || frag_threshold > 2346) | ||
1017 | frag_threshold = 2346; | ||
1018 | |||
1019 | tmp = cpu_to_le32(frag_threshold); | ||
1020 | return rndis_set_oid(usbdev, OID_802_11_FRAGMENTATION_THRESHOLD, &tmp, | ||
1021 | sizeof(tmp)); | ||
1022 | } | ||
1023 | |||
1024 | |||
971 | static void set_default_iw_params(struct usbnet *usbdev) | 1025 | static void set_default_iw_params(struct usbnet *usbdev) |
972 | { | 1026 | { |
973 | struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); | 1027 | struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); |
@@ -1222,20 +1276,14 @@ static void set_multicast_list(struct usbnet *usbdev) | |||
1222 | /* | 1276 | /* |
1223 | * cfg80211 ops | 1277 | * cfg80211 ops |
1224 | */ | 1278 | */ |
1225 | static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex, | 1279 | static int rndis_change_virtual_intf(struct wiphy *wiphy, |
1280 | struct net_device *dev, | ||
1226 | enum nl80211_iftype type, u32 *flags, | 1281 | enum nl80211_iftype type, u32 *flags, |
1227 | struct vif_params *params) | 1282 | struct vif_params *params) |
1228 | { | 1283 | { |
1229 | struct net_device *dev; | 1284 | struct usbnet *usbdev = netdev_priv(dev); |
1230 | struct usbnet *usbdev; | ||
1231 | int mode; | 1285 | int mode; |
1232 | 1286 | ||
1233 | /* we're under RTNL */ | ||
1234 | dev = __dev_get_by_index(&init_net, ifindex); | ||
1235 | if (!dev) | ||
1236 | return -ENODEV; | ||
1237 | usbdev = netdev_priv(dev); | ||
1238 | |||
1239 | switch (type) { | 1287 | switch (type) { |
1240 | case NL80211_IFTYPE_ADHOC: | 1288 | case NL80211_IFTYPE_ADHOC: |
1241 | mode = NDIS_80211_INFRA_ADHOC; | 1289 | mode = NDIS_80211_INFRA_ADHOC; |
@@ -1251,6 +1299,64 @@ static int rndis_change_virtual_intf(struct wiphy *wiphy, int ifindex, | |||
1251 | } | 1299 | } |
1252 | 1300 | ||
1253 | 1301 | ||
1302 | static int rndis_set_wiphy_params(struct wiphy *wiphy, u32 changed) | ||
1303 | { | ||
1304 | struct rndis_wlan_private *priv = wiphy_priv(wiphy); | ||
1305 | struct usbnet *usbdev = priv->usbdev; | ||
1306 | int err; | ||
1307 | |||
1308 | if (changed & WIPHY_PARAM_FRAG_THRESHOLD) { | ||
1309 | err = set_frag_threshold(usbdev, wiphy->frag_threshold); | ||
1310 | if (err < 0) | ||
1311 | return err; | ||
1312 | } | ||
1313 | |||
1314 | if (changed & WIPHY_PARAM_RTS_THRESHOLD) { | ||
1315 | err = set_rts_threshold(usbdev, wiphy->rts_threshold); | ||
1316 | if (err < 0) | ||
1317 | return err; | ||
1318 | } | ||
1319 | |||
1320 | return 0; | ||
1321 | } | ||
1322 | |||
1323 | |||
1324 | static int rndis_set_tx_power(struct wiphy *wiphy, enum tx_power_setting type, | ||
1325 | int dbm) | ||
1326 | { | ||
1327 | struct rndis_wlan_private *priv = wiphy_priv(wiphy); | ||
1328 | struct usbnet *usbdev = priv->usbdev; | ||
1329 | |||
1330 | devdbg(usbdev, "rndis_set_tx_power type:0x%x dbm:%i", type, dbm); | ||
1331 | |||
1332 | /* Device doesn't support changing txpower after initialization, only | ||
1333 | * turn off/on radio. Support 'auto' mode and setting same dBm that is | ||
1334 | * currently used. | ||
1335 | */ | ||
1336 | if (type == TX_POWER_AUTOMATIC || dbm == get_bcm4320_power_dbm(priv)) { | ||
1337 | if (!priv->radio_on) | ||
1338 | disassociate(usbdev, 1); /* turn on radio */ | ||
1339 | |||
1340 | return 0; | ||
1341 | } | ||
1342 | |||
1343 | return -ENOTSUPP; | ||
1344 | } | ||
1345 | |||
1346 | |||
1347 | static int rndis_get_tx_power(struct wiphy *wiphy, int *dbm) | ||
1348 | { | ||
1349 | struct rndis_wlan_private *priv = wiphy_priv(wiphy); | ||
1350 | struct usbnet *usbdev = priv->usbdev; | ||
1351 | |||
1352 | *dbm = get_bcm4320_power_dbm(priv); | ||
1353 | |||
1354 | devdbg(usbdev, "rndis_get_tx_power dbm:%i", *dbm); | ||
1355 | |||
1356 | return 0; | ||
1357 | } | ||
1358 | |||
1359 | |||
1254 | #define SCAN_DELAY_JIFFIES (HZ) | 1360 | #define SCAN_DELAY_JIFFIES (HZ) |
1255 | static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, | 1361 | static int rndis_scan(struct wiphy *wiphy, struct net_device *dev, |
1256 | struct cfg80211_scan_request *request) | 1362 | struct cfg80211_scan_request *request) |
@@ -1766,74 +1872,6 @@ static int rndis_iw_get_genie(struct net_device *dev, | |||
1766 | } | 1872 | } |
1767 | 1873 | ||
1768 | 1874 | ||
1769 | static int rndis_iw_set_rts(struct net_device *dev, | ||
1770 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | ||
1771 | { | ||
1772 | struct usbnet *usbdev = netdev_priv(dev); | ||
1773 | __le32 tmp; | ||
1774 | devdbg(usbdev, "SIOCSIWRTS"); | ||
1775 | |||
1776 | tmp = cpu_to_le32(wrqu->rts.value); | ||
1777 | return rndis_set_oid(usbdev, OID_802_11_RTS_THRESHOLD, &tmp, | ||
1778 | sizeof(tmp)); | ||
1779 | } | ||
1780 | |||
1781 | |||
1782 | static int rndis_iw_get_rts(struct net_device *dev, | ||
1783 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | ||
1784 | { | ||
1785 | struct usbnet *usbdev = netdev_priv(dev); | ||
1786 | __le32 tmp; | ||
1787 | int len, ret; | ||
1788 | |||
1789 | len = sizeof(tmp); | ||
1790 | ret = rndis_query_oid(usbdev, OID_802_11_RTS_THRESHOLD, &tmp, &len); | ||
1791 | if (ret == 0) { | ||
1792 | wrqu->rts.value = le32_to_cpu(tmp); | ||
1793 | wrqu->rts.flags = 1; | ||
1794 | wrqu->rts.disabled = 0; | ||
1795 | } | ||
1796 | |||
1797 | devdbg(usbdev, "SIOCGIWRTS: %d", wrqu->rts.value); | ||
1798 | |||
1799 | return ret; | ||
1800 | } | ||
1801 | |||
1802 | |||
1803 | static int rndis_iw_set_frag(struct net_device *dev, | ||
1804 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | ||
1805 | { | ||
1806 | struct usbnet *usbdev = netdev_priv(dev); | ||
1807 | __le32 tmp; | ||
1808 | |||
1809 | devdbg(usbdev, "SIOCSIWFRAG"); | ||
1810 | |||
1811 | tmp = cpu_to_le32(wrqu->frag.value); | ||
1812 | return rndis_set_oid(usbdev, OID_802_11_FRAGMENTATION_THRESHOLD, &tmp, | ||
1813 | sizeof(tmp)); | ||
1814 | } | ||
1815 | |||
1816 | |||
1817 | static int rndis_iw_get_frag(struct net_device *dev, | ||
1818 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | ||
1819 | { | ||
1820 | struct usbnet *usbdev = netdev_priv(dev); | ||
1821 | __le32 tmp; | ||
1822 | int len, ret; | ||
1823 | |||
1824 | len = sizeof(tmp); | ||
1825 | ret = rndis_query_oid(usbdev, OID_802_11_FRAGMENTATION_THRESHOLD, &tmp, | ||
1826 | &len); | ||
1827 | if (ret == 0) { | ||
1828 | wrqu->frag.value = le32_to_cpu(tmp); | ||
1829 | wrqu->frag.flags = 1; | ||
1830 | wrqu->frag.disabled = 0; | ||
1831 | } | ||
1832 | devdbg(usbdev, "SIOCGIWFRAG: %d", wrqu->frag.value); | ||
1833 | return ret; | ||
1834 | } | ||
1835 | |||
1836 | |||
1837 | static int rndis_iw_set_freq(struct net_device *dev, | 1875 | static int rndis_iw_set_freq(struct net_device *dev, |
1838 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | 1876 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) |
1839 | { | 1877 | { |
@@ -1882,71 +1920,6 @@ static int rndis_iw_get_freq(struct net_device *dev, | |||
1882 | } | 1920 | } |
1883 | 1921 | ||
1884 | 1922 | ||
1885 | static int rndis_iw_get_txpower(struct net_device *dev, | ||
1886 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | ||
1887 | { | ||
1888 | struct usbnet *usbdev = netdev_priv(dev); | ||
1889 | struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); | ||
1890 | __le32 tx_power; | ||
1891 | |||
1892 | if (priv->radio_on) { | ||
1893 | /* fake since changing tx_power (by userlevel) not supported */ | ||
1894 | tx_power = cpu_to_le32(get_bcm4320_power(priv)); | ||
1895 | |||
1896 | wrqu->txpower.flags = IW_TXPOW_MWATT; | ||
1897 | wrqu->txpower.value = le32_to_cpu(tx_power); | ||
1898 | wrqu->txpower.disabled = 0; | ||
1899 | } else { | ||
1900 | wrqu->txpower.flags = IW_TXPOW_MWATT; | ||
1901 | wrqu->txpower.value = 0; | ||
1902 | wrqu->txpower.disabled = 1; | ||
1903 | } | ||
1904 | |||
1905 | devdbg(usbdev, "SIOCGIWTXPOW: %d", wrqu->txpower.value); | ||
1906 | |||
1907 | return 0; | ||
1908 | } | ||
1909 | |||
1910 | |||
1911 | static int rndis_iw_set_txpower(struct net_device *dev, | ||
1912 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | ||
1913 | { | ||
1914 | struct usbnet *usbdev = netdev_priv(dev); | ||
1915 | struct rndis_wlan_private *priv = get_rndis_wlan_priv(usbdev); | ||
1916 | __le32 tx_power = 0; | ||
1917 | |||
1918 | if (!wrqu->txpower.disabled) { | ||
1919 | if (wrqu->txpower.flags == IW_TXPOW_MWATT) | ||
1920 | tx_power = cpu_to_le32(wrqu->txpower.value); | ||
1921 | else { /* wrqu->txpower.flags == IW_TXPOW_DBM */ | ||
1922 | if (wrqu->txpower.value > 20) | ||
1923 | tx_power = cpu_to_le32(128); | ||
1924 | else if (wrqu->txpower.value < -43) | ||
1925 | tx_power = cpu_to_le32(127); | ||
1926 | else { | ||
1927 | signed char tmp; | ||
1928 | tmp = wrqu->txpower.value; | ||
1929 | tmp = -12 - tmp; | ||
1930 | tmp <<= 2; | ||
1931 | tx_power = cpu_to_le32((unsigned char)tmp); | ||
1932 | } | ||
1933 | } | ||
1934 | } | ||
1935 | |||
1936 | devdbg(usbdev, "SIOCSIWTXPOW: %d", le32_to_cpu(tx_power)); | ||
1937 | |||
1938 | if (le32_to_cpu(tx_power) != 0) { | ||
1939 | /* txpower unsupported, just turn radio on */ | ||
1940 | if (!priv->radio_on) | ||
1941 | return disassociate(usbdev, 1); | ||
1942 | return 0; /* all ready on */ | ||
1943 | } | ||
1944 | |||
1945 | /* tx_power == 0, turn off radio */ | ||
1946 | return disassociate(usbdev, 0); | ||
1947 | } | ||
1948 | |||
1949 | |||
1950 | static int rndis_iw_get_rate(struct net_device *dev, | 1923 | static int rndis_iw_get_rate(struct net_device *dev, |
1951 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) | 1924 | struct iw_request_info *info, union iwreq_data *wrqu, char *extra) |
1952 | { | 1925 | { |
@@ -2022,12 +1995,12 @@ static const iw_handler rndis_iw_handler[] = | |||
2022 | IW_IOCTL(SIOCSIWESSID) = rndis_iw_set_essid, | 1995 | IW_IOCTL(SIOCSIWESSID) = rndis_iw_set_essid, |
2023 | IW_IOCTL(SIOCGIWESSID) = rndis_iw_get_essid, | 1996 | IW_IOCTL(SIOCGIWESSID) = rndis_iw_get_essid, |
2024 | IW_IOCTL(SIOCGIWRATE) = rndis_iw_get_rate, | 1997 | IW_IOCTL(SIOCGIWRATE) = rndis_iw_get_rate, |
2025 | IW_IOCTL(SIOCSIWRTS) = rndis_iw_set_rts, | 1998 | IW_IOCTL(SIOCSIWRTS) = (iw_handler) cfg80211_wext_siwrts, |
2026 | IW_IOCTL(SIOCGIWRTS) = rndis_iw_get_rts, | 1999 | IW_IOCTL(SIOCGIWRTS) = (iw_handler) cfg80211_wext_giwrts, |
2027 | IW_IOCTL(SIOCSIWFRAG) = rndis_iw_set_frag, | 2000 | IW_IOCTL(SIOCSIWFRAG) = (iw_handler) cfg80211_wext_siwfrag, |
2028 | IW_IOCTL(SIOCGIWFRAG) = rndis_iw_get_frag, | 2001 | IW_IOCTL(SIOCGIWFRAG) = (iw_handler) cfg80211_wext_giwfrag, |
2029 | IW_IOCTL(SIOCSIWTXPOW) = rndis_iw_set_txpower, | 2002 | IW_IOCTL(SIOCSIWTXPOW) = (iw_handler) cfg80211_wext_siwtxpower, |
2030 | IW_IOCTL(SIOCGIWTXPOW) = rndis_iw_get_txpower, | 2003 | IW_IOCTL(SIOCGIWTXPOW) = (iw_handler) cfg80211_wext_giwtxpower, |
2031 | IW_IOCTL(SIOCSIWENCODE) = rndis_iw_set_encode, | 2004 | IW_IOCTL(SIOCSIWENCODE) = rndis_iw_set_encode, |
2032 | IW_IOCTL(SIOCSIWENCODEEXT) = rndis_iw_set_encode_ext, | 2005 | IW_IOCTL(SIOCSIWENCODEEXT) = rndis_iw_set_encode_ext, |
2033 | IW_IOCTL(SIOCSIWAUTH) = rndis_iw_set_auth, | 2006 | IW_IOCTL(SIOCSIWAUTH) = rndis_iw_set_auth, |
@@ -2475,6 +2448,10 @@ static int rndis_wlan_bind(struct usbnet *usbdev, struct usb_interface *intf) | |||
2475 | 2448 | ||
2476 | set_default_iw_params(usbdev); | 2449 | set_default_iw_params(usbdev); |
2477 | 2450 | ||
2451 | /* set default rts/frag */ | ||
2452 | rndis_set_wiphy_params(wiphy, | ||
2453 | WIPHY_PARAM_FRAG_THRESHOLD | WIPHY_PARAM_RTS_THRESHOLD); | ||
2454 | |||
2478 | /* turn radio on */ | 2455 | /* turn radio on */ |
2479 | priv->radio_on = 1; | 2456 | priv->radio_on = 1; |
2480 | disassociate(usbdev, 1); | 2457 | disassociate(usbdev, 1); |
@@ -2522,10 +2499,18 @@ static void rndis_wlan_unbind(struct usbnet *usbdev, struct usb_interface *intf) | |||
2522 | 2499 | ||
2523 | static int rndis_wlan_reset(struct usbnet *usbdev) | 2500 | static int rndis_wlan_reset(struct usbnet *usbdev) |
2524 | { | 2501 | { |
2502 | devdbg(usbdev, "rndis_wlan_reset"); | ||
2525 | return deauthenticate(usbdev); | 2503 | return deauthenticate(usbdev); |
2526 | } | 2504 | } |
2527 | 2505 | ||
2528 | 2506 | ||
2507 | static int rndis_wlan_stop(struct usbnet *usbdev) | ||
2508 | { | ||
2509 | devdbg(usbdev, "rndis_wlan_stop"); | ||
2510 | return disassociate(usbdev, 0); | ||
2511 | } | ||
2512 | |||
2513 | |||
2529 | static const struct driver_info bcm4320b_info = { | 2514 | static const struct driver_info bcm4320b_info = { |
2530 | .description = "Wireless RNDIS device, BCM4320b based", | 2515 | .description = "Wireless RNDIS device, BCM4320b based", |
2531 | .flags = FLAG_WLAN | FLAG_FRAMING_RN | FLAG_NO_SETINT, | 2516 | .flags = FLAG_WLAN | FLAG_FRAMING_RN | FLAG_NO_SETINT, |
@@ -2535,6 +2520,7 @@ static const struct driver_info bcm4320b_info = { | |||
2535 | .rx_fixup = rndis_rx_fixup, | 2520 | .rx_fixup = rndis_rx_fixup, |
2536 | .tx_fixup = rndis_tx_fixup, | 2521 | .tx_fixup = rndis_tx_fixup, |
2537 | .reset = rndis_wlan_reset, | 2522 | .reset = rndis_wlan_reset, |
2523 | .stop = rndis_wlan_stop, | ||
2538 | .early_init = bcm4320b_early_init, | 2524 | .early_init = bcm4320b_early_init, |
2539 | .link_change = rndis_wlan_link_change, | 2525 | .link_change = rndis_wlan_link_change, |
2540 | }; | 2526 | }; |
@@ -2548,6 +2534,7 @@ static const struct driver_info bcm4320a_info = { | |||
2548 | .rx_fixup = rndis_rx_fixup, | 2534 | .rx_fixup = rndis_rx_fixup, |
2549 | .tx_fixup = rndis_tx_fixup, | 2535 | .tx_fixup = rndis_tx_fixup, |
2550 | .reset = rndis_wlan_reset, | 2536 | .reset = rndis_wlan_reset, |
2537 | .stop = rndis_wlan_stop, | ||
2551 | .early_init = bcm4320a_early_init, | 2538 | .early_init = bcm4320a_early_init, |
2552 | .link_change = rndis_wlan_link_change, | 2539 | .link_change = rndis_wlan_link_change, |
2553 | }; | 2540 | }; |
@@ -2561,6 +2548,7 @@ static const struct driver_info rndis_wlan_info = { | |||
2561 | .rx_fixup = rndis_rx_fixup, | 2548 | .rx_fixup = rndis_rx_fixup, |
2562 | .tx_fixup = rndis_tx_fixup, | 2549 | .tx_fixup = rndis_tx_fixup, |
2563 | .reset = rndis_wlan_reset, | 2550 | .reset = rndis_wlan_reset, |
2551 | .stop = rndis_wlan_stop, | ||
2564 | .early_init = bcm4320a_early_init, | 2552 | .early_init = bcm4320a_early_init, |
2565 | .link_change = rndis_wlan_link_change, | 2553 | .link_change = rndis_wlan_link_change, |
2566 | }; | 2554 | }; |
diff --git a/drivers/net/wireless/rt2x00/Kconfig b/drivers/net/wireless/rt2x00/Kconfig index 8aab3e6754bd..f970aa25326a 100644 --- a/drivers/net/wireless/rt2x00/Kconfig +++ b/drivers/net/wireless/rt2x00/Kconfig | |||
@@ -112,14 +112,6 @@ config RT2X00_LIB_FIRMWARE | |||
112 | config RT2X00_LIB_CRYPTO | 112 | config RT2X00_LIB_CRYPTO |
113 | boolean | 113 | boolean |
114 | 114 | ||
115 | config RT2X00_LIB_RFKILL | ||
116 | boolean | ||
117 | default y if (RT2X00_LIB=y && INPUT=y) || (RT2X00_LIB=m && INPUT!=n) | ||
118 | select INPUT_POLLDEV | ||
119 | |||
120 | comment "rt2x00 rfkill support disabled due to modularized INPUT and built-in rt2x00" | ||
121 | depends on RT2X00_LIB=y && INPUT=m | ||
122 | |||
123 | config RT2X00_LIB_LEDS | 115 | config RT2X00_LIB_LEDS |
124 | boolean | 116 | boolean |
125 | default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n) | 117 | default y if (RT2X00_LIB=y && LEDS_CLASS=y) || (RT2X00_LIB=m && LEDS_CLASS!=n) |
diff --git a/drivers/net/wireless/rt2x00/Makefile b/drivers/net/wireless/rt2x00/Makefile index bfc7226f0afe..13043ea97667 100644 --- a/drivers/net/wireless/rt2x00/Makefile +++ b/drivers/net/wireless/rt2x00/Makefile | |||
@@ -5,7 +5,6 @@ rt2x00lib-y += rt2x00queue.o | |||
5 | rt2x00lib-y += rt2x00link.o | 5 | rt2x00lib-y += rt2x00link.o |
6 | rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) += rt2x00debug.o | 6 | rt2x00lib-$(CONFIG_RT2X00_LIB_DEBUGFS) += rt2x00debug.o |
7 | rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o | 7 | rt2x00lib-$(CONFIG_RT2X00_LIB_CRYPTO) += rt2x00crypto.o |
8 | rt2x00lib-$(CONFIG_RT2X00_LIB_RFKILL) += rt2x00rfkill.o | ||
9 | rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o | 8 | rt2x00lib-$(CONFIG_RT2X00_LIB_FIRMWARE) += rt2x00firmware.o |
10 | rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o | 9 | rt2x00lib-$(CONFIG_RT2X00_LIB_LEDS) += rt2x00leds.o |
11 | rt2x00lib-$(CONFIG_RT2X00_LIB_HT) += rt2x00ht.o | 10 | rt2x00lib-$(CONFIG_RT2X00_LIB_HT) += rt2x00ht.o |
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c index 435f945fe64d..d8035e3575e8 100644 --- a/drivers/net/wireless/rt2x00/rt2400pci.c +++ b/drivers/net/wireless/rt2x00/rt2400pci.c | |||
@@ -199,7 +199,6 @@ static const struct rt2x00debug rt2400pci_rt2x00debug = { | |||
199 | }; | 199 | }; |
200 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ | 200 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
201 | 201 | ||
202 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
203 | static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) | 202 | static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) |
204 | { | 203 | { |
205 | u32 reg; | 204 | u32 reg; |
@@ -207,9 +206,6 @@ static int rt2400pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) | |||
207 | rt2x00pci_register_read(rt2x00dev, GPIOCSR, ®); | 206 | rt2x00pci_register_read(rt2x00dev, GPIOCSR, ®); |
208 | return rt2x00_get_field32(reg, GPIOCSR_BIT0); | 207 | return rt2x00_get_field32(reg, GPIOCSR_BIT0); |
209 | } | 208 | } |
210 | #else | ||
211 | #define rt2400pci_rfkill_poll NULL | ||
212 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
213 | 209 | ||
214 | #ifdef CONFIG_RT2X00_LIB_LEDS | 210 | #ifdef CONFIG_RT2X00_LIB_LEDS |
215 | static void rt2400pci_brightness_set(struct led_classdev *led_cdev, | 211 | static void rt2400pci_brightness_set(struct led_classdev *led_cdev, |
@@ -1391,10 +1387,8 @@ static int rt2400pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1391 | /* | 1387 | /* |
1392 | * Detect if this device has an hardware controlled radio. | 1388 | * Detect if this device has an hardware controlled radio. |
1393 | */ | 1389 | */ |
1394 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
1395 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) | 1390 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) |
1396 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); | 1391 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); |
1397 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
1398 | 1392 | ||
1399 | /* | 1393 | /* |
1400 | * Check if the BBP tuning should be enabled. | 1394 | * Check if the BBP tuning should be enabled. |
@@ -1573,6 +1567,7 @@ static const struct ieee80211_ops rt2400pci_mac80211_ops = { | |||
1573 | .get_tx_stats = rt2x00mac_get_tx_stats, | 1567 | .get_tx_stats = rt2x00mac_get_tx_stats, |
1574 | .get_tsf = rt2400pci_get_tsf, | 1568 | .get_tsf = rt2400pci_get_tsf, |
1575 | .tx_last_beacon = rt2400pci_tx_last_beacon, | 1569 | .tx_last_beacon = rt2400pci_tx_last_beacon, |
1570 | .rfkill_poll = rt2x00mac_rfkill_poll, | ||
1576 | }; | 1571 | }; |
1577 | 1572 | ||
1578 | static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = { | 1573 | static const struct rt2x00lib_ops rt2400pci_rt2x00_ops = { |
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c index 08b30d01e67d..c123e28396d0 100644 --- a/drivers/net/wireless/rt2x00/rt2500pci.c +++ b/drivers/net/wireless/rt2x00/rt2500pci.c | |||
@@ -199,7 +199,6 @@ static const struct rt2x00debug rt2500pci_rt2x00debug = { | |||
199 | }; | 199 | }; |
200 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ | 200 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
201 | 201 | ||
202 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
203 | static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) | 202 | static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) |
204 | { | 203 | { |
205 | u32 reg; | 204 | u32 reg; |
@@ -207,9 +206,6 @@ static int rt2500pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) | |||
207 | rt2x00pci_register_read(rt2x00dev, GPIOCSR, ®); | 206 | rt2x00pci_register_read(rt2x00dev, GPIOCSR, ®); |
208 | return rt2x00_get_field32(reg, GPIOCSR_BIT0); | 207 | return rt2x00_get_field32(reg, GPIOCSR_BIT0); |
209 | } | 208 | } |
210 | #else | ||
211 | #define rt2500pci_rfkill_poll NULL | ||
212 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
213 | 209 | ||
214 | #ifdef CONFIG_RT2X00_LIB_LEDS | 210 | #ifdef CONFIG_RT2X00_LIB_LEDS |
215 | static void rt2500pci_brightness_set(struct led_classdev *led_cdev, | 211 | static void rt2500pci_brightness_set(struct led_classdev *led_cdev, |
@@ -1548,10 +1544,8 @@ static int rt2500pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1548 | /* | 1544 | /* |
1549 | * Detect if this device has an hardware controlled radio. | 1545 | * Detect if this device has an hardware controlled radio. |
1550 | */ | 1546 | */ |
1551 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
1552 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) | 1547 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) |
1553 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); | 1548 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); |
1554 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
1555 | 1549 | ||
1556 | /* | 1550 | /* |
1557 | * Check if the BBP tuning should be enabled. | 1551 | * Check if the BBP tuning should be enabled. |
@@ -1872,6 +1866,7 @@ static const struct ieee80211_ops rt2500pci_mac80211_ops = { | |||
1872 | .get_tx_stats = rt2x00mac_get_tx_stats, | 1866 | .get_tx_stats = rt2x00mac_get_tx_stats, |
1873 | .get_tsf = rt2500pci_get_tsf, | 1867 | .get_tsf = rt2500pci_get_tsf, |
1874 | .tx_last_beacon = rt2500pci_tx_last_beacon, | 1868 | .tx_last_beacon = rt2500pci_tx_last_beacon, |
1869 | .rfkill_poll = rt2x00mac_rfkill_poll, | ||
1875 | }; | 1870 | }; |
1876 | 1871 | ||
1877 | static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = { | 1872 | static const struct rt2x00lib_ops rt2500pci_rt2x00_ops = { |
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c index 66daf68ff0ee..795706d63b94 100644 --- a/drivers/net/wireless/rt2x00/rt2500usb.c +++ b/drivers/net/wireless/rt2x00/rt2500usb.c | |||
@@ -277,7 +277,6 @@ static const struct rt2x00debug rt2500usb_rt2x00debug = { | |||
277 | }; | 277 | }; |
278 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ | 278 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
279 | 279 | ||
280 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
281 | static int rt2500usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) | 280 | static int rt2500usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) |
282 | { | 281 | { |
283 | u16 reg; | 282 | u16 reg; |
@@ -285,9 +284,6 @@ static int rt2500usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) | |||
285 | rt2500usb_register_read(rt2x00dev, MAC_CSR19, ®); | 284 | rt2500usb_register_read(rt2x00dev, MAC_CSR19, ®); |
286 | return rt2x00_get_field32(reg, MAC_CSR19_BIT7); | 285 | return rt2x00_get_field32(reg, MAC_CSR19_BIT7); |
287 | } | 286 | } |
288 | #else | ||
289 | #define rt2500usb_rfkill_poll NULL | ||
290 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
291 | 287 | ||
292 | #ifdef CONFIG_RT2X00_LIB_LEDS | 288 | #ifdef CONFIG_RT2X00_LIB_LEDS |
293 | static void rt2500usb_brightness_set(struct led_classdev *led_cdev, | 289 | static void rt2500usb_brightness_set(struct led_classdev *led_cdev, |
@@ -1601,10 +1597,8 @@ static int rt2500usb_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1601 | /* | 1597 | /* |
1602 | * Detect if this device has an hardware controlled radio. | 1598 | * Detect if this device has an hardware controlled radio. |
1603 | */ | 1599 | */ |
1604 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
1605 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) | 1600 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) |
1606 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); | 1601 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); |
1607 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
1608 | 1602 | ||
1609 | /* | 1603 | /* |
1610 | * Check if the BBP tuning should be disabled. | 1604 | * Check if the BBP tuning should be disabled. |
@@ -1905,6 +1899,7 @@ static const struct ieee80211_ops rt2500usb_mac80211_ops = { | |||
1905 | .bss_info_changed = rt2x00mac_bss_info_changed, | 1899 | .bss_info_changed = rt2x00mac_bss_info_changed, |
1906 | .conf_tx = rt2x00mac_conf_tx, | 1900 | .conf_tx = rt2x00mac_conf_tx, |
1907 | .get_tx_stats = rt2x00mac_get_tx_stats, | 1901 | .get_tx_stats = rt2x00mac_get_tx_stats, |
1902 | .rfkill_poll = rt2x00mac_rfkill_poll, | ||
1908 | }; | 1903 | }; |
1909 | 1904 | ||
1910 | static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = { | 1905 | static const struct rt2x00lib_ops rt2500usb_rt2x00_ops = { |
diff --git a/drivers/net/wireless/rt2x00/rt2800usb.c b/drivers/net/wireless/rt2x00/rt2800usb.c index 37561667925b..a204e66753c2 100644 --- a/drivers/net/wireless/rt2x00/rt2800usb.c +++ b/drivers/net/wireless/rt2x00/rt2800usb.c | |||
@@ -264,7 +264,6 @@ static const struct rt2x00debug rt2800usb_rt2x00debug = { | |||
264 | }; | 264 | }; |
265 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ | 265 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
266 | 266 | ||
267 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
268 | static int rt2800usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) | 267 | static int rt2800usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) |
269 | { | 268 | { |
270 | u32 reg; | 269 | u32 reg; |
@@ -272,9 +271,6 @@ static int rt2800usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) | |||
272 | rt2x00usb_register_read(rt2x00dev, GPIO_CTRL_CFG, ®); | 271 | rt2x00usb_register_read(rt2x00dev, GPIO_CTRL_CFG, ®); |
273 | return rt2x00_get_field32(reg, GPIO_CTRL_CFG_BIT2); | 272 | return rt2x00_get_field32(reg, GPIO_CTRL_CFG_BIT2); |
274 | } | 273 | } |
275 | #else | ||
276 | #define rt2800usb_rfkill_poll NULL | ||
277 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
278 | 274 | ||
279 | #ifdef CONFIG_RT2X00_LIB_LEDS | 275 | #ifdef CONFIG_RT2X00_LIB_LEDS |
280 | static void rt2800usb_brightness_set(struct led_classdev *led_cdev, | 276 | static void rt2800usb_brightness_set(struct led_classdev *led_cdev, |
@@ -2385,10 +2381,8 @@ static int rt2800usb_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
2385 | /* | 2381 | /* |
2386 | * Detect if this device has an hardware controlled radio. | 2382 | * Detect if this device has an hardware controlled radio. |
2387 | */ | 2383 | */ |
2388 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
2389 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO)) | 2384 | if (rt2x00_get_field16(eeprom, EEPROM_NIC_HW_RADIO)) |
2390 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); | 2385 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); |
2391 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
2392 | 2386 | ||
2393 | /* | 2387 | /* |
2394 | * Store led settings, for correct led behaviour. | 2388 | * Store led settings, for correct led behaviour. |
@@ -2800,6 +2794,7 @@ static const struct ieee80211_ops rt2800usb_mac80211_ops = { | |||
2800 | .conf_tx = rt2800usb_conf_tx, | 2794 | .conf_tx = rt2800usb_conf_tx, |
2801 | .get_tx_stats = rt2x00mac_get_tx_stats, | 2795 | .get_tx_stats = rt2x00mac_get_tx_stats, |
2802 | .get_tsf = rt2800usb_get_tsf, | 2796 | .get_tsf = rt2800usb_get_tsf, |
2797 | .rfkill_poll = rt2x00mac_rfkill_poll, | ||
2803 | }; | 2798 | }; |
2804 | 2799 | ||
2805 | static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = { | 2800 | static const struct rt2x00lib_ops rt2800usb_rt2x00_ops = { |
diff --git a/drivers/net/wireless/rt2x00/rt2x00.h b/drivers/net/wireless/rt2x00/rt2x00.h index a498dde024e1..71f37cb476b0 100644 --- a/drivers/net/wireless/rt2x00/rt2x00.h +++ b/drivers/net/wireless/rt2x00/rt2x00.h | |||
@@ -651,18 +651,6 @@ struct rt2x00_dev { | |||
651 | enum ieee80211_band curr_band; | 651 | enum ieee80211_band curr_band; |
652 | 652 | ||
653 | /* | 653 | /* |
654 | * rfkill structure for RF state switching support. | ||
655 | * This will only be compiled in when required. | ||
656 | */ | ||
657 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
658 | unsigned long rfkill_state; | ||
659 | #define RFKILL_STATE_ALLOCATED 1 | ||
660 | #define RFKILL_STATE_REGISTERED 2 | ||
661 | #define RFKILL_STATE_BLOCKED 3 | ||
662 | struct input_polled_dev *rfkill_poll_dev; | ||
663 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
664 | |||
665 | /* | ||
666 | * If enabled, the debugfs interface structures | 654 | * If enabled, the debugfs interface structures |
667 | * required for deregistration of debugfs. | 655 | * required for deregistration of debugfs. |
668 | */ | 656 | */ |
@@ -992,6 +980,7 @@ void rt2x00mac_bss_info_changed(struct ieee80211_hw *hw, | |||
992 | u32 changes); | 980 | u32 changes); |
993 | int rt2x00mac_conf_tx(struct ieee80211_hw *hw, u16 queue, | 981 | int rt2x00mac_conf_tx(struct ieee80211_hw *hw, u16 queue, |
994 | const struct ieee80211_tx_queue_params *params); | 982 | const struct ieee80211_tx_queue_params *params); |
983 | void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw); | ||
995 | 984 | ||
996 | /* | 985 | /* |
997 | * Driver allocation handlers. | 986 | * Driver allocation handlers. |
diff --git a/drivers/net/wireless/rt2x00/rt2x00crypto.c b/drivers/net/wireless/rt2x00/rt2x00crypto.c index bc4e81e21841..c54eda3c2db0 100644 --- a/drivers/net/wireless/rt2x00/rt2x00crypto.c +++ b/drivers/net/wireless/rt2x00/rt2x00crypto.c | |||
@@ -53,8 +53,7 @@ void rt2x00crypto_create_tx_descriptor(struct queue_entry *entry, | |||
53 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); | 53 | struct ieee80211_tx_info *tx_info = IEEE80211_SKB_CB(entry->skb); |
54 | struct ieee80211_key_conf *hw_key = tx_info->control.hw_key; | 54 | struct ieee80211_key_conf *hw_key = tx_info->control.hw_key; |
55 | 55 | ||
56 | if (!test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags) || | 56 | if (!test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags) || !hw_key) |
57 | !hw_key || entry->skb->do_not_encrypt) | ||
58 | return; | 57 | return; |
59 | 58 | ||
60 | __set_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags); | 59 | __set_bit(ENTRY_TXD_ENCRYPT, &txdesc->flags); |
@@ -82,8 +81,7 @@ unsigned int rt2x00crypto_tx_overhead(struct rt2x00_dev *rt2x00dev, | |||
82 | struct ieee80211_key_conf *key = tx_info->control.hw_key; | 81 | struct ieee80211_key_conf *key = tx_info->control.hw_key; |
83 | unsigned int overhead = 0; | 82 | unsigned int overhead = 0; |
84 | 83 | ||
85 | if (!test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags) || | 84 | if (!test_bit(CONFIG_SUPPORT_HW_CRYPTO, &rt2x00dev->flags) || !key) |
86 | !key || skb->do_not_encrypt) | ||
87 | return overhead; | 85 | return overhead; |
88 | 86 | ||
89 | /* | 87 | /* |
diff --git a/drivers/net/wireless/rt2x00/rt2x00dev.c b/drivers/net/wireless/rt2x00/rt2x00dev.c index 57813e72c808..4fff3a83f7df 100644 --- a/drivers/net/wireless/rt2x00/rt2x00dev.c +++ b/drivers/net/wireless/rt2x00/rt2x00dev.c | |||
@@ -449,7 +449,8 @@ void rt2x00lib_rxdone(struct rt2x00_dev *rt2x00dev, | |||
449 | * mac80211 will clean up the skb structure. | 449 | * mac80211 will clean up the skb structure. |
450 | */ | 450 | */ |
451 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_RXDONE, entry->skb); | 451 | rt2x00debug_dump_frame(rt2x00dev, DUMP_FRAME_RXDONE, entry->skb); |
452 | ieee80211_rx_irqsafe(rt2x00dev->hw, entry->skb, rx_status); | 452 | memcpy(IEEE80211_SKB_RXCB(entry->skb), rx_status, sizeof(*rx_status)); |
453 | ieee80211_rx_irqsafe(rt2x00dev->hw, entry->skb); | ||
453 | 454 | ||
454 | /* | 455 | /* |
455 | * Replace the skb with the freshly allocated one. | 456 | * Replace the skb with the freshly allocated one. |
@@ -870,7 +871,6 @@ int rt2x00lib_probe_dev(struct rt2x00_dev *rt2x00dev) | |||
870 | */ | 871 | */ |
871 | rt2x00link_register(rt2x00dev); | 872 | rt2x00link_register(rt2x00dev); |
872 | rt2x00leds_register(rt2x00dev); | 873 | rt2x00leds_register(rt2x00dev); |
873 | rt2x00rfkill_allocate(rt2x00dev); | ||
874 | rt2x00debug_register(rt2x00dev); | 874 | rt2x00debug_register(rt2x00dev); |
875 | 875 | ||
876 | set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); | 876 | set_bit(DEVICE_STATE_PRESENT, &rt2x00dev->flags); |
@@ -902,7 +902,6 @@ void rt2x00lib_remove_dev(struct rt2x00_dev *rt2x00dev) | |||
902 | * Free extra components | 902 | * Free extra components |
903 | */ | 903 | */ |
904 | rt2x00debug_deregister(rt2x00dev); | 904 | rt2x00debug_deregister(rt2x00dev); |
905 | rt2x00rfkill_free(rt2x00dev); | ||
906 | rt2x00leds_unregister(rt2x00dev); | 905 | rt2x00leds_unregister(rt2x00dev); |
907 | 906 | ||
908 | /* | 907 | /* |
diff --git a/drivers/net/wireless/rt2x00/rt2x00lib.h b/drivers/net/wireless/rt2x00/rt2x00lib.h index 0bf2715fa93a..512fa2bc3a10 100644 --- a/drivers/net/wireless/rt2x00/rt2x00lib.h +++ b/drivers/net/wireless/rt2x00/rt2x00lib.h | |||
@@ -30,10 +30,8 @@ | |||
30 | 30 | ||
31 | /* | 31 | /* |
32 | * Interval defines | 32 | * Interval defines |
33 | * Both the link tuner as the rfkill will be called once per second. | ||
34 | */ | 33 | */ |
35 | #define LINK_TUNE_INTERVAL round_jiffies_relative(HZ) | 34 | #define LINK_TUNE_INTERVAL round_jiffies_relative(HZ) |
36 | #define RFKILL_POLL_INTERVAL 1000 | ||
37 | 35 | ||
38 | /* | 36 | /* |
39 | * rt2x00_rate: Per rate device information | 37 | * rt2x00_rate: Per rate device information |
@@ -386,29 +384,18 @@ static inline void rt2x00ht_create_tx_descriptor(struct queue_entry *entry, | |||
386 | /* | 384 | /* |
387 | * RFkill handlers. | 385 | * RFkill handlers. |
388 | */ | 386 | */ |
389 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
390 | void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev); | ||
391 | void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev); | ||
392 | void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev); | ||
393 | void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev); | ||
394 | #else | ||
395 | static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) | 387 | static inline void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) |
396 | { | 388 | { |
389 | if (test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) | ||
390 | wiphy_rfkill_start_polling(rt2x00dev->hw->wiphy); | ||
397 | } | 391 | } |
398 | 392 | ||
399 | static inline void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev) | 393 | static inline void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev) |
400 | { | 394 | { |
395 | if (test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) | ||
396 | wiphy_rfkill_stop_polling(rt2x00dev->hw->wiphy); | ||
401 | } | 397 | } |
402 | 398 | ||
403 | static inline void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) | ||
404 | { | ||
405 | } | ||
406 | |||
407 | static inline void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) | ||
408 | { | ||
409 | } | ||
410 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
411 | |||
412 | /* | 399 | /* |
413 | * LED handlers | 400 | * LED handlers |
414 | */ | 401 | */ |
diff --git a/drivers/net/wireless/rt2x00/rt2x00mac.c b/drivers/net/wireless/rt2x00/rt2x00mac.c index c4c06b4e1f08..b7e0ddda38f5 100644 --- a/drivers/net/wireless/rt2x00/rt2x00mac.c +++ b/drivers/net/wireless/rt2x00/rt2x00mac.c | |||
@@ -73,7 +73,8 @@ static int rt2x00mac_tx_rts_cts(struct rt2x00_dev *rt2x00dev, | |||
73 | else | 73 | else |
74 | rts_info->flags &= ~IEEE80211_TX_CTL_NO_ACK; | 74 | rts_info->flags &= ~IEEE80211_TX_CTL_NO_ACK; |
75 | 75 | ||
76 | skb->do_not_encrypt = 1; | 76 | /* Disable hardware encryption */ |
77 | rts_info->control.hw_key = NULL; | ||
77 | 78 | ||
78 | /* | 79 | /* |
79 | * RTS/CTS frame should use the length of the frame plus any | 80 | * RTS/CTS frame should use the length of the frame plus any |
@@ -687,3 +688,12 @@ int rt2x00mac_conf_tx(struct ieee80211_hw *hw, u16 queue_idx, | |||
687 | return 0; | 688 | return 0; |
688 | } | 689 | } |
689 | EXPORT_SYMBOL_GPL(rt2x00mac_conf_tx); | 690 | EXPORT_SYMBOL_GPL(rt2x00mac_conf_tx); |
691 | |||
692 | void rt2x00mac_rfkill_poll(struct ieee80211_hw *hw) | ||
693 | { | ||
694 | struct rt2x00_dev *rt2x00dev = hw->priv; | ||
695 | bool blocked = !!rt2x00dev->ops->lib->rfkill_poll(rt2x00dev); | ||
696 | |||
697 | wiphy_rfkill_set_hw_state(hw->wiphy, blocked); | ||
698 | } | ||
699 | EXPORT_SYMBOL_GPL(rt2x00mac_rfkill_poll); | ||
diff --git a/drivers/net/wireless/rt2x00/rt2x00rfkill.c b/drivers/net/wireless/rt2x00/rt2x00rfkill.c deleted file mode 100644 index b6d4c6700bf3..000000000000 --- a/drivers/net/wireless/rt2x00/rt2x00rfkill.c +++ /dev/null | |||
@@ -1,127 +0,0 @@ | |||
1 | /* | ||
2 | Copyright (C) 2004 - 2009 rt2x00 SourceForge Project | ||
3 | <http://rt2x00.serialmonkey.com> | ||
4 | |||
5 | This program is free software; you can redistribute it and/or modify | ||
6 | it under the terms of the GNU General Public License as published by | ||
7 | the Free Software Foundation; either version 2 of the License, or | ||
8 | (at your option) any later version. | ||
9 | |||
10 | This program is distributed in the hope that it will be useful, | ||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
13 | GNU General Public License for more details. | ||
14 | |||
15 | You should have received a copy of the GNU General Public License | ||
16 | along with this program; if not, write to the | ||
17 | Free Software Foundation, Inc., | ||
18 | 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | ||
19 | */ | ||
20 | |||
21 | /* | ||
22 | Module: rt2x00rfkill | ||
23 | Abstract: rt2x00 rfkill routines. | ||
24 | */ | ||
25 | |||
26 | #include <linux/kernel.h> | ||
27 | #include <linux/module.h> | ||
28 | |||
29 | #include "rt2x00.h" | ||
30 | #include "rt2x00lib.h" | ||
31 | |||
32 | static void rt2x00rfkill_poll(struct input_polled_dev *poll_dev) | ||
33 | { | ||
34 | struct rt2x00_dev *rt2x00dev = poll_dev->private; | ||
35 | int state, old_state; | ||
36 | |||
37 | if (!test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state) || | ||
38 | !test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) | ||
39 | return; | ||
40 | |||
41 | /* | ||
42 | * Poll latest state, if the state is different then the previous state, | ||
43 | * we should generate an input event. | ||
44 | */ | ||
45 | state = !!rt2x00dev->ops->lib->rfkill_poll(rt2x00dev); | ||
46 | old_state = !!test_bit(RFKILL_STATE_BLOCKED, &rt2x00dev->rfkill_state); | ||
47 | |||
48 | if (old_state != state) { | ||
49 | input_report_switch(poll_dev->input, SW_RFKILL_ALL, state); | ||
50 | change_bit(RFKILL_STATE_BLOCKED, &rt2x00dev->rfkill_state); | ||
51 | } | ||
52 | } | ||
53 | |||
54 | void rt2x00rfkill_register(struct rt2x00_dev *rt2x00dev) | ||
55 | { | ||
56 | if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state) || | ||
57 | test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state)) | ||
58 | return; | ||
59 | |||
60 | if (input_register_polled_device(rt2x00dev->rfkill_poll_dev)) { | ||
61 | ERROR(rt2x00dev, "Failed to register polled device.\n"); | ||
62 | return; | ||
63 | } | ||
64 | |||
65 | __set_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state); | ||
66 | |||
67 | /* | ||
68 | * Force initial poll which will detect the initial device state, | ||
69 | * and correctly sends the signal to the input layer about this | ||
70 | * state. | ||
71 | */ | ||
72 | rt2x00rfkill_poll(rt2x00dev->rfkill_poll_dev); | ||
73 | } | ||
74 | |||
75 | void rt2x00rfkill_unregister(struct rt2x00_dev *rt2x00dev) | ||
76 | { | ||
77 | if (!test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state) || | ||
78 | !test_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state)) | ||
79 | return; | ||
80 | |||
81 | input_unregister_polled_device(rt2x00dev->rfkill_poll_dev); | ||
82 | |||
83 | __clear_bit(RFKILL_STATE_REGISTERED, &rt2x00dev->rfkill_state); | ||
84 | } | ||
85 | |||
86 | void rt2x00rfkill_allocate(struct rt2x00_dev *rt2x00dev) | ||
87 | { | ||
88 | struct input_polled_dev *poll_dev; | ||
89 | |||
90 | if (test_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state) || | ||
91 | !test_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags)) | ||
92 | return; | ||
93 | |||
94 | poll_dev = input_allocate_polled_device(); | ||
95 | if (!poll_dev) { | ||
96 | ERROR(rt2x00dev, "Failed to allocate polled device.\n"); | ||
97 | return; | ||
98 | } | ||
99 | |||
100 | poll_dev->private = rt2x00dev; | ||
101 | poll_dev->poll = rt2x00rfkill_poll; | ||
102 | poll_dev->poll_interval = RFKILL_POLL_INTERVAL; | ||
103 | |||
104 | poll_dev->input->name = rt2x00dev->ops->name; | ||
105 | poll_dev->input->phys = wiphy_name(rt2x00dev->hw->wiphy); | ||
106 | poll_dev->input->id.bustype = BUS_HOST; | ||
107 | poll_dev->input->id.vendor = 0x1814; | ||
108 | poll_dev->input->id.product = rt2x00dev->chip.rt; | ||
109 | poll_dev->input->id.version = rt2x00dev->chip.rev; | ||
110 | poll_dev->input->dev.parent = wiphy_dev(rt2x00dev->hw->wiphy); | ||
111 | poll_dev->input->evbit[0] = BIT(EV_SW); | ||
112 | poll_dev->input->swbit[0] = BIT(SW_RFKILL_ALL); | ||
113 | |||
114 | rt2x00dev->rfkill_poll_dev = poll_dev; | ||
115 | |||
116 | __set_bit(RFKILL_STATE_ALLOCATED, &rt2x00dev->rfkill_state); | ||
117 | } | ||
118 | |||
119 | void rt2x00rfkill_free(struct rt2x00_dev *rt2x00dev) | ||
120 | { | ||
121 | if (!__test_and_clear_bit(RFKILL_STATE_ALLOCATED, | ||
122 | &rt2x00dev->rfkill_state)) | ||
123 | return; | ||
124 | |||
125 | input_free_polled_device(rt2x00dev->rfkill_poll_dev); | ||
126 | rt2x00dev->rfkill_poll_dev = NULL; | ||
127 | } | ||
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c index 49b29ff90c47..8a49d99df682 100644 --- a/drivers/net/wireless/rt2x00/rt61pci.c +++ b/drivers/net/wireless/rt2x00/rt61pci.c | |||
@@ -237,7 +237,6 @@ static const struct rt2x00debug rt61pci_rt2x00debug = { | |||
237 | }; | 237 | }; |
238 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ | 238 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
239 | 239 | ||
240 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
241 | static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) | 240 | static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) |
242 | { | 241 | { |
243 | u32 reg; | 242 | u32 reg; |
@@ -245,9 +244,6 @@ static int rt61pci_rfkill_poll(struct rt2x00_dev *rt2x00dev) | |||
245 | rt2x00pci_register_read(rt2x00dev, MAC_CSR13, ®); | 244 | rt2x00pci_register_read(rt2x00dev, MAC_CSR13, ®); |
246 | return rt2x00_get_field32(reg, MAC_CSR13_BIT5); | 245 | return rt2x00_get_field32(reg, MAC_CSR13_BIT5); |
247 | } | 246 | } |
248 | #else | ||
249 | #define rt61pci_rfkill_poll NULL | ||
250 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
251 | 247 | ||
252 | #ifdef CONFIG_RT2X00_LIB_LEDS | 248 | #ifdef CONFIG_RT2X00_LIB_LEDS |
253 | static void rt61pci_brightness_set(struct led_classdev *led_cdev, | 249 | static void rt61pci_brightness_set(struct led_classdev *led_cdev, |
@@ -2338,10 +2334,8 @@ static int rt61pci_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
2338 | /* | 2334 | /* |
2339 | * Detect if this device has an hardware controlled radio. | 2335 | * Detect if this device has an hardware controlled radio. |
2340 | */ | 2336 | */ |
2341 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
2342 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) | 2337 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) |
2343 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); | 2338 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); |
2344 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
2345 | 2339 | ||
2346 | /* | 2340 | /* |
2347 | * Read frequency offset and RF programming sequence. | 2341 | * Read frequency offset and RF programming sequence. |
@@ -2728,6 +2722,7 @@ static const struct ieee80211_ops rt61pci_mac80211_ops = { | |||
2728 | .conf_tx = rt61pci_conf_tx, | 2722 | .conf_tx = rt61pci_conf_tx, |
2729 | .get_tx_stats = rt2x00mac_get_tx_stats, | 2723 | .get_tx_stats = rt2x00mac_get_tx_stats, |
2730 | .get_tsf = rt61pci_get_tsf, | 2724 | .get_tsf = rt61pci_get_tsf, |
2725 | .rfkill_poll = rt2x00mac_rfkill_poll, | ||
2731 | }; | 2726 | }; |
2732 | 2727 | ||
2733 | static const struct rt2x00lib_ops rt61pci_rt2x00_ops = { | 2728 | static const struct rt2x00lib_ops rt61pci_rt2x00_ops = { |
diff --git a/drivers/net/wireless/rt2x00/rt73usb.c b/drivers/net/wireless/rt2x00/rt73usb.c index c18848836f2d..ad2898ca8677 100644 --- a/drivers/net/wireless/rt2x00/rt73usb.c +++ b/drivers/net/wireless/rt2x00/rt73usb.c | |||
@@ -183,7 +183,6 @@ static const struct rt2x00debug rt73usb_rt2x00debug = { | |||
183 | }; | 183 | }; |
184 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ | 184 | #endif /* CONFIG_RT2X00_LIB_DEBUGFS */ |
185 | 185 | ||
186 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
187 | static int rt73usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) | 186 | static int rt73usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) |
188 | { | 187 | { |
189 | u32 reg; | 188 | u32 reg; |
@@ -191,9 +190,6 @@ static int rt73usb_rfkill_poll(struct rt2x00_dev *rt2x00dev) | |||
191 | rt2x00usb_register_read(rt2x00dev, MAC_CSR13, ®); | 190 | rt2x00usb_register_read(rt2x00dev, MAC_CSR13, ®); |
192 | return rt2x00_get_field32(reg, MAC_CSR13_BIT7); | 191 | return rt2x00_get_field32(reg, MAC_CSR13_BIT7); |
193 | } | 192 | } |
194 | #else | ||
195 | #define rt73usb_rfkill_poll NULL | ||
196 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
197 | 193 | ||
198 | #ifdef CONFIG_RT2X00_LIB_LEDS | 194 | #ifdef CONFIG_RT2X00_LIB_LEDS |
199 | static void rt73usb_brightness_set(struct led_classdev *led_cdev, | 195 | static void rt73usb_brightness_set(struct led_classdev *led_cdev, |
@@ -1863,10 +1859,8 @@ static int rt73usb_init_eeprom(struct rt2x00_dev *rt2x00dev) | |||
1863 | /* | 1859 | /* |
1864 | * Detect if this device has an hardware controlled radio. | 1860 | * Detect if this device has an hardware controlled radio. |
1865 | */ | 1861 | */ |
1866 | #ifdef CONFIG_RT2X00_LIB_RFKILL | ||
1867 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) | 1862 | if (rt2x00_get_field16(eeprom, EEPROM_ANTENNA_HARDWARE_RADIO)) |
1868 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); | 1863 | __set_bit(CONFIG_SUPPORT_HW_BUTTON, &rt2x00dev->flags); |
1869 | #endif /* CONFIG_RT2X00_LIB_RFKILL */ | ||
1870 | 1864 | ||
1871 | /* | 1865 | /* |
1872 | * Read frequency offset. | 1866 | * Read frequency offset. |
@@ -2253,6 +2247,7 @@ static const struct ieee80211_ops rt73usb_mac80211_ops = { | |||
2253 | .conf_tx = rt73usb_conf_tx, | 2247 | .conf_tx = rt73usb_conf_tx, |
2254 | .get_tx_stats = rt2x00mac_get_tx_stats, | 2248 | .get_tx_stats = rt2x00mac_get_tx_stats, |
2255 | .get_tsf = rt73usb_get_tsf, | 2249 | .get_tsf = rt73usb_get_tsf, |
2250 | .rfkill_poll = rt2x00mac_rfkill_poll, | ||
2256 | }; | 2251 | }; |
2257 | 2252 | ||
2258 | static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { | 2253 | static const struct rt2x00lib_ops rt73usb_rt2x00_ops = { |
diff --git a/drivers/net/wireless/rtl818x/rtl8180_dev.c b/drivers/net/wireless/rtl818x/rtl8180_dev.c index 7e65d7c31802..09f46abc730a 100644 --- a/drivers/net/wireless/rtl818x/rtl8180_dev.c +++ b/drivers/net/wireless/rtl818x/rtl8180_dev.c | |||
@@ -143,7 +143,8 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev) | |||
143 | if (flags & RTL818X_RX_DESC_FLAG_CRC32_ERR) | 143 | if (flags & RTL818X_RX_DESC_FLAG_CRC32_ERR) |
144 | rx_status.flag |= RX_FLAG_FAILED_FCS_CRC; | 144 | rx_status.flag |= RX_FLAG_FAILED_FCS_CRC; |
145 | 145 | ||
146 | ieee80211_rx_irqsafe(dev, skb, &rx_status); | 146 | memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); |
147 | ieee80211_rx_irqsafe(dev, skb); | ||
147 | 148 | ||
148 | skb = new_skb; | 149 | skb = new_skb; |
149 | priv->rx_buf[priv->rx_idx] = skb; | 150 | priv->rx_buf[priv->rx_idx] = skb; |
@@ -280,7 +281,7 @@ static int rtl8180_tx(struct ieee80211_hw *dev, struct sk_buff *skb) | |||
280 | (ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); | 281 | (ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); |
281 | remainder = (16 * (skb->len + 4)) % | 282 | remainder = (16 * (skb->len + 4)) % |
282 | ((ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); | 283 | ((ieee80211_get_tx_rate(dev, info)->bitrate * 2) / 10); |
283 | if (remainder > 0 && remainder <= 6) | 284 | if (remainder <= 6) |
284 | plcp_len |= 1 << 15; | 285 | plcp_len |= 1 << 15; |
285 | } | 286 | } |
286 | 287 | ||
diff --git a/drivers/net/wireless/rtl818x/rtl8187_dev.c b/drivers/net/wireless/rtl818x/rtl8187_dev.c index 294250e294dd..c9b9dbe584c6 100644 --- a/drivers/net/wireless/rtl818x/rtl8187_dev.c +++ b/drivers/net/wireless/rtl818x/rtl8187_dev.c | |||
@@ -380,7 +380,8 @@ static void rtl8187_rx_cb(struct urb *urb) | |||
380 | rx_status.flag |= RX_FLAG_TSFT; | 380 | rx_status.flag |= RX_FLAG_TSFT; |
381 | if (flags & RTL818X_RX_DESC_FLAG_CRC32_ERR) | 381 | if (flags & RTL818X_RX_DESC_FLAG_CRC32_ERR) |
382 | rx_status.flag |= RX_FLAG_FAILED_FCS_CRC; | 382 | rx_status.flag |= RX_FLAG_FAILED_FCS_CRC; |
383 | ieee80211_rx_irqsafe(dev, skb, &rx_status); | 383 | memcpy(IEEE80211_SKB_RXCB(skb), &rx_status, sizeof(rx_status)); |
384 | ieee80211_rx_irqsafe(dev, skb); | ||
384 | 385 | ||
385 | skb = dev_alloc_skb(RTL8187_MAX_RX); | 386 | skb = dev_alloc_skb(RTL8187_MAX_RX); |
386 | if (unlikely(!skb)) { | 387 | if (unlikely(!skb)) { |
diff --git a/drivers/net/wireless/strip.c b/drivers/net/wireless/strip.c index 38366a56b71f..73300c226f67 100644 --- a/drivers/net/wireless/strip.c +++ b/drivers/net/wireless/strip.c | |||
@@ -1582,7 +1582,7 @@ static int strip_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1582 | 1582 | ||
1583 | if (skb) | 1583 | if (skb) |
1584 | dev_kfree_skb(skb); | 1584 | dev_kfree_skb(skb); |
1585 | return 0; | 1585 | return NETDEV_TX_OK; |
1586 | } | 1586 | } |
1587 | 1587 | ||
1588 | /* | 1588 | /* |
diff --git a/drivers/net/wireless/wavelan.c b/drivers/net/wireless/wavelan.c index ab7fc5c0c8b4..5cb5329a20d1 100644 --- a/drivers/net/wireless/wavelan.c +++ b/drivers/net/wireless/wavelan.c | |||
@@ -2891,7 +2891,7 @@ static int wavelan_packet_xmit(struct sk_buff *skb, struct net_device * dev) | |||
2891 | #ifdef DEBUG_TX_TRACE | 2891 | #ifdef DEBUG_TX_TRACE |
2892 | printk(KERN_DEBUG "%s: <-wavelan_packet_xmit()\n", dev->name); | 2892 | printk(KERN_DEBUG "%s: <-wavelan_packet_xmit()\n", dev->name); |
2893 | #endif | 2893 | #endif |
2894 | return 0; | 2894 | return NETDEV_TX_OK; |
2895 | } | 2895 | } |
2896 | 2896 | ||
2897 | /*********************** HARDWARE CONFIGURATION ***********************/ | 2897 | /*********************** HARDWARE CONFIGURATION ***********************/ |
diff --git a/drivers/net/wireless/wavelan_cs.c b/drivers/net/wireless/wavelan_cs.c index 6af706408ac0..9dd241adc379 100644 --- a/drivers/net/wireless/wavelan_cs.c +++ b/drivers/net/wireless/wavelan_cs.c | |||
@@ -3113,7 +3113,7 @@ wavelan_packet_xmit(struct sk_buff * skb, | |||
3113 | * able to detect collisions, therefore in theory we don't really | 3113 | * able to detect collisions, therefore in theory we don't really |
3114 | * need to pad. Jean II */ | 3114 | * need to pad. Jean II */ |
3115 | if (skb_padto(skb, ETH_ZLEN)) | 3115 | if (skb_padto(skb, ETH_ZLEN)) |
3116 | return 0; | 3116 | return NETDEV_TX_OK; |
3117 | 3117 | ||
3118 | wv_packet_write(dev, skb->data, skb->len); | 3118 | wv_packet_write(dev, skb->data, skb->len); |
3119 | 3119 | ||
@@ -3122,7 +3122,7 @@ wavelan_packet_xmit(struct sk_buff * skb, | |||
3122 | #ifdef DEBUG_TX_TRACE | 3122 | #ifdef DEBUG_TX_TRACE |
3123 | printk(KERN_DEBUG "%s: <-wavelan_packet_xmit()\n", dev->name); | 3123 | printk(KERN_DEBUG "%s: <-wavelan_packet_xmit()\n", dev->name); |
3124 | #endif | 3124 | #endif |
3125 | return(0); | 3125 | return NETDEV_TX_OK; |
3126 | } | 3126 | } |
3127 | 3127 | ||
3128 | /********************** HARDWARE CONFIGURATION **********************/ | 3128 | /********************** HARDWARE CONFIGURATION **********************/ |
diff --git a/drivers/net/wireless/wl12xx/Kconfig b/drivers/net/wireless/wl12xx/Kconfig index a82c4cd436d8..82a0f97975de 100644 --- a/drivers/net/wireless/wl12xx/Kconfig +++ b/drivers/net/wireless/wl12xx/Kconfig | |||
@@ -1,11 +1,18 @@ | |||
1 | config WL12XX | 1 | menuconfig WL12XX |
2 | tristate "TI wl1251/wl1271 support" | 2 | boolean "TI wl12xx driver support" |
3 | depends on MAC80211 && WLAN_80211 && SPI_MASTER && GENERIC_HARDIRQS && EXPERIMENTAL | 3 | depends on MAC80211 && WLAN_80211 && EXPERIMENTAL |
4 | ---help--- | ||
5 | This will enable TI wl12xx driver support. The drivers make | ||
6 | use of the mac80211 stack. | ||
7 | |||
8 | config WL1251 | ||
9 | tristate "TI wl1251 support" | ||
10 | depends on WL12XX && SPI_MASTER && GENERIC_HARDIRQS | ||
4 | select FW_LOADER | 11 | select FW_LOADER |
5 | select CRC7 | 12 | select CRC7 |
6 | ---help--- | 13 | ---help--- |
7 | This module adds support for wireless adapters based on | 14 | This module adds support for wireless adapters based on |
8 | TI wl1251/wl1271 chipsets. | 15 | TI wl1251 chipset. |
9 | 16 | ||
10 | If you choose to build a module, it'll be called wl12xx. Say N if | 17 | If you choose to build a module, it'll be called wl1251. Say N if |
11 | unsure. | 18 | unsure. |
diff --git a/drivers/net/wireless/wl12xx/Makefile b/drivers/net/wireless/wl12xx/Makefile index d43de27dc54c..d5595a841f5f 100644 --- a/drivers/net/wireless/wl12xx/Makefile +++ b/drivers/net/wireless/wl12xx/Makefile | |||
@@ -1,4 +1,5 @@ | |||
1 | wl12xx-objs = main.o spi.o event.o tx.o rx.o \ | 1 | wl1251-objs = wl1251_main.o wl1251_spi.o wl1251_event.o \ |
2 | ps.o cmd.o acx.o boot.o init.o wl1251.o \ | 2 | wl1251_tx.o wl1251_rx.o wl1251_ps.o wl1251_cmd.o \ |
3 | debugfs.o | 3 | wl1251_acx.o wl1251_boot.o wl1251_init.o \ |
4 | obj-$(CONFIG_WL12XX) += wl12xx.o | 4 | wl1251_ops.o wl1251_debugfs.o |
5 | obj-$(CONFIG_WL1251) += wl1251.o | ||
diff --git a/drivers/net/wireless/wl12xx/acx.c b/drivers/net/wireless/wl12xx/acx.c deleted file mode 100644 index 1cfd458ad5ab..000000000000 --- a/drivers/net/wireless/wl12xx/acx.c +++ /dev/null | |||
@@ -1,689 +0,0 @@ | |||
1 | #include "acx.h" | ||
2 | |||
3 | #include <linux/module.h> | ||
4 | #include <linux/crc7.h> | ||
5 | #include <linux/spi/spi.h> | ||
6 | |||
7 | #include "wl12xx.h" | ||
8 | #include "wl12xx_80211.h" | ||
9 | #include "reg.h" | ||
10 | #include "spi.h" | ||
11 | #include "ps.h" | ||
12 | |||
13 | int wl12xx_acx_frame_rates(struct wl12xx *wl, u8 ctrl_rate, u8 ctrl_mod, | ||
14 | u8 mgt_rate, u8 mgt_mod) | ||
15 | { | ||
16 | int ret; | ||
17 | struct acx_fw_gen_frame_rates rates; | ||
18 | |||
19 | wl12xx_debug(DEBUG_ACX, "acx frame rates"); | ||
20 | |||
21 | rates.header.id = ACX_FW_GEN_FRAME_RATES; | ||
22 | rates.header.len = sizeof(struct acx_fw_gen_frame_rates) - | ||
23 | sizeof(struct acx_header); | ||
24 | |||
25 | rates.tx_ctrl_frame_rate = ctrl_rate; | ||
26 | rates.tx_ctrl_frame_mod = ctrl_mod; | ||
27 | rates.tx_mgt_frame_rate = mgt_rate; | ||
28 | rates.tx_mgt_frame_mod = mgt_mod; | ||
29 | |||
30 | ret = wl12xx_cmd_configure(wl, &rates, sizeof(rates)); | ||
31 | if (ret < 0) { | ||
32 | wl12xx_error("Failed to set FW rates and modulation"); | ||
33 | return ret; | ||
34 | } | ||
35 | |||
36 | return 0; | ||
37 | } | ||
38 | |||
39 | |||
40 | int wl12xx_acx_station_id(struct wl12xx *wl) | ||
41 | { | ||
42 | int ret, i; | ||
43 | struct dot11_station_id mac; | ||
44 | |||
45 | wl12xx_debug(DEBUG_ACX, "acx dot11_station_id"); | ||
46 | |||
47 | mac.header.id = DOT11_STATION_ID; | ||
48 | mac.header.len = sizeof(mac) - sizeof(struct acx_header); | ||
49 | |||
50 | for (i = 0; i < ETH_ALEN; i++) | ||
51 | mac.mac[i] = wl->mac_addr[ETH_ALEN - 1 - i]; | ||
52 | |||
53 | ret = wl12xx_cmd_configure(wl, &mac, sizeof(mac)); | ||
54 | if (ret < 0) | ||
55 | return ret; | ||
56 | |||
57 | return 0; | ||
58 | } | ||
59 | |||
60 | int wl12xx_acx_default_key(struct wl12xx *wl, u8 key_id) | ||
61 | { | ||
62 | struct acx_dot11_default_key default_key; | ||
63 | int ret; | ||
64 | |||
65 | wl12xx_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id); | ||
66 | |||
67 | default_key.header.id = DOT11_DEFAULT_KEY; | ||
68 | default_key.header.len = sizeof(default_key) - | ||
69 | sizeof(struct acx_header); | ||
70 | |||
71 | default_key.id = key_id; | ||
72 | |||
73 | ret = wl12xx_cmd_configure(wl, &default_key, sizeof(default_key)); | ||
74 | if (ret < 0) { | ||
75 | wl12xx_error("Couldnt set default key"); | ||
76 | return ret; | ||
77 | } | ||
78 | |||
79 | wl->default_key = key_id; | ||
80 | |||
81 | return 0; | ||
82 | } | ||
83 | |||
84 | int wl12xx_acx_wake_up_conditions(struct wl12xx *wl, u8 listen_interval) | ||
85 | { | ||
86 | struct acx_wake_up_condition wake_up; | ||
87 | |||
88 | wl12xx_debug(DEBUG_ACX, "acx wake up conditions"); | ||
89 | |||
90 | wake_up.header.id = ACX_WAKE_UP_CONDITIONS; | ||
91 | wake_up.header.len = sizeof(wake_up) - sizeof(struct acx_header); | ||
92 | |||
93 | wake_up.wake_up_event = WAKE_UP_EVENT_DTIM_BITMAP; | ||
94 | wake_up.listen_interval = listen_interval; | ||
95 | |||
96 | return wl12xx_cmd_configure(wl, &wake_up, sizeof(wake_up)); | ||
97 | } | ||
98 | |||
99 | int wl12xx_acx_sleep_auth(struct wl12xx *wl, u8 sleep_auth) | ||
100 | { | ||
101 | int ret; | ||
102 | struct acx_sleep_auth auth; | ||
103 | |||
104 | wl12xx_debug(DEBUG_ACX, "acx sleep auth"); | ||
105 | |||
106 | auth.header.id = ACX_SLEEP_AUTH; | ||
107 | auth.header.len = sizeof(auth) - sizeof(struct acx_header); | ||
108 | |||
109 | auth.sleep_auth = sleep_auth; | ||
110 | |||
111 | ret = wl12xx_cmd_configure(wl, &auth, sizeof(auth)); | ||
112 | if (ret < 0) | ||
113 | return ret; | ||
114 | |||
115 | return 0; | ||
116 | } | ||
117 | |||
118 | int wl12xx_acx_fw_version(struct wl12xx *wl, char *buf, size_t len) | ||
119 | { | ||
120 | struct wl12xx_command cmd; | ||
121 | struct acx_revision *rev; | ||
122 | int ret; | ||
123 | |||
124 | wl12xx_debug(DEBUG_ACX, "acx fw rev"); | ||
125 | |||
126 | memset(&cmd, 0, sizeof(cmd)); | ||
127 | |||
128 | ret = wl12xx_cmd_interrogate(wl, ACX_FW_REV, sizeof(*rev), &cmd); | ||
129 | if (ret < 0) { | ||
130 | wl12xx_warning("ACX_FW_REV interrogate failed"); | ||
131 | return ret; | ||
132 | } | ||
133 | |||
134 | rev = (struct acx_revision *) &cmd.parameters; | ||
135 | |||
136 | /* be careful with the buffer sizes */ | ||
137 | strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); | ||
138 | |||
139 | /* | ||
140 | * if the firmware version string is exactly | ||
141 | * sizeof(rev->fw_version) long or fw_len is less than | ||
142 | * sizeof(rev->fw_version) it won't be null terminated | ||
143 | */ | ||
144 | buf[min(len, sizeof(rev->fw_version)) - 1] = '\0'; | ||
145 | |||
146 | return 0; | ||
147 | } | ||
148 | |||
149 | int wl12xx_acx_tx_power(struct wl12xx *wl, int power) | ||
150 | { | ||
151 | struct acx_current_tx_power ie; | ||
152 | int ret; | ||
153 | |||
154 | wl12xx_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr"); | ||
155 | |||
156 | if (power < 0 || power > 25) | ||
157 | return -EINVAL; | ||
158 | |||
159 | memset(&ie, 0, sizeof(ie)); | ||
160 | |||
161 | ie.header.id = DOT11_CUR_TX_PWR; | ||
162 | ie.header.len = sizeof(ie) - sizeof(struct acx_header); | ||
163 | ie.current_tx_power = power * 10; | ||
164 | |||
165 | ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie)); | ||
166 | if (ret < 0) { | ||
167 | wl12xx_warning("configure of tx power failed: %d", ret); | ||
168 | return ret; | ||
169 | } | ||
170 | |||
171 | return 0; | ||
172 | } | ||
173 | |||
174 | int wl12xx_acx_feature_cfg(struct wl12xx *wl) | ||
175 | { | ||
176 | struct acx_feature_config feature; | ||
177 | int ret; | ||
178 | |||
179 | wl12xx_debug(DEBUG_ACX, "acx feature cfg"); | ||
180 | |||
181 | memset(&feature, 0, sizeof(feature)); | ||
182 | |||
183 | feature.header.id = ACX_FEATURE_CFG; | ||
184 | feature.header.len = sizeof(feature) - sizeof(struct acx_header); | ||
185 | |||
186 | /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */ | ||
187 | feature.data_flow_options = 0; | ||
188 | feature.options = 0; | ||
189 | |||
190 | ret = wl12xx_cmd_configure(wl, &feature, sizeof(feature)); | ||
191 | if (ret < 0) | ||
192 | wl12xx_error("Couldnt set HW encryption"); | ||
193 | |||
194 | return ret; | ||
195 | } | ||
196 | |||
197 | int wl12xx_acx_mem_map(struct wl12xx *wl, void *mem_map, size_t len) | ||
198 | { | ||
199 | struct wl12xx_command cmd; | ||
200 | int ret; | ||
201 | |||
202 | wl12xx_debug(DEBUG_ACX, "acx mem map"); | ||
203 | |||
204 | ret = wl12xx_cmd_interrogate(wl, ACX_MEM_MAP, len, &cmd); | ||
205 | if (ret < 0) | ||
206 | return ret; | ||
207 | else if (cmd.status != CMD_STATUS_SUCCESS) | ||
208 | return -EIO; | ||
209 | |||
210 | memcpy(mem_map, &cmd.parameters, len); | ||
211 | |||
212 | return 0; | ||
213 | } | ||
214 | |||
215 | int wl12xx_acx_data_path_params(struct wl12xx *wl, | ||
216 | struct acx_data_path_params_resp *data_path) | ||
217 | { | ||
218 | struct acx_data_path_params params; | ||
219 | struct wl12xx_command cmd; | ||
220 | int ret; | ||
221 | |||
222 | wl12xx_debug(DEBUG_ACX, "acx data path params"); | ||
223 | |||
224 | params.rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE; | ||
225 | params.tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE; | ||
226 | |||
227 | params.rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM; | ||
228 | params.tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM; | ||
229 | |||
230 | params.tx_complete_threshold = 1; | ||
231 | |||
232 | params.tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE; | ||
233 | |||
234 | params.tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT; | ||
235 | |||
236 | params.header.id = ACX_DATA_PATH_PARAMS; | ||
237 | params.header.len = sizeof(params) - sizeof(struct acx_header); | ||
238 | |||
239 | ret = wl12xx_cmd_configure(wl, ¶ms, sizeof(params)); | ||
240 | if (ret < 0) | ||
241 | return ret; | ||
242 | |||
243 | |||
244 | ret = wl12xx_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS, | ||
245 | sizeof(struct acx_data_path_params_resp), | ||
246 | &cmd); | ||
247 | |||
248 | if (ret < 0) { | ||
249 | wl12xx_warning("failed to read data path parameters: %d", ret); | ||
250 | return ret; | ||
251 | } else if (cmd.status != CMD_STATUS_SUCCESS) { | ||
252 | wl12xx_warning("data path parameter acx status failed"); | ||
253 | return -EIO; | ||
254 | } | ||
255 | |||
256 | memcpy(data_path, &cmd.parameters, sizeof(*data_path)); | ||
257 | |||
258 | return 0; | ||
259 | } | ||
260 | |||
261 | int wl12xx_acx_rx_msdu_life_time(struct wl12xx *wl, u32 life_time) | ||
262 | { | ||
263 | struct rx_msdu_lifetime msdu_lifetime; | ||
264 | int ret; | ||
265 | |||
266 | wl12xx_debug(DEBUG_ACX, "acx rx msdu life time"); | ||
267 | |||
268 | msdu_lifetime.header.id = DOT11_RX_MSDU_LIFE_TIME; | ||
269 | msdu_lifetime.header.len = sizeof(msdu_lifetime) - | ||
270 | sizeof(struct acx_header); | ||
271 | msdu_lifetime.lifetime = life_time; | ||
272 | |||
273 | ret = wl12xx_cmd_configure(wl, &msdu_lifetime, sizeof(msdu_lifetime)); | ||
274 | if (ret < 0) { | ||
275 | wl12xx_warning("failed to set rx msdu life time: %d", ret); | ||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | return 0; | ||
280 | } | ||
281 | |||
282 | int wl12xx_acx_rx_config(struct wl12xx *wl, u32 config, u32 filter) | ||
283 | { | ||
284 | struct acx_rx_config rx_config; | ||
285 | int ret; | ||
286 | |||
287 | wl12xx_debug(DEBUG_ACX, "acx rx config"); | ||
288 | |||
289 | rx_config.header.id = ACX_RX_CFG; | ||
290 | rx_config.header.len = sizeof(rx_config) - sizeof(struct acx_header); | ||
291 | rx_config.config_options = config; | ||
292 | rx_config.filter_options = filter; | ||
293 | |||
294 | ret = wl12xx_cmd_configure(wl, &rx_config, sizeof(rx_config)); | ||
295 | if (ret < 0) { | ||
296 | wl12xx_warning("failed to set rx config: %d", ret); | ||
297 | return ret; | ||
298 | } | ||
299 | |||
300 | return 0; | ||
301 | } | ||
302 | |||
303 | int wl12xx_acx_pd_threshold(struct wl12xx *wl) | ||
304 | { | ||
305 | struct acx_packet_detection packet_detection; | ||
306 | int ret; | ||
307 | |||
308 | wl12xx_debug(DEBUG_ACX, "acx data pd threshold"); | ||
309 | |||
310 | /* FIXME: threshold value not set */ | ||
311 | packet_detection.header.id = ACX_PD_THRESHOLD; | ||
312 | packet_detection.header.len = sizeof(packet_detection) - | ||
313 | sizeof(struct acx_header); | ||
314 | |||
315 | ret = wl12xx_cmd_configure(wl, &packet_detection, | ||
316 | sizeof(packet_detection)); | ||
317 | if (ret < 0) { | ||
318 | wl12xx_warning("failed to set pd threshold: %d", ret); | ||
319 | return ret; | ||
320 | } | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | int wl12xx_acx_slot(struct wl12xx *wl, enum acx_slot_type slot_time) | ||
326 | { | ||
327 | struct acx_slot slot; | ||
328 | int ret; | ||
329 | |||
330 | wl12xx_debug(DEBUG_ACX, "acx slot"); | ||
331 | |||
332 | slot.header.id = ACX_SLOT; | ||
333 | slot.header.len = sizeof(slot) - sizeof(struct acx_header); | ||
334 | |||
335 | slot.wone_index = STATION_WONE_INDEX; | ||
336 | slot.slot_time = slot_time; | ||
337 | |||
338 | ret = wl12xx_cmd_configure(wl, &slot, sizeof(slot)); | ||
339 | if (ret < 0) { | ||
340 | wl12xx_warning("failed to set slot time: %d", ret); | ||
341 | return ret; | ||
342 | } | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | int wl12xx_acx_group_address_tbl(struct wl12xx *wl) | ||
348 | { | ||
349 | struct multicast_grp_addr_start multicast; | ||
350 | int ret; | ||
351 | |||
352 | wl12xx_debug(DEBUG_ACX, "acx group address tbl"); | ||
353 | |||
354 | /* MAC filtering */ | ||
355 | multicast.header.id = DOT11_GROUP_ADDRESS_TBL; | ||
356 | multicast.header.len = sizeof(multicast) - sizeof(struct acx_header); | ||
357 | |||
358 | multicast.enabled = 0; | ||
359 | multicast.num_groups = 0; | ||
360 | memset(multicast.mac_table, 0, ADDRESS_GROUP_MAX_LEN); | ||
361 | |||
362 | ret = wl12xx_cmd_configure(wl, &multicast, sizeof(multicast)); | ||
363 | if (ret < 0) { | ||
364 | wl12xx_warning("failed to set group addr table: %d", ret); | ||
365 | return ret; | ||
366 | } | ||
367 | |||
368 | return 0; | ||
369 | } | ||
370 | |||
371 | int wl12xx_acx_service_period_timeout(struct wl12xx *wl) | ||
372 | { | ||
373 | struct acx_rx_timeout rx_timeout; | ||
374 | int ret; | ||
375 | |||
376 | wl12xx_debug(DEBUG_ACX, "acx service period timeout"); | ||
377 | |||
378 | /* RX timeout */ | ||
379 | rx_timeout.header.id = ACX_SERVICE_PERIOD_TIMEOUT; | ||
380 | rx_timeout.header.len = sizeof(rx_timeout) - sizeof(struct acx_header); | ||
381 | |||
382 | rx_timeout.ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF; | ||
383 | rx_timeout.upsd_timeout = RX_TIMEOUT_UPSD_DEF; | ||
384 | |||
385 | ret = wl12xx_cmd_configure(wl, &rx_timeout, sizeof(rx_timeout)); | ||
386 | if (ret < 0) { | ||
387 | wl12xx_warning("failed to set service period timeout: %d", | ||
388 | ret); | ||
389 | return ret; | ||
390 | } | ||
391 | |||
392 | return 0; | ||
393 | } | ||
394 | |||
395 | int wl12xx_acx_rts_threshold(struct wl12xx *wl, u16 rts_threshold) | ||
396 | { | ||
397 | struct acx_rts_threshold rts; | ||
398 | int ret; | ||
399 | |||
400 | wl12xx_debug(DEBUG_ACX, "acx rts threshold"); | ||
401 | |||
402 | rts.header.id = DOT11_RTS_THRESHOLD; | ||
403 | rts.header.len = sizeof(rts) - sizeof(struct acx_header); | ||
404 | |||
405 | rts.threshold = rts_threshold; | ||
406 | |||
407 | ret = wl12xx_cmd_configure(wl, &rts, sizeof(rts)); | ||
408 | if (ret < 0) { | ||
409 | wl12xx_warning("failed to set rts threshold: %d", ret); | ||
410 | return ret; | ||
411 | } | ||
412 | |||
413 | return 0; | ||
414 | } | ||
415 | |||
416 | int wl12xx_acx_beacon_filter_opt(struct wl12xx *wl) | ||
417 | { | ||
418 | struct acx_beacon_filter_option beacon_filter; | ||
419 | int ret; | ||
420 | |||
421 | wl12xx_debug(DEBUG_ACX, "acx beacon filter opt"); | ||
422 | |||
423 | beacon_filter.header.id = ACX_BEACON_FILTER_OPT; | ||
424 | beacon_filter.header.len = sizeof(beacon_filter) - | ||
425 | sizeof(struct acx_header); | ||
426 | |||
427 | beacon_filter.enable = 0; | ||
428 | beacon_filter.max_num_beacons = 0; | ||
429 | |||
430 | ret = wl12xx_cmd_configure(wl, &beacon_filter, sizeof(beacon_filter)); | ||
431 | if (ret < 0) { | ||
432 | wl12xx_warning("failed to set beacon filter opt: %d", ret); | ||
433 | return ret; | ||
434 | } | ||
435 | |||
436 | return 0; | ||
437 | } | ||
438 | |||
439 | int wl12xx_acx_beacon_filter_table(struct wl12xx *wl) | ||
440 | { | ||
441 | struct acx_beacon_filter_ie_table ie_table; | ||
442 | int ret; | ||
443 | |||
444 | wl12xx_debug(DEBUG_ACX, "acx beacon filter table"); | ||
445 | |||
446 | ie_table.header.id = ACX_BEACON_FILTER_TABLE; | ||
447 | ie_table.header.len = sizeof(ie_table) - sizeof(struct acx_header); | ||
448 | |||
449 | ie_table.num_ie = 0; | ||
450 | memset(ie_table.table, 0, BEACON_FILTER_TABLE_MAX_SIZE); | ||
451 | |||
452 | ret = wl12xx_cmd_configure(wl, &ie_table, sizeof(ie_table)); | ||
453 | if (ret < 0) { | ||
454 | wl12xx_warning("failed to set beacon filter table: %d", ret); | ||
455 | return ret; | ||
456 | } | ||
457 | |||
458 | return 0; | ||
459 | } | ||
460 | |||
461 | int wl12xx_acx_sg_enable(struct wl12xx *wl) | ||
462 | { | ||
463 | struct acx_bt_wlan_coex pta; | ||
464 | int ret; | ||
465 | |||
466 | wl12xx_debug(DEBUG_ACX, "acx sg enable"); | ||
467 | |||
468 | pta.header.id = ACX_SG_ENABLE; | ||
469 | pta.header.len = sizeof(pta) - sizeof(struct acx_header); | ||
470 | |||
471 | pta.enable = SG_ENABLE; | ||
472 | |||
473 | ret = wl12xx_cmd_configure(wl, &pta, sizeof(pta)); | ||
474 | if (ret < 0) { | ||
475 | wl12xx_warning("failed to set softgemini enable: %d", ret); | ||
476 | return ret; | ||
477 | } | ||
478 | |||
479 | return 0; | ||
480 | } | ||
481 | |||
482 | int wl12xx_acx_sg_cfg(struct wl12xx *wl) | ||
483 | { | ||
484 | struct acx_bt_wlan_coex_param param; | ||
485 | int ret; | ||
486 | |||
487 | wl12xx_debug(DEBUG_ACX, "acx sg cfg"); | ||
488 | |||
489 | /* BT-WLAN coext parameters */ | ||
490 | param.header.id = ACX_SG_CFG; | ||
491 | param.header.len = sizeof(param) - sizeof(struct acx_header); | ||
492 | |||
493 | param.min_rate = RATE_INDEX_24MBPS; | ||
494 | param.bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF; | ||
495 | param.wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF; | ||
496 | param.sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF; | ||
497 | param.rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF; | ||
498 | param.tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF; | ||
499 | param.rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF; | ||
500 | param.tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF; | ||
501 | param.wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF; | ||
502 | param.bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF; | ||
503 | param.next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF; | ||
504 | param.wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF; | ||
505 | param.hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF; | ||
506 | param.next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF; | ||
507 | param.antenna_type = PTA_ANTENNA_TYPE_DEF; | ||
508 | param.signal_type = PTA_SIGNALING_TYPE_DEF; | ||
509 | param.afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF; | ||
510 | param.quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF; | ||
511 | param.max_cts = PTA_MAX_NUM_CTS_DEF; | ||
512 | param.wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF; | ||
513 | param.bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF; | ||
514 | param.missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF; | ||
515 | param.wlan_elp_hp = PTA_ELP_HP_DEF; | ||
516 | param.bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF; | ||
517 | param.ack_mode_dual_ant = PTA_ACK_MODE_DEF; | ||
518 | param.pa_sd_enable = PTA_ALLOW_PA_SD_DEF; | ||
519 | param.pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF; | ||
520 | param.bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF; | ||
521 | |||
522 | ret = wl12xx_cmd_configure(wl, ¶m, sizeof(param)); | ||
523 | if (ret < 0) { | ||
524 | wl12xx_warning("failed to set sg config: %d", ret); | ||
525 | return ret; | ||
526 | } | ||
527 | |||
528 | return 0; | ||
529 | } | ||
530 | |||
531 | int wl12xx_acx_cca_threshold(struct wl12xx *wl) | ||
532 | { | ||
533 | struct acx_energy_detection detection; | ||
534 | int ret; | ||
535 | |||
536 | wl12xx_debug(DEBUG_ACX, "acx cca threshold"); | ||
537 | |||
538 | detection.header.id = ACX_CCA_THRESHOLD; | ||
539 | detection.header.len = sizeof(detection) - sizeof(struct acx_header); | ||
540 | |||
541 | detection.rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D; | ||
542 | detection.tx_energy_detection = 0; | ||
543 | |||
544 | ret = wl12xx_cmd_configure(wl, &detection, sizeof(detection)); | ||
545 | if (ret < 0) { | ||
546 | wl12xx_warning("failed to set cca threshold: %d", ret); | ||
547 | return ret; | ||
548 | } | ||
549 | |||
550 | return 0; | ||
551 | } | ||
552 | |||
553 | int wl12xx_acx_bcn_dtim_options(struct wl12xx *wl) | ||
554 | { | ||
555 | struct acx_beacon_broadcast bb; | ||
556 | int ret; | ||
557 | |||
558 | wl12xx_debug(DEBUG_ACX, "acx bcn dtim options"); | ||
559 | |||
560 | bb.header.id = ACX_BCN_DTIM_OPTIONS; | ||
561 | bb.header.len = sizeof(bb) - sizeof(struct acx_header); | ||
562 | |||
563 | bb.beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE; | ||
564 | bb.broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE; | ||
565 | bb.rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE; | ||
566 | bb.ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF; | ||
567 | |||
568 | ret = wl12xx_cmd_configure(wl, &bb, sizeof(bb)); | ||
569 | if (ret < 0) { | ||
570 | wl12xx_warning("failed to set rx config: %d", ret); | ||
571 | return ret; | ||
572 | } | ||
573 | |||
574 | return 0; | ||
575 | } | ||
576 | |||
577 | int wl12xx_acx_aid(struct wl12xx *wl, u16 aid) | ||
578 | { | ||
579 | struct acx_aid acx_aid; | ||
580 | int ret; | ||
581 | |||
582 | wl12xx_debug(DEBUG_ACX, "acx aid"); | ||
583 | |||
584 | acx_aid.header.id = ACX_AID; | ||
585 | acx_aid.header.len = sizeof(acx_aid) - sizeof(struct acx_header); | ||
586 | |||
587 | acx_aid.aid = aid; | ||
588 | |||
589 | ret = wl12xx_cmd_configure(wl, &acx_aid, sizeof(acx_aid)); | ||
590 | if (ret < 0) { | ||
591 | wl12xx_warning("failed to set aid: %d", ret); | ||
592 | return ret; | ||
593 | } | ||
594 | |||
595 | return 0; | ||
596 | } | ||
597 | |||
598 | int wl12xx_acx_event_mbox_mask(struct wl12xx *wl, u32 event_mask) | ||
599 | { | ||
600 | struct acx_event_mask mask; | ||
601 | int ret; | ||
602 | |||
603 | wl12xx_debug(DEBUG_ACX, "acx event mbox mask"); | ||
604 | |||
605 | mask.header.id = ACX_EVENT_MBOX_MASK; | ||
606 | mask.header.len = sizeof(mask) - sizeof(struct acx_header); | ||
607 | |||
608 | /* high event mask is unused */ | ||
609 | mask.high_event_mask = 0xffffffff; | ||
610 | |||
611 | mask.event_mask = event_mask; | ||
612 | |||
613 | ret = wl12xx_cmd_configure(wl, &mask, sizeof(mask)); | ||
614 | if (ret < 0) { | ||
615 | wl12xx_warning("failed to set aid: %d", ret); | ||
616 | return ret; | ||
617 | } | ||
618 | |||
619 | return 0; | ||
620 | } | ||
621 | |||
622 | int wl12xx_acx_set_preamble(struct wl12xx *wl, enum acx_preamble_type preamble) | ||
623 | { | ||
624 | struct acx_preamble ie; | ||
625 | int ret; | ||
626 | |||
627 | wl12xx_debug(DEBUG_ACX, "acx_set_preamble"); | ||
628 | |||
629 | memset(&ie, 0, sizeof(ie)); | ||
630 | |||
631 | ie.header.id = ACX_PREAMBLE_TYPE; | ||
632 | ie.header.len = sizeof(ie) - sizeof(struct acx_header); | ||
633 | ie.preamble = preamble; | ||
634 | ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie)); | ||
635 | if (ret < 0) { | ||
636 | wl12xx_warning("Setting of preamble failed: %d", ret); | ||
637 | return ret; | ||
638 | } | ||
639 | return 0; | ||
640 | } | ||
641 | |||
642 | int wl12xx_acx_cts_protect(struct wl12xx *wl, | ||
643 | enum acx_ctsprotect_type ctsprotect) | ||
644 | { | ||
645 | struct acx_ctsprotect ie; | ||
646 | int ret; | ||
647 | |||
648 | wl12xx_debug(DEBUG_ACX, "acx_set_ctsprotect"); | ||
649 | |||
650 | memset(&ie, 0, sizeof(ie)); | ||
651 | |||
652 | ie.header.id = ACX_CTS_PROTECTION; | ||
653 | ie.header.len = sizeof(ie) - sizeof(struct acx_header); | ||
654 | ie.ctsprotect = ctsprotect; | ||
655 | ret = wl12xx_cmd_configure(wl, &ie, sizeof(ie)); | ||
656 | if (ret < 0) { | ||
657 | wl12xx_warning("Setting of ctsprotect failed: %d", ret); | ||
658 | return ret; | ||
659 | } | ||
660 | return 0; | ||
661 | } | ||
662 | |||
663 | int wl12xx_acx_statistics(struct wl12xx *wl, struct acx_statistics *stats) | ||
664 | { | ||
665 | struct wl12xx_command *answer; | ||
666 | int ret; | ||
667 | |||
668 | wl12xx_debug(DEBUG_ACX, "acx statistics"); | ||
669 | |||
670 | answer = kmalloc(sizeof(*answer), GFP_KERNEL); | ||
671 | if (!answer) { | ||
672 | wl12xx_warning("could not allocate memory for acx statistics"); | ||
673 | ret = -ENOMEM; | ||
674 | goto out; | ||
675 | } | ||
676 | |||
677 | ret = wl12xx_cmd_interrogate(wl, ACX_STATISTICS, sizeof(*answer), | ||
678 | answer); | ||
679 | if (ret < 0) { | ||
680 | wl12xx_warning("acx statistics failed: %d", ret); | ||
681 | goto out; | ||
682 | } | ||
683 | |||
684 | memcpy(stats, answer->parameters, sizeof(*stats)); | ||
685 | |||
686 | out: | ||
687 | kfree(answer); | ||
688 | return ret; | ||
689 | } | ||
diff --git a/drivers/net/wireless/wl12xx/cmd.c b/drivers/net/wireless/wl12xx/cmd.c deleted file mode 100644 index f73ab602b7ae..000000000000 --- a/drivers/net/wireless/wl12xx/cmd.c +++ /dev/null | |||
@@ -1,353 +0,0 @@ | |||
1 | #include "cmd.h" | ||
2 | |||
3 | #include <linux/module.h> | ||
4 | #include <linux/crc7.h> | ||
5 | #include <linux/spi/spi.h> | ||
6 | |||
7 | #include "wl12xx.h" | ||
8 | #include "wl12xx_80211.h" | ||
9 | #include "reg.h" | ||
10 | #include "spi.h" | ||
11 | #include "ps.h" | ||
12 | |||
13 | int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len) | ||
14 | { | ||
15 | struct wl12xx_command cmd; | ||
16 | unsigned long timeout; | ||
17 | size_t cmd_len; | ||
18 | u32 intr; | ||
19 | int ret = 0; | ||
20 | |||
21 | memset(&cmd, 0, sizeof(cmd)); | ||
22 | cmd.id = type; | ||
23 | cmd.status = 0; | ||
24 | memcpy(cmd.parameters, buf, buf_len); | ||
25 | cmd_len = ALIGN(buf_len, 4) + CMDMBOX_HEADER_LEN; | ||
26 | |||
27 | wl12xx_ps_elp_wakeup(wl); | ||
28 | |||
29 | wl12xx_spi_mem_write(wl, wl->cmd_box_addr, &cmd, cmd_len); | ||
30 | |||
31 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); | ||
32 | |||
33 | timeout = jiffies + msecs_to_jiffies(WL12XX_COMMAND_TIMEOUT); | ||
34 | |||
35 | intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | ||
36 | while (!(intr & wl->chip.intr_cmd_complete)) { | ||
37 | if (time_after(jiffies, timeout)) { | ||
38 | wl12xx_error("command complete timeout"); | ||
39 | ret = -ETIMEDOUT; | ||
40 | goto out; | ||
41 | } | ||
42 | |||
43 | msleep(1); | ||
44 | |||
45 | intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | ||
46 | } | ||
47 | |||
48 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_ACK, | ||
49 | wl->chip.intr_cmd_complete); | ||
50 | |||
51 | out: | ||
52 | wl12xx_ps_elp_sleep(wl); | ||
53 | |||
54 | return ret; | ||
55 | } | ||
56 | |||
57 | int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer) | ||
58 | { | ||
59 | int ret; | ||
60 | |||
61 | wl12xx_debug(DEBUG_CMD, "cmd test"); | ||
62 | |||
63 | ret = wl12xx_cmd_send(wl, CMD_TEST, buf, buf_len); | ||
64 | if (ret < 0) { | ||
65 | wl12xx_warning("TEST command failed"); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | if (answer) { | ||
70 | struct wl12xx_command *cmd_answer; | ||
71 | |||
72 | /* | ||
73 | * The test command got in, we can read the answer. | ||
74 | * The answer would be a wl12xx_command, where the | ||
75 | * parameter array contains the actual answer. | ||
76 | */ | ||
77 | |||
78 | wl12xx_ps_elp_wakeup(wl); | ||
79 | |||
80 | wl12xx_spi_mem_read(wl, wl->cmd_box_addr, buf, buf_len); | ||
81 | |||
82 | wl12xx_ps_elp_sleep(wl); | ||
83 | |||
84 | cmd_answer = buf; | ||
85 | if (cmd_answer->status != CMD_STATUS_SUCCESS) | ||
86 | wl12xx_error("TEST command answer error: %d", | ||
87 | cmd_answer->status); | ||
88 | } | ||
89 | |||
90 | return 0; | ||
91 | } | ||
92 | |||
93 | |||
94 | int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 ie_id, u16 ie_len, | ||
95 | void *answer) | ||
96 | { | ||
97 | struct wl12xx_command *cmd; | ||
98 | struct acx_header header; | ||
99 | int ret; | ||
100 | |||
101 | wl12xx_debug(DEBUG_CMD, "cmd interrogate"); | ||
102 | |||
103 | header.id = ie_id; | ||
104 | header.len = ie_len - sizeof(header); | ||
105 | |||
106 | ret = wl12xx_cmd_send(wl, CMD_INTERROGATE, &header, sizeof(header)); | ||
107 | if (ret < 0) { | ||
108 | wl12xx_error("INTERROGATE command failed"); | ||
109 | return ret; | ||
110 | } | ||
111 | |||
112 | wl12xx_ps_elp_wakeup(wl); | ||
113 | |||
114 | /* the interrogate command got in, we can read the answer */ | ||
115 | wl12xx_spi_mem_read(wl, wl->cmd_box_addr, answer, | ||
116 | CMDMBOX_HEADER_LEN + ie_len); | ||
117 | |||
118 | wl12xx_ps_elp_sleep(wl); | ||
119 | |||
120 | cmd = answer; | ||
121 | if (cmd->status != CMD_STATUS_SUCCESS) | ||
122 | wl12xx_error("INTERROGATE command error: %d", | ||
123 | cmd->status); | ||
124 | |||
125 | return 0; | ||
126 | |||
127 | } | ||
128 | |||
129 | int wl12xx_cmd_configure(struct wl12xx *wl, void *ie, int ie_len) | ||
130 | { | ||
131 | int ret; | ||
132 | |||
133 | wl12xx_debug(DEBUG_CMD, "cmd configure"); | ||
134 | |||
135 | ret = wl12xx_cmd_send(wl, CMD_CONFIGURE, ie, | ||
136 | ie_len); | ||
137 | if (ret < 0) { | ||
138 | wl12xx_warning("CONFIGURE command NOK"); | ||
139 | return ret; | ||
140 | } | ||
141 | |||
142 | return 0; | ||
143 | |||
144 | } | ||
145 | |||
146 | int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity, | ||
147 | void *bitmap, u16 bitmap_len, u8 bitmap_control) | ||
148 | { | ||
149 | struct vbm_update_request vbm; | ||
150 | int ret; | ||
151 | |||
152 | wl12xx_debug(DEBUG_CMD, "cmd vbm"); | ||
153 | |||
154 | /* Count and period will be filled by the target */ | ||
155 | vbm.tim.bitmap_ctrl = bitmap_control; | ||
156 | if (bitmap_len > PARTIAL_VBM_MAX) { | ||
157 | wl12xx_warning("cmd vbm len is %d B, truncating to %d", | ||
158 | bitmap_len, PARTIAL_VBM_MAX); | ||
159 | bitmap_len = PARTIAL_VBM_MAX; | ||
160 | } | ||
161 | memcpy(vbm.tim.pvb_field, bitmap, bitmap_len); | ||
162 | vbm.tim.identity = identity; | ||
163 | vbm.tim.length = bitmap_len + 3; | ||
164 | |||
165 | vbm.len = cpu_to_le16(bitmap_len + 5); | ||
166 | |||
167 | ret = wl12xx_cmd_send(wl, CMD_VBM, &vbm, sizeof(vbm)); | ||
168 | if (ret < 0) { | ||
169 | wl12xx_error("VBM command failed"); | ||
170 | return ret; | ||
171 | } | ||
172 | |||
173 | return 0; | ||
174 | } | ||
175 | |||
176 | int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, u8 enable) | ||
177 | { | ||
178 | int ret; | ||
179 | u16 cmd_rx, cmd_tx; | ||
180 | |||
181 | wl12xx_debug(DEBUG_CMD, "cmd data path"); | ||
182 | |||
183 | if (enable) { | ||
184 | cmd_rx = CMD_ENABLE_RX; | ||
185 | cmd_tx = CMD_ENABLE_TX; | ||
186 | } else { | ||
187 | cmd_rx = CMD_DISABLE_RX; | ||
188 | cmd_tx = CMD_DISABLE_TX; | ||
189 | } | ||
190 | |||
191 | ret = wl12xx_cmd_send(wl, cmd_rx, &channel, sizeof(channel)); | ||
192 | if (ret < 0) { | ||
193 | wl12xx_error("rx %s cmd for channel %d failed", | ||
194 | enable ? "start" : "stop", channel); | ||
195 | return ret; | ||
196 | } | ||
197 | |||
198 | wl12xx_debug(DEBUG_BOOT, "rx %s cmd channel %d", | ||
199 | enable ? "start" : "stop", channel); | ||
200 | |||
201 | ret = wl12xx_cmd_send(wl, cmd_tx, &channel, sizeof(channel)); | ||
202 | if (ret < 0) { | ||
203 | wl12xx_error("tx %s cmd for channel %d failed", | ||
204 | enable ? "start" : "stop", channel); | ||
205 | return ret; | ||
206 | } | ||
207 | |||
208 | wl12xx_debug(DEBUG_BOOT, "tx %s cmd channel %d", | ||
209 | enable ? "start" : "stop", channel); | ||
210 | |||
211 | return 0; | ||
212 | } | ||
213 | |||
214 | int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval, | ||
215 | u16 beacon_interval, u8 wait) | ||
216 | { | ||
217 | unsigned long timeout; | ||
218 | struct cmd_join join = {}; | ||
219 | int ret, i; | ||
220 | u8 *bssid; | ||
221 | |||
222 | /* FIXME: this should be in main.c */ | ||
223 | ret = wl12xx_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE, | ||
224 | DEFAULT_HW_GEN_MODULATION_TYPE, | ||
225 | wl->tx_mgmt_frm_rate, | ||
226 | wl->tx_mgmt_frm_mod); | ||
227 | if (ret < 0) | ||
228 | return ret; | ||
229 | |||
230 | wl12xx_debug(DEBUG_CMD, "cmd join"); | ||
231 | |||
232 | /* Reverse order BSSID */ | ||
233 | bssid = (u8 *)&join.bssid_lsb; | ||
234 | for (i = 0; i < ETH_ALEN; i++) | ||
235 | bssid[i] = wl->bssid[ETH_ALEN - i - 1]; | ||
236 | |||
237 | join.rx_config_options = wl->rx_config; | ||
238 | join.rx_filter_options = wl->rx_filter; | ||
239 | |||
240 | join.basic_rate_set = RATE_MASK_1MBPS | RATE_MASK_2MBPS | | ||
241 | RATE_MASK_5_5MBPS | RATE_MASK_11MBPS; | ||
242 | |||
243 | join.beacon_interval = beacon_interval; | ||
244 | join.dtim_interval = dtim_interval; | ||
245 | join.bss_type = bss_type; | ||
246 | join.channel = wl->channel; | ||
247 | join.ctrl = JOIN_CMD_CTRL_TX_FLUSH; | ||
248 | |||
249 | ret = wl12xx_cmd_send(wl, CMD_START_JOIN, &join, sizeof(join)); | ||
250 | if (ret < 0) { | ||
251 | wl12xx_error("failed to initiate cmd join"); | ||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | timeout = msecs_to_jiffies(JOIN_TIMEOUT); | ||
256 | |||
257 | /* | ||
258 | * ugly hack: we should wait for JOIN_EVENT_COMPLETE_ID but to | ||
259 | * simplify locking we just sleep instead, for now | ||
260 | */ | ||
261 | if (wait) | ||
262 | msleep(10); | ||
263 | |||
264 | return 0; | ||
265 | } | ||
266 | |||
267 | int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode) | ||
268 | { | ||
269 | int ret; | ||
270 | struct acx_ps_params ps_params; | ||
271 | |||
272 | /* FIXME: this should be in ps.c */ | ||
273 | ret = wl12xx_acx_wake_up_conditions(wl, wl->listen_int); | ||
274 | if (ret < 0) { | ||
275 | wl12xx_error("Couldnt set wake up conditions"); | ||
276 | return ret; | ||
277 | } | ||
278 | |||
279 | wl12xx_debug(DEBUG_CMD, "cmd set ps mode"); | ||
280 | |||
281 | ps_params.ps_mode = ps_mode; | ||
282 | ps_params.send_null_data = 1; | ||
283 | ps_params.retries = 5; | ||
284 | ps_params.hang_over_period = 128; | ||
285 | ps_params.null_data_rate = 1; /* 1 Mbps */ | ||
286 | |||
287 | ret = wl12xx_cmd_send(wl, CMD_SET_PS_MODE, &ps_params, | ||
288 | sizeof(ps_params)); | ||
289 | if (ret < 0) { | ||
290 | wl12xx_error("cmd set_ps_mode failed"); | ||
291 | return ret; | ||
292 | } | ||
293 | |||
294 | return 0; | ||
295 | } | ||
296 | |||
297 | int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, u32 len, void *answer) | ||
298 | { | ||
299 | struct cmd_read_write_memory mem_cmd, *mem_answer; | ||
300 | struct wl12xx_command cmd; | ||
301 | int ret; | ||
302 | |||
303 | wl12xx_debug(DEBUG_CMD, "cmd read memory"); | ||
304 | |||
305 | memset(&mem_cmd, 0, sizeof(mem_cmd)); | ||
306 | mem_cmd.addr = addr; | ||
307 | mem_cmd.size = len; | ||
308 | |||
309 | ret = wl12xx_cmd_send(wl, CMD_READ_MEMORY, &mem_cmd, sizeof(mem_cmd)); | ||
310 | if (ret < 0) { | ||
311 | wl12xx_error("read memory command failed: %d", ret); | ||
312 | return ret; | ||
313 | } | ||
314 | |||
315 | /* the read command got in, we can now read the answer */ | ||
316 | wl12xx_spi_mem_read(wl, wl->cmd_box_addr, &cmd, | ||
317 | CMDMBOX_HEADER_LEN + sizeof(mem_cmd)); | ||
318 | |||
319 | if (cmd.status != CMD_STATUS_SUCCESS) | ||
320 | wl12xx_error("error in read command result: %d", cmd.status); | ||
321 | |||
322 | mem_answer = (struct cmd_read_write_memory *) cmd.parameters; | ||
323 | memcpy(answer, mem_answer->value, len); | ||
324 | |||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id, | ||
329 | void *buf, size_t buf_len) | ||
330 | { | ||
331 | struct wl12xx_cmd_packet_template template; | ||
332 | int ret; | ||
333 | |||
334 | wl12xx_debug(DEBUG_CMD, "cmd template %d", cmd_id); | ||
335 | |||
336 | memset(&template, 0, sizeof(template)); | ||
337 | |||
338 | WARN_ON(buf_len > WL12XX_MAX_TEMPLATE_SIZE); | ||
339 | buf_len = min_t(size_t, buf_len, WL12XX_MAX_TEMPLATE_SIZE); | ||
340 | template.size = cpu_to_le16(buf_len); | ||
341 | |||
342 | if (buf) | ||
343 | memcpy(template.template, buf, buf_len); | ||
344 | |||
345 | ret = wl12xx_cmd_send(wl, cmd_id, &template, | ||
346 | sizeof(template.size) + buf_len); | ||
347 | if (ret < 0) { | ||
348 | wl12xx_warning("cmd set_template failed: %d", ret); | ||
349 | return ret; | ||
350 | } | ||
351 | |||
352 | return 0; | ||
353 | } | ||
diff --git a/drivers/net/wireless/wl12xx/reg.h b/drivers/net/wireless/wl12xx/reg.h index e421643215cd..2de47cc32b8b 100644 --- a/drivers/net/wireless/wl12xx/reg.h +++ b/drivers/net/wireless/wl12xx/reg.h | |||
@@ -26,7 +26,6 @@ | |||
26 | #define __REG_H__ | 26 | #define __REG_H__ |
27 | 27 | ||
28 | #include <linux/bitops.h> | 28 | #include <linux/bitops.h> |
29 | #include "wl12xx.h" | ||
30 | 29 | ||
31 | #define REGISTERS_BASE 0x00300000 | 30 | #define REGISTERS_BASE 0x00300000 |
32 | #define DRPW_BASE 0x00310000 | 31 | #define DRPW_BASE 0x00310000 |
diff --git a/drivers/net/wireless/wl12xx/wl1251.h b/drivers/net/wireless/wl12xx/wl1251.h index 1f4a44330394..665aca02bea9 100644 --- a/drivers/net/wireless/wl12xx/wl1251.h +++ b/drivers/net/wireless/wl12xx/wl1251.h | |||
@@ -1,7 +1,8 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Nokia Corporation | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008-2009 Nokia Corporation | ||
5 | * | 6 | * |
6 | * Contact: Kalle Valo <kalle.valo@nokia.com> | 7 | * Contact: Kalle Valo <kalle.valo@nokia.com> |
7 | * | 8 | * |
@@ -24,142 +25,396 @@ | |||
24 | #ifndef __WL1251_H__ | 25 | #ifndef __WL1251_H__ |
25 | #define __WL1251_H__ | 26 | #define __WL1251_H__ |
26 | 27 | ||
28 | #include <linux/mutex.h> | ||
29 | #include <linux/list.h> | ||
27 | #include <linux/bitops.h> | 30 | #include <linux/bitops.h> |
28 | 31 | #include <net/mac80211.h> | |
29 | #include "wl12xx.h" | 32 | |
30 | #include "acx.h" | 33 | #define DRIVER_NAME "wl1251" |
31 | 34 | #define DRIVER_PREFIX DRIVER_NAME ": " | |
32 | #define WL1251_FW_NAME "wl1251-fw.bin" | 35 | |
33 | #define WL1251_NVS_NAME "wl1251-nvs.bin" | 36 | enum { |
34 | 37 | DEBUG_NONE = 0, | |
35 | #define WL1251_POWER_ON_SLEEP 10 /* in miliseconds */ | 38 | DEBUG_IRQ = BIT(0), |
36 | 39 | DEBUG_SPI = BIT(1), | |
37 | void wl1251_setup(struct wl12xx *wl); | 40 | DEBUG_BOOT = BIT(2), |
38 | 41 | DEBUG_MAILBOX = BIT(3), | |
39 | 42 | DEBUG_NETLINK = BIT(4), | |
40 | struct wl1251_acx_memory { | 43 | DEBUG_EVENT = BIT(5), |
41 | __le16 num_stations; /* number of STAs to be supported. */ | 44 | DEBUG_TX = BIT(6), |
42 | u16 reserved_1; | 45 | DEBUG_RX = BIT(7), |
46 | DEBUG_SCAN = BIT(8), | ||
47 | DEBUG_CRYPT = BIT(9), | ||
48 | DEBUG_PSM = BIT(10), | ||
49 | DEBUG_MAC80211 = BIT(11), | ||
50 | DEBUG_CMD = BIT(12), | ||
51 | DEBUG_ACX = BIT(13), | ||
52 | DEBUG_ALL = ~0, | ||
53 | }; | ||
54 | |||
55 | #define DEBUG_LEVEL (DEBUG_NONE) | ||
56 | |||
57 | #define DEBUG_DUMP_LIMIT 1024 | ||
58 | |||
59 | #define wl1251_error(fmt, arg...) \ | ||
60 | printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg) | ||
61 | |||
62 | #define wl1251_warning(fmt, arg...) \ | ||
63 | printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg) | ||
64 | |||
65 | #define wl1251_notice(fmt, arg...) \ | ||
66 | printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg) | ||
67 | |||
68 | #define wl1251_info(fmt, arg...) \ | ||
69 | printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg) | ||
70 | |||
71 | #define wl1251_debug(level, fmt, arg...) \ | ||
72 | do { \ | ||
73 | if (level & DEBUG_LEVEL) \ | ||
74 | printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \ | ||
75 | } while (0) | ||
76 | |||
77 | #define wl1251_dump(level, prefix, buf, len) \ | ||
78 | do { \ | ||
79 | if (level & DEBUG_LEVEL) \ | ||
80 | print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ | ||
81 | DUMP_PREFIX_OFFSET, 16, 1, \ | ||
82 | buf, \ | ||
83 | min_t(size_t, len, DEBUG_DUMP_LIMIT), \ | ||
84 | 0); \ | ||
85 | } while (0) | ||
86 | |||
87 | #define wl1251_dump_ascii(level, prefix, buf, len) \ | ||
88 | do { \ | ||
89 | if (level & DEBUG_LEVEL) \ | ||
90 | print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ | ||
91 | DUMP_PREFIX_OFFSET, 16, 1, \ | ||
92 | buf, \ | ||
93 | min_t(size_t, len, DEBUG_DUMP_LIMIT), \ | ||
94 | true); \ | ||
95 | } while (0) | ||
96 | |||
97 | #define WL1251_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \ | ||
98 | CFG_BSSID_FILTER_EN) | ||
99 | |||
100 | #define WL1251_DEFAULT_RX_FILTER (CFG_RX_PRSP_EN | \ | ||
101 | CFG_RX_MGMT_EN | \ | ||
102 | CFG_RX_DATA_EN | \ | ||
103 | CFG_RX_CTL_EN | \ | ||
104 | CFG_RX_BCN_EN | \ | ||
105 | CFG_RX_AUTH_EN | \ | ||
106 | CFG_RX_ASSOC_EN) | ||
107 | |||
108 | #define WL1251_BUSY_WORD_LEN 8 | ||
109 | |||
110 | struct boot_attr { | ||
111 | u32 radio_type; | ||
112 | u8 mac_clock; | ||
113 | u8 arm_clock; | ||
114 | int firmware_debug; | ||
115 | u32 minor; | ||
116 | u32 major; | ||
117 | u32 bugfix; | ||
118 | }; | ||
119 | |||
120 | enum wl1251_state { | ||
121 | WL1251_STATE_OFF, | ||
122 | WL1251_STATE_ON, | ||
123 | WL1251_STATE_PLT, | ||
124 | }; | ||
125 | |||
126 | enum wl1251_partition_type { | ||
127 | PART_DOWN, | ||
128 | PART_WORK, | ||
129 | PART_DRPW, | ||
130 | |||
131 | PART_TABLE_LEN | ||
132 | }; | ||
133 | |||
134 | struct wl1251_partition { | ||
135 | u32 size; | ||
136 | u32 start; | ||
137 | }; | ||
138 | |||
139 | struct wl1251_partition_set { | ||
140 | struct wl1251_partition mem; | ||
141 | struct wl1251_partition reg; | ||
142 | }; | ||
143 | |||
144 | struct wl1251; | ||
145 | |||
146 | /* FIXME: I'm not sure about this structure name */ | ||
147 | struct wl1251_chip { | ||
148 | u32 id; | ||
149 | |||
150 | const char *fw_filename; | ||
151 | const char *nvs_filename; | ||
152 | |||
153 | char fw_ver[21]; | ||
154 | |||
155 | unsigned int power_on_sleep; | ||
156 | int intr_cmd_complete; | ||
157 | int intr_init_complete; | ||
158 | |||
159 | int (*op_upload_fw)(struct wl1251 *wl); | ||
160 | int (*op_upload_nvs)(struct wl1251 *wl); | ||
161 | int (*op_boot)(struct wl1251 *wl); | ||
162 | void (*op_set_ecpu_ctrl)(struct wl1251 *wl, u32 flag); | ||
163 | void (*op_target_enable_interrupts)(struct wl1251 *wl); | ||
164 | int (*op_hw_init)(struct wl1251 *wl); | ||
165 | int (*op_plt_init)(struct wl1251 *wl); | ||
166 | void (*op_tx_flush)(struct wl1251 *wl); | ||
167 | void (*op_fw_version)(struct wl1251 *wl); | ||
168 | int (*op_cmd_join)(struct wl1251 *wl, u8 bss_type, u8 dtim_interval, | ||
169 | u16 beacon_interval, u8 wait); | ||
170 | |||
171 | struct wl1251_partition_set *p_table; | ||
172 | enum wl12xx_acx_int_reg *acx_reg_table; | ||
173 | }; | ||
174 | |||
175 | struct wl1251_stats { | ||
176 | struct acx_statistics *fw_stats; | ||
177 | unsigned long fw_stats_update; | ||
178 | |||
179 | unsigned int retry_count; | ||
180 | unsigned int excessive_retries; | ||
181 | }; | ||
182 | |||
183 | struct wl1251_debugfs { | ||
184 | struct dentry *rootdir; | ||
185 | struct dentry *fw_statistics; | ||
186 | |||
187 | struct dentry *tx_internal_desc_overflow; | ||
188 | |||
189 | struct dentry *rx_out_of_mem; | ||
190 | struct dentry *rx_hdr_overflow; | ||
191 | struct dentry *rx_hw_stuck; | ||
192 | struct dentry *rx_dropped; | ||
193 | struct dentry *rx_fcs_err; | ||
194 | struct dentry *rx_xfr_hint_trig; | ||
195 | struct dentry *rx_path_reset; | ||
196 | struct dentry *rx_reset_counter; | ||
197 | |||
198 | struct dentry *dma_rx_requested; | ||
199 | struct dentry *dma_rx_errors; | ||
200 | struct dentry *dma_tx_requested; | ||
201 | struct dentry *dma_tx_errors; | ||
202 | |||
203 | struct dentry *isr_cmd_cmplt; | ||
204 | struct dentry *isr_fiqs; | ||
205 | struct dentry *isr_rx_headers; | ||
206 | struct dentry *isr_rx_mem_overflow; | ||
207 | struct dentry *isr_rx_rdys; | ||
208 | struct dentry *isr_irqs; | ||
209 | struct dentry *isr_tx_procs; | ||
210 | struct dentry *isr_decrypt_done; | ||
211 | struct dentry *isr_dma0_done; | ||
212 | struct dentry *isr_dma1_done; | ||
213 | struct dentry *isr_tx_exch_complete; | ||
214 | struct dentry *isr_commands; | ||
215 | struct dentry *isr_rx_procs; | ||
216 | struct dentry *isr_hw_pm_mode_changes; | ||
217 | struct dentry *isr_host_acknowledges; | ||
218 | struct dentry *isr_pci_pm; | ||
219 | struct dentry *isr_wakeups; | ||
220 | struct dentry *isr_low_rssi; | ||
221 | |||
222 | struct dentry *wep_addr_key_count; | ||
223 | struct dentry *wep_default_key_count; | ||
224 | /* skipping wep.reserved */ | ||
225 | struct dentry *wep_key_not_found; | ||
226 | struct dentry *wep_decrypt_fail; | ||
227 | struct dentry *wep_packets; | ||
228 | struct dentry *wep_interrupt; | ||
229 | |||
230 | struct dentry *pwr_ps_enter; | ||
231 | struct dentry *pwr_elp_enter; | ||
232 | struct dentry *pwr_missing_bcns; | ||
233 | struct dentry *pwr_wake_on_host; | ||
234 | struct dentry *pwr_wake_on_timer_exp; | ||
235 | struct dentry *pwr_tx_with_ps; | ||
236 | struct dentry *pwr_tx_without_ps; | ||
237 | struct dentry *pwr_rcvd_beacons; | ||
238 | struct dentry *pwr_power_save_off; | ||
239 | struct dentry *pwr_enable_ps; | ||
240 | struct dentry *pwr_disable_ps; | ||
241 | struct dentry *pwr_fix_tsf_ps; | ||
242 | /* skipping cont_miss_bcns_spread for now */ | ||
243 | struct dentry *pwr_rcvd_awake_beacons; | ||
244 | |||
245 | struct dentry *mic_rx_pkts; | ||
246 | struct dentry *mic_calc_failure; | ||
247 | |||
248 | struct dentry *aes_encrypt_fail; | ||
249 | struct dentry *aes_decrypt_fail; | ||
250 | struct dentry *aes_encrypt_packets; | ||
251 | struct dentry *aes_decrypt_packets; | ||
252 | struct dentry *aes_encrypt_interrupt; | ||
253 | struct dentry *aes_decrypt_interrupt; | ||
254 | |||
255 | struct dentry *event_heart_beat; | ||
256 | struct dentry *event_calibration; | ||
257 | struct dentry *event_rx_mismatch; | ||
258 | struct dentry *event_rx_mem_empty; | ||
259 | struct dentry *event_rx_pool; | ||
260 | struct dentry *event_oom_late; | ||
261 | struct dentry *event_phy_transmit_error; | ||
262 | struct dentry *event_tx_stuck; | ||
263 | |||
264 | struct dentry *ps_pspoll_timeouts; | ||
265 | struct dentry *ps_upsd_timeouts; | ||
266 | struct dentry *ps_upsd_max_sptime; | ||
267 | struct dentry *ps_upsd_max_apturn; | ||
268 | struct dentry *ps_pspoll_max_apturn; | ||
269 | struct dentry *ps_pspoll_utilization; | ||
270 | struct dentry *ps_upsd_utilization; | ||
271 | |||
272 | struct dentry *rxpipe_rx_prep_beacon_drop; | ||
273 | struct dentry *rxpipe_descr_host_int_trig_rx_data; | ||
274 | struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data; | ||
275 | struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data; | ||
276 | struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data; | ||
277 | |||
278 | struct dentry *tx_queue_len; | ||
279 | |||
280 | struct dentry *retry_count; | ||
281 | struct dentry *excessive_retries; | ||
282 | }; | ||
283 | |||
284 | struct wl1251 { | ||
285 | struct ieee80211_hw *hw; | ||
286 | bool mac80211_registered; | ||
287 | |||
288 | struct spi_device *spi; | ||
289 | |||
290 | void (*set_power)(bool enable); | ||
291 | int irq; | ||
292 | |||
293 | enum wl1251_state state; | ||
294 | struct mutex mutex; | ||
295 | |||
296 | int physical_mem_addr; | ||
297 | int physical_reg_addr; | ||
298 | int virtual_mem_addr; | ||
299 | int virtual_reg_addr; | ||
300 | |||
301 | struct wl1251_chip chip; | ||
302 | |||
303 | int cmd_box_addr; | ||
304 | int event_box_addr; | ||
305 | struct boot_attr boot_attr; | ||
306 | |||
307 | u8 *fw; | ||
308 | size_t fw_len; | ||
309 | u8 *nvs; | ||
310 | size_t nvs_len; | ||
311 | |||
312 | u8 bssid[ETH_ALEN]; | ||
313 | u8 mac_addr[ETH_ALEN]; | ||
314 | u8 bss_type; | ||
315 | u8 listen_int; | ||
316 | int channel; | ||
317 | |||
318 | void *target_mem_map; | ||
319 | struct acx_data_path_params_resp *data_path; | ||
320 | |||
321 | /* Number of TX packets transferred to the FW, modulo 16 */ | ||
322 | u32 data_in_count; | ||
323 | |||
324 | /* Frames scheduled for transmission, not handled yet */ | ||
325 | struct sk_buff_head tx_queue; | ||
326 | bool tx_queue_stopped; | ||
327 | |||
328 | struct work_struct tx_work; | ||
329 | struct work_struct filter_work; | ||
330 | |||
331 | /* Pending TX frames */ | ||
332 | struct sk_buff *tx_frames[16]; | ||
43 | 333 | ||
44 | /* | 334 | /* |
45 | * Nmber of memory buffers for the RX mem pool. | 335 | * Index pointing to the next TX complete entry |
46 | * The actual number may be less if there are | 336 | * in the cyclic XT complete array we get from |
47 | * not enough blocks left for the minimum num | 337 | * the FW. |
48 | * of TX ones. | ||
49 | */ | 338 | */ |
50 | u8 rx_mem_block_num; | 339 | u32 next_tx_complete; |
51 | u8 reserved_2; | ||
52 | u8 num_tx_queues; /* From 1 to 16 */ | ||
53 | u8 host_if_options; /* HOST_IF* */ | ||
54 | u8 tx_min_mem_block_num; | ||
55 | u8 num_ssid_profiles; | ||
56 | __le16 debug_buffer_size; | ||
57 | } __attribute__ ((packed)); | ||
58 | |||
59 | |||
60 | #define ACX_RX_DESC_MIN 1 | ||
61 | #define ACX_RX_DESC_MAX 127 | ||
62 | #define ACX_RX_DESC_DEF 32 | ||
63 | struct wl1251_acx_rx_queue_config { | ||
64 | u8 num_descs; | ||
65 | u8 pad; | ||
66 | u8 type; | ||
67 | u8 priority; | ||
68 | __le32 dma_address; | ||
69 | } __attribute__ ((packed)); | ||
70 | |||
71 | #define ACX_TX_DESC_MIN 1 | ||
72 | #define ACX_TX_DESC_MAX 127 | ||
73 | #define ACX_TX_DESC_DEF 16 | ||
74 | struct wl1251_acx_tx_queue_config { | ||
75 | u8 num_descs; | ||
76 | u8 pad[2]; | ||
77 | u8 attributes; | ||
78 | } __attribute__ ((packed)); | ||
79 | |||
80 | #define MAX_TX_QUEUE_CONFIGS 5 | ||
81 | #define MAX_TX_QUEUES 4 | ||
82 | struct wl1251_acx_config_memory { | ||
83 | struct acx_header header; | ||
84 | |||
85 | struct wl1251_acx_memory mem_config; | ||
86 | struct wl1251_acx_rx_queue_config rx_queue_config; | ||
87 | struct wl1251_acx_tx_queue_config tx_queue_config[MAX_TX_QUEUE_CONFIGS]; | ||
88 | } __attribute__ ((packed)); | ||
89 | |||
90 | struct wl1251_acx_mem_map { | ||
91 | struct acx_header header; | ||
92 | |||
93 | void *code_start; | ||
94 | void *code_end; | ||
95 | |||
96 | void *wep_defkey_start; | ||
97 | void *wep_defkey_end; | ||
98 | 340 | ||
99 | void *sta_table_start; | 341 | /* FW Rx counter */ |
100 | void *sta_table_end; | 342 | u32 rx_counter; |
101 | 343 | ||
102 | void *packet_template_start; | 344 | /* Rx frames handled */ |
103 | void *packet_template_end; | 345 | u32 rx_handled; |
104 | 346 | ||
105 | void *queue_memory_start; | 347 | /* Current double buffer */ |
106 | void *queue_memory_end; | 348 | u32 rx_current_buffer; |
349 | u32 rx_last_id; | ||
107 | 350 | ||
108 | void *packet_memory_pool_start; | 351 | /* The target interrupt mask */ |
109 | void *packet_memory_pool_end; | 352 | u32 intr_mask; |
353 | struct work_struct irq_work; | ||
110 | 354 | ||
111 | void *debug_buffer1_start; | 355 | /* The mbox event mask */ |
112 | void *debug_buffer1_end; | 356 | u32 event_mask; |
113 | 357 | ||
114 | void *debug_buffer2_start; | 358 | /* Mailbox pointers */ |
115 | void *debug_buffer2_end; | 359 | u32 mbox_ptr[2]; |
116 | 360 | ||
117 | /* Number of blocks FW allocated for TX packets */ | 361 | /* Are we currently scanning */ |
118 | u32 num_tx_mem_blocks; | 362 | bool scanning; |
119 | 363 | ||
120 | /* Number of blocks FW allocated for RX packets */ | 364 | /* Our association ID */ |
121 | u32 num_rx_mem_blocks; | 365 | u16 aid; |
122 | } __attribute__ ((packed)); | ||
123 | 366 | ||
124 | /************************************************************************* | 367 | /* Default key (for WEP) */ |
368 | u32 default_key; | ||
125 | 369 | ||
126 | Host Interrupt Register (WiLink -> Host) | 370 | unsigned int tx_mgmt_frm_rate; |
371 | unsigned int tx_mgmt_frm_mod; | ||
127 | 372 | ||
128 | **************************************************************************/ | 373 | unsigned int rx_config; |
374 | unsigned int rx_filter; | ||
129 | 375 | ||
130 | /* RX packet is ready in Xfer buffer #0 */ | 376 | /* is firmware in elp mode */ |
131 | #define WL1251_ACX_INTR_RX0_DATA BIT(0) | 377 | bool elp; |
132 | 378 | ||
133 | /* TX result(s) are in the TX complete buffer */ | 379 | /* we can be in psm, but not in elp, we have to differentiate */ |
134 | #define WL1251_ACX_INTR_TX_RESULT BIT(1) | 380 | bool psm; |
135 | 381 | ||
136 | /* OBSOLETE */ | 382 | /* PSM mode requested */ |
137 | #define WL1251_ACX_INTR_TX_XFR BIT(2) | 383 | bool psm_requested; |
138 | 384 | ||
139 | /* RX packet is ready in Xfer buffer #1 */ | 385 | /* in dBm */ |
140 | #define WL1251_ACX_INTR_RX1_DATA BIT(3) | 386 | int power_level; |
141 | 387 | ||
142 | /* Event was entered to Event MBOX #A */ | 388 | struct wl1251_stats stats; |
143 | #define WL1251_ACX_INTR_EVENT_A BIT(4) | 389 | struct wl1251_debugfs debugfs; |
144 | 390 | ||
145 | /* Event was entered to Event MBOX #B */ | 391 | u32 buffer_32; |
146 | #define WL1251_ACX_INTR_EVENT_B BIT(5) | 392 | u32 buffer_cmd; |
393 | u8 buffer_busyword[WL1251_BUSY_WORD_LEN]; | ||
394 | struct wl1251_rx_descriptor *rx_descriptor; | ||
395 | }; | ||
147 | 396 | ||
148 | /* OBSOLETE */ | 397 | int wl1251_plt_start(struct wl1251 *wl); |
149 | #define WL1251_ACX_INTR_WAKE_ON_HOST BIT(6) | 398 | int wl1251_plt_stop(struct wl1251 *wl); |
150 | 399 | ||
151 | /* Trace meassge on MBOX #A */ | 400 | #define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG /* Long Preamble */ |
152 | #define WL1251_ACX_INTR_TRACE_A BIT(7) | 401 | #define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS |
402 | #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */ | ||
153 | 403 | ||
154 | /* Trace meassge on MBOX #B */ | 404 | #define WL1251_DEFAULT_POWER_LEVEL 20 |
155 | #define WL1251_ACX_INTR_TRACE_B BIT(8) | ||
156 | 405 | ||
157 | /* Command processing completion */ | 406 | #define WL1251_TX_QUEUE_MAX_LENGTH 20 |
158 | #define WL1251_ACX_INTR_CMD_COMPLETE BIT(9) | ||
159 | 407 | ||
160 | /* Init sequence is done */ | 408 | /* Different chips need different sleep times after power on. WL1271 needs |
161 | #define WL1251_ACX_INTR_INIT_COMPLETE BIT(14) | 409 | * 200ms, WL1251 needs only 10ms. By default we use 200ms, but as soon as we |
410 | * know the chip ID, we change the sleep value in the wl1251 chip structure, | ||
411 | * so in subsequent power ons, we don't waste more time then needed. */ | ||
412 | #define WL1251_DEFAULT_POWER_ON_SLEEP 200 | ||
162 | 413 | ||
163 | #define WL1251_ACX_INTR_ALL 0xFFFFFFFF | 414 | #define CHIP_ID_1251_PG10 (0x7010101) |
415 | #define CHIP_ID_1251_PG11 (0x7020101) | ||
416 | #define CHIP_ID_1251_PG12 (0x7030101) | ||
417 | #define CHIP_ID_1271_PG10 (0x4030101) | ||
418 | #define CHIP_ID_1271_PG20 (0x4030111) | ||
164 | 419 | ||
165 | #endif | 420 | #endif |
diff --git a/drivers/net/wireless/wl12xx/wl1251_acx.c b/drivers/net/wireless/wl12xx/wl1251_acx.c new file mode 100644 index 000000000000..5a8d21c3192d --- /dev/null +++ b/drivers/net/wireless/wl12xx/wl1251_acx.c | |||
@@ -0,0 +1,840 @@ | |||
1 | #include "wl1251_acx.h" | ||
2 | |||
3 | #include <linux/module.h> | ||
4 | #include <linux/crc7.h> | ||
5 | #include <linux/spi/spi.h> | ||
6 | |||
7 | #include "wl1251.h" | ||
8 | #include "reg.h" | ||
9 | #include "wl1251_spi.h" | ||
10 | #include "wl1251_ps.h" | ||
11 | |||
12 | int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod, | ||
13 | u8 mgt_rate, u8 mgt_mod) | ||
14 | { | ||
15 | struct acx_fw_gen_frame_rates *rates; | ||
16 | int ret; | ||
17 | |||
18 | wl1251_debug(DEBUG_ACX, "acx frame rates"); | ||
19 | |||
20 | rates = kzalloc(sizeof(*rates), GFP_KERNEL); | ||
21 | if (!rates) { | ||
22 | ret = -ENOMEM; | ||
23 | goto out; | ||
24 | } | ||
25 | |||
26 | rates->tx_ctrl_frame_rate = ctrl_rate; | ||
27 | rates->tx_ctrl_frame_mod = ctrl_mod; | ||
28 | rates->tx_mgt_frame_rate = mgt_rate; | ||
29 | rates->tx_mgt_frame_mod = mgt_mod; | ||
30 | |||
31 | ret = wl1251_cmd_configure(wl, ACX_FW_GEN_FRAME_RATES, | ||
32 | rates, sizeof(*rates)); | ||
33 | if (ret < 0) { | ||
34 | wl1251_error("Failed to set FW rates and modulation"); | ||
35 | goto out; | ||
36 | } | ||
37 | |||
38 | out: | ||
39 | kfree(rates); | ||
40 | return ret; | ||
41 | } | ||
42 | |||
43 | |||
44 | int wl1251_acx_station_id(struct wl1251 *wl) | ||
45 | { | ||
46 | struct acx_dot11_station_id *mac; | ||
47 | int ret, i; | ||
48 | |||
49 | wl1251_debug(DEBUG_ACX, "acx dot11_station_id"); | ||
50 | |||
51 | mac = kzalloc(sizeof(*mac), GFP_KERNEL); | ||
52 | if (!mac) { | ||
53 | ret = -ENOMEM; | ||
54 | goto out; | ||
55 | } | ||
56 | |||
57 | for (i = 0; i < ETH_ALEN; i++) | ||
58 | mac->mac[i] = wl->mac_addr[ETH_ALEN - 1 - i]; | ||
59 | |||
60 | ret = wl1251_cmd_configure(wl, DOT11_STATION_ID, mac, sizeof(*mac)); | ||
61 | if (ret < 0) | ||
62 | goto out; | ||
63 | |||
64 | out: | ||
65 | kfree(mac); | ||
66 | return ret; | ||
67 | } | ||
68 | |||
69 | int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id) | ||
70 | { | ||
71 | struct acx_dot11_default_key *default_key; | ||
72 | int ret; | ||
73 | |||
74 | wl1251_debug(DEBUG_ACX, "acx dot11_default_key (%d)", key_id); | ||
75 | |||
76 | default_key = kzalloc(sizeof(*default_key), GFP_KERNEL); | ||
77 | if (!default_key) { | ||
78 | ret = -ENOMEM; | ||
79 | goto out; | ||
80 | } | ||
81 | |||
82 | default_key->id = key_id; | ||
83 | |||
84 | ret = wl1251_cmd_configure(wl, DOT11_DEFAULT_KEY, | ||
85 | default_key, sizeof(*default_key)); | ||
86 | if (ret < 0) { | ||
87 | wl1251_error("Couldnt set default key"); | ||
88 | goto out; | ||
89 | } | ||
90 | |||
91 | wl->default_key = key_id; | ||
92 | |||
93 | out: | ||
94 | kfree(default_key); | ||
95 | return ret; | ||
96 | } | ||
97 | |||
98 | int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event, | ||
99 | u8 listen_interval) | ||
100 | { | ||
101 | struct acx_wake_up_condition *wake_up; | ||
102 | int ret; | ||
103 | |||
104 | wl1251_debug(DEBUG_ACX, "acx wake up conditions"); | ||
105 | |||
106 | wake_up = kzalloc(sizeof(*wake_up), GFP_KERNEL); | ||
107 | if (!wake_up) { | ||
108 | ret = -ENOMEM; | ||
109 | goto out; | ||
110 | } | ||
111 | |||
112 | wake_up->wake_up_event = wake_up_event; | ||
113 | wake_up->listen_interval = listen_interval; | ||
114 | |||
115 | ret = wl1251_cmd_configure(wl, ACX_WAKE_UP_CONDITIONS, | ||
116 | wake_up, sizeof(*wake_up)); | ||
117 | if (ret < 0) { | ||
118 | wl1251_warning("could not set wake up conditions: %d", ret); | ||
119 | goto out; | ||
120 | } | ||
121 | |||
122 | out: | ||
123 | kfree(wake_up); | ||
124 | return ret; | ||
125 | } | ||
126 | |||
127 | int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth) | ||
128 | { | ||
129 | struct acx_sleep_auth *auth; | ||
130 | int ret; | ||
131 | |||
132 | wl1251_debug(DEBUG_ACX, "acx sleep auth"); | ||
133 | |||
134 | auth = kzalloc(sizeof(*auth), GFP_KERNEL); | ||
135 | if (!auth) { | ||
136 | ret = -ENOMEM; | ||
137 | goto out; | ||
138 | } | ||
139 | |||
140 | auth->sleep_auth = sleep_auth; | ||
141 | |||
142 | ret = wl1251_cmd_configure(wl, ACX_SLEEP_AUTH, auth, sizeof(*auth)); | ||
143 | if (ret < 0) | ||
144 | return ret; | ||
145 | |||
146 | out: | ||
147 | kfree(auth); | ||
148 | return ret; | ||
149 | } | ||
150 | |||
151 | int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len) | ||
152 | { | ||
153 | struct acx_revision *rev; | ||
154 | int ret; | ||
155 | |||
156 | wl1251_debug(DEBUG_ACX, "acx fw rev"); | ||
157 | |||
158 | rev = kzalloc(sizeof(*rev), GFP_KERNEL); | ||
159 | if (!rev) { | ||
160 | ret = -ENOMEM; | ||
161 | goto out; | ||
162 | } | ||
163 | |||
164 | ret = wl1251_cmd_interrogate(wl, ACX_FW_REV, rev, sizeof(*rev)); | ||
165 | if (ret < 0) { | ||
166 | wl1251_warning("ACX_FW_REV interrogate failed"); | ||
167 | goto out; | ||
168 | } | ||
169 | |||
170 | /* be careful with the buffer sizes */ | ||
171 | strncpy(buf, rev->fw_version, min(len, sizeof(rev->fw_version))); | ||
172 | |||
173 | /* | ||
174 | * if the firmware version string is exactly | ||
175 | * sizeof(rev->fw_version) long or fw_len is less than | ||
176 | * sizeof(rev->fw_version) it won't be null terminated | ||
177 | */ | ||
178 | buf[min(len, sizeof(rev->fw_version)) - 1] = '\0'; | ||
179 | |||
180 | out: | ||
181 | kfree(rev); | ||
182 | return ret; | ||
183 | } | ||
184 | |||
185 | int wl1251_acx_tx_power(struct wl1251 *wl, int power) | ||
186 | { | ||
187 | struct acx_current_tx_power *acx; | ||
188 | int ret; | ||
189 | |||
190 | wl1251_debug(DEBUG_ACX, "acx dot11_cur_tx_pwr"); | ||
191 | |||
192 | if (power < 0 || power > 25) | ||
193 | return -EINVAL; | ||
194 | |||
195 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
196 | if (!acx) { | ||
197 | ret = -ENOMEM; | ||
198 | goto out; | ||
199 | } | ||
200 | |||
201 | acx->current_tx_power = power * 10; | ||
202 | |||
203 | ret = wl1251_cmd_configure(wl, DOT11_CUR_TX_PWR, acx, sizeof(*acx)); | ||
204 | if (ret < 0) { | ||
205 | wl1251_warning("configure of tx power failed: %d", ret); | ||
206 | goto out; | ||
207 | } | ||
208 | |||
209 | out: | ||
210 | kfree(acx); | ||
211 | return ret; | ||
212 | } | ||
213 | |||
214 | int wl1251_acx_feature_cfg(struct wl1251 *wl) | ||
215 | { | ||
216 | struct acx_feature_config *feature; | ||
217 | int ret; | ||
218 | |||
219 | wl1251_debug(DEBUG_ACX, "acx feature cfg"); | ||
220 | |||
221 | feature = kzalloc(sizeof(*feature), GFP_KERNEL); | ||
222 | if (!feature) { | ||
223 | ret = -ENOMEM; | ||
224 | goto out; | ||
225 | } | ||
226 | |||
227 | /* DF_ENCRYPTION_DISABLE and DF_SNIFF_MODE_ENABLE are disabled */ | ||
228 | feature->data_flow_options = 0; | ||
229 | feature->options = 0; | ||
230 | |||
231 | ret = wl1251_cmd_configure(wl, ACX_FEATURE_CFG, | ||
232 | feature, sizeof(*feature)); | ||
233 | if (ret < 0) { | ||
234 | wl1251_error("Couldnt set HW encryption"); | ||
235 | goto out; | ||
236 | } | ||
237 | |||
238 | out: | ||
239 | kfree(feature); | ||
240 | return ret; | ||
241 | } | ||
242 | |||
243 | int wl1251_acx_mem_map(struct wl1251 *wl, struct acx_header *mem_map, | ||
244 | size_t len) | ||
245 | { | ||
246 | int ret; | ||
247 | |||
248 | wl1251_debug(DEBUG_ACX, "acx mem map"); | ||
249 | |||
250 | ret = wl1251_cmd_interrogate(wl, ACX_MEM_MAP, mem_map, len); | ||
251 | if (ret < 0) | ||
252 | return ret; | ||
253 | |||
254 | return 0; | ||
255 | } | ||
256 | |||
257 | int wl1251_acx_data_path_params(struct wl1251 *wl, | ||
258 | struct acx_data_path_params_resp *resp) | ||
259 | { | ||
260 | struct acx_data_path_params *params; | ||
261 | int ret; | ||
262 | |||
263 | wl1251_debug(DEBUG_ACX, "acx data path params"); | ||
264 | |||
265 | params = kzalloc(sizeof(*params), GFP_KERNEL); | ||
266 | if (!params) { | ||
267 | ret = -ENOMEM; | ||
268 | goto out; | ||
269 | } | ||
270 | |||
271 | params->rx_packet_ring_chunk_size = DP_RX_PACKET_RING_CHUNK_SIZE; | ||
272 | params->tx_packet_ring_chunk_size = DP_TX_PACKET_RING_CHUNK_SIZE; | ||
273 | |||
274 | params->rx_packet_ring_chunk_num = DP_RX_PACKET_RING_CHUNK_NUM; | ||
275 | params->tx_packet_ring_chunk_num = DP_TX_PACKET_RING_CHUNK_NUM; | ||
276 | |||
277 | params->tx_complete_threshold = 1; | ||
278 | |||
279 | params->tx_complete_ring_depth = FW_TX_CMPLT_BLOCK_SIZE; | ||
280 | |||
281 | params->tx_complete_timeout = DP_TX_COMPLETE_TIME_OUT; | ||
282 | |||
283 | ret = wl1251_cmd_configure(wl, ACX_DATA_PATH_PARAMS, | ||
284 | params, sizeof(*params)); | ||
285 | if (ret < 0) | ||
286 | goto out; | ||
287 | |||
288 | /* FIXME: shouldn't this be ACX_DATA_PATH_RESP_PARAMS? */ | ||
289 | ret = wl1251_cmd_interrogate(wl, ACX_DATA_PATH_PARAMS, | ||
290 | resp, sizeof(*resp)); | ||
291 | |||
292 | if (ret < 0) { | ||
293 | wl1251_warning("failed to read data path parameters: %d", ret); | ||
294 | goto out; | ||
295 | } else if (resp->header.cmd.status != CMD_STATUS_SUCCESS) { | ||
296 | wl1251_warning("data path parameter acx status failed"); | ||
297 | ret = -EIO; | ||
298 | goto out; | ||
299 | } | ||
300 | |||
301 | out: | ||
302 | kfree(params); | ||
303 | return ret; | ||
304 | } | ||
305 | |||
306 | int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time) | ||
307 | { | ||
308 | struct acx_rx_msdu_lifetime *acx; | ||
309 | int ret; | ||
310 | |||
311 | wl1251_debug(DEBUG_ACX, "acx rx msdu life time"); | ||
312 | |||
313 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
314 | if (!acx) { | ||
315 | ret = -ENOMEM; | ||
316 | goto out; | ||
317 | } | ||
318 | |||
319 | acx->lifetime = life_time; | ||
320 | ret = wl1251_cmd_configure(wl, DOT11_RX_MSDU_LIFE_TIME, | ||
321 | acx, sizeof(*acx)); | ||
322 | if (ret < 0) { | ||
323 | wl1251_warning("failed to set rx msdu life time: %d", ret); | ||
324 | goto out; | ||
325 | } | ||
326 | |||
327 | out: | ||
328 | kfree(acx); | ||
329 | return ret; | ||
330 | } | ||
331 | |||
332 | int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter) | ||
333 | { | ||
334 | struct acx_rx_config *rx_config; | ||
335 | int ret; | ||
336 | |||
337 | wl1251_debug(DEBUG_ACX, "acx rx config"); | ||
338 | |||
339 | rx_config = kzalloc(sizeof(*rx_config), GFP_KERNEL); | ||
340 | if (!rx_config) { | ||
341 | ret = -ENOMEM; | ||
342 | goto out; | ||
343 | } | ||
344 | |||
345 | rx_config->config_options = config; | ||
346 | rx_config->filter_options = filter; | ||
347 | |||
348 | ret = wl1251_cmd_configure(wl, ACX_RX_CFG, | ||
349 | rx_config, sizeof(*rx_config)); | ||
350 | if (ret < 0) { | ||
351 | wl1251_warning("failed to set rx config: %d", ret); | ||
352 | goto out; | ||
353 | } | ||
354 | |||
355 | out: | ||
356 | kfree(rx_config); | ||
357 | return ret; | ||
358 | } | ||
359 | |||
360 | int wl1251_acx_pd_threshold(struct wl1251 *wl) | ||
361 | { | ||
362 | struct acx_packet_detection *pd; | ||
363 | int ret; | ||
364 | |||
365 | wl1251_debug(DEBUG_ACX, "acx data pd threshold"); | ||
366 | |||
367 | pd = kzalloc(sizeof(*pd), GFP_KERNEL); | ||
368 | if (!pd) { | ||
369 | ret = -ENOMEM; | ||
370 | goto out; | ||
371 | } | ||
372 | |||
373 | /* FIXME: threshold value not set */ | ||
374 | |||
375 | ret = wl1251_cmd_configure(wl, ACX_PD_THRESHOLD, pd, sizeof(*pd)); | ||
376 | if (ret < 0) { | ||
377 | wl1251_warning("failed to set pd threshold: %d", ret); | ||
378 | goto out; | ||
379 | } | ||
380 | |||
381 | out: | ||
382 | kfree(pd); | ||
383 | return 0; | ||
384 | } | ||
385 | |||
386 | int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time) | ||
387 | { | ||
388 | struct acx_slot *slot; | ||
389 | int ret; | ||
390 | |||
391 | wl1251_debug(DEBUG_ACX, "acx slot"); | ||
392 | |||
393 | slot = kzalloc(sizeof(*slot), GFP_KERNEL); | ||
394 | if (!slot) { | ||
395 | ret = -ENOMEM; | ||
396 | goto out; | ||
397 | } | ||
398 | |||
399 | slot->wone_index = STATION_WONE_INDEX; | ||
400 | slot->slot_time = slot_time; | ||
401 | |||
402 | ret = wl1251_cmd_configure(wl, ACX_SLOT, slot, sizeof(*slot)); | ||
403 | if (ret < 0) { | ||
404 | wl1251_warning("failed to set slot time: %d", ret); | ||
405 | goto out; | ||
406 | } | ||
407 | |||
408 | out: | ||
409 | kfree(slot); | ||
410 | return ret; | ||
411 | } | ||
412 | |||
413 | int wl1251_acx_group_address_tbl(struct wl1251 *wl) | ||
414 | { | ||
415 | struct acx_dot11_grp_addr_tbl *acx; | ||
416 | int ret; | ||
417 | |||
418 | wl1251_debug(DEBUG_ACX, "acx group address tbl"); | ||
419 | |||
420 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
421 | if (!acx) { | ||
422 | ret = -ENOMEM; | ||
423 | goto out; | ||
424 | } | ||
425 | |||
426 | /* MAC filtering */ | ||
427 | acx->enabled = 0; | ||
428 | acx->num_groups = 0; | ||
429 | memset(acx->mac_table, 0, ADDRESS_GROUP_MAX_LEN); | ||
430 | |||
431 | ret = wl1251_cmd_configure(wl, DOT11_GROUP_ADDRESS_TBL, | ||
432 | acx, sizeof(*acx)); | ||
433 | if (ret < 0) { | ||
434 | wl1251_warning("failed to set group addr table: %d", ret); | ||
435 | goto out; | ||
436 | } | ||
437 | |||
438 | out: | ||
439 | kfree(acx); | ||
440 | return ret; | ||
441 | } | ||
442 | |||
443 | int wl1251_acx_service_period_timeout(struct wl1251 *wl) | ||
444 | { | ||
445 | struct acx_rx_timeout *rx_timeout; | ||
446 | int ret; | ||
447 | |||
448 | rx_timeout = kzalloc(sizeof(*rx_timeout), GFP_KERNEL); | ||
449 | if (!rx_timeout) { | ||
450 | ret = -ENOMEM; | ||
451 | goto out; | ||
452 | } | ||
453 | |||
454 | wl1251_debug(DEBUG_ACX, "acx service period timeout"); | ||
455 | |||
456 | rx_timeout->ps_poll_timeout = RX_TIMEOUT_PS_POLL_DEF; | ||
457 | rx_timeout->upsd_timeout = RX_TIMEOUT_UPSD_DEF; | ||
458 | |||
459 | ret = wl1251_cmd_configure(wl, ACX_SERVICE_PERIOD_TIMEOUT, | ||
460 | rx_timeout, sizeof(*rx_timeout)); | ||
461 | if (ret < 0) { | ||
462 | wl1251_warning("failed to set service period timeout: %d", | ||
463 | ret); | ||
464 | goto out; | ||
465 | } | ||
466 | |||
467 | out: | ||
468 | kfree(rx_timeout); | ||
469 | return ret; | ||
470 | } | ||
471 | |||
472 | int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold) | ||
473 | { | ||
474 | struct acx_rts_threshold *rts; | ||
475 | int ret; | ||
476 | |||
477 | wl1251_debug(DEBUG_ACX, "acx rts threshold"); | ||
478 | |||
479 | rts = kzalloc(sizeof(*rts), GFP_KERNEL); | ||
480 | if (!rts) { | ||
481 | ret = -ENOMEM; | ||
482 | goto out; | ||
483 | } | ||
484 | |||
485 | rts->threshold = rts_threshold; | ||
486 | |||
487 | ret = wl1251_cmd_configure(wl, DOT11_RTS_THRESHOLD, rts, sizeof(*rts)); | ||
488 | if (ret < 0) { | ||
489 | wl1251_warning("failed to set rts threshold: %d", ret); | ||
490 | goto out; | ||
491 | } | ||
492 | |||
493 | out: | ||
494 | kfree(rts); | ||
495 | return ret; | ||
496 | } | ||
497 | |||
498 | int wl1251_acx_beacon_filter_opt(struct wl1251 *wl) | ||
499 | { | ||
500 | struct acx_beacon_filter_option *beacon_filter; | ||
501 | int ret; | ||
502 | |||
503 | wl1251_debug(DEBUG_ACX, "acx beacon filter opt"); | ||
504 | |||
505 | beacon_filter = kzalloc(sizeof(*beacon_filter), GFP_KERNEL); | ||
506 | if (!beacon_filter) { | ||
507 | ret = -ENOMEM; | ||
508 | goto out; | ||
509 | } | ||
510 | |||
511 | beacon_filter->enable = 0; | ||
512 | beacon_filter->max_num_beacons = 0; | ||
513 | |||
514 | ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_OPT, | ||
515 | beacon_filter, sizeof(*beacon_filter)); | ||
516 | if (ret < 0) { | ||
517 | wl1251_warning("failed to set beacon filter opt: %d", ret); | ||
518 | goto out; | ||
519 | } | ||
520 | |||
521 | out: | ||
522 | kfree(beacon_filter); | ||
523 | return ret; | ||
524 | } | ||
525 | |||
526 | int wl1251_acx_beacon_filter_table(struct wl1251 *wl) | ||
527 | { | ||
528 | struct acx_beacon_filter_ie_table *ie_table; | ||
529 | int ret; | ||
530 | |||
531 | wl1251_debug(DEBUG_ACX, "acx beacon filter table"); | ||
532 | |||
533 | ie_table = kzalloc(sizeof(*ie_table), GFP_KERNEL); | ||
534 | if (!ie_table) { | ||
535 | ret = -ENOMEM; | ||
536 | goto out; | ||
537 | } | ||
538 | |||
539 | ie_table->num_ie = 0; | ||
540 | memset(ie_table->table, 0, BEACON_FILTER_TABLE_MAX_SIZE); | ||
541 | |||
542 | ret = wl1251_cmd_configure(wl, ACX_BEACON_FILTER_TABLE, | ||
543 | ie_table, sizeof(*ie_table)); | ||
544 | if (ret < 0) { | ||
545 | wl1251_warning("failed to set beacon filter table: %d", ret); | ||
546 | goto out; | ||
547 | } | ||
548 | |||
549 | out: | ||
550 | kfree(ie_table); | ||
551 | return ret; | ||
552 | } | ||
553 | |||
554 | int wl1251_acx_sg_enable(struct wl1251 *wl) | ||
555 | { | ||
556 | struct acx_bt_wlan_coex *pta; | ||
557 | int ret; | ||
558 | |||
559 | wl1251_debug(DEBUG_ACX, "acx sg enable"); | ||
560 | |||
561 | pta = kzalloc(sizeof(*pta), GFP_KERNEL); | ||
562 | if (!pta) { | ||
563 | ret = -ENOMEM; | ||
564 | goto out; | ||
565 | } | ||
566 | |||
567 | pta->enable = SG_ENABLE; | ||
568 | |||
569 | ret = wl1251_cmd_configure(wl, ACX_SG_ENABLE, pta, sizeof(*pta)); | ||
570 | if (ret < 0) { | ||
571 | wl1251_warning("failed to set softgemini enable: %d", ret); | ||
572 | goto out; | ||
573 | } | ||
574 | |||
575 | out: | ||
576 | kfree(pta); | ||
577 | return ret; | ||
578 | } | ||
579 | |||
580 | int wl1251_acx_sg_cfg(struct wl1251 *wl) | ||
581 | { | ||
582 | struct acx_bt_wlan_coex_param *param; | ||
583 | int ret; | ||
584 | |||
585 | wl1251_debug(DEBUG_ACX, "acx sg cfg"); | ||
586 | |||
587 | param = kzalloc(sizeof(*param), GFP_KERNEL); | ||
588 | if (!param) { | ||
589 | ret = -ENOMEM; | ||
590 | goto out; | ||
591 | } | ||
592 | |||
593 | /* BT-WLAN coext parameters */ | ||
594 | param->min_rate = RATE_INDEX_24MBPS; | ||
595 | param->bt_hp_max_time = PTA_BT_HP_MAXTIME_DEF; | ||
596 | param->wlan_hp_max_time = PTA_WLAN_HP_MAX_TIME_DEF; | ||
597 | param->sense_disable_timer = PTA_SENSE_DISABLE_TIMER_DEF; | ||
598 | param->rx_time_bt_hp = PTA_PROTECTIVE_RX_TIME_DEF; | ||
599 | param->tx_time_bt_hp = PTA_PROTECTIVE_TX_TIME_DEF; | ||
600 | param->rx_time_bt_hp_fast = PTA_PROTECTIVE_RX_TIME_FAST_DEF; | ||
601 | param->tx_time_bt_hp_fast = PTA_PROTECTIVE_TX_TIME_FAST_DEF; | ||
602 | param->wlan_cycle_fast = PTA_CYCLE_TIME_FAST_DEF; | ||
603 | param->bt_anti_starvation_period = PTA_ANTI_STARVE_PERIOD_DEF; | ||
604 | param->next_bt_lp_packet = PTA_TIMEOUT_NEXT_BT_LP_PACKET_DEF; | ||
605 | param->wake_up_beacon = PTA_TIME_BEFORE_BEACON_DEF; | ||
606 | param->hp_dm_max_guard_time = PTA_HPDM_MAX_TIME_DEF; | ||
607 | param->next_wlan_packet = PTA_TIME_OUT_NEXT_WLAN_DEF; | ||
608 | param->antenna_type = PTA_ANTENNA_TYPE_DEF; | ||
609 | param->signal_type = PTA_SIGNALING_TYPE_DEF; | ||
610 | param->afh_leverage_on = PTA_AFH_LEVERAGE_ON_DEF; | ||
611 | param->quiet_cycle_num = PTA_NUMBER_QUIET_CYCLE_DEF; | ||
612 | param->max_cts = PTA_MAX_NUM_CTS_DEF; | ||
613 | param->wlan_packets_num = PTA_NUMBER_OF_WLAN_PACKETS_DEF; | ||
614 | param->bt_packets_num = PTA_NUMBER_OF_BT_PACKETS_DEF; | ||
615 | param->missed_rx_avalanche = PTA_RX_FOR_AVALANCHE_DEF; | ||
616 | param->wlan_elp_hp = PTA_ELP_HP_DEF; | ||
617 | param->bt_anti_starvation_cycles = PTA_ANTI_STARVE_NUM_CYCLE_DEF; | ||
618 | param->ack_mode_dual_ant = PTA_ACK_MODE_DEF; | ||
619 | param->pa_sd_enable = PTA_ALLOW_PA_SD_DEF; | ||
620 | param->pta_auto_mode_enable = PTA_AUTO_MODE_NO_CTS_DEF; | ||
621 | param->bt_hp_respected_num = PTA_BT_HP_RESPECTED_DEF; | ||
622 | |||
623 | ret = wl1251_cmd_configure(wl, ACX_SG_CFG, param, sizeof(*param)); | ||
624 | if (ret < 0) { | ||
625 | wl1251_warning("failed to set sg config: %d", ret); | ||
626 | goto out; | ||
627 | } | ||
628 | |||
629 | out: | ||
630 | kfree(param); | ||
631 | return ret; | ||
632 | } | ||
633 | |||
634 | int wl1251_acx_cca_threshold(struct wl1251 *wl) | ||
635 | { | ||
636 | struct acx_energy_detection *detection; | ||
637 | int ret; | ||
638 | |||
639 | wl1251_debug(DEBUG_ACX, "acx cca threshold"); | ||
640 | |||
641 | detection = kzalloc(sizeof(*detection), GFP_KERNEL); | ||
642 | if (!detection) { | ||
643 | ret = -ENOMEM; | ||
644 | goto out; | ||
645 | } | ||
646 | |||
647 | detection->rx_cca_threshold = CCA_THRSH_DISABLE_ENERGY_D; | ||
648 | detection->tx_energy_detection = 0; | ||
649 | |||
650 | ret = wl1251_cmd_configure(wl, ACX_CCA_THRESHOLD, | ||
651 | detection, sizeof(*detection)); | ||
652 | if (ret < 0) { | ||
653 | wl1251_warning("failed to set cca threshold: %d", ret); | ||
654 | return ret; | ||
655 | } | ||
656 | |||
657 | out: | ||
658 | kfree(detection); | ||
659 | return ret; | ||
660 | } | ||
661 | |||
662 | int wl1251_acx_bcn_dtim_options(struct wl1251 *wl) | ||
663 | { | ||
664 | struct acx_beacon_broadcast *bb; | ||
665 | int ret; | ||
666 | |||
667 | wl1251_debug(DEBUG_ACX, "acx bcn dtim options"); | ||
668 | |||
669 | bb = kzalloc(sizeof(*bb), GFP_KERNEL); | ||
670 | if (!bb) { | ||
671 | ret = -ENOMEM; | ||
672 | goto out; | ||
673 | } | ||
674 | |||
675 | bb->beacon_rx_timeout = BCN_RX_TIMEOUT_DEF_VALUE; | ||
676 | bb->broadcast_timeout = BROADCAST_RX_TIMEOUT_DEF_VALUE; | ||
677 | bb->rx_broadcast_in_ps = RX_BROADCAST_IN_PS_DEF_VALUE; | ||
678 | bb->ps_poll_threshold = CONSECUTIVE_PS_POLL_FAILURE_DEF; | ||
679 | |||
680 | ret = wl1251_cmd_configure(wl, ACX_BCN_DTIM_OPTIONS, bb, sizeof(*bb)); | ||
681 | if (ret < 0) { | ||
682 | wl1251_warning("failed to set rx config: %d", ret); | ||
683 | goto out; | ||
684 | } | ||
685 | |||
686 | out: | ||
687 | kfree(bb); | ||
688 | return ret; | ||
689 | } | ||
690 | |||
691 | int wl1251_acx_aid(struct wl1251 *wl, u16 aid) | ||
692 | { | ||
693 | struct acx_aid *acx_aid; | ||
694 | int ret; | ||
695 | |||
696 | wl1251_debug(DEBUG_ACX, "acx aid"); | ||
697 | |||
698 | acx_aid = kzalloc(sizeof(*acx_aid), GFP_KERNEL); | ||
699 | if (!acx_aid) { | ||
700 | ret = -ENOMEM; | ||
701 | goto out; | ||
702 | } | ||
703 | |||
704 | acx_aid->aid = aid; | ||
705 | |||
706 | ret = wl1251_cmd_configure(wl, ACX_AID, acx_aid, sizeof(*acx_aid)); | ||
707 | if (ret < 0) { | ||
708 | wl1251_warning("failed to set aid: %d", ret); | ||
709 | goto out; | ||
710 | } | ||
711 | |||
712 | out: | ||
713 | kfree(acx_aid); | ||
714 | return ret; | ||
715 | } | ||
716 | |||
717 | int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask) | ||
718 | { | ||
719 | struct acx_event_mask *mask; | ||
720 | int ret; | ||
721 | |||
722 | wl1251_debug(DEBUG_ACX, "acx event mbox mask"); | ||
723 | |||
724 | mask = kzalloc(sizeof(*mask), GFP_KERNEL); | ||
725 | if (!mask) { | ||
726 | ret = -ENOMEM; | ||
727 | goto out; | ||
728 | } | ||
729 | |||
730 | /* high event mask is unused */ | ||
731 | mask->high_event_mask = 0xffffffff; | ||
732 | |||
733 | mask->event_mask = event_mask; | ||
734 | |||
735 | ret = wl1251_cmd_configure(wl, ACX_EVENT_MBOX_MASK, | ||
736 | mask, sizeof(*mask)); | ||
737 | if (ret < 0) { | ||
738 | wl1251_warning("failed to set acx_event_mbox_mask: %d", ret); | ||
739 | goto out; | ||
740 | } | ||
741 | |||
742 | out: | ||
743 | kfree(mask); | ||
744 | return ret; | ||
745 | } | ||
746 | |||
747 | int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble) | ||
748 | { | ||
749 | struct acx_preamble *acx; | ||
750 | int ret; | ||
751 | |||
752 | wl1251_debug(DEBUG_ACX, "acx_set_preamble"); | ||
753 | |||
754 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
755 | if (!acx) { | ||
756 | ret = -ENOMEM; | ||
757 | goto out; | ||
758 | } | ||
759 | |||
760 | acx->preamble = preamble; | ||
761 | |||
762 | ret = wl1251_cmd_configure(wl, ACX_PREAMBLE_TYPE, acx, sizeof(*acx)); | ||
763 | if (ret < 0) { | ||
764 | wl1251_warning("Setting of preamble failed: %d", ret); | ||
765 | goto out; | ||
766 | } | ||
767 | |||
768 | out: | ||
769 | kfree(acx); | ||
770 | return ret; | ||
771 | } | ||
772 | |||
773 | int wl1251_acx_cts_protect(struct wl1251 *wl, | ||
774 | enum acx_ctsprotect_type ctsprotect) | ||
775 | { | ||
776 | struct acx_ctsprotect *acx; | ||
777 | int ret; | ||
778 | |||
779 | wl1251_debug(DEBUG_ACX, "acx_set_ctsprotect"); | ||
780 | |||
781 | acx = kzalloc(sizeof(*acx), GFP_KERNEL); | ||
782 | if (!acx) { | ||
783 | ret = -ENOMEM; | ||
784 | goto out; | ||
785 | } | ||
786 | |||
787 | acx->ctsprotect = ctsprotect; | ||
788 | |||
789 | ret = wl1251_cmd_configure(wl, ACX_CTS_PROTECTION, acx, sizeof(*acx)); | ||
790 | if (ret < 0) { | ||
791 | wl1251_warning("Setting of ctsprotect failed: %d", ret); | ||
792 | goto out; | ||
793 | } | ||
794 | |||
795 | out: | ||
796 | kfree(acx); | ||
797 | return ret; | ||
798 | } | ||
799 | |||
800 | int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime) | ||
801 | { | ||
802 | struct acx_tsf_info *tsf_info; | ||
803 | int ret; | ||
804 | |||
805 | tsf_info = kzalloc(sizeof(*tsf_info), GFP_KERNEL); | ||
806 | if (!tsf_info) { | ||
807 | ret = -ENOMEM; | ||
808 | goto out; | ||
809 | } | ||
810 | |||
811 | ret = wl1251_cmd_interrogate(wl, ACX_TSF_INFO, | ||
812 | tsf_info, sizeof(*tsf_info)); | ||
813 | if (ret < 0) { | ||
814 | wl1251_warning("ACX_FW_REV interrogate failed"); | ||
815 | goto out; | ||
816 | } | ||
817 | |||
818 | *mactime = tsf_info->current_tsf_lsb | | ||
819 | (tsf_info->current_tsf_msb << 31); | ||
820 | |||
821 | out: | ||
822 | kfree(tsf_info); | ||
823 | return ret; | ||
824 | } | ||
825 | |||
826 | int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats) | ||
827 | { | ||
828 | int ret; | ||
829 | |||
830 | wl1251_debug(DEBUG_ACX, "acx statistics"); | ||
831 | |||
832 | ret = wl1251_cmd_interrogate(wl, ACX_STATISTICS, stats, | ||
833 | sizeof(*stats)); | ||
834 | if (ret < 0) { | ||
835 | wl1251_warning("acx statistics failed: %d", ret); | ||
836 | return -ENOMEM; | ||
837 | } | ||
838 | |||
839 | return 0; | ||
840 | } | ||
diff --git a/drivers/net/wireless/wl12xx/acx.h b/drivers/net/wireless/wl12xx/wl1251_acx.h index fb2d2340993c..2e7b1933a8f9 100644 --- a/drivers/net/wireless/wl12xx/acx.h +++ b/drivers/net/wireless/wl12xx/wl1251_acx.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -22,14 +22,20 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef __WL12XX_ACX_H__ | 25 | #ifndef __WL1251_ACX_H__ |
26 | #define __WL12XX_ACX_H__ | 26 | #define __WL1251_ACX_H__ |
27 | 27 | ||
28 | #include "wl12xx.h" | 28 | #include "wl1251.h" |
29 | #include "wl1251_cmd.h" | ||
29 | 30 | ||
30 | /* Target's information element */ | 31 | /* Target's information element */ |
31 | struct acx_header { | 32 | struct acx_header { |
33 | struct wl1251_cmd_header cmd; | ||
34 | |||
35 | /* acx (or information element) header */ | ||
32 | u16 id; | 36 | u16 id; |
37 | |||
38 | /* payload length (not including headers */ | ||
33 | u16 len; | 39 | u16 len; |
34 | }; | 40 | }; |
35 | 41 | ||
@@ -85,15 +91,15 @@ struct acx_revision { | |||
85 | u32 hw_version; | 91 | u32 hw_version; |
86 | } __attribute__ ((packed)); | 92 | } __attribute__ ((packed)); |
87 | 93 | ||
88 | enum wl12xx_psm_mode { | 94 | enum wl1251_psm_mode { |
89 | /* Active mode */ | 95 | /* Active mode */ |
90 | WL12XX_PSM_CAM = 0, | 96 | WL1251_PSM_CAM = 0, |
91 | 97 | ||
92 | /* Power save mode */ | 98 | /* Power save mode */ |
93 | WL12XX_PSM_PS = 1, | 99 | WL1251_PSM_PS = 1, |
94 | 100 | ||
95 | /* Extreme low power */ | 101 | /* Extreme low power */ |
96 | WL12XX_PSM_ELP = 2, | 102 | WL1251_PSM_ELP = 2, |
97 | }; | 103 | }; |
98 | 104 | ||
99 | struct acx_sleep_auth { | 105 | struct acx_sleep_auth { |
@@ -107,25 +113,6 @@ struct acx_sleep_auth { | |||
107 | u8 padding[3]; | 113 | u8 padding[3]; |
108 | } __attribute__ ((packed)); | 114 | } __attribute__ ((packed)); |
109 | 115 | ||
110 | #define TIM_ELE_ID 5 | ||
111 | #define PARTIAL_VBM_MAX 251 | ||
112 | |||
113 | struct tim { | ||
114 | u8 identity; | ||
115 | u8 length; | ||
116 | u8 dtim_count; | ||
117 | u8 dtim_period; | ||
118 | u8 bitmap_ctrl; | ||
119 | u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */ | ||
120 | } __attribute__ ((packed)); | ||
121 | |||
122 | /* Virtual Bit Map update */ | ||
123 | struct vbm_update_request { | ||
124 | __le16 len; | ||
125 | u8 padding[2]; | ||
126 | struct tim tim; | ||
127 | } __attribute__ ((packed)); | ||
128 | |||
129 | enum { | 116 | enum { |
130 | HOSTIF_PCI_MASTER_HOST_INDIRECT, | 117 | HOSTIF_PCI_MASTER_HOST_INDIRECT, |
131 | HOSTIF_PCI_MASTER_HOST_DIRECT, | 118 | HOSTIF_PCI_MASTER_HOST_DIRECT, |
@@ -202,7 +189,7 @@ struct acx_data_path_params_resp { | |||
202 | #define RX_MSDU_LIFETIME_MAX 0xFFFFFFFF | 189 | #define RX_MSDU_LIFETIME_MAX 0xFFFFFFFF |
203 | #define RX_MSDU_LIFETIME_DEF 512000 | 190 | #define RX_MSDU_LIFETIME_DEF 512000 |
204 | 191 | ||
205 | struct rx_msdu_lifetime { | 192 | struct acx_rx_msdu_lifetime { |
206 | struct acx_header header; | 193 | struct acx_header header; |
207 | 194 | ||
208 | /* | 195 | /* |
@@ -368,7 +355,7 @@ struct acx_slot { | |||
368 | #define ADDRESS_GROUP_MAX (8) | 355 | #define ADDRESS_GROUP_MAX (8) |
369 | #define ADDRESS_GROUP_MAX_LEN (ETH_ALEN * ADDRESS_GROUP_MAX) | 356 | #define ADDRESS_GROUP_MAX_LEN (ETH_ALEN * ADDRESS_GROUP_MAX) |
370 | 357 | ||
371 | struct multicast_grp_addr_start { | 358 | struct acx_dot11_grp_addr_tbl { |
372 | struct acx_header header; | 359 | struct acx_header header; |
373 | 360 | ||
374 | u8 enabled; | 361 | u8 enabled; |
@@ -730,22 +717,13 @@ struct acx_fw_gen_frame_rates { | |||
730 | } __attribute__ ((packed)); | 717 | } __attribute__ ((packed)); |
731 | 718 | ||
732 | /* STA MAC */ | 719 | /* STA MAC */ |
733 | struct dot11_station_id { | 720 | struct acx_dot11_station_id { |
734 | struct acx_header header; | 721 | struct acx_header header; |
735 | 722 | ||
736 | u8 mac[ETH_ALEN]; | 723 | u8 mac[ETH_ALEN]; |
737 | u8 pad[2]; | 724 | u8 pad[2]; |
738 | } __attribute__ ((packed)); | 725 | } __attribute__ ((packed)); |
739 | 726 | ||
740 | /* HW encryption keys */ | ||
741 | #define NUM_ACCESS_CATEGORIES_COPY 4 | ||
742 | #define MAX_KEY_SIZE 32 | ||
743 | |||
744 | /* When set, disable HW encryption */ | ||
745 | #define DF_ENCRYPTION_DISABLE 0x01 | ||
746 | /* When set, disable HW decryption */ | ||
747 | #define DF_SNIFF_MODE_ENABLE 0x80 | ||
748 | |||
749 | struct acx_feature_config { | 727 | struct acx_feature_config { |
750 | struct acx_header header; | 728 | struct acx_header header; |
751 | 729 | ||
@@ -753,67 +731,6 @@ struct acx_feature_config { | |||
753 | u32 data_flow_options; | 731 | u32 data_flow_options; |
754 | } __attribute__ ((packed)); | 732 | } __attribute__ ((packed)); |
755 | 733 | ||
756 | enum acx_key_action { | ||
757 | KEY_ADD_OR_REPLACE = 1, | ||
758 | KEY_REMOVE = 2, | ||
759 | KEY_SET_ID = 3, | ||
760 | MAX_KEY_ACTION = 0xffff, | ||
761 | }; | ||
762 | |||
763 | enum acx_key_type { | ||
764 | KEY_WEP_DEFAULT = 0, | ||
765 | KEY_WEP_ADDR = 1, | ||
766 | KEY_AES_GROUP = 4, | ||
767 | KEY_AES_PAIRWISE = 5, | ||
768 | KEY_WEP_GROUP = 6, | ||
769 | KEY_TKIP_MIC_GROUP = 10, | ||
770 | KEY_TKIP_MIC_PAIRWISE = 11, | ||
771 | }; | ||
772 | |||
773 | /* | ||
774 | * | ||
775 | * key_type_e key size key format | ||
776 | * ---------- --------- ---------- | ||
777 | * 0x00 5, 13, 29 Key data | ||
778 | * 0x01 5, 13, 29 Key data | ||
779 | * 0x04 16 16 bytes of key data | ||
780 | * 0x05 16 16 bytes of key data | ||
781 | * 0x0a 32 16 bytes of TKIP key data | ||
782 | * 8 bytes of RX MIC key data | ||
783 | * 8 bytes of TX MIC key data | ||
784 | * 0x0b 32 16 bytes of TKIP key data | ||
785 | * 8 bytes of RX MIC key data | ||
786 | * 8 bytes of TX MIC key data | ||
787 | * | ||
788 | */ | ||
789 | |||
790 | struct acx_set_key { | ||
791 | /* Ignored for default WEP key */ | ||
792 | u8 addr[ETH_ALEN]; | ||
793 | |||
794 | /* key_action_e */ | ||
795 | u16 key_action; | ||
796 | |||
797 | u16 reserved_1; | ||
798 | |||
799 | /* key size in bytes */ | ||
800 | u8 key_size; | ||
801 | |||
802 | /* key_type_e */ | ||
803 | u8 key_type; | ||
804 | u8 ssid_profile; | ||
805 | |||
806 | /* | ||
807 | * TKIP, AES: frame's key id field. | ||
808 | * For WEP default key: key id; | ||
809 | */ | ||
810 | u8 id; | ||
811 | u8 reserved_2[6]; | ||
812 | u8 key[MAX_KEY_SIZE]; | ||
813 | u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY]; | ||
814 | u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY]; | ||
815 | } __attribute__ ((packed)); | ||
816 | |||
817 | struct acx_current_tx_power { | 734 | struct acx_current_tx_power { |
818 | struct acx_header header; | 735 | struct acx_header header; |
819 | 736 | ||
@@ -839,26 +756,6 @@ struct acx_tsf_info { | |||
839 | u8 pad[3]; | 756 | u8 pad[3]; |
840 | } __attribute__ ((packed)); | 757 | } __attribute__ ((packed)); |
841 | 758 | ||
842 | /* 802.11 PS */ | ||
843 | enum acx_ps_mode { | ||
844 | STATION_ACTIVE_MODE, | ||
845 | STATION_POWER_SAVE_MODE | ||
846 | }; | ||
847 | |||
848 | struct acx_ps_params { | ||
849 | u8 ps_mode; /* STATION_* */ | ||
850 | u8 send_null_data; /* Do we have to send NULL data packet ? */ | ||
851 | u8 retries; /* Number of retires for the initial NULL data packet */ | ||
852 | |||
853 | /* | ||
854 | * TUs during which the target stays awake after switching | ||
855 | * to power save mode. | ||
856 | */ | ||
857 | u8 hang_over_period; | ||
858 | u16 null_data_rate; | ||
859 | u8 pad[2]; | ||
860 | } __attribute__ ((packed)); | ||
861 | |||
862 | enum acx_wake_up_event { | 759 | enum acx_wake_up_event { |
863 | WAKE_UP_EVENT_BEACON_BITMAP = 0x01, /* Wake on every Beacon*/ | 760 | WAKE_UP_EVENT_BEACON_BITMAP = 0x01, /* Wake on every Beacon*/ |
864 | WAKE_UP_EVENT_DTIM_BITMAP = 0x02, /* Wake on every DTIM*/ | 761 | WAKE_UP_EVENT_DTIM_BITMAP = 0x02, /* Wake on every DTIM*/ |
@@ -892,6 +789,7 @@ enum acx_preamble_type { | |||
892 | 789 | ||
893 | struct acx_preamble { | 790 | struct acx_preamble { |
894 | struct acx_header header; | 791 | struct acx_header header; |
792 | |||
895 | /* | 793 | /* |
896 | * When set, the WiLink transmits the frames with a short preamble and | 794 | * When set, the WiLink transmits the frames with a short preamble and |
897 | * when cleared, the WiLink transmits the frames with a long preamble. | 795 | * when cleared, the WiLink transmits the frames with a long preamble. |
@@ -1210,36 +1108,39 @@ enum { | |||
1210 | }; | 1108 | }; |
1211 | 1109 | ||
1212 | 1110 | ||
1213 | int wl12xx_acx_frame_rates(struct wl12xx *wl, u8 ctrl_rate, u8 ctrl_mod, | 1111 | int wl1251_acx_frame_rates(struct wl1251 *wl, u8 ctrl_rate, u8 ctrl_mod, |
1214 | u8 mgt_rate, u8 mgt_mod); | 1112 | u8 mgt_rate, u8 mgt_mod); |
1215 | int wl12xx_acx_station_id(struct wl12xx *wl); | 1113 | int wl1251_acx_station_id(struct wl1251 *wl); |
1216 | int wl12xx_acx_default_key(struct wl12xx *wl, u8 key_id); | 1114 | int wl1251_acx_default_key(struct wl1251 *wl, u8 key_id); |
1217 | int wl12xx_acx_wake_up_conditions(struct wl12xx *wl, u8 listen_interval); | 1115 | int wl1251_acx_wake_up_conditions(struct wl1251 *wl, u8 wake_up_event, |
1218 | int wl12xx_acx_sleep_auth(struct wl12xx *wl, u8 sleep_auth); | 1116 | u8 listen_interval); |
1219 | int wl12xx_acx_fw_version(struct wl12xx *wl, char *buf, size_t len); | 1117 | int wl1251_acx_sleep_auth(struct wl1251 *wl, u8 sleep_auth); |
1220 | int wl12xx_acx_tx_power(struct wl12xx *wl, int power); | 1118 | int wl1251_acx_fw_version(struct wl1251 *wl, char *buf, size_t len); |
1221 | int wl12xx_acx_feature_cfg(struct wl12xx *wl); | 1119 | int wl1251_acx_tx_power(struct wl1251 *wl, int power); |
1222 | int wl12xx_acx_mem_map(struct wl12xx *wl, void *mem_map, size_t len); | 1120 | int wl1251_acx_feature_cfg(struct wl1251 *wl); |
1223 | int wl12xx_acx_data_path_params(struct wl12xx *wl, | 1121 | int wl1251_acx_mem_map(struct wl1251 *wl, |
1122 | struct acx_header *mem_map, size_t len); | ||
1123 | int wl1251_acx_data_path_params(struct wl1251 *wl, | ||
1224 | struct acx_data_path_params_resp *data_path); | 1124 | struct acx_data_path_params_resp *data_path); |
1225 | int wl12xx_acx_rx_msdu_life_time(struct wl12xx *wl, u32 life_time); | 1125 | int wl1251_acx_rx_msdu_life_time(struct wl1251 *wl, u32 life_time); |
1226 | int wl12xx_acx_rx_config(struct wl12xx *wl, u32 config, u32 filter); | 1126 | int wl1251_acx_rx_config(struct wl1251 *wl, u32 config, u32 filter); |
1227 | int wl12xx_acx_pd_threshold(struct wl12xx *wl); | 1127 | int wl1251_acx_pd_threshold(struct wl1251 *wl); |
1228 | int wl12xx_acx_slot(struct wl12xx *wl, enum acx_slot_type slot_time); | 1128 | int wl1251_acx_slot(struct wl1251 *wl, enum acx_slot_type slot_time); |
1229 | int wl12xx_acx_group_address_tbl(struct wl12xx *wl); | 1129 | int wl1251_acx_group_address_tbl(struct wl1251 *wl); |
1230 | int wl12xx_acx_service_period_timeout(struct wl12xx *wl); | 1130 | int wl1251_acx_service_period_timeout(struct wl1251 *wl); |
1231 | int wl12xx_acx_rts_threshold(struct wl12xx *wl, u16 rts_threshold); | 1131 | int wl1251_acx_rts_threshold(struct wl1251 *wl, u16 rts_threshold); |
1232 | int wl12xx_acx_beacon_filter_opt(struct wl12xx *wl); | 1132 | int wl1251_acx_beacon_filter_opt(struct wl1251 *wl); |
1233 | int wl12xx_acx_beacon_filter_table(struct wl12xx *wl); | 1133 | int wl1251_acx_beacon_filter_table(struct wl1251 *wl); |
1234 | int wl12xx_acx_sg_enable(struct wl12xx *wl); | 1134 | int wl1251_acx_sg_enable(struct wl1251 *wl); |
1235 | int wl12xx_acx_sg_cfg(struct wl12xx *wl); | 1135 | int wl1251_acx_sg_cfg(struct wl1251 *wl); |
1236 | int wl12xx_acx_cca_threshold(struct wl12xx *wl); | 1136 | int wl1251_acx_cca_threshold(struct wl1251 *wl); |
1237 | int wl12xx_acx_bcn_dtim_options(struct wl12xx *wl); | 1137 | int wl1251_acx_bcn_dtim_options(struct wl1251 *wl); |
1238 | int wl12xx_acx_aid(struct wl12xx *wl, u16 aid); | 1138 | int wl1251_acx_aid(struct wl1251 *wl, u16 aid); |
1239 | int wl12xx_acx_event_mbox_mask(struct wl12xx *wl, u32 event_mask); | 1139 | int wl1251_acx_event_mbox_mask(struct wl1251 *wl, u32 event_mask); |
1240 | int wl12xx_acx_set_preamble(struct wl12xx *wl, enum acx_preamble_type preamble); | 1140 | int wl1251_acx_set_preamble(struct wl1251 *wl, enum acx_preamble_type preamble); |
1241 | int wl12xx_acx_cts_protect(struct wl12xx *wl, | 1141 | int wl1251_acx_cts_protect(struct wl1251 *wl, |
1242 | enum acx_ctsprotect_type ctsprotect); | 1142 | enum acx_ctsprotect_type ctsprotect); |
1243 | int wl12xx_acx_statistics(struct wl12xx *wl, struct acx_statistics *stats); | 1143 | int wl1251_acx_statistics(struct wl1251 *wl, struct acx_statistics *stats); |
1144 | int wl1251_acx_tsf_info(struct wl1251 *wl, u64 *mactime); | ||
1244 | 1145 | ||
1245 | #endif /* __WL12XX_ACX_H__ */ | 1146 | #endif /* __WL1251_ACX_H__ */ |
diff --git a/drivers/net/wireless/wl12xx/boot.c b/drivers/net/wireless/wl12xx/wl1251_boot.c index 48ac08c429bd..d8a155dc2fa1 100644 --- a/drivers/net/wireless/wl12xx/boot.c +++ b/drivers/net/wireless/wl12xx/wl1251_boot.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Nokia Corporation | 4 | * Copyright (C) 2008 Nokia Corporation |
5 | * | 5 | * |
@@ -24,41 +24,41 @@ | |||
24 | #include <linux/gpio.h> | 24 | #include <linux/gpio.h> |
25 | 25 | ||
26 | #include "reg.h" | 26 | #include "reg.h" |
27 | #include "boot.h" | 27 | #include "wl1251_boot.h" |
28 | #include "spi.h" | 28 | #include "wl1251_spi.h" |
29 | #include "event.h" | 29 | #include "wl1251_event.h" |
30 | 30 | ||
31 | static void wl12xx_boot_enable_interrupts(struct wl12xx *wl) | 31 | static void wl1251_boot_enable_interrupts(struct wl1251 *wl) |
32 | { | 32 | { |
33 | enable_irq(wl->irq); | 33 | enable_irq(wl->irq); |
34 | } | 34 | } |
35 | 35 | ||
36 | void wl12xx_boot_target_enable_interrupts(struct wl12xx *wl) | 36 | void wl1251_boot_target_enable_interrupts(struct wl1251 *wl) |
37 | { | 37 | { |
38 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); | 38 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); |
39 | wl12xx_reg_write32(wl, HI_CFG, HI_CFG_DEF_VAL); | 39 | wl1251_reg_write32(wl, HI_CFG, HI_CFG_DEF_VAL); |
40 | } | 40 | } |
41 | 41 | ||
42 | int wl12xx_boot_soft_reset(struct wl12xx *wl) | 42 | int wl1251_boot_soft_reset(struct wl1251 *wl) |
43 | { | 43 | { |
44 | unsigned long timeout; | 44 | unsigned long timeout; |
45 | u32 boot_data; | 45 | u32 boot_data; |
46 | 46 | ||
47 | /* perform soft reset */ | 47 | /* perform soft reset */ |
48 | wl12xx_reg_write32(wl, ACX_REG_SLV_SOFT_RESET, ACX_SLV_SOFT_RESET_BIT); | 48 | wl1251_reg_write32(wl, ACX_REG_SLV_SOFT_RESET, ACX_SLV_SOFT_RESET_BIT); |
49 | 49 | ||
50 | /* SOFT_RESET is self clearing */ | 50 | /* SOFT_RESET is self clearing */ |
51 | timeout = jiffies + usecs_to_jiffies(SOFT_RESET_MAX_TIME); | 51 | timeout = jiffies + usecs_to_jiffies(SOFT_RESET_MAX_TIME); |
52 | while (1) { | 52 | while (1) { |
53 | boot_data = wl12xx_reg_read32(wl, ACX_REG_SLV_SOFT_RESET); | 53 | boot_data = wl1251_reg_read32(wl, ACX_REG_SLV_SOFT_RESET); |
54 | wl12xx_debug(DEBUG_BOOT, "soft reset bootdata 0x%x", boot_data); | 54 | wl1251_debug(DEBUG_BOOT, "soft reset bootdata 0x%x", boot_data); |
55 | if ((boot_data & ACX_SLV_SOFT_RESET_BIT) == 0) | 55 | if ((boot_data & ACX_SLV_SOFT_RESET_BIT) == 0) |
56 | break; | 56 | break; |
57 | 57 | ||
58 | if (time_after(jiffies, timeout)) { | 58 | if (time_after(jiffies, timeout)) { |
59 | /* 1.2 check pWhalBus->uSelfClearTime if the | 59 | /* 1.2 check pWhalBus->uSelfClearTime if the |
60 | * timeout was reached */ | 60 | * timeout was reached */ |
61 | wl12xx_error("soft reset timeout"); | 61 | wl1251_error("soft reset timeout"); |
62 | return -1; | 62 | return -1; |
63 | } | 63 | } |
64 | 64 | ||
@@ -66,15 +66,15 @@ int wl12xx_boot_soft_reset(struct wl12xx *wl) | |||
66 | } | 66 | } |
67 | 67 | ||
68 | /* disable Rx/Tx */ | 68 | /* disable Rx/Tx */ |
69 | wl12xx_reg_write32(wl, ENABLE, 0x0); | 69 | wl1251_reg_write32(wl, ENABLE, 0x0); |
70 | 70 | ||
71 | /* disable auto calibration on start*/ | 71 | /* disable auto calibration on start*/ |
72 | wl12xx_reg_write32(wl, SPARE_A2, 0xffff); | 72 | wl1251_reg_write32(wl, SPARE_A2, 0xffff); |
73 | 73 | ||
74 | return 0; | 74 | return 0; |
75 | } | 75 | } |
76 | 76 | ||
77 | int wl12xx_boot_init_seq(struct wl12xx *wl) | 77 | int wl1251_boot_init_seq(struct wl1251 *wl) |
78 | { | 78 | { |
79 | u32 scr_pad6, init_data, tmp, elp_cmd, ref_freq; | 79 | u32 scr_pad6, init_data, tmp, elp_cmd, ref_freq; |
80 | 80 | ||
@@ -96,23 +96,23 @@ int wl12xx_boot_init_seq(struct wl12xx *wl) | |||
96 | }; | 96 | }; |
97 | 97 | ||
98 | /* read NVS params */ | 98 | /* read NVS params */ |
99 | scr_pad6 = wl12xx_reg_read32(wl, SCR_PAD6); | 99 | scr_pad6 = wl1251_reg_read32(wl, SCR_PAD6); |
100 | wl12xx_debug(DEBUG_BOOT, "scr_pad6 0x%x", scr_pad6); | 100 | wl1251_debug(DEBUG_BOOT, "scr_pad6 0x%x", scr_pad6); |
101 | 101 | ||
102 | /* read ELP_CMD */ | 102 | /* read ELP_CMD */ |
103 | elp_cmd = wl12xx_reg_read32(wl, ELP_CMD); | 103 | elp_cmd = wl1251_reg_read32(wl, ELP_CMD); |
104 | wl12xx_debug(DEBUG_BOOT, "elp_cmd 0x%x", elp_cmd); | 104 | wl1251_debug(DEBUG_BOOT, "elp_cmd 0x%x", elp_cmd); |
105 | 105 | ||
106 | /* set the BB calibration time to be 300 usec (PLL_CAL_TIME) */ | 106 | /* set the BB calibration time to be 300 usec (PLL_CAL_TIME) */ |
107 | ref_freq = scr_pad6 & 0x000000FF; | 107 | ref_freq = scr_pad6 & 0x000000FF; |
108 | wl12xx_debug(DEBUG_BOOT, "ref_freq 0x%x", ref_freq); | 108 | wl1251_debug(DEBUG_BOOT, "ref_freq 0x%x", ref_freq); |
109 | 109 | ||
110 | wl12xx_reg_write32(wl, PLL_CAL_TIME, 0x9); | 110 | wl1251_reg_write32(wl, PLL_CAL_TIME, 0x9); |
111 | 111 | ||
112 | /* | 112 | /* |
113 | * PG 1.2: set the clock buffer time to be 210 usec (CLK_BUF_TIME) | 113 | * PG 1.2: set the clock buffer time to be 210 usec (CLK_BUF_TIME) |
114 | */ | 114 | */ |
115 | wl12xx_reg_write32(wl, CLK_BUF_TIME, 0x6); | 115 | wl1251_reg_write32(wl, CLK_BUF_TIME, 0x6); |
116 | 116 | ||
117 | /* | 117 | /* |
118 | * set the clock detect feature to work in the restart wu procedure | 118 | * set the clock detect feature to work in the restart wu procedure |
@@ -120,18 +120,18 @@ int wl12xx_boot_init_seq(struct wl12xx *wl) | |||
120 | * (ELP_CFG_MODE[13:12]) | 120 | * (ELP_CFG_MODE[13:12]) |
121 | */ | 121 | */ |
122 | tmp = ((scr_pad6 & 0x0000FF00) << 4) | 0x00004000; | 122 | tmp = ((scr_pad6 & 0x0000FF00) << 4) | 0x00004000; |
123 | wl12xx_reg_write32(wl, ELP_CFG_MODE, tmp); | 123 | wl1251_reg_write32(wl, ELP_CFG_MODE, tmp); |
124 | 124 | ||
125 | /* PG 1.2: enable the BB PLL fix. Enable the PLL_LIMP_CLK_EN_CMD */ | 125 | /* PG 1.2: enable the BB PLL fix. Enable the PLL_LIMP_CLK_EN_CMD */ |
126 | elp_cmd |= 0x00000040; | 126 | elp_cmd |= 0x00000040; |
127 | wl12xx_reg_write32(wl, ELP_CMD, elp_cmd); | 127 | wl1251_reg_write32(wl, ELP_CMD, elp_cmd); |
128 | 128 | ||
129 | /* PG 1.2: Set the BB PLL stable time to be 1000usec | 129 | /* PG 1.2: Set the BB PLL stable time to be 1000usec |
130 | * (PLL_STABLE_TIME) */ | 130 | * (PLL_STABLE_TIME) */ |
131 | wl12xx_reg_write32(wl, CFG_PLL_SYNC_CNT, 0x20); | 131 | wl1251_reg_write32(wl, CFG_PLL_SYNC_CNT, 0x20); |
132 | 132 | ||
133 | /* PG 1.2: read clock request time */ | 133 | /* PG 1.2: read clock request time */ |
134 | init_data = wl12xx_reg_read32(wl, CLK_REQ_TIME); | 134 | init_data = wl1251_reg_read32(wl, CLK_REQ_TIME); |
135 | 135 | ||
136 | /* | 136 | /* |
137 | * PG 1.2: set the clock request time to be ref_clk_settling_time - | 137 | * PG 1.2: set the clock request time to be ref_clk_settling_time - |
@@ -141,35 +141,35 @@ int wl12xx_boot_init_seq(struct wl12xx *wl) | |||
141 | tmp = init_data - 0x21; | 141 | tmp = init_data - 0x21; |
142 | else | 142 | else |
143 | tmp = 0; | 143 | tmp = 0; |
144 | wl12xx_reg_write32(wl, CLK_REQ_TIME, tmp); | 144 | wl1251_reg_write32(wl, CLK_REQ_TIME, tmp); |
145 | 145 | ||
146 | /* set BB PLL configurations in RF AFE */ | 146 | /* set BB PLL configurations in RF AFE */ |
147 | wl12xx_reg_write32(wl, 0x003058cc, 0x4B5); | 147 | wl1251_reg_write32(wl, 0x003058cc, 0x4B5); |
148 | 148 | ||
149 | /* set RF_AFE_REG_5 */ | 149 | /* set RF_AFE_REG_5 */ |
150 | wl12xx_reg_write32(wl, 0x003058d4, 0x50); | 150 | wl1251_reg_write32(wl, 0x003058d4, 0x50); |
151 | 151 | ||
152 | /* set RF_AFE_CTRL_REG_2 */ | 152 | /* set RF_AFE_CTRL_REG_2 */ |
153 | wl12xx_reg_write32(wl, 0x00305948, 0x11c001); | 153 | wl1251_reg_write32(wl, 0x00305948, 0x11c001); |
154 | 154 | ||
155 | /* | 155 | /* |
156 | * change RF PLL and BB PLL divider for VCO clock and adjust VCO | 156 | * change RF PLL and BB PLL divider for VCO clock and adjust VCO |
157 | * bais current(RF_AFE_REG_13) | 157 | * bais current(RF_AFE_REG_13) |
158 | */ | 158 | */ |
159 | wl12xx_reg_write32(wl, 0x003058f4, 0x1e); | 159 | wl1251_reg_write32(wl, 0x003058f4, 0x1e); |
160 | 160 | ||
161 | /* set BB PLL configurations */ | 161 | /* set BB PLL configurations */ |
162 | tmp = LUT[ref_freq][LUT_PARAM_INTEGER_DIVIDER] | 0x00017000; | 162 | tmp = LUT[ref_freq][LUT_PARAM_INTEGER_DIVIDER] | 0x00017000; |
163 | wl12xx_reg_write32(wl, 0x00305840, tmp); | 163 | wl1251_reg_write32(wl, 0x00305840, tmp); |
164 | 164 | ||
165 | /* set fractional divider according to Appendix C-BB PLL | 165 | /* set fractional divider according to Appendix C-BB PLL |
166 | * Calculations | 166 | * Calculations |
167 | */ | 167 | */ |
168 | tmp = LUT[ref_freq][LUT_PARAM_FRACTIONAL_DIVIDER]; | 168 | tmp = LUT[ref_freq][LUT_PARAM_FRACTIONAL_DIVIDER]; |
169 | wl12xx_reg_write32(wl, 0x00305844, tmp); | 169 | wl1251_reg_write32(wl, 0x00305844, tmp); |
170 | 170 | ||
171 | /* set the initial data for the sigma delta */ | 171 | /* set the initial data for the sigma delta */ |
172 | wl12xx_reg_write32(wl, 0x00305848, 0x3039); | 172 | wl1251_reg_write32(wl, 0x00305848, 0x3039); |
173 | 173 | ||
174 | /* | 174 | /* |
175 | * set the accumulator attenuation value, calibration loop1 | 175 | * set the accumulator attenuation value, calibration loop1 |
@@ -178,14 +178,14 @@ int wl12xx_boot_init_seq(struct wl12xx *wl) | |||
178 | */ | 178 | */ |
179 | tmp = (LUT[ref_freq][LUT_PARAM_ATTN_BB] << 16) | | 179 | tmp = (LUT[ref_freq][LUT_PARAM_ATTN_BB] << 16) | |
180 | (LUT[ref_freq][LUT_PARAM_ALPHA_BB] << 12) | 0x1; | 180 | (LUT[ref_freq][LUT_PARAM_ALPHA_BB] << 12) | 0x1; |
181 | wl12xx_reg_write32(wl, 0x00305854, tmp); | 181 | wl1251_reg_write32(wl, 0x00305854, tmp); |
182 | 182 | ||
183 | /* | 183 | /* |
184 | * set the calibration stop time after holdoff time expires and set | 184 | * set the calibration stop time after holdoff time expires and set |
185 | * settling time HOLD_OFF_TIME_BB | 185 | * settling time HOLD_OFF_TIME_BB |
186 | */ | 186 | */ |
187 | tmp = LUT[ref_freq][LUT_PARAM_STOP_TIME_BB] | 0x000A0000; | 187 | tmp = LUT[ref_freq][LUT_PARAM_STOP_TIME_BB] | 0x000A0000; |
188 | wl12xx_reg_write32(wl, 0x00305858, tmp); | 188 | wl1251_reg_write32(wl, 0x00305858, tmp); |
189 | 189 | ||
190 | /* | 190 | /* |
191 | * set BB PLL Loop filter capacitor3- BB_C3[2:0] and set BB PLL | 191 | * set BB PLL Loop filter capacitor3- BB_C3[2:0] and set BB PLL |
@@ -193,7 +193,7 @@ int wl12xx_boot_init_seq(struct wl12xx *wl) | |||
193 | * BB_ILOOPF[7:3] | 193 | * BB_ILOOPF[7:3] |
194 | */ | 194 | */ |
195 | tmp = LUT[ref_freq][LUT_PARAM_BB_PLL_LOOP_FILTER] | 0x00000030; | 195 | tmp = LUT[ref_freq][LUT_PARAM_BB_PLL_LOOP_FILTER] | 0x00000030; |
196 | wl12xx_reg_write32(wl, 0x003058f8, tmp); | 196 | wl1251_reg_write32(wl, 0x003058f8, tmp); |
197 | 197 | ||
198 | /* | 198 | /* |
199 | * set regulator output voltage for n divider to | 199 | * set regulator output voltage for n divider to |
@@ -201,10 +201,10 @@ int wl12xx_boot_init_seq(struct wl12xx *wl) | |||
201 | * set BB PLL Loop filter capacitor2- BB_C2[7:5], set gain of BB | 201 | * set BB PLL Loop filter capacitor2- BB_C2[7:5], set gain of BB |
202 | * PLL auto-call to normal mode- BB_CALGAIN_3DB[8] | 202 | * PLL auto-call to normal mode- BB_CALGAIN_3DB[8] |
203 | */ | 203 | */ |
204 | wl12xx_reg_write32(wl, 0x003058f0, 0x29); | 204 | wl1251_reg_write32(wl, 0x003058f0, 0x29); |
205 | 205 | ||
206 | /* enable restart wakeup sequence (ELP_CMD[0]) */ | 206 | /* enable restart wakeup sequence (ELP_CMD[0]) */ |
207 | wl12xx_reg_write32(wl, ELP_CMD, elp_cmd | 0x1); | 207 | wl1251_reg_write32(wl, ELP_CMD, elp_cmd | 0x1); |
208 | 208 | ||
209 | /* restart sequence completed */ | 209 | /* restart sequence completed */ |
210 | udelay(2000); | 210 | udelay(2000); |
@@ -212,19 +212,19 @@ int wl12xx_boot_init_seq(struct wl12xx *wl) | |||
212 | return 0; | 212 | return 0; |
213 | } | 213 | } |
214 | 214 | ||
215 | int wl12xx_boot_run_firmware(struct wl12xx *wl) | 215 | int wl1251_boot_run_firmware(struct wl1251 *wl) |
216 | { | 216 | { |
217 | int loop, ret; | 217 | int loop, ret; |
218 | u32 chip_id, interrupt; | 218 | u32 chip_id, interrupt; |
219 | 219 | ||
220 | wl->chip.op_set_ecpu_ctrl(wl, ECPU_CONTROL_HALT); | 220 | wl->chip.op_set_ecpu_ctrl(wl, ECPU_CONTROL_HALT); |
221 | 221 | ||
222 | chip_id = wl12xx_reg_read32(wl, CHIP_ID_B); | 222 | chip_id = wl1251_reg_read32(wl, CHIP_ID_B); |
223 | 223 | ||
224 | wl12xx_debug(DEBUG_BOOT, "chip id after firmware boot: 0x%x", chip_id); | 224 | wl1251_debug(DEBUG_BOOT, "chip id after firmware boot: 0x%x", chip_id); |
225 | 225 | ||
226 | if (chip_id != wl->chip.id) { | 226 | if (chip_id != wl->chip.id) { |
227 | wl12xx_error("chip id doesn't match after firmware boot"); | 227 | wl1251_error("chip id doesn't match after firmware boot"); |
228 | return -EIO; | 228 | return -EIO; |
229 | } | 229 | } |
230 | 230 | ||
@@ -232,63 +232,65 @@ int wl12xx_boot_run_firmware(struct wl12xx *wl) | |||
232 | loop = 0; | 232 | loop = 0; |
233 | while (loop++ < INIT_LOOP) { | 233 | while (loop++ < INIT_LOOP) { |
234 | udelay(INIT_LOOP_DELAY); | 234 | udelay(INIT_LOOP_DELAY); |
235 | interrupt = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | 235 | interrupt = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); |
236 | 236 | ||
237 | if (interrupt == 0xffffffff) { | 237 | if (interrupt == 0xffffffff) { |
238 | wl12xx_error("error reading hardware complete " | 238 | wl1251_error("error reading hardware complete " |
239 | "init indication"); | 239 | "init indication"); |
240 | return -EIO; | 240 | return -EIO; |
241 | } | 241 | } |
242 | /* check that ACX_INTR_INIT_COMPLETE is enabled */ | 242 | /* check that ACX_INTR_INIT_COMPLETE is enabled */ |
243 | else if (interrupt & wl->chip.intr_init_complete) { | 243 | else if (interrupt & wl->chip.intr_init_complete) { |
244 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_ACK, | 244 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_ACK, |
245 | wl->chip.intr_init_complete); | 245 | wl->chip.intr_init_complete); |
246 | break; | 246 | break; |
247 | } | 247 | } |
248 | } | 248 | } |
249 | 249 | ||
250 | if (loop >= INIT_LOOP) { | 250 | if (loop >= INIT_LOOP) { |
251 | wl12xx_error("timeout waiting for the hardware to " | 251 | wl1251_error("timeout waiting for the hardware to " |
252 | "complete initialization"); | 252 | "complete initialization"); |
253 | return -EIO; | 253 | return -EIO; |
254 | } | 254 | } |
255 | 255 | ||
256 | /* get hardware config command mail box */ | 256 | /* get hardware config command mail box */ |
257 | wl->cmd_box_addr = wl12xx_reg_read32(wl, REG_COMMAND_MAILBOX_PTR); | 257 | wl->cmd_box_addr = wl1251_reg_read32(wl, REG_COMMAND_MAILBOX_PTR); |
258 | 258 | ||
259 | /* get hardware config event mail box */ | 259 | /* get hardware config event mail box */ |
260 | wl->event_box_addr = wl12xx_reg_read32(wl, REG_EVENT_MAILBOX_PTR); | 260 | wl->event_box_addr = wl1251_reg_read32(wl, REG_EVENT_MAILBOX_PTR); |
261 | 261 | ||
262 | /* set the working partition to its "running" mode offset */ | 262 | /* set the working partition to its "running" mode offset */ |
263 | wl12xx_set_partition(wl, | 263 | wl1251_set_partition(wl, |
264 | wl->chip.p_table[PART_WORK].mem.start, | 264 | wl->chip.p_table[PART_WORK].mem.start, |
265 | wl->chip.p_table[PART_WORK].mem.size, | 265 | wl->chip.p_table[PART_WORK].mem.size, |
266 | wl->chip.p_table[PART_WORK].reg.start, | 266 | wl->chip.p_table[PART_WORK].reg.start, |
267 | wl->chip.p_table[PART_WORK].reg.size); | 267 | wl->chip.p_table[PART_WORK].reg.size); |
268 | 268 | ||
269 | wl12xx_debug(DEBUG_MAILBOX, "cmd_box_addr 0x%x event_box_addr 0x%x", | 269 | wl1251_debug(DEBUG_MAILBOX, "cmd_box_addr 0x%x event_box_addr 0x%x", |
270 | wl->cmd_box_addr, wl->event_box_addr); | 270 | wl->cmd_box_addr, wl->event_box_addr); |
271 | 271 | ||
272 | wl->chip.op_fw_version(wl); | ||
273 | |||
272 | /* | 274 | /* |
273 | * in case of full asynchronous mode the firmware event must be | 275 | * in case of full asynchronous mode the firmware event must be |
274 | * ready to receive event from the command mailbox | 276 | * ready to receive event from the command mailbox |
275 | */ | 277 | */ |
276 | 278 | ||
277 | /* enable gpio interrupts */ | 279 | /* enable gpio interrupts */ |
278 | wl12xx_boot_enable_interrupts(wl); | 280 | wl1251_boot_enable_interrupts(wl); |
279 | 281 | ||
280 | wl->chip.op_target_enable_interrupts(wl); | 282 | wl->chip.op_target_enable_interrupts(wl); |
281 | 283 | ||
282 | /* unmask all mbox events */ | 284 | /* unmask all mbox events */ |
283 | wl->event_mask = 0xffffffff; | 285 | wl->event_mask = 0xffffffff; |
284 | 286 | ||
285 | ret = wl12xx_event_unmask(wl); | 287 | ret = wl1251_event_unmask(wl); |
286 | if (ret < 0) { | 288 | if (ret < 0) { |
287 | wl12xx_error("EVENT mask setting failed"); | 289 | wl1251_error("EVENT mask setting failed"); |
288 | return ret; | 290 | return ret; |
289 | } | 291 | } |
290 | 292 | ||
291 | wl12xx_event_mbox_config(wl); | 293 | wl1251_event_mbox_config(wl); |
292 | 294 | ||
293 | /* firmware startup completed */ | 295 | /* firmware startup completed */ |
294 | return 0; | 296 | return 0; |
diff --git a/drivers/net/wireless/wl12xx/boot.h b/drivers/net/wireless/wl12xx/wl1251_boot.h index 4fa73132baae..798362d71e3f 100644 --- a/drivers/net/wireless/wl12xx/boot.h +++ b/drivers/net/wireless/wl12xx/wl1251_boot.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Nokia Corporation | 4 | * Copyright (C) 2008 Nokia Corporation |
5 | * | 5 | * |
@@ -24,12 +24,12 @@ | |||
24 | #ifndef __BOOT_H__ | 24 | #ifndef __BOOT_H__ |
25 | #define __BOOT_H__ | 25 | #define __BOOT_H__ |
26 | 26 | ||
27 | #include "wl12xx.h" | 27 | #include "wl1251.h" |
28 | 28 | ||
29 | int wl12xx_boot_soft_reset(struct wl12xx *wl); | 29 | int wl1251_boot_soft_reset(struct wl1251 *wl); |
30 | int wl12xx_boot_init_seq(struct wl12xx *wl); | 30 | int wl1251_boot_init_seq(struct wl1251 *wl); |
31 | int wl12xx_boot_run_firmware(struct wl12xx *wl); | 31 | int wl1251_boot_run_firmware(struct wl1251 *wl); |
32 | void wl12xx_boot_target_enable_interrupts(struct wl12xx *wl); | 32 | void wl1251_boot_target_enable_interrupts(struct wl1251 *wl); |
33 | 33 | ||
34 | /* number of times we try to read the INIT interrupt */ | 34 | /* number of times we try to read the INIT interrupt */ |
35 | #define INIT_LOOP 20000 | 35 | #define INIT_LOOP 20000 |
diff --git a/drivers/net/wireless/wl12xx/wl1251_cmd.c b/drivers/net/wireless/wl12xx/wl1251_cmd.c new file mode 100644 index 000000000000..dc04d1fc2ee4 --- /dev/null +++ b/drivers/net/wireless/wl12xx/wl1251_cmd.c | |||
@@ -0,0 +1,428 @@ | |||
1 | #include "wl1251_cmd.h" | ||
2 | |||
3 | #include <linux/module.h> | ||
4 | #include <linux/crc7.h> | ||
5 | #include <linux/spi/spi.h> | ||
6 | |||
7 | #include "wl1251.h" | ||
8 | #include "reg.h" | ||
9 | #include "wl1251_spi.h" | ||
10 | #include "wl1251_ps.h" | ||
11 | #include "wl1251_acx.h" | ||
12 | |||
13 | /** | ||
14 | * send command to firmware | ||
15 | * | ||
16 | * @wl: wl struct | ||
17 | * @id: command id | ||
18 | * @buf: buffer containing the command, must work with dma | ||
19 | * @len: length of the buffer | ||
20 | */ | ||
21 | int wl1251_cmd_send(struct wl1251 *wl, u16 id, void *buf, size_t len) | ||
22 | { | ||
23 | struct wl1251_cmd_header *cmd; | ||
24 | unsigned long timeout; | ||
25 | u32 intr; | ||
26 | int ret = 0; | ||
27 | |||
28 | cmd = buf; | ||
29 | cmd->id = id; | ||
30 | cmd->status = 0; | ||
31 | |||
32 | WARN_ON(len % 4 != 0); | ||
33 | |||
34 | wl1251_spi_mem_write(wl, wl->cmd_box_addr, buf, len); | ||
35 | |||
36 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_CMD); | ||
37 | |||
38 | timeout = jiffies + msecs_to_jiffies(WL1251_COMMAND_TIMEOUT); | ||
39 | |||
40 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | ||
41 | while (!(intr & wl->chip.intr_cmd_complete)) { | ||
42 | if (time_after(jiffies, timeout)) { | ||
43 | wl1251_error("command complete timeout"); | ||
44 | ret = -ETIMEDOUT; | ||
45 | goto out; | ||
46 | } | ||
47 | |||
48 | msleep(1); | ||
49 | |||
50 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_NO_CLEAR); | ||
51 | } | ||
52 | |||
53 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_ACK, | ||
54 | wl->chip.intr_cmd_complete); | ||
55 | |||
56 | out: | ||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | /** | ||
61 | * send test command to firmware | ||
62 | * | ||
63 | * @wl: wl struct | ||
64 | * @buf: buffer containing the command, with all headers, must work with dma | ||
65 | * @len: length of the buffer | ||
66 | * @answer: is answer needed | ||
67 | */ | ||
68 | int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer) | ||
69 | { | ||
70 | int ret; | ||
71 | |||
72 | wl1251_debug(DEBUG_CMD, "cmd test"); | ||
73 | |||
74 | ret = wl1251_cmd_send(wl, CMD_TEST, buf, buf_len); | ||
75 | |||
76 | if (ret < 0) { | ||
77 | wl1251_warning("TEST command failed"); | ||
78 | return ret; | ||
79 | } | ||
80 | |||
81 | if (answer) { | ||
82 | struct wl1251_command *cmd_answer; | ||
83 | |||
84 | /* | ||
85 | * The test command got in, we can read the answer. | ||
86 | * The answer would be a wl1251_command, where the | ||
87 | * parameter array contains the actual answer. | ||
88 | */ | ||
89 | wl1251_spi_mem_read(wl, wl->cmd_box_addr, buf, buf_len); | ||
90 | |||
91 | cmd_answer = buf; | ||
92 | |||
93 | if (cmd_answer->header.status != CMD_STATUS_SUCCESS) | ||
94 | wl1251_error("TEST command answer error: %d", | ||
95 | cmd_answer->header.status); | ||
96 | } | ||
97 | |||
98 | return 0; | ||
99 | } | ||
100 | |||
101 | /** | ||
102 | * read acx from firmware | ||
103 | * | ||
104 | * @wl: wl struct | ||
105 | * @id: acx id | ||
106 | * @buf: buffer for the response, including all headers, must work with dma | ||
107 | * @len: lenght of buf | ||
108 | */ | ||
109 | int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len) | ||
110 | { | ||
111 | struct acx_header *acx = buf; | ||
112 | int ret; | ||
113 | |||
114 | wl1251_debug(DEBUG_CMD, "cmd interrogate"); | ||
115 | |||
116 | acx->id = id; | ||
117 | |||
118 | /* payload length, does not include any headers */ | ||
119 | acx->len = len - sizeof(*acx); | ||
120 | |||
121 | ret = wl1251_cmd_send(wl, CMD_INTERROGATE, acx, sizeof(*acx)); | ||
122 | if (ret < 0) { | ||
123 | wl1251_error("INTERROGATE command failed"); | ||
124 | goto out; | ||
125 | } | ||
126 | |||
127 | /* the interrogate command got in, we can read the answer */ | ||
128 | wl1251_spi_mem_read(wl, wl->cmd_box_addr, buf, len); | ||
129 | |||
130 | acx = buf; | ||
131 | if (acx->cmd.status != CMD_STATUS_SUCCESS) | ||
132 | wl1251_error("INTERROGATE command error: %d", | ||
133 | acx->cmd.status); | ||
134 | |||
135 | out: | ||
136 | return ret; | ||
137 | } | ||
138 | |||
139 | /** | ||
140 | * write acx value to firmware | ||
141 | * | ||
142 | * @wl: wl struct | ||
143 | * @id: acx id | ||
144 | * @buf: buffer containing acx, including all headers, must work with dma | ||
145 | * @len: length of buf | ||
146 | */ | ||
147 | int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len) | ||
148 | { | ||
149 | struct acx_header *acx = buf; | ||
150 | int ret; | ||
151 | |||
152 | wl1251_debug(DEBUG_CMD, "cmd configure"); | ||
153 | |||
154 | acx->id = id; | ||
155 | |||
156 | /* payload length, does not include any headers */ | ||
157 | acx->len = len - sizeof(*acx); | ||
158 | |||
159 | ret = wl1251_cmd_send(wl, CMD_CONFIGURE, acx, len); | ||
160 | if (ret < 0) { | ||
161 | wl1251_warning("CONFIGURE command NOK"); | ||
162 | return ret; | ||
163 | } | ||
164 | |||
165 | return 0; | ||
166 | } | ||
167 | |||
168 | int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity, | ||
169 | void *bitmap, u16 bitmap_len, u8 bitmap_control) | ||
170 | { | ||
171 | struct wl1251_cmd_vbm_update *vbm; | ||
172 | int ret; | ||
173 | |||
174 | wl1251_debug(DEBUG_CMD, "cmd vbm"); | ||
175 | |||
176 | vbm = kzalloc(sizeof(*vbm), GFP_KERNEL); | ||
177 | if (!vbm) { | ||
178 | ret = -ENOMEM; | ||
179 | goto out; | ||
180 | } | ||
181 | |||
182 | /* Count and period will be filled by the target */ | ||
183 | vbm->tim.bitmap_ctrl = bitmap_control; | ||
184 | if (bitmap_len > PARTIAL_VBM_MAX) { | ||
185 | wl1251_warning("cmd vbm len is %d B, truncating to %d", | ||
186 | bitmap_len, PARTIAL_VBM_MAX); | ||
187 | bitmap_len = PARTIAL_VBM_MAX; | ||
188 | } | ||
189 | memcpy(vbm->tim.pvb_field, bitmap, bitmap_len); | ||
190 | vbm->tim.identity = identity; | ||
191 | vbm->tim.length = bitmap_len + 3; | ||
192 | |||
193 | vbm->len = cpu_to_le16(bitmap_len + 5); | ||
194 | |||
195 | ret = wl1251_cmd_send(wl, CMD_VBM, vbm, sizeof(*vbm)); | ||
196 | if (ret < 0) { | ||
197 | wl1251_error("VBM command failed"); | ||
198 | goto out; | ||
199 | } | ||
200 | |||
201 | out: | ||
202 | kfree(vbm); | ||
203 | return 0; | ||
204 | } | ||
205 | |||
206 | int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable) | ||
207 | { | ||
208 | struct cmd_enabledisable_path *cmd; | ||
209 | int ret; | ||
210 | u16 cmd_rx, cmd_tx; | ||
211 | |||
212 | wl1251_debug(DEBUG_CMD, "cmd data path"); | ||
213 | |||
214 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
215 | if (!cmd) { | ||
216 | ret = -ENOMEM; | ||
217 | goto out; | ||
218 | } | ||
219 | |||
220 | cmd->channel = channel; | ||
221 | |||
222 | if (enable) { | ||
223 | cmd_rx = CMD_ENABLE_RX; | ||
224 | cmd_tx = CMD_ENABLE_TX; | ||
225 | } else { | ||
226 | cmd_rx = CMD_DISABLE_RX; | ||
227 | cmd_tx = CMD_DISABLE_TX; | ||
228 | } | ||
229 | |||
230 | ret = wl1251_cmd_send(wl, cmd_rx, cmd, sizeof(*cmd)); | ||
231 | if (ret < 0) { | ||
232 | wl1251_error("rx %s cmd for channel %d failed", | ||
233 | enable ? "start" : "stop", channel); | ||
234 | goto out; | ||
235 | } | ||
236 | |||
237 | wl1251_debug(DEBUG_BOOT, "rx %s cmd channel %d", | ||
238 | enable ? "start" : "stop", channel); | ||
239 | |||
240 | ret = wl1251_cmd_send(wl, cmd_tx, cmd, sizeof(*cmd)); | ||
241 | if (ret < 0) { | ||
242 | wl1251_error("tx %s cmd for channel %d failed", | ||
243 | enable ? "start" : "stop", channel); | ||
244 | return ret; | ||
245 | } | ||
246 | |||
247 | wl1251_debug(DEBUG_BOOT, "tx %s cmd channel %d", | ||
248 | enable ? "start" : "stop", channel); | ||
249 | |||
250 | out: | ||
251 | kfree(cmd); | ||
252 | return ret; | ||
253 | } | ||
254 | |||
255 | int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 dtim_interval, | ||
256 | u16 beacon_interval, u8 wait) | ||
257 | { | ||
258 | unsigned long timeout; | ||
259 | struct cmd_join *join; | ||
260 | int ret, i; | ||
261 | u8 *bssid; | ||
262 | |||
263 | join = kzalloc(sizeof(*join), GFP_KERNEL); | ||
264 | if (!join) { | ||
265 | ret = -ENOMEM; | ||
266 | goto out; | ||
267 | } | ||
268 | |||
269 | /* FIXME: this should be in main.c */ | ||
270 | ret = wl1251_acx_frame_rates(wl, DEFAULT_HW_GEN_TX_RATE, | ||
271 | DEFAULT_HW_GEN_MODULATION_TYPE, | ||
272 | wl->tx_mgmt_frm_rate, | ||
273 | wl->tx_mgmt_frm_mod); | ||
274 | if (ret < 0) | ||
275 | goto out; | ||
276 | |||
277 | wl1251_debug(DEBUG_CMD, "cmd join"); | ||
278 | |||
279 | /* Reverse order BSSID */ | ||
280 | bssid = (u8 *) &join->bssid_lsb; | ||
281 | for (i = 0; i < ETH_ALEN; i++) | ||
282 | bssid[i] = wl->bssid[ETH_ALEN - i - 1]; | ||
283 | |||
284 | join->rx_config_options = wl->rx_config; | ||
285 | join->rx_filter_options = wl->rx_filter; | ||
286 | |||
287 | join->basic_rate_set = RATE_MASK_1MBPS | RATE_MASK_2MBPS | | ||
288 | RATE_MASK_5_5MBPS | RATE_MASK_11MBPS; | ||
289 | |||
290 | join->beacon_interval = beacon_interval; | ||
291 | join->dtim_interval = dtim_interval; | ||
292 | join->bss_type = bss_type; | ||
293 | join->channel = wl->channel; | ||
294 | join->ctrl = JOIN_CMD_CTRL_TX_FLUSH; | ||
295 | |||
296 | ret = wl1251_cmd_send(wl, CMD_START_JOIN, join, sizeof(*join)); | ||
297 | if (ret < 0) { | ||
298 | wl1251_error("failed to initiate cmd join"); | ||
299 | goto out; | ||
300 | } | ||
301 | |||
302 | timeout = msecs_to_jiffies(JOIN_TIMEOUT); | ||
303 | |||
304 | /* | ||
305 | * ugly hack: we should wait for JOIN_EVENT_COMPLETE_ID but to | ||
306 | * simplify locking we just sleep instead, for now | ||
307 | */ | ||
308 | if (wait) | ||
309 | msleep(10); | ||
310 | |||
311 | out: | ||
312 | kfree(join); | ||
313 | return ret; | ||
314 | } | ||
315 | |||
316 | int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode) | ||
317 | { | ||
318 | struct wl1251_cmd_ps_params *ps_params = NULL; | ||
319 | int ret = 0; | ||
320 | |||
321 | /* FIXME: this should be in ps.c */ | ||
322 | ret = wl1251_acx_wake_up_conditions(wl, WAKE_UP_EVENT_DTIM_BITMAP, | ||
323 | wl->listen_int); | ||
324 | if (ret < 0) { | ||
325 | wl1251_error("couldn't set wake up conditions"); | ||
326 | goto out; | ||
327 | } | ||
328 | |||
329 | wl1251_debug(DEBUG_CMD, "cmd set ps mode"); | ||
330 | |||
331 | ps_params = kzalloc(sizeof(*ps_params), GFP_KERNEL); | ||
332 | if (!ps_params) { | ||
333 | ret = -ENOMEM; | ||
334 | goto out; | ||
335 | } | ||
336 | |||
337 | ps_params->ps_mode = ps_mode; | ||
338 | ps_params->send_null_data = 1; | ||
339 | ps_params->retries = 5; | ||
340 | ps_params->hang_over_period = 128; | ||
341 | ps_params->null_data_rate = 1; /* 1 Mbps */ | ||
342 | |||
343 | ret = wl1251_cmd_send(wl, CMD_SET_PS_MODE, ps_params, | ||
344 | sizeof(*ps_params)); | ||
345 | if (ret < 0) { | ||
346 | wl1251_error("cmd set_ps_mode failed"); | ||
347 | goto out; | ||
348 | } | ||
349 | |||
350 | out: | ||
351 | kfree(ps_params); | ||
352 | return ret; | ||
353 | } | ||
354 | |||
355 | int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer, | ||
356 | size_t len) | ||
357 | { | ||
358 | struct cmd_read_write_memory *cmd; | ||
359 | int ret = 0; | ||
360 | |||
361 | wl1251_debug(DEBUG_CMD, "cmd read memory"); | ||
362 | |||
363 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
364 | if (!cmd) { | ||
365 | ret = -ENOMEM; | ||
366 | goto out; | ||
367 | } | ||
368 | |||
369 | WARN_ON(len > MAX_READ_SIZE); | ||
370 | len = min_t(size_t, len, MAX_READ_SIZE); | ||
371 | |||
372 | cmd->addr = addr; | ||
373 | cmd->size = len; | ||
374 | |||
375 | ret = wl1251_cmd_send(wl, CMD_READ_MEMORY, cmd, sizeof(*cmd)); | ||
376 | if (ret < 0) { | ||
377 | wl1251_error("read memory command failed: %d", ret); | ||
378 | goto out; | ||
379 | } | ||
380 | |||
381 | /* the read command got in, we can now read the answer */ | ||
382 | wl1251_spi_mem_read(wl, wl->cmd_box_addr, cmd, sizeof(*cmd)); | ||
383 | |||
384 | if (cmd->header.status != CMD_STATUS_SUCCESS) | ||
385 | wl1251_error("error in read command result: %d", | ||
386 | cmd->header.status); | ||
387 | |||
388 | memcpy(answer, cmd->value, len); | ||
389 | |||
390 | out: | ||
391 | kfree(cmd); | ||
392 | return ret; | ||
393 | } | ||
394 | |||
395 | int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id, | ||
396 | void *buf, size_t buf_len) | ||
397 | { | ||
398 | struct wl1251_cmd_packet_template *cmd; | ||
399 | size_t cmd_len; | ||
400 | int ret = 0; | ||
401 | |||
402 | wl1251_debug(DEBUG_CMD, "cmd template %d", cmd_id); | ||
403 | |||
404 | WARN_ON(buf_len > WL1251_MAX_TEMPLATE_SIZE); | ||
405 | buf_len = min_t(size_t, buf_len, WL1251_MAX_TEMPLATE_SIZE); | ||
406 | cmd_len = ALIGN(sizeof(*cmd) + buf_len, 4); | ||
407 | |||
408 | cmd = kzalloc(cmd_len, GFP_KERNEL); | ||
409 | if (!cmd) { | ||
410 | ret = -ENOMEM; | ||
411 | goto out; | ||
412 | } | ||
413 | |||
414 | cmd->size = cpu_to_le16(buf_len); | ||
415 | |||
416 | if (buf) | ||
417 | memcpy(cmd->data, buf, buf_len); | ||
418 | |||
419 | ret = wl1251_cmd_send(wl, cmd_id, cmd, cmd_len); | ||
420 | if (ret < 0) { | ||
421 | wl1251_warning("cmd set_template failed: %d", ret); | ||
422 | goto out; | ||
423 | } | ||
424 | |||
425 | out: | ||
426 | kfree(cmd); | ||
427 | return ret; | ||
428 | } | ||
diff --git a/drivers/net/wireless/wl12xx/cmd.h b/drivers/net/wireless/wl12xx/wl1251_cmd.h index aa307dcd081f..64f228dd9a9b 100644 --- a/drivers/net/wireless/wl12xx/cmd.h +++ b/drivers/net/wireless/wl12xx/wl1251_cmd.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -22,37 +22,32 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef __WL12XX_CMD_H__ | 25 | #ifndef __WL1251_CMD_H__ |
26 | #define __WL12XX_CMD_H__ | 26 | #define __WL1251_CMD_H__ |
27 | 27 | ||
28 | #include "wl12xx.h" | 28 | #include "wl1251.h" |
29 | 29 | ||
30 | int wl12xx_cmd_send(struct wl12xx *wl, u16 type, void *buf, size_t buf_len); | 30 | struct acx_header; |
31 | int wl12xx_cmd_test(struct wl12xx *wl, void *buf, size_t buf_len, u8 answer); | 31 | |
32 | int wl12xx_cmd_interrogate(struct wl12xx *wl, u16 ie_id, u16 ie_len, | 32 | int wl1251_cmd_send(struct wl1251 *wl, u16 type, void *buf, size_t buf_len); |
33 | void *answer); | 33 | int wl1251_cmd_test(struct wl1251 *wl, void *buf, size_t buf_len, u8 answer); |
34 | int wl12xx_cmd_configure(struct wl12xx *wl, void *ie, int ie_len); | 34 | int wl1251_cmd_interrogate(struct wl1251 *wl, u16 id, void *buf, size_t len); |
35 | int wl12xx_cmd_vbm(struct wl12xx *wl, u8 identity, | 35 | int wl1251_cmd_configure(struct wl1251 *wl, u16 id, void *buf, size_t len); |
36 | int wl1251_cmd_vbm(struct wl1251 *wl, u8 identity, | ||
36 | void *bitmap, u16 bitmap_len, u8 bitmap_control); | 37 | void *bitmap, u16 bitmap_len, u8 bitmap_control); |
37 | int wl12xx_cmd_data_path(struct wl12xx *wl, u8 channel, u8 enable); | 38 | int wl1251_cmd_data_path(struct wl1251 *wl, u8 channel, bool enable); |
38 | int wl12xx_cmd_join(struct wl12xx *wl, u8 bss_type, u8 dtim_interval, | 39 | int wl1251_cmd_join(struct wl1251 *wl, u8 bss_type, u8 dtim_interval, |
39 | u16 beacon_interval, u8 wait); | 40 | u16 beacon_interval, u8 wait); |
40 | int wl12xx_cmd_ps_mode(struct wl12xx *wl, u8 ps_mode); | 41 | int wl1251_cmd_ps_mode(struct wl1251 *wl, u8 ps_mode); |
41 | int wl12xx_cmd_read_memory(struct wl12xx *wl, u32 addr, u32 len, void *answer); | 42 | int wl1251_cmd_read_memory(struct wl1251 *wl, u32 addr, void *answer, |
42 | int wl12xx_cmd_template_set(struct wl12xx *wl, u16 cmd_id, | 43 | size_t len); |
44 | int wl1251_cmd_template_set(struct wl1251 *wl, u16 cmd_id, | ||
43 | void *buf, size_t buf_len); | 45 | void *buf, size_t buf_len); |
44 | 46 | ||
45 | /* unit ms */ | 47 | /* unit ms */ |
46 | #define WL12XX_COMMAND_TIMEOUT 2000 | 48 | #define WL1251_COMMAND_TIMEOUT 2000 |
47 | |||
48 | #define WL12XX_MAX_TEMPLATE_SIZE 300 | ||
49 | 49 | ||
50 | struct wl12xx_cmd_packet_template { | 50 | enum wl1251_commands { |
51 | __le16 size; | ||
52 | u8 template[WL12XX_MAX_TEMPLATE_SIZE]; | ||
53 | } __attribute__ ((packed)); | ||
54 | |||
55 | enum wl12xx_commands { | ||
56 | CMD_RESET = 0, | 51 | CMD_RESET = 0, |
57 | CMD_INTERROGATE = 1, /*use this to read information elements*/ | 52 | CMD_INTERROGATE = 1, /*use this to read information elements*/ |
58 | CMD_CONFIGURE = 2, /*use this to write information elements*/ | 53 | CMD_CONFIGURE = 2, /*use this to write information elements*/ |
@@ -100,9 +95,15 @@ enum wl12xx_commands { | |||
100 | 95 | ||
101 | #define MAX_CMD_PARAMS 572 | 96 | #define MAX_CMD_PARAMS 572 |
102 | 97 | ||
103 | struct wl12xx_command { | 98 | struct wl1251_cmd_header { |
104 | u16 id; | 99 | u16 id; |
105 | u16 status; | 100 | u16 status; |
101 | /* payload */ | ||
102 | u8 data[0]; | ||
103 | } __attribute__ ((packed)); | ||
104 | |||
105 | struct wl1251_command { | ||
106 | struct wl1251_cmd_header header; | ||
106 | u8 parameters[MAX_CMD_PARAMS]; | 107 | u8 parameters[MAX_CMD_PARAMS]; |
107 | }; | 108 | }; |
108 | 109 | ||
@@ -144,6 +145,8 @@ enum { | |||
144 | #define MAX_READ_SIZE 256 | 145 | #define MAX_READ_SIZE 256 |
145 | 146 | ||
146 | struct cmd_read_write_memory { | 147 | struct cmd_read_write_memory { |
148 | struct wl1251_cmd_header header; | ||
149 | |||
147 | /* The address of the memory to read from or write to.*/ | 150 | /* The address of the memory to read from or write to.*/ |
148 | u32 addr; | 151 | u32 addr; |
149 | 152 | ||
@@ -211,6 +214,8 @@ struct basic_scan_channel_parameters { | |||
211 | #define SCAN_MAX_NUM_OF_CHANNELS 16 | 214 | #define SCAN_MAX_NUM_OF_CHANNELS 16 |
212 | 215 | ||
213 | struct cmd_scan { | 216 | struct cmd_scan { |
217 | struct wl1251_cmd_header header; | ||
218 | |||
214 | struct basic_scan_parameters params; | 219 | struct basic_scan_parameters params; |
215 | struct basic_scan_channel_parameters channels[SCAN_MAX_NUM_OF_CHANNELS]; | 220 | struct basic_scan_channel_parameters channels[SCAN_MAX_NUM_OF_CHANNELS]; |
216 | } __attribute__ ((packed)); | 221 | } __attribute__ ((packed)); |
@@ -227,6 +232,8 @@ enum { | |||
227 | 232 | ||
228 | 233 | ||
229 | struct cmd_join { | 234 | struct cmd_join { |
235 | struct wl1251_cmd_header header; | ||
236 | |||
230 | u32 bssid_lsb; | 237 | u32 bssid_lsb; |
231 | u16 bssid_msb; | 238 | u16 bssid_msb; |
232 | u16 beacon_interval; /* in TBTTs */ | 239 | u16 beacon_interval; /* in TBTTs */ |
@@ -261,5 +268,140 @@ struct cmd_join { | |||
261 | u8 reserved; | 268 | u8 reserved; |
262 | } __attribute__ ((packed)); | 269 | } __attribute__ ((packed)); |
263 | 270 | ||
271 | struct cmd_enabledisable_path { | ||
272 | struct wl1251_cmd_header header; | ||
273 | |||
274 | u8 channel; | ||
275 | u8 padding[3]; | ||
276 | } __attribute__ ((packed)); | ||
277 | |||
278 | #define WL1251_MAX_TEMPLATE_SIZE 300 | ||
279 | |||
280 | struct wl1251_cmd_packet_template { | ||
281 | struct wl1251_cmd_header header; | ||
282 | |||
283 | __le16 size; | ||
284 | u8 data[0]; | ||
285 | } __attribute__ ((packed)); | ||
286 | |||
287 | #define TIM_ELE_ID 5 | ||
288 | #define PARTIAL_VBM_MAX 251 | ||
289 | |||
290 | struct wl1251_tim { | ||
291 | u8 identity; | ||
292 | u8 length; | ||
293 | u8 dtim_count; | ||
294 | u8 dtim_period; | ||
295 | u8 bitmap_ctrl; | ||
296 | u8 pvb_field[PARTIAL_VBM_MAX]; /* Partial Virtual Bitmap */ | ||
297 | } __attribute__ ((packed)); | ||
298 | |||
299 | /* Virtual Bit Map update */ | ||
300 | struct wl1251_cmd_vbm_update { | ||
301 | struct wl1251_cmd_header header; | ||
302 | __le16 len; | ||
303 | u8 padding[2]; | ||
304 | struct wl1251_tim tim; | ||
305 | } __attribute__ ((packed)); | ||
306 | |||
307 | enum wl1251_cmd_ps_mode { | ||
308 | STATION_ACTIVE_MODE, | ||
309 | STATION_POWER_SAVE_MODE | ||
310 | }; | ||
311 | |||
312 | struct wl1251_cmd_ps_params { | ||
313 | struct wl1251_cmd_header header; | ||
314 | |||
315 | u8 ps_mode; /* STATION_* */ | ||
316 | u8 send_null_data; /* Do we have to send NULL data packet ? */ | ||
317 | u8 retries; /* Number of retires for the initial NULL data packet */ | ||
318 | |||
319 | /* | ||
320 | * TUs during which the target stays awake after switching | ||
321 | * to power save mode. | ||
322 | */ | ||
323 | u8 hang_over_period; | ||
324 | u16 null_data_rate; | ||
325 | u8 pad[2]; | ||
326 | } __attribute__ ((packed)); | ||
327 | |||
328 | struct wl1251_cmd_trigger_scan_to { | ||
329 | struct wl1251_cmd_header header; | ||
330 | |||
331 | u32 timeout; | ||
332 | }; | ||
333 | |||
334 | /* HW encryption keys */ | ||
335 | #define NUM_ACCESS_CATEGORIES_COPY 4 | ||
336 | #define MAX_KEY_SIZE 32 | ||
337 | |||
338 | /* When set, disable HW encryption */ | ||
339 | #define DF_ENCRYPTION_DISABLE 0x01 | ||
340 | /* When set, disable HW decryption */ | ||
341 | #define DF_SNIFF_MODE_ENABLE 0x80 | ||
342 | |||
343 | enum wl1251_cmd_key_action { | ||
344 | KEY_ADD_OR_REPLACE = 1, | ||
345 | KEY_REMOVE = 2, | ||
346 | KEY_SET_ID = 3, | ||
347 | MAX_KEY_ACTION = 0xffff, | ||
348 | }; | ||
349 | |||
350 | enum wl1251_cmd_key_type { | ||
351 | KEY_WEP_DEFAULT = 0, | ||
352 | KEY_WEP_ADDR = 1, | ||
353 | KEY_AES_GROUP = 4, | ||
354 | KEY_AES_PAIRWISE = 5, | ||
355 | KEY_WEP_GROUP = 6, | ||
356 | KEY_TKIP_MIC_GROUP = 10, | ||
357 | KEY_TKIP_MIC_PAIRWISE = 11, | ||
358 | }; | ||
359 | |||
360 | /* | ||
361 | * | ||
362 | * key_type_e key size key format | ||
363 | * ---------- --------- ---------- | ||
364 | * 0x00 5, 13, 29 Key data | ||
365 | * 0x01 5, 13, 29 Key data | ||
366 | * 0x04 16 16 bytes of key data | ||
367 | * 0x05 16 16 bytes of key data | ||
368 | * 0x0a 32 16 bytes of TKIP key data | ||
369 | * 8 bytes of RX MIC key data | ||
370 | * 8 bytes of TX MIC key data | ||
371 | * 0x0b 32 16 bytes of TKIP key data | ||
372 | * 8 bytes of RX MIC key data | ||
373 | * 8 bytes of TX MIC key data | ||
374 | * | ||
375 | */ | ||
376 | |||
377 | struct wl1251_cmd_set_keys { | ||
378 | struct wl1251_cmd_header header; | ||
379 | |||
380 | /* Ignored for default WEP key */ | ||
381 | u8 addr[ETH_ALEN]; | ||
382 | |||
383 | /* key_action_e */ | ||
384 | u16 key_action; | ||
385 | |||
386 | u16 reserved_1; | ||
387 | |||
388 | /* key size in bytes */ | ||
389 | u8 key_size; | ||
390 | |||
391 | /* key_type_e */ | ||
392 | u8 key_type; | ||
393 | u8 ssid_profile; | ||
394 | |||
395 | /* | ||
396 | * TKIP, AES: frame's key id field. | ||
397 | * For WEP default key: key id; | ||
398 | */ | ||
399 | u8 id; | ||
400 | u8 reserved_2[6]; | ||
401 | u8 key[MAX_KEY_SIZE]; | ||
402 | u16 ac_seq_num16[NUM_ACCESS_CATEGORIES_COPY]; | ||
403 | u32 ac_seq_num32[NUM_ACCESS_CATEGORIES_COPY]; | ||
404 | } __attribute__ ((packed)); | ||
405 | |||
264 | 406 | ||
265 | #endif /* __WL12XX_CMD_H__ */ | 407 | #endif /* __WL1251_CMD_H__ */ |
diff --git a/drivers/net/wireless/wl12xx/debugfs.c b/drivers/net/wireless/wl12xx/wl1251_debugfs.c index cdb368ce4dae..a00723059f83 100644 --- a/drivers/net/wireless/wl12xx/debugfs.c +++ b/drivers/net/wireless/wl12xx/wl1251_debugfs.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Nokia Corporation | 4 | * Copyright (C) 2009 Nokia Corporation |
5 | * | 5 | * |
@@ -21,15 +21,16 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "debugfs.h" | 24 | #include "wl1251_debugfs.h" |
25 | 25 | ||
26 | #include <linux/skbuff.h> | 26 | #include <linux/skbuff.h> |
27 | 27 | ||
28 | #include "wl12xx.h" | 28 | #include "wl1251.h" |
29 | #include "acx.h" | 29 | #include "wl1251_acx.h" |
30 | #include "wl1251_ps.h" | ||
30 | 31 | ||
31 | /* ms */ | 32 | /* ms */ |
32 | #define WL12XX_DEBUGFS_STATS_LIFETIME 1000 | 33 | #define WL1251_DEBUGFS_STATS_LIFETIME 1000 |
33 | 34 | ||
34 | /* debugfs macros idea from mac80211 */ | 35 | /* debugfs macros idea from mac80211 */ |
35 | 36 | ||
@@ -37,7 +38,7 @@ | |||
37 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ | 38 | static ssize_t name## _read(struct file *file, char __user *userbuf, \ |
38 | size_t count, loff_t *ppos) \ | 39 | size_t count, loff_t *ppos) \ |
39 | { \ | 40 | { \ |
40 | struct wl12xx *wl = file->private_data; \ | 41 | struct wl1251 *wl = file->private_data; \ |
41 | char buf[buflen]; \ | 42 | char buf[buflen]; \ |
42 | int res; \ | 43 | int res; \ |
43 | \ | 44 | \ |
@@ -47,7 +48,7 @@ static ssize_t name## _read(struct file *file, char __user *userbuf, \ | |||
47 | \ | 48 | \ |
48 | static const struct file_operations name## _ops = { \ | 49 | static const struct file_operations name## _ops = { \ |
49 | .read = name## _read, \ | 50 | .read = name## _read, \ |
50 | .open = wl12xx_open_file_generic, \ | 51 | .open = wl1251_open_file_generic, \ |
51 | }; | 52 | }; |
52 | 53 | ||
53 | #define DEBUGFS_ADD(name, parent) \ | 54 | #define DEBUGFS_ADD(name, parent) \ |
@@ -70,11 +71,11 @@ static ssize_t sub## _ ##name## _read(struct file *file, \ | |||
70 | char __user *userbuf, \ | 71 | char __user *userbuf, \ |
71 | size_t count, loff_t *ppos) \ | 72 | size_t count, loff_t *ppos) \ |
72 | { \ | 73 | { \ |
73 | struct wl12xx *wl = file->private_data; \ | 74 | struct wl1251 *wl = file->private_data; \ |
74 | char buf[buflen]; \ | 75 | char buf[buflen]; \ |
75 | int res; \ | 76 | int res; \ |
76 | \ | 77 | \ |
77 | wl12xx_debugfs_update_stats(wl); \ | 78 | wl1251_debugfs_update_stats(wl); \ |
78 | \ | 79 | \ |
79 | res = scnprintf(buf, buflen, fmt "\n", \ | 80 | res = scnprintf(buf, buflen, fmt "\n", \ |
80 | wl->stats.fw_stats->sub.name); \ | 81 | wl->stats.fw_stats->sub.name); \ |
@@ -83,7 +84,7 @@ static ssize_t sub## _ ##name## _read(struct file *file, \ | |||
83 | \ | 84 | \ |
84 | static const struct file_operations sub## _ ##name## _ops = { \ | 85 | static const struct file_operations sub## _ ##name## _ops = { \ |
85 | .read = sub## _ ##name## _read, \ | 86 | .read = sub## _ ##name## _read, \ |
86 | .open = wl12xx_open_file_generic, \ | 87 | .open = wl1251_open_file_generic, \ |
87 | }; | 88 | }; |
88 | 89 | ||
89 | #define DEBUGFS_FWSTATS_ADD(sub, name) \ | 90 | #define DEBUGFS_FWSTATS_ADD(sub, name) \ |
@@ -92,21 +93,30 @@ static const struct file_operations sub## _ ##name## _ops = { \ | |||
92 | #define DEBUGFS_FWSTATS_DEL(sub, name) \ | 93 | #define DEBUGFS_FWSTATS_DEL(sub, name) \ |
93 | DEBUGFS_DEL(sub## _ ##name) | 94 | DEBUGFS_DEL(sub## _ ##name) |
94 | 95 | ||
95 | static void wl12xx_debugfs_update_stats(struct wl12xx *wl) | 96 | static void wl1251_debugfs_update_stats(struct wl1251 *wl) |
96 | { | 97 | { |
98 | int ret; | ||
99 | |||
97 | mutex_lock(&wl->mutex); | 100 | mutex_lock(&wl->mutex); |
98 | 101 | ||
99 | if (wl->state == WL12XX_STATE_ON && | 102 | ret = wl1251_ps_elp_wakeup(wl); |
103 | if (ret < 0) | ||
104 | goto out; | ||
105 | |||
106 | if (wl->state == WL1251_STATE_ON && | ||
100 | time_after(jiffies, wl->stats.fw_stats_update + | 107 | time_after(jiffies, wl->stats.fw_stats_update + |
101 | msecs_to_jiffies(WL12XX_DEBUGFS_STATS_LIFETIME))) { | 108 | msecs_to_jiffies(WL1251_DEBUGFS_STATS_LIFETIME))) { |
102 | wl12xx_acx_statistics(wl, wl->stats.fw_stats); | 109 | wl1251_acx_statistics(wl, wl->stats.fw_stats); |
103 | wl->stats.fw_stats_update = jiffies; | 110 | wl->stats.fw_stats_update = jiffies; |
104 | } | 111 | } |
105 | 112 | ||
113 | wl1251_ps_elp_sleep(wl); | ||
114 | |||
115 | out: | ||
106 | mutex_unlock(&wl->mutex); | 116 | mutex_unlock(&wl->mutex); |
107 | } | 117 | } |
108 | 118 | ||
109 | static int wl12xx_open_file_generic(struct inode *inode, struct file *file) | 119 | static int wl1251_open_file_generic(struct inode *inode, struct file *file) |
110 | { | 120 | { |
111 | file->private_data = inode->i_private; | 121 | file->private_data = inode->i_private; |
112 | return 0; | 122 | return 0; |
@@ -211,7 +221,7 @@ DEBUGFS_READONLY_FILE(excessive_retries, 20, "%u", | |||
211 | static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, | 221 | static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, |
212 | size_t count, loff_t *ppos) | 222 | size_t count, loff_t *ppos) |
213 | { | 223 | { |
214 | struct wl12xx *wl = file->private_data; | 224 | struct wl1251 *wl = file->private_data; |
215 | u32 queue_len; | 225 | u32 queue_len; |
216 | char buf[20]; | 226 | char buf[20]; |
217 | int res; | 227 | int res; |
@@ -224,10 +234,10 @@ static ssize_t tx_queue_len_read(struct file *file, char __user *userbuf, | |||
224 | 234 | ||
225 | static const struct file_operations tx_queue_len_ops = { | 235 | static const struct file_operations tx_queue_len_ops = { |
226 | .read = tx_queue_len_read, | 236 | .read = tx_queue_len_read, |
227 | .open = wl12xx_open_file_generic, | 237 | .open = wl1251_open_file_generic, |
228 | }; | 238 | }; |
229 | 239 | ||
230 | static void wl12xx_debugfs_delete_files(struct wl12xx *wl) | 240 | static void wl1251_debugfs_delete_files(struct wl1251 *wl) |
231 | { | 241 | { |
232 | DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow); | 242 | DEBUGFS_FWSTATS_DEL(tx, internal_desc_overflow); |
233 | 243 | ||
@@ -325,7 +335,7 @@ static void wl12xx_debugfs_delete_files(struct wl12xx *wl) | |||
325 | DEBUGFS_DEL(excessive_retries); | 335 | DEBUGFS_DEL(excessive_retries); |
326 | } | 336 | } |
327 | 337 | ||
328 | static int wl12xx_debugfs_add_files(struct wl12xx *wl) | 338 | static int wl1251_debugfs_add_files(struct wl1251 *wl) |
329 | { | 339 | { |
330 | int ret = 0; | 340 | int ret = 0; |
331 | 341 | ||
@@ -426,19 +436,19 @@ static int wl12xx_debugfs_add_files(struct wl12xx *wl) | |||
426 | 436 | ||
427 | out: | 437 | out: |
428 | if (ret < 0) | 438 | if (ret < 0) |
429 | wl12xx_debugfs_delete_files(wl); | 439 | wl1251_debugfs_delete_files(wl); |
430 | 440 | ||
431 | return ret; | 441 | return ret; |
432 | } | 442 | } |
433 | 443 | ||
434 | void wl12xx_debugfs_reset(struct wl12xx *wl) | 444 | void wl1251_debugfs_reset(struct wl1251 *wl) |
435 | { | 445 | { |
436 | memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); | 446 | memset(wl->stats.fw_stats, 0, sizeof(*wl->stats.fw_stats)); |
437 | wl->stats.retry_count = 0; | 447 | wl->stats.retry_count = 0; |
438 | wl->stats.excessive_retries = 0; | 448 | wl->stats.excessive_retries = 0; |
439 | } | 449 | } |
440 | 450 | ||
441 | int wl12xx_debugfs_init(struct wl12xx *wl) | 451 | int wl1251_debugfs_init(struct wl1251 *wl) |
442 | { | 452 | { |
443 | int ret; | 453 | int ret; |
444 | 454 | ||
@@ -469,7 +479,7 @@ int wl12xx_debugfs_init(struct wl12xx *wl) | |||
469 | 479 | ||
470 | wl->stats.fw_stats_update = jiffies; | 480 | wl->stats.fw_stats_update = jiffies; |
471 | 481 | ||
472 | ret = wl12xx_debugfs_add_files(wl); | 482 | ret = wl1251_debugfs_add_files(wl); |
473 | 483 | ||
474 | if (ret < 0) | 484 | if (ret < 0) |
475 | goto err_file; | 485 | goto err_file; |
@@ -492,9 +502,9 @@ err: | |||
492 | return ret; | 502 | return ret; |
493 | } | 503 | } |
494 | 504 | ||
495 | void wl12xx_debugfs_exit(struct wl12xx *wl) | 505 | void wl1251_debugfs_exit(struct wl1251 *wl) |
496 | { | 506 | { |
497 | wl12xx_debugfs_delete_files(wl); | 507 | wl1251_debugfs_delete_files(wl); |
498 | 508 | ||
499 | kfree(wl->stats.fw_stats); | 509 | kfree(wl->stats.fw_stats); |
500 | wl->stats.fw_stats = NULL; | 510 | wl->stats.fw_stats = NULL; |
diff --git a/drivers/net/wireless/wl12xx/debugfs.h b/drivers/net/wireless/wl12xx/wl1251_debugfs.h index 562cdcbcc874..6dc3d080853c 100644 --- a/drivers/net/wireless/wl12xx/debugfs.h +++ b/drivers/net/wireless/wl12xx/wl1251_debugfs.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Nokia Corporation | 4 | * Copyright (C) 2009 Nokia Corporation |
5 | * | 5 | * |
@@ -21,13 +21,13 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef WL12XX_DEBUGFS_H | 24 | #ifndef WL1251_DEBUGFS_H |
25 | #define WL12XX_DEBUGFS_H | 25 | #define WL1251_DEBUGFS_H |
26 | 26 | ||
27 | #include "wl12xx.h" | 27 | #include "wl1251.h" |
28 | 28 | ||
29 | int wl12xx_debugfs_init(struct wl12xx *wl); | 29 | int wl1251_debugfs_init(struct wl1251 *wl); |
30 | void wl12xx_debugfs_exit(struct wl12xx *wl); | 30 | void wl1251_debugfs_exit(struct wl1251 *wl); |
31 | void wl12xx_debugfs_reset(struct wl12xx *wl); | 31 | void wl1251_debugfs_reset(struct wl1251 *wl); |
32 | 32 | ||
33 | #endif /* WL12XX_DEBUGFS_H */ | 33 | #endif /* WL1251_DEBUGFS_H */ |
diff --git a/drivers/net/wireless/wl12xx/event.c b/drivers/net/wireless/wl12xx/wl1251_event.c index 99529ca89a7e..1a0a0bc1a31f 100644 --- a/drivers/net/wireless/wl12xx/event.c +++ b/drivers/net/wireless/wl12xx/wl1251_event.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -22,16 +22,16 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #include "wl12xx.h" | 25 | #include "wl1251.h" |
26 | #include "reg.h" | 26 | #include "reg.h" |
27 | #include "spi.h" | 27 | #include "wl1251_spi.h" |
28 | #include "event.h" | 28 | #include "wl1251_event.h" |
29 | #include "ps.h" | 29 | #include "wl1251_ps.h" |
30 | 30 | ||
31 | static int wl12xx_event_scan_complete(struct wl12xx *wl, | 31 | static int wl1251_event_scan_complete(struct wl1251 *wl, |
32 | struct event_mailbox *mbox) | 32 | struct event_mailbox *mbox) |
33 | { | 33 | { |
34 | wl12xx_debug(DEBUG_EVENT, "status: 0x%x, channels: %d", | 34 | wl1251_debug(DEBUG_EVENT, "status: 0x%x, channels: %d", |
35 | mbox->scheduled_scan_status, | 35 | mbox->scheduled_scan_status, |
36 | mbox->scheduled_scan_channels); | 36 | mbox->scheduled_scan_channels); |
37 | 37 | ||
@@ -45,34 +45,34 @@ static int wl12xx_event_scan_complete(struct wl12xx *wl, | |||
45 | return 0; | 45 | return 0; |
46 | } | 46 | } |
47 | 47 | ||
48 | static void wl12xx_event_mbox_dump(struct event_mailbox *mbox) | 48 | static void wl1251_event_mbox_dump(struct event_mailbox *mbox) |
49 | { | 49 | { |
50 | wl12xx_debug(DEBUG_EVENT, "MBOX DUMP:"); | 50 | wl1251_debug(DEBUG_EVENT, "MBOX DUMP:"); |
51 | wl12xx_debug(DEBUG_EVENT, "\tvector: 0x%x", mbox->events_vector); | 51 | wl1251_debug(DEBUG_EVENT, "\tvector: 0x%x", mbox->events_vector); |
52 | wl12xx_debug(DEBUG_EVENT, "\tmask: 0x%x", mbox->events_mask); | 52 | wl1251_debug(DEBUG_EVENT, "\tmask: 0x%x", mbox->events_mask); |
53 | } | 53 | } |
54 | 54 | ||
55 | static int wl12xx_event_process(struct wl12xx *wl, struct event_mailbox *mbox) | 55 | static int wl1251_event_process(struct wl1251 *wl, struct event_mailbox *mbox) |
56 | { | 56 | { |
57 | int ret; | 57 | int ret; |
58 | u32 vector; | 58 | u32 vector; |
59 | 59 | ||
60 | wl12xx_event_mbox_dump(mbox); | 60 | wl1251_event_mbox_dump(mbox); |
61 | 61 | ||
62 | vector = mbox->events_vector & ~(mbox->events_mask); | 62 | vector = mbox->events_vector & ~(mbox->events_mask); |
63 | wl12xx_debug(DEBUG_EVENT, "vector: 0x%x", vector); | 63 | wl1251_debug(DEBUG_EVENT, "vector: 0x%x", vector); |
64 | 64 | ||
65 | if (vector & SCAN_COMPLETE_EVENT_ID) { | 65 | if (vector & SCAN_COMPLETE_EVENT_ID) { |
66 | ret = wl12xx_event_scan_complete(wl, mbox); | 66 | ret = wl1251_event_scan_complete(wl, mbox); |
67 | if (ret < 0) | 67 | if (ret < 0) |
68 | return ret; | 68 | return ret; |
69 | } | 69 | } |
70 | 70 | ||
71 | if (vector & BSS_LOSE_EVENT_ID) { | 71 | if (vector & BSS_LOSE_EVENT_ID) { |
72 | wl12xx_debug(DEBUG_EVENT, "BSS_LOSE_EVENT"); | 72 | wl1251_debug(DEBUG_EVENT, "BSS_LOSE_EVENT"); |
73 | 73 | ||
74 | if (wl->psm_requested && wl->psm) { | 74 | if (wl->psm_requested && wl->psm) { |
75 | ret = wl12xx_ps_set_mode(wl, STATION_ACTIVE_MODE); | 75 | ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE); |
76 | if (ret < 0) | 76 | if (ret < 0) |
77 | return ret; | 77 | return ret; |
78 | } | 78 | } |
@@ -81,47 +81,47 @@ static int wl12xx_event_process(struct wl12xx *wl, struct event_mailbox *mbox) | |||
81 | return 0; | 81 | return 0; |
82 | } | 82 | } |
83 | 83 | ||
84 | int wl12xx_event_unmask(struct wl12xx *wl) | 84 | int wl1251_event_unmask(struct wl1251 *wl) |
85 | { | 85 | { |
86 | int ret; | 86 | int ret; |
87 | 87 | ||
88 | ret = wl12xx_acx_event_mbox_mask(wl, ~(wl->event_mask)); | 88 | ret = wl1251_acx_event_mbox_mask(wl, ~(wl->event_mask)); |
89 | if (ret < 0) | 89 | if (ret < 0) |
90 | return ret; | 90 | return ret; |
91 | 91 | ||
92 | return 0; | 92 | return 0; |
93 | } | 93 | } |
94 | 94 | ||
95 | void wl12xx_event_mbox_config(struct wl12xx *wl) | 95 | void wl1251_event_mbox_config(struct wl1251 *wl) |
96 | { | 96 | { |
97 | wl->mbox_ptr[0] = wl12xx_reg_read32(wl, REG_EVENT_MAILBOX_PTR); | 97 | wl->mbox_ptr[0] = wl1251_reg_read32(wl, REG_EVENT_MAILBOX_PTR); |
98 | wl->mbox_ptr[1] = wl->mbox_ptr[0] + sizeof(struct event_mailbox); | 98 | wl->mbox_ptr[1] = wl->mbox_ptr[0] + sizeof(struct event_mailbox); |
99 | 99 | ||
100 | wl12xx_debug(DEBUG_EVENT, "MBOX ptrs: 0x%x 0x%x", | 100 | wl1251_debug(DEBUG_EVENT, "MBOX ptrs: 0x%x 0x%x", |
101 | wl->mbox_ptr[0], wl->mbox_ptr[1]); | 101 | wl->mbox_ptr[0], wl->mbox_ptr[1]); |
102 | } | 102 | } |
103 | 103 | ||
104 | int wl12xx_event_handle(struct wl12xx *wl, u8 mbox_num) | 104 | int wl1251_event_handle(struct wl1251 *wl, u8 mbox_num) |
105 | { | 105 | { |
106 | struct event_mailbox mbox; | 106 | struct event_mailbox mbox; |
107 | int ret; | 107 | int ret; |
108 | 108 | ||
109 | wl12xx_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num); | 109 | wl1251_debug(DEBUG_EVENT, "EVENT on mbox %d", mbox_num); |
110 | 110 | ||
111 | if (mbox_num > 1) | 111 | if (mbox_num > 1) |
112 | return -EINVAL; | 112 | return -EINVAL; |
113 | 113 | ||
114 | /* first we read the mbox descriptor */ | 114 | /* first we read the mbox descriptor */ |
115 | wl12xx_spi_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox, | 115 | wl1251_spi_mem_read(wl, wl->mbox_ptr[mbox_num], &mbox, |
116 | sizeof(struct event_mailbox)); | 116 | sizeof(struct event_mailbox)); |
117 | 117 | ||
118 | /* process the descriptor */ | 118 | /* process the descriptor */ |
119 | ret = wl12xx_event_process(wl, &mbox); | 119 | ret = wl1251_event_process(wl, &mbox); |
120 | if (ret < 0) | 120 | if (ret < 0) |
121 | return ret; | 121 | return ret; |
122 | 122 | ||
123 | /* then we let the firmware know it can go on...*/ | 123 | /* then we let the firmware know it can go on...*/ |
124 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_EVENT_ACK); | 124 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_TRIG, INTR_TRIG_EVENT_ACK); |
125 | 125 | ||
126 | return 0; | 126 | return 0; |
127 | } | 127 | } |
diff --git a/drivers/net/wireless/wl12xx/event.h b/drivers/net/wireless/wl12xx/wl1251_event.h index 1f4c2f7438a7..be0ac54d6246 100644 --- a/drivers/net/wireless/wl12xx/event.h +++ b/drivers/net/wireless/wl12xx/wl1251_event.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -22,8 +22,8 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef __WL12XX_EVENT_H__ | 25 | #ifndef __WL1251_EVENT_H__ |
26 | #define __WL12XX_EVENT_H__ | 26 | #define __WL1251_EVENT_H__ |
27 | 27 | ||
28 | /* | 28 | /* |
29 | * Mbox events | 29 | * Mbox events |
@@ -114,8 +114,8 @@ struct event_mailbox { | |||
114 | u8 padding[19]; | 114 | u8 padding[19]; |
115 | } __attribute__ ((packed)); | 115 | } __attribute__ ((packed)); |
116 | 116 | ||
117 | int wl12xx_event_unmask(struct wl12xx *wl); | 117 | int wl1251_event_unmask(struct wl1251 *wl); |
118 | void wl12xx_event_mbox_config(struct wl12xx *wl); | 118 | void wl1251_event_mbox_config(struct wl1251 *wl); |
119 | int wl12xx_event_handle(struct wl12xx *wl, u8 mbox); | 119 | int wl1251_event_handle(struct wl1251 *wl, u8 mbox); |
120 | 120 | ||
121 | #endif | 121 | #endif |
diff --git a/drivers/net/wireless/wl12xx/init.c b/drivers/net/wireless/wl12xx/wl1251_init.c index 2a573a6010bd..df6c60f0fd66 100644 --- a/drivers/net/wireless/wl12xx/init.c +++ b/drivers/net/wireless/wl12xx/wl1251_init.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Nokia Corporation | 4 | * Copyright (C) 2009 Nokia Corporation |
5 | * | 5 | * |
@@ -24,64 +24,64 @@ | |||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | 26 | ||
27 | #include "init.h" | 27 | #include "wl1251_init.h" |
28 | #include "wl12xx_80211.h" | 28 | #include "wl12xx_80211.h" |
29 | #include "acx.h" | 29 | #include "wl1251_acx.h" |
30 | #include "cmd.h" | 30 | #include "wl1251_cmd.h" |
31 | 31 | ||
32 | int wl12xx_hw_init_hwenc_config(struct wl12xx *wl) | 32 | int wl1251_hw_init_hwenc_config(struct wl1251 *wl) |
33 | { | 33 | { |
34 | int ret; | 34 | int ret; |
35 | 35 | ||
36 | ret = wl12xx_acx_feature_cfg(wl); | 36 | ret = wl1251_acx_feature_cfg(wl); |
37 | if (ret < 0) { | 37 | if (ret < 0) { |
38 | wl12xx_warning("couldn't set feature config"); | 38 | wl1251_warning("couldn't set feature config"); |
39 | return ret; | 39 | return ret; |
40 | } | 40 | } |
41 | 41 | ||
42 | ret = wl12xx_acx_default_key(wl, wl->default_key); | 42 | ret = wl1251_acx_default_key(wl, wl->default_key); |
43 | if (ret < 0) { | 43 | if (ret < 0) { |
44 | wl12xx_warning("couldn't set default key"); | 44 | wl1251_warning("couldn't set default key"); |
45 | return ret; | 45 | return ret; |
46 | } | 46 | } |
47 | 47 | ||
48 | return 0; | 48 | return 0; |
49 | } | 49 | } |
50 | 50 | ||
51 | int wl12xx_hw_init_templates_config(struct wl12xx *wl) | 51 | int wl1251_hw_init_templates_config(struct wl1251 *wl) |
52 | { | 52 | { |
53 | int ret; | 53 | int ret; |
54 | u8 partial_vbm[PARTIAL_VBM_MAX]; | 54 | u8 partial_vbm[PARTIAL_VBM_MAX]; |
55 | 55 | ||
56 | /* send empty templates for fw memory reservation */ | 56 | /* send empty templates for fw memory reservation */ |
57 | ret = wl12xx_cmd_template_set(wl, CMD_PROBE_REQ, NULL, | 57 | ret = wl1251_cmd_template_set(wl, CMD_PROBE_REQ, NULL, |
58 | sizeof(struct wl12xx_probe_req_template)); | 58 | sizeof(struct wl12xx_probe_req_template)); |
59 | if (ret < 0) | 59 | if (ret < 0) |
60 | return ret; | 60 | return ret; |
61 | 61 | ||
62 | ret = wl12xx_cmd_template_set(wl, CMD_NULL_DATA, NULL, | 62 | ret = wl1251_cmd_template_set(wl, CMD_NULL_DATA, NULL, |
63 | sizeof(struct wl12xx_null_data_template)); | 63 | sizeof(struct wl12xx_null_data_template)); |
64 | if (ret < 0) | 64 | if (ret < 0) |
65 | return ret; | 65 | return ret; |
66 | 66 | ||
67 | ret = wl12xx_cmd_template_set(wl, CMD_PS_POLL, NULL, | 67 | ret = wl1251_cmd_template_set(wl, CMD_PS_POLL, NULL, |
68 | sizeof(struct wl12xx_ps_poll_template)); | 68 | sizeof(struct wl12xx_ps_poll_template)); |
69 | if (ret < 0) | 69 | if (ret < 0) |
70 | return ret; | 70 | return ret; |
71 | 71 | ||
72 | ret = wl12xx_cmd_template_set(wl, CMD_QOS_NULL_DATA, NULL, | 72 | ret = wl1251_cmd_template_set(wl, CMD_QOS_NULL_DATA, NULL, |
73 | sizeof | 73 | sizeof |
74 | (struct wl12xx_qos_null_data_template)); | 74 | (struct wl12xx_qos_null_data_template)); |
75 | if (ret < 0) | 75 | if (ret < 0) |
76 | return ret; | 76 | return ret; |
77 | 77 | ||
78 | ret = wl12xx_cmd_template_set(wl, CMD_PROBE_RESP, NULL, | 78 | ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, NULL, |
79 | sizeof | 79 | sizeof |
80 | (struct wl12xx_probe_resp_template)); | 80 | (struct wl12xx_probe_resp_template)); |
81 | if (ret < 0) | 81 | if (ret < 0) |
82 | return ret; | 82 | return ret; |
83 | 83 | ||
84 | ret = wl12xx_cmd_template_set(wl, CMD_BEACON, NULL, | 84 | ret = wl1251_cmd_template_set(wl, CMD_BEACON, NULL, |
85 | sizeof | 85 | sizeof |
86 | (struct wl12xx_beacon_template)); | 86 | (struct wl12xx_beacon_template)); |
87 | if (ret < 0) | 87 | if (ret < 0) |
@@ -89,112 +89,112 @@ int wl12xx_hw_init_templates_config(struct wl12xx *wl) | |||
89 | 89 | ||
90 | /* tim templates, first reserve space then allocate an empty one */ | 90 | /* tim templates, first reserve space then allocate an empty one */ |
91 | memset(partial_vbm, 0, PARTIAL_VBM_MAX); | 91 | memset(partial_vbm, 0, PARTIAL_VBM_MAX); |
92 | ret = wl12xx_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, PARTIAL_VBM_MAX, 0); | 92 | ret = wl1251_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, PARTIAL_VBM_MAX, 0); |
93 | if (ret < 0) | 93 | if (ret < 0) |
94 | return ret; | 94 | return ret; |
95 | 95 | ||
96 | ret = wl12xx_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, 1, 0); | 96 | ret = wl1251_cmd_vbm(wl, TIM_ELE_ID, partial_vbm, 1, 0); |
97 | if (ret < 0) | 97 | if (ret < 0) |
98 | return ret; | 98 | return ret; |
99 | 99 | ||
100 | return 0; | 100 | return 0; |
101 | } | 101 | } |
102 | 102 | ||
103 | int wl12xx_hw_init_rx_config(struct wl12xx *wl, u32 config, u32 filter) | 103 | int wl1251_hw_init_rx_config(struct wl1251 *wl, u32 config, u32 filter) |
104 | { | 104 | { |
105 | int ret; | 105 | int ret; |
106 | 106 | ||
107 | ret = wl12xx_acx_rx_msdu_life_time(wl, RX_MSDU_LIFETIME_DEF); | 107 | ret = wl1251_acx_rx_msdu_life_time(wl, RX_MSDU_LIFETIME_DEF); |
108 | if (ret < 0) | 108 | if (ret < 0) |
109 | return ret; | 109 | return ret; |
110 | 110 | ||
111 | ret = wl12xx_acx_rx_config(wl, config, filter); | 111 | ret = wl1251_acx_rx_config(wl, config, filter); |
112 | if (ret < 0) | 112 | if (ret < 0) |
113 | return ret; | 113 | return ret; |
114 | 114 | ||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | int wl12xx_hw_init_phy_config(struct wl12xx *wl) | 118 | int wl1251_hw_init_phy_config(struct wl1251 *wl) |
119 | { | 119 | { |
120 | int ret; | 120 | int ret; |
121 | 121 | ||
122 | ret = wl12xx_acx_pd_threshold(wl); | 122 | ret = wl1251_acx_pd_threshold(wl); |
123 | if (ret < 0) | 123 | if (ret < 0) |
124 | return ret; | 124 | return ret; |
125 | 125 | ||
126 | ret = wl12xx_acx_slot(wl, DEFAULT_SLOT_TIME); | 126 | ret = wl1251_acx_slot(wl, DEFAULT_SLOT_TIME); |
127 | if (ret < 0) | 127 | if (ret < 0) |
128 | return ret; | 128 | return ret; |
129 | 129 | ||
130 | ret = wl12xx_acx_group_address_tbl(wl); | 130 | ret = wl1251_acx_group_address_tbl(wl); |
131 | if (ret < 0) | 131 | if (ret < 0) |
132 | return ret; | 132 | return ret; |
133 | 133 | ||
134 | ret = wl12xx_acx_service_period_timeout(wl); | 134 | ret = wl1251_acx_service_period_timeout(wl); |
135 | if (ret < 0) | 135 | if (ret < 0) |
136 | return ret; | 136 | return ret; |
137 | 137 | ||
138 | ret = wl12xx_acx_rts_threshold(wl, RTS_THRESHOLD_DEF); | 138 | ret = wl1251_acx_rts_threshold(wl, RTS_THRESHOLD_DEF); |
139 | if (ret < 0) | 139 | if (ret < 0) |
140 | return ret; | 140 | return ret; |
141 | 141 | ||
142 | return 0; | 142 | return 0; |
143 | } | 143 | } |
144 | 144 | ||
145 | int wl12xx_hw_init_beacon_filter(struct wl12xx *wl) | 145 | int wl1251_hw_init_beacon_filter(struct wl1251 *wl) |
146 | { | 146 | { |
147 | int ret; | 147 | int ret; |
148 | 148 | ||
149 | ret = wl12xx_acx_beacon_filter_opt(wl); | 149 | ret = wl1251_acx_beacon_filter_opt(wl); |
150 | if (ret < 0) | 150 | if (ret < 0) |
151 | return ret; | 151 | return ret; |
152 | 152 | ||
153 | ret = wl12xx_acx_beacon_filter_table(wl); | 153 | ret = wl1251_acx_beacon_filter_table(wl); |
154 | if (ret < 0) | 154 | if (ret < 0) |
155 | return ret; | 155 | return ret; |
156 | 156 | ||
157 | return 0; | 157 | return 0; |
158 | } | 158 | } |
159 | 159 | ||
160 | int wl12xx_hw_init_pta(struct wl12xx *wl) | 160 | int wl1251_hw_init_pta(struct wl1251 *wl) |
161 | { | 161 | { |
162 | int ret; | 162 | int ret; |
163 | 163 | ||
164 | ret = wl12xx_acx_sg_enable(wl); | 164 | ret = wl1251_acx_sg_enable(wl); |
165 | if (ret < 0) | 165 | if (ret < 0) |
166 | return ret; | 166 | return ret; |
167 | 167 | ||
168 | ret = wl12xx_acx_sg_cfg(wl); | 168 | ret = wl1251_acx_sg_cfg(wl); |
169 | if (ret < 0) | 169 | if (ret < 0) |
170 | return ret; | 170 | return ret; |
171 | 171 | ||
172 | return 0; | 172 | return 0; |
173 | } | 173 | } |
174 | 174 | ||
175 | int wl12xx_hw_init_energy_detection(struct wl12xx *wl) | 175 | int wl1251_hw_init_energy_detection(struct wl1251 *wl) |
176 | { | 176 | { |
177 | int ret; | 177 | int ret; |
178 | 178 | ||
179 | ret = wl12xx_acx_cca_threshold(wl); | 179 | ret = wl1251_acx_cca_threshold(wl); |
180 | if (ret < 0) | 180 | if (ret < 0) |
181 | return ret; | 181 | return ret; |
182 | 182 | ||
183 | return 0; | 183 | return 0; |
184 | } | 184 | } |
185 | 185 | ||
186 | int wl12xx_hw_init_beacon_broadcast(struct wl12xx *wl) | 186 | int wl1251_hw_init_beacon_broadcast(struct wl1251 *wl) |
187 | { | 187 | { |
188 | int ret; | 188 | int ret; |
189 | 189 | ||
190 | ret = wl12xx_acx_bcn_dtim_options(wl); | 190 | ret = wl1251_acx_bcn_dtim_options(wl); |
191 | if (ret < 0) | 191 | if (ret < 0) |
192 | return ret; | 192 | return ret; |
193 | 193 | ||
194 | return 0; | 194 | return 0; |
195 | } | 195 | } |
196 | 196 | ||
197 | int wl12xx_hw_init_power_auth(struct wl12xx *wl) | 197 | int wl1251_hw_init_power_auth(struct wl1251 *wl) |
198 | { | 198 | { |
199 | return wl12xx_acx_sleep_auth(wl, WL12XX_PSM_CAM); | 199 | return wl1251_acx_sleep_auth(wl, WL1251_PSM_CAM); |
200 | } | 200 | } |
diff --git a/drivers/net/wireless/wl12xx/init.h b/drivers/net/wireless/wl12xx/wl1251_init.h index c8b6cd0b7c3e..8596188e834e 100644 --- a/drivers/net/wireless/wl12xx/init.h +++ b/drivers/net/wireless/wl12xx/wl1251_init.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2009 Nokia Corporation | 4 | * Copyright (C) 2009 Nokia Corporation |
5 | * | 5 | * |
@@ -21,20 +21,19 @@ | |||
21 | * | 21 | * |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #ifndef __WL12XX_INIT_H__ | 24 | #ifndef __WL1251_INIT_H__ |
25 | #define __WL12XX_INIT_H__ | 25 | #define __WL1251_INIT_H__ |
26 | 26 | ||
27 | #include "wl12xx.h" | 27 | #include "wl1251.h" |
28 | 28 | ||
29 | int wl12xx_hw_init_hwenc_config(struct wl12xx *wl); | 29 | int wl1251_hw_init_hwenc_config(struct wl1251 *wl); |
30 | int wl12xx_hw_init_templates_config(struct wl12xx *wl); | 30 | int wl1251_hw_init_templates_config(struct wl1251 *wl); |
31 | int wl12xx_hw_init_mem_config(struct wl12xx *wl); | 31 | int wl1251_hw_init_rx_config(struct wl1251 *wl, u32 config, u32 filter); |
32 | int wl12xx_hw_init_rx_config(struct wl12xx *wl, u32 config, u32 filter); | 32 | int wl1251_hw_init_phy_config(struct wl1251 *wl); |
33 | int wl12xx_hw_init_phy_config(struct wl12xx *wl); | 33 | int wl1251_hw_init_beacon_filter(struct wl1251 *wl); |
34 | int wl12xx_hw_init_beacon_filter(struct wl12xx *wl); | 34 | int wl1251_hw_init_pta(struct wl1251 *wl); |
35 | int wl12xx_hw_init_pta(struct wl12xx *wl); | 35 | int wl1251_hw_init_energy_detection(struct wl1251 *wl); |
36 | int wl12xx_hw_init_energy_detection(struct wl12xx *wl); | 36 | int wl1251_hw_init_beacon_broadcast(struct wl1251 *wl); |
37 | int wl12xx_hw_init_beacon_broadcast(struct wl12xx *wl); | 37 | int wl1251_hw_init_power_auth(struct wl1251 *wl); |
38 | int wl12xx_hw_init_power_auth(struct wl12xx *wl); | ||
39 | 38 | ||
40 | #endif | 39 | #endif |
diff --git a/drivers/net/wireless/wl12xx/main.c b/drivers/net/wireless/wl12xx/wl1251_main.c index 603d6114882e..cf5e0549fa14 100644 --- a/drivers/net/wireless/wl12xx/main.c +++ b/drivers/net/wireless/wl12xx/wl1251_main.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2008-2009 Nokia Corporation | 4 | * Copyright (C) 2008-2009 Nokia Corporation |
5 | * | 5 | * |
@@ -31,38 +31,38 @@ | |||
31 | #include <linux/etherdevice.h> | 31 | #include <linux/etherdevice.h> |
32 | #include <linux/spi/wl12xx.h> | 32 | #include <linux/spi/wl12xx.h> |
33 | 33 | ||
34 | #include "wl12xx.h" | 34 | #include "wl1251.h" |
35 | #include "wl12xx_80211.h" | 35 | #include "wl12xx_80211.h" |
36 | #include "reg.h" | 36 | #include "reg.h" |
37 | #include "wl1251.h" | 37 | #include "wl1251_ops.h" |
38 | #include "spi.h" | 38 | #include "wl1251_spi.h" |
39 | #include "event.h" | 39 | #include "wl1251_event.h" |
40 | #include "tx.h" | 40 | #include "wl1251_tx.h" |
41 | #include "rx.h" | 41 | #include "wl1251_rx.h" |
42 | #include "ps.h" | 42 | #include "wl1251_ps.h" |
43 | #include "init.h" | 43 | #include "wl1251_init.h" |
44 | #include "debugfs.h" | 44 | #include "wl1251_debugfs.h" |
45 | 45 | ||
46 | static void wl12xx_disable_interrupts(struct wl12xx *wl) | 46 | static void wl1251_disable_interrupts(struct wl1251 *wl) |
47 | { | 47 | { |
48 | disable_irq(wl->irq); | 48 | disable_irq(wl->irq); |
49 | } | 49 | } |
50 | 50 | ||
51 | static void wl12xx_power_off(struct wl12xx *wl) | 51 | static void wl1251_power_off(struct wl1251 *wl) |
52 | { | 52 | { |
53 | wl->set_power(false); | 53 | wl->set_power(false); |
54 | } | 54 | } |
55 | 55 | ||
56 | static void wl12xx_power_on(struct wl12xx *wl) | 56 | static void wl1251_power_on(struct wl1251 *wl) |
57 | { | 57 | { |
58 | wl->set_power(true); | 58 | wl->set_power(true); |
59 | } | 59 | } |
60 | 60 | ||
61 | static irqreturn_t wl12xx_irq(int irq, void *cookie) | 61 | static irqreturn_t wl1251_irq(int irq, void *cookie) |
62 | { | 62 | { |
63 | struct wl12xx *wl; | 63 | struct wl1251 *wl; |
64 | 64 | ||
65 | wl12xx_debug(DEBUG_IRQ, "IRQ"); | 65 | wl1251_debug(DEBUG_IRQ, "IRQ"); |
66 | 66 | ||
67 | wl = cookie; | 67 | wl = cookie; |
68 | 68 | ||
@@ -71,7 +71,7 @@ static irqreturn_t wl12xx_irq(int irq, void *cookie) | |||
71 | return IRQ_HANDLED; | 71 | return IRQ_HANDLED; |
72 | } | 72 | } |
73 | 73 | ||
74 | static int wl12xx_fetch_firmware(struct wl12xx *wl) | 74 | static int wl1251_fetch_firmware(struct wl1251 *wl) |
75 | { | 75 | { |
76 | const struct firmware *fw; | 76 | const struct firmware *fw; |
77 | int ret; | 77 | int ret; |
@@ -79,12 +79,12 @@ static int wl12xx_fetch_firmware(struct wl12xx *wl) | |||
79 | ret = request_firmware(&fw, wl->chip.fw_filename, &wl->spi->dev); | 79 | ret = request_firmware(&fw, wl->chip.fw_filename, &wl->spi->dev); |
80 | 80 | ||
81 | if (ret < 0) { | 81 | if (ret < 0) { |
82 | wl12xx_error("could not get firmware: %d", ret); | 82 | wl1251_error("could not get firmware: %d", ret); |
83 | return ret; | 83 | return ret; |
84 | } | 84 | } |
85 | 85 | ||
86 | if (fw->size % 4) { | 86 | if (fw->size % 4) { |
87 | wl12xx_error("firmware size is not multiple of 32 bits: %zu", | 87 | wl1251_error("firmware size is not multiple of 32 bits: %zu", |
88 | fw->size); | 88 | fw->size); |
89 | ret = -EILSEQ; | 89 | ret = -EILSEQ; |
90 | goto out; | 90 | goto out; |
@@ -94,7 +94,7 @@ static int wl12xx_fetch_firmware(struct wl12xx *wl) | |||
94 | wl->fw = kmalloc(wl->fw_len, GFP_KERNEL); | 94 | wl->fw = kmalloc(wl->fw_len, GFP_KERNEL); |
95 | 95 | ||
96 | if (!wl->fw) { | 96 | if (!wl->fw) { |
97 | wl12xx_error("could not allocate memory for the firmware"); | 97 | wl1251_error("could not allocate memory for the firmware"); |
98 | ret = -ENOMEM; | 98 | ret = -ENOMEM; |
99 | goto out; | 99 | goto out; |
100 | } | 100 | } |
@@ -109,7 +109,7 @@ out: | |||
109 | return ret; | 109 | return ret; |
110 | } | 110 | } |
111 | 111 | ||
112 | static int wl12xx_fetch_nvs(struct wl12xx *wl) | 112 | static int wl1251_fetch_nvs(struct wl1251 *wl) |
113 | { | 113 | { |
114 | const struct firmware *fw; | 114 | const struct firmware *fw; |
115 | int ret; | 115 | int ret; |
@@ -117,12 +117,12 @@ static int wl12xx_fetch_nvs(struct wl12xx *wl) | |||
117 | ret = request_firmware(&fw, wl->chip.nvs_filename, &wl->spi->dev); | 117 | ret = request_firmware(&fw, wl->chip.nvs_filename, &wl->spi->dev); |
118 | 118 | ||
119 | if (ret < 0) { | 119 | if (ret < 0) { |
120 | wl12xx_error("could not get nvs file: %d", ret); | 120 | wl1251_error("could not get nvs file: %d", ret); |
121 | return ret; | 121 | return ret; |
122 | } | 122 | } |
123 | 123 | ||
124 | if (fw->size % 4) { | 124 | if (fw->size % 4) { |
125 | wl12xx_error("nvs size is not multiple of 32 bits: %zu", | 125 | wl1251_error("nvs size is not multiple of 32 bits: %zu", |
126 | fw->size); | 126 | fw->size); |
127 | ret = -EILSEQ; | 127 | ret = -EILSEQ; |
128 | goto out; | 128 | goto out; |
@@ -132,7 +132,7 @@ static int wl12xx_fetch_nvs(struct wl12xx *wl) | |||
132 | wl->nvs = kmalloc(wl->nvs_len, GFP_KERNEL); | 132 | wl->nvs = kmalloc(wl->nvs_len, GFP_KERNEL); |
133 | 133 | ||
134 | if (!wl->nvs) { | 134 | if (!wl->nvs) { |
135 | wl12xx_error("could not allocate memory for the nvs file"); | 135 | wl1251_error("could not allocate memory for the nvs file"); |
136 | ret = -ENOMEM; | 136 | ret = -ENOMEM; |
137 | goto out; | 137 | goto out; |
138 | } | 138 | } |
@@ -147,74 +147,70 @@ out: | |||
147 | return ret; | 147 | return ret; |
148 | } | 148 | } |
149 | 149 | ||
150 | static void wl12xx_fw_wakeup(struct wl12xx *wl) | 150 | static void wl1251_fw_wakeup(struct wl1251 *wl) |
151 | { | 151 | { |
152 | u32 elp_reg; | 152 | u32 elp_reg; |
153 | 153 | ||
154 | elp_reg = ELPCTRL_WAKE_UP; | 154 | elp_reg = ELPCTRL_WAKE_UP; |
155 | wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); | 155 | wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); |
156 | elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); | 156 | elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); |
157 | 157 | ||
158 | if (!(elp_reg & ELPCTRL_WLAN_READY)) { | 158 | if (!(elp_reg & ELPCTRL_WLAN_READY)) |
159 | wl12xx_warning("WLAN not ready"); | 159 | wl1251_warning("WLAN not ready"); |
160 | elp_reg = ELPCTRL_WAKE_UP_WLAN_READY; | ||
161 | wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, elp_reg); | ||
162 | } | ||
163 | } | 160 | } |
164 | 161 | ||
165 | static int wl12xx_chip_wakeup(struct wl12xx *wl) | 162 | static int wl1251_chip_wakeup(struct wl1251 *wl) |
166 | { | 163 | { |
167 | int ret = 0; | 164 | int ret = 0; |
168 | 165 | ||
169 | wl12xx_power_on(wl); | 166 | wl1251_power_on(wl); |
170 | msleep(wl->chip.power_on_sleep); | 167 | msleep(wl->chip.power_on_sleep); |
171 | wl12xx_spi_reset(wl); | 168 | wl1251_spi_reset(wl); |
172 | wl12xx_spi_init(wl); | 169 | wl1251_spi_init(wl); |
173 | 170 | ||
174 | /* We don't need a real memory partition here, because we only want | 171 | /* We don't need a real memory partition here, because we only want |
175 | * to use the registers at this point. */ | 172 | * to use the registers at this point. */ |
176 | wl12xx_set_partition(wl, | 173 | wl1251_set_partition(wl, |
177 | 0x00000000, | 174 | 0x00000000, |
178 | 0x00000000, | 175 | 0x00000000, |
179 | REGISTERS_BASE, | 176 | REGISTERS_BASE, |
180 | REGISTERS_DOWN_SIZE); | 177 | REGISTERS_DOWN_SIZE); |
181 | 178 | ||
182 | /* ELP module wake up */ | 179 | /* ELP module wake up */ |
183 | wl12xx_fw_wakeup(wl); | 180 | wl1251_fw_wakeup(wl); |
184 | 181 | ||
185 | /* whal_FwCtrl_BootSm() */ | 182 | /* whal_FwCtrl_BootSm() */ |
186 | 183 | ||
187 | /* 0. read chip id from CHIP_ID */ | 184 | /* 0. read chip id from CHIP_ID */ |
188 | wl->chip.id = wl12xx_reg_read32(wl, CHIP_ID_B); | 185 | wl->chip.id = wl1251_reg_read32(wl, CHIP_ID_B); |
189 | 186 | ||
190 | /* 1. check if chip id is valid */ | 187 | /* 1. check if chip id is valid */ |
191 | 188 | ||
192 | switch (wl->chip.id) { | 189 | switch (wl->chip.id) { |
193 | case CHIP_ID_1251_PG12: | 190 | case CHIP_ID_1251_PG12: |
194 | wl12xx_debug(DEBUG_BOOT, "chip id 0x%x (1251 PG12)", | 191 | wl1251_debug(DEBUG_BOOT, "chip id 0x%x (1251 PG12)", |
195 | wl->chip.id); | 192 | wl->chip.id); |
196 | 193 | ||
197 | wl1251_setup(wl); | 194 | wl1251_setup(wl); |
198 | 195 | ||
199 | break; | 196 | break; |
200 | case CHIP_ID_1271_PG10: | ||
201 | case CHIP_ID_1251_PG10: | 197 | case CHIP_ID_1251_PG10: |
202 | case CHIP_ID_1251_PG11: | 198 | case CHIP_ID_1251_PG11: |
203 | default: | 199 | default: |
204 | wl12xx_error("unsupported chip id: 0x%x", wl->chip.id); | 200 | wl1251_error("unsupported chip id: 0x%x", wl->chip.id); |
205 | ret = -ENODEV; | 201 | ret = -ENODEV; |
206 | goto out; | 202 | goto out; |
207 | } | 203 | } |
208 | 204 | ||
209 | if (wl->fw == NULL) { | 205 | if (wl->fw == NULL) { |
210 | ret = wl12xx_fetch_firmware(wl); | 206 | ret = wl1251_fetch_firmware(wl); |
211 | if (ret < 0) | 207 | if (ret < 0) |
212 | goto out; | 208 | goto out; |
213 | } | 209 | } |
214 | 210 | ||
215 | /* No NVS from netlink, try to get it from the filesystem */ | 211 | /* No NVS from netlink, try to get it from the filesystem */ |
216 | if (wl->nvs == NULL) { | 212 | if (wl->nvs == NULL) { |
217 | ret = wl12xx_fetch_nvs(wl); | 213 | ret = wl1251_fetch_nvs(wl); |
218 | if (ret < 0) | 214 | if (ret < 0) |
219 | goto out; | 215 | goto out; |
220 | } | 216 | } |
@@ -223,40 +219,50 @@ out: | |||
223 | return ret; | 219 | return ret; |
224 | } | 220 | } |
225 | 221 | ||
226 | static void wl12xx_filter_work(struct work_struct *work) | 222 | static void wl1251_filter_work(struct work_struct *work) |
227 | { | 223 | { |
228 | struct wl12xx *wl = | 224 | struct wl1251 *wl = |
229 | container_of(work, struct wl12xx, filter_work); | 225 | container_of(work, struct wl1251, filter_work); |
230 | int ret; | 226 | int ret; |
231 | 227 | ||
232 | mutex_lock(&wl->mutex); | 228 | mutex_lock(&wl->mutex); |
233 | 229 | ||
234 | if (wl->state == WL12XX_STATE_OFF) | 230 | if (wl->state == WL1251_STATE_OFF) |
235 | goto out; | 231 | goto out; |
236 | 232 | ||
237 | ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0); | 233 | ret = wl1251_ps_elp_wakeup(wl); |
238 | if (ret < 0) | 234 | if (ret < 0) |
239 | goto out; | 235 | goto out; |
240 | 236 | ||
237 | /* FIXME: replace the magic numbers with proper definitions */ | ||
238 | ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0); | ||
239 | if (ret < 0) | ||
240 | goto out_sleep; | ||
241 | |||
242 | out_sleep: | ||
243 | wl1251_ps_elp_sleep(wl); | ||
244 | |||
241 | out: | 245 | out: |
242 | mutex_unlock(&wl->mutex); | 246 | mutex_unlock(&wl->mutex); |
243 | } | 247 | } |
244 | 248 | ||
245 | int wl12xx_plt_start(struct wl12xx *wl) | 249 | int wl1251_plt_start(struct wl1251 *wl) |
246 | { | 250 | { |
247 | int ret; | 251 | int ret; |
248 | 252 | ||
249 | wl12xx_notice("power up"); | 253 | mutex_lock(&wl->mutex); |
254 | |||
255 | wl1251_notice("power up"); | ||
250 | 256 | ||
251 | if (wl->state != WL12XX_STATE_OFF) { | 257 | if (wl->state != WL1251_STATE_OFF) { |
252 | wl12xx_error("cannot go into PLT state because not " | 258 | wl1251_error("cannot go into PLT state because not " |
253 | "in off state: %d", wl->state); | 259 | "in off state: %d", wl->state); |
254 | return -EBUSY; | 260 | return -EBUSY; |
255 | } | 261 | } |
256 | 262 | ||
257 | wl->state = WL12XX_STATE_PLT; | 263 | wl->state = WL1251_STATE_PLT; |
258 | 264 | ||
259 | ret = wl12xx_chip_wakeup(wl); | 265 | ret = wl1251_chip_wakeup(wl); |
260 | if (ret < 0) | 266 | if (ret < 0) |
261 | return ret; | 267 | return ret; |
262 | 268 | ||
@@ -264,7 +270,7 @@ int wl12xx_plt_start(struct wl12xx *wl) | |||
264 | if (ret < 0) | 270 | if (ret < 0) |
265 | return ret; | 271 | return ret; |
266 | 272 | ||
267 | wl12xx_notice("firmware booted in PLT mode (%s)", wl->chip.fw_ver); | 273 | wl1251_notice("firmware booted in PLT mode (%s)", wl->chip.fw_ver); |
268 | 274 | ||
269 | ret = wl->chip.op_plt_init(wl); | 275 | ret = wl->chip.op_plt_init(wl); |
270 | if (ret < 0) | 276 | if (ret < 0) |
@@ -273,38 +279,45 @@ int wl12xx_plt_start(struct wl12xx *wl) | |||
273 | return 0; | 279 | return 0; |
274 | } | 280 | } |
275 | 281 | ||
276 | int wl12xx_plt_stop(struct wl12xx *wl) | 282 | int wl1251_plt_stop(struct wl1251 *wl) |
277 | { | 283 | { |
278 | wl12xx_notice("power down"); | 284 | mutex_lock(&wl->mutex); |
285 | |||
286 | wl1251_notice("power down"); | ||
279 | 287 | ||
280 | if (wl->state != WL12XX_STATE_PLT) { | 288 | if (wl->state != WL1251_STATE_PLT) { |
281 | wl12xx_error("cannot power down because not in PLT " | 289 | wl1251_error("cannot power down because not in PLT " |
282 | "state: %d", wl->state); | 290 | "state: %d", wl->state); |
283 | return -EBUSY; | 291 | return -EBUSY; |
284 | } | 292 | } |
285 | 293 | ||
286 | wl12xx_disable_interrupts(wl); | 294 | wl1251_disable_interrupts(wl); |
287 | wl12xx_power_off(wl); | 295 | wl1251_power_off(wl); |
288 | 296 | ||
289 | wl->state = WL12XX_STATE_OFF; | 297 | wl->state = WL1251_STATE_OFF; |
290 | 298 | ||
291 | return 0; | 299 | return 0; |
292 | } | 300 | } |
293 | 301 | ||
294 | 302 | ||
295 | static int wl12xx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | 303 | static int wl1251_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) |
296 | { | 304 | { |
297 | struct wl12xx *wl = hw->priv; | 305 | struct wl1251 *wl = hw->priv; |
298 | 306 | ||
299 | skb_queue_tail(&wl->tx_queue, skb); | 307 | skb_queue_tail(&wl->tx_queue, skb); |
300 | 308 | ||
309 | /* | ||
310 | * The chip specific setup must run before the first TX packet - | ||
311 | * before that, the tx_work will not be initialized! | ||
312 | */ | ||
313 | |||
301 | schedule_work(&wl->tx_work); | 314 | schedule_work(&wl->tx_work); |
302 | 315 | ||
303 | /* | 316 | /* |
304 | * The workqueue is slow to process the tx_queue and we need stop | 317 | * The workqueue is slow to process the tx_queue and we need stop |
305 | * the queue here, otherwise the queue will get too long. | 318 | * the queue here, otherwise the queue will get too long. |
306 | */ | 319 | */ |
307 | if (skb_queue_len(&wl->tx_queue) >= WL12XX_TX_QUEUE_MAX_LENGTH) { | 320 | if (skb_queue_len(&wl->tx_queue) >= WL1251_TX_QUEUE_MAX_LENGTH) { |
308 | ieee80211_stop_queues(wl->hw); | 321 | ieee80211_stop_queues(wl->hw); |
309 | 322 | ||
310 | /* | 323 | /* |
@@ -318,23 +331,23 @@ static int wl12xx_op_tx(struct ieee80211_hw *hw, struct sk_buff *skb) | |||
318 | return NETDEV_TX_OK; | 331 | return NETDEV_TX_OK; |
319 | } | 332 | } |
320 | 333 | ||
321 | static int wl12xx_op_start(struct ieee80211_hw *hw) | 334 | static int wl1251_op_start(struct ieee80211_hw *hw) |
322 | { | 335 | { |
323 | struct wl12xx *wl = hw->priv; | 336 | struct wl1251 *wl = hw->priv; |
324 | int ret = 0; | 337 | int ret = 0; |
325 | 338 | ||
326 | wl12xx_debug(DEBUG_MAC80211, "mac80211 start"); | 339 | wl1251_debug(DEBUG_MAC80211, "mac80211 start"); |
327 | 340 | ||
328 | mutex_lock(&wl->mutex); | 341 | mutex_lock(&wl->mutex); |
329 | 342 | ||
330 | if (wl->state != WL12XX_STATE_OFF) { | 343 | if (wl->state != WL1251_STATE_OFF) { |
331 | wl12xx_error("cannot start because not in off state: %d", | 344 | wl1251_error("cannot start because not in off state: %d", |
332 | wl->state); | 345 | wl->state); |
333 | ret = -EBUSY; | 346 | ret = -EBUSY; |
334 | goto out; | 347 | goto out; |
335 | } | 348 | } |
336 | 349 | ||
337 | ret = wl12xx_chip_wakeup(wl); | 350 | ret = wl1251_chip_wakeup(wl); |
338 | if (ret < 0) | 351 | if (ret < 0) |
339 | return ret; | 352 | return ret; |
340 | 353 | ||
@@ -346,34 +359,34 @@ static int wl12xx_op_start(struct ieee80211_hw *hw) | |||
346 | if (ret < 0) | 359 | if (ret < 0) |
347 | goto out; | 360 | goto out; |
348 | 361 | ||
349 | ret = wl12xx_acx_station_id(wl); | 362 | ret = wl1251_acx_station_id(wl); |
350 | if (ret < 0) | 363 | if (ret < 0) |
351 | goto out; | 364 | goto out; |
352 | 365 | ||
353 | wl->state = WL12XX_STATE_ON; | 366 | wl->state = WL1251_STATE_ON; |
354 | 367 | ||
355 | wl12xx_info("firmware booted (%s)", wl->chip.fw_ver); | 368 | wl1251_info("firmware booted (%s)", wl->chip.fw_ver); |
356 | 369 | ||
357 | out: | 370 | out: |
358 | if (ret < 0) | 371 | if (ret < 0) |
359 | wl12xx_power_off(wl); | 372 | wl1251_power_off(wl); |
360 | 373 | ||
361 | mutex_unlock(&wl->mutex); | 374 | mutex_unlock(&wl->mutex); |
362 | 375 | ||
363 | return ret; | 376 | return ret; |
364 | } | 377 | } |
365 | 378 | ||
366 | static void wl12xx_op_stop(struct ieee80211_hw *hw) | 379 | static void wl1251_op_stop(struct ieee80211_hw *hw) |
367 | { | 380 | { |
368 | struct wl12xx *wl = hw->priv; | 381 | struct wl1251 *wl = hw->priv; |
369 | 382 | ||
370 | wl12xx_info("down"); | 383 | wl1251_info("down"); |
371 | 384 | ||
372 | wl12xx_debug(DEBUG_MAC80211, "mac80211 stop"); | 385 | wl1251_debug(DEBUG_MAC80211, "mac80211 stop"); |
373 | 386 | ||
374 | mutex_lock(&wl->mutex); | 387 | mutex_lock(&wl->mutex); |
375 | 388 | ||
376 | WARN_ON(wl->state != WL12XX_STATE_ON); | 389 | WARN_ON(wl->state != WL1251_STATE_ON); |
377 | 390 | ||
378 | if (wl->scanning) { | 391 | if (wl->scanning) { |
379 | mutex_unlock(&wl->mutex); | 392 | mutex_unlock(&wl->mutex); |
@@ -382,9 +395,9 @@ static void wl12xx_op_stop(struct ieee80211_hw *hw) | |||
382 | wl->scanning = false; | 395 | wl->scanning = false; |
383 | } | 396 | } |
384 | 397 | ||
385 | wl->state = WL12XX_STATE_OFF; | 398 | wl->state = WL1251_STATE_OFF; |
386 | 399 | ||
387 | wl12xx_disable_interrupts(wl); | 400 | wl1251_disable_interrupts(wl); |
388 | 401 | ||
389 | mutex_unlock(&wl->mutex); | 402 | mutex_unlock(&wl->mutex); |
390 | 403 | ||
@@ -395,9 +408,8 @@ static void wl12xx_op_stop(struct ieee80211_hw *hw) | |||
395 | mutex_lock(&wl->mutex); | 408 | mutex_lock(&wl->mutex); |
396 | 409 | ||
397 | /* let's notify MAC80211 about the remaining pending TX frames */ | 410 | /* let's notify MAC80211 about the remaining pending TX frames */ |
398 | wl12xx_tx_flush(wl); | 411 | wl->chip.op_tx_flush(wl); |
399 | 412 | wl1251_power_off(wl); | |
400 | wl12xx_power_off(wl); | ||
401 | 413 | ||
402 | memset(wl->bssid, 0, ETH_ALEN); | 414 | memset(wl->bssid, 0, ETH_ALEN); |
403 | wl->listen_int = 1; | 415 | wl->listen_int = 1; |
@@ -412,21 +424,21 @@ static void wl12xx_op_stop(struct ieee80211_hw *hw) | |||
412 | wl->elp = false; | 424 | wl->elp = false; |
413 | wl->psm = 0; | 425 | wl->psm = 0; |
414 | wl->tx_queue_stopped = false; | 426 | wl->tx_queue_stopped = false; |
415 | wl->power_level = WL12XX_DEFAULT_POWER_LEVEL; | 427 | wl->power_level = WL1251_DEFAULT_POWER_LEVEL; |
416 | 428 | ||
417 | wl12xx_debugfs_reset(wl); | 429 | wl1251_debugfs_reset(wl); |
418 | 430 | ||
419 | mutex_unlock(&wl->mutex); | 431 | mutex_unlock(&wl->mutex); |
420 | } | 432 | } |
421 | 433 | ||
422 | static int wl12xx_op_add_interface(struct ieee80211_hw *hw, | 434 | static int wl1251_op_add_interface(struct ieee80211_hw *hw, |
423 | struct ieee80211_if_init_conf *conf) | 435 | struct ieee80211_if_init_conf *conf) |
424 | { | 436 | { |
425 | struct wl12xx *wl = hw->priv; | 437 | struct wl1251 *wl = hw->priv; |
426 | DECLARE_MAC_BUF(mac); | 438 | DECLARE_MAC_BUF(mac); |
427 | int ret = 0; | 439 | int ret = 0; |
428 | 440 | ||
429 | wl12xx_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %s", | 441 | wl1251_debug(DEBUG_MAC80211, "mac80211 add interface type %d mac %s", |
430 | conf->type, print_mac(mac, conf->mac_addr)); | 442 | conf->type, print_mac(mac, conf->mac_addr)); |
431 | 443 | ||
432 | mutex_lock(&wl->mutex); | 444 | mutex_lock(&wl->mutex); |
@@ -446,7 +458,7 @@ static int wl12xx_op_add_interface(struct ieee80211_hw *hw, | |||
446 | if (memcmp(wl->mac_addr, conf->mac_addr, ETH_ALEN)) { | 458 | if (memcmp(wl->mac_addr, conf->mac_addr, ETH_ALEN)) { |
447 | memcpy(wl->mac_addr, conf->mac_addr, ETH_ALEN); | 459 | memcpy(wl->mac_addr, conf->mac_addr, ETH_ALEN); |
448 | SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr); | 460 | SET_IEEE80211_PERM_ADDR(wl->hw, wl->mac_addr); |
449 | ret = wl12xx_acx_station_id(wl); | 461 | ret = wl1251_acx_station_id(wl); |
450 | if (ret < 0) | 462 | if (ret < 0) |
451 | goto out; | 463 | goto out; |
452 | } | 464 | } |
@@ -456,13 +468,13 @@ out: | |||
456 | return ret; | 468 | return ret; |
457 | } | 469 | } |
458 | 470 | ||
459 | static void wl12xx_op_remove_interface(struct ieee80211_hw *hw, | 471 | static void wl1251_op_remove_interface(struct ieee80211_hw *hw, |
460 | struct ieee80211_if_init_conf *conf) | 472 | struct ieee80211_if_init_conf *conf) |
461 | { | 473 | { |
462 | wl12xx_debug(DEBUG_MAC80211, "mac80211 remove interface"); | 474 | wl1251_debug(DEBUG_MAC80211, "mac80211 remove interface"); |
463 | } | 475 | } |
464 | 476 | ||
465 | static int wl12xx_build_null_data(struct wl12xx *wl) | 477 | static int wl1251_build_null_data(struct wl1251 *wl) |
466 | { | 478 | { |
467 | struct wl12xx_null_data_template template; | 479 | struct wl12xx_null_data_template template; |
468 | 480 | ||
@@ -478,12 +490,12 @@ static int wl12xx_build_null_data(struct wl12xx *wl) | |||
478 | template.header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | | 490 | template.header.frame_ctl = cpu_to_le16(IEEE80211_FTYPE_DATA | |
479 | IEEE80211_STYPE_NULLFUNC); | 491 | IEEE80211_STYPE_NULLFUNC); |
480 | 492 | ||
481 | return wl12xx_cmd_template_set(wl, CMD_NULL_DATA, &template, | 493 | return wl1251_cmd_template_set(wl, CMD_NULL_DATA, &template, |
482 | sizeof(template)); | 494 | sizeof(template)); |
483 | 495 | ||
484 | } | 496 | } |
485 | 497 | ||
486 | static int wl12xx_build_ps_poll(struct wl12xx *wl, u16 aid) | 498 | static int wl1251_build_ps_poll(struct wl1251 *wl, u16 aid) |
487 | { | 499 | { |
488 | struct wl12xx_ps_poll_template template; | 500 | struct wl12xx_ps_poll_template template; |
489 | 501 | ||
@@ -492,41 +504,45 @@ static int wl12xx_build_ps_poll(struct wl12xx *wl, u16 aid) | |||
492 | template.aid = aid; | 504 | template.aid = aid; |
493 | template.fc = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); | 505 | template.fc = cpu_to_le16(IEEE80211_FTYPE_CTL | IEEE80211_STYPE_PSPOLL); |
494 | 506 | ||
495 | return wl12xx_cmd_template_set(wl, CMD_PS_POLL, &template, | 507 | return wl1251_cmd_template_set(wl, CMD_PS_POLL, &template, |
496 | sizeof(template)); | 508 | sizeof(template)); |
497 | 509 | ||
498 | } | 510 | } |
499 | 511 | ||
500 | static int wl12xx_op_config(struct ieee80211_hw *hw, u32 changed) | 512 | static int wl1251_op_config(struct ieee80211_hw *hw, u32 changed) |
501 | { | 513 | { |
502 | struct wl12xx *wl = hw->priv; | 514 | struct wl1251 *wl = hw->priv; |
503 | struct ieee80211_conf *conf = &hw->conf; | 515 | struct ieee80211_conf *conf = &hw->conf; |
504 | int channel, ret = 0; | 516 | int channel, ret = 0; |
505 | 517 | ||
506 | channel = ieee80211_frequency_to_channel(conf->channel->center_freq); | 518 | channel = ieee80211_frequency_to_channel(conf->channel->center_freq); |
507 | 519 | ||
508 | wl12xx_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d", | 520 | wl1251_debug(DEBUG_MAC80211, "mac80211 config ch %d psm %s power %d", |
509 | channel, | 521 | channel, |
510 | conf->flags & IEEE80211_CONF_PS ? "on" : "off", | 522 | conf->flags & IEEE80211_CONF_PS ? "on" : "off", |
511 | conf->power_level); | 523 | conf->power_level); |
512 | 524 | ||
513 | mutex_lock(&wl->mutex); | 525 | mutex_lock(&wl->mutex); |
514 | 526 | ||
527 | ret = wl1251_ps_elp_wakeup(wl); | ||
528 | if (ret < 0) | ||
529 | goto out; | ||
530 | |||
515 | if (channel != wl->channel) { | 531 | if (channel != wl->channel) { |
516 | /* FIXME: use beacon interval provided by mac80211 */ | 532 | /* FIXME: use beacon interval provided by mac80211 */ |
517 | ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0); | 533 | ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0); |
518 | if (ret < 0) | 534 | if (ret < 0) |
519 | goto out; | 535 | goto out_sleep; |
520 | 536 | ||
521 | wl->channel = channel; | 537 | wl->channel = channel; |
522 | } | 538 | } |
523 | 539 | ||
524 | ret = wl12xx_build_null_data(wl); | 540 | ret = wl1251_build_null_data(wl); |
525 | if (ret < 0) | 541 | if (ret < 0) |
526 | goto out; | 542 | goto out_sleep; |
527 | 543 | ||
528 | if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) { | 544 | if (conf->flags & IEEE80211_CONF_PS && !wl->psm_requested) { |
529 | wl12xx_info("psm enabled"); | 545 | wl1251_debug(DEBUG_PSM, "psm enabled"); |
530 | 546 | ||
531 | wl->psm_requested = true; | 547 | wl->psm_requested = true; |
532 | 548 | ||
@@ -535,49 +551,53 @@ static int wl12xx_op_config(struct ieee80211_hw *hw, u32 changed) | |||
535 | * If we're not, we'll enter it when joining an SSID, | 551 | * If we're not, we'll enter it when joining an SSID, |
536 | * through the bss_info_changed() hook. | 552 | * through the bss_info_changed() hook. |
537 | */ | 553 | */ |
538 | ret = wl12xx_ps_set_mode(wl, STATION_POWER_SAVE_MODE); | 554 | ret = wl1251_ps_set_mode(wl, STATION_POWER_SAVE_MODE); |
539 | } else if (!(conf->flags & IEEE80211_CONF_PS) && | 555 | } else if (!(conf->flags & IEEE80211_CONF_PS) && |
540 | wl->psm_requested) { | 556 | wl->psm_requested) { |
541 | wl12xx_info("psm disabled"); | 557 | wl1251_debug(DEBUG_PSM, "psm disabled"); |
542 | 558 | ||
543 | wl->psm_requested = false; | 559 | wl->psm_requested = false; |
544 | 560 | ||
545 | if (wl->psm) | 561 | if (wl->psm) |
546 | ret = wl12xx_ps_set_mode(wl, STATION_ACTIVE_MODE); | 562 | ret = wl1251_ps_set_mode(wl, STATION_ACTIVE_MODE); |
547 | } | 563 | } |
548 | 564 | ||
549 | if (conf->power_level != wl->power_level) { | 565 | if (conf->power_level != wl->power_level) { |
550 | ret = wl12xx_acx_tx_power(wl, conf->power_level); | 566 | ret = wl1251_acx_tx_power(wl, conf->power_level); |
551 | if (ret < 0) | 567 | if (ret < 0) |
552 | goto out; | 568 | goto out; |
553 | 569 | ||
554 | wl->power_level = conf->power_level; | 570 | wl->power_level = conf->power_level; |
555 | } | 571 | } |
556 | 572 | ||
573 | out_sleep: | ||
574 | wl1251_ps_elp_sleep(wl); | ||
575 | |||
557 | out: | 576 | out: |
558 | mutex_unlock(&wl->mutex); | 577 | mutex_unlock(&wl->mutex); |
578 | |||
559 | return ret; | 579 | return ret; |
560 | } | 580 | } |
561 | 581 | ||
562 | #define WL12XX_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \ | 582 | #define WL1251_SUPPORTED_FILTERS (FIF_PROMISC_IN_BSS | \ |
563 | FIF_ALLMULTI | \ | 583 | FIF_ALLMULTI | \ |
564 | FIF_FCSFAIL | \ | 584 | FIF_FCSFAIL | \ |
565 | FIF_BCN_PRBRESP_PROMISC | \ | 585 | FIF_BCN_PRBRESP_PROMISC | \ |
566 | FIF_CONTROL | \ | 586 | FIF_CONTROL | \ |
567 | FIF_OTHER_BSS) | 587 | FIF_OTHER_BSS) |
568 | 588 | ||
569 | static void wl12xx_op_configure_filter(struct ieee80211_hw *hw, | 589 | static void wl1251_op_configure_filter(struct ieee80211_hw *hw, |
570 | unsigned int changed, | 590 | unsigned int changed, |
571 | unsigned int *total, | 591 | unsigned int *total, |
572 | int mc_count, | 592 | int mc_count, |
573 | struct dev_addr_list *mc_list) | 593 | struct dev_addr_list *mc_list) |
574 | { | 594 | { |
575 | struct wl12xx *wl = hw->priv; | 595 | struct wl1251 *wl = hw->priv; |
576 | 596 | ||
577 | wl12xx_debug(DEBUG_MAC80211, "mac80211 configure filter"); | 597 | wl1251_debug(DEBUG_MAC80211, "mac80211 configure filter"); |
578 | 598 | ||
579 | *total &= WL12XX_SUPPORTED_FILTERS; | 599 | *total &= WL1251_SUPPORTED_FILTERS; |
580 | changed &= WL12XX_SUPPORTED_FILTERS; | 600 | changed &= WL1251_SUPPORTED_FILTERS; |
581 | 601 | ||
582 | if (changed == 0) | 602 | if (changed == 0) |
583 | /* no filters which we support changed */ | 603 | /* no filters which we support changed */ |
@@ -585,8 +605,8 @@ static void wl12xx_op_configure_filter(struct ieee80211_hw *hw, | |||
585 | 605 | ||
586 | /* FIXME: wl->rx_config and wl->rx_filter are not protected */ | 606 | /* FIXME: wl->rx_config and wl->rx_filter are not protected */ |
587 | 607 | ||
588 | wl->rx_config = WL12XX_DEFAULT_RX_CONFIG; | 608 | wl->rx_config = WL1251_DEFAULT_RX_CONFIG; |
589 | wl->rx_filter = WL12XX_DEFAULT_RX_FILTER; | 609 | wl->rx_filter = WL1251_DEFAULT_RX_FILTER; |
590 | 610 | ||
591 | if (*total & FIF_PROMISC_IN_BSS) { | 611 | if (*total & FIF_PROMISC_IN_BSS) { |
592 | wl->rx_config |= CFG_BSSID_FILTER_EN; | 612 | wl->rx_config |= CFG_BSSID_FILTER_EN; |
@@ -618,7 +638,8 @@ static void wl12xx_op_configure_filter(struct ieee80211_hw *hw, | |||
618 | } | 638 | } |
619 | 639 | ||
620 | /* HW encryption */ | 640 | /* HW encryption */ |
621 | static int wl12xx_set_key_type(struct wl12xx *wl, struct acx_set_key *key, | 641 | static int wl1251_set_key_type(struct wl1251 *wl, |
642 | struct wl1251_cmd_set_keys *key, | ||
622 | enum set_key_cmd cmd, | 643 | enum set_key_cmd cmd, |
623 | struct ieee80211_key_conf *mac80211_key, | 644 | struct ieee80211_key_conf *mac80211_key, |
624 | const u8 *addr) | 645 | const u8 *addr) |
@@ -648,95 +669,116 @@ static int wl12xx_set_key_type(struct wl12xx *wl, struct acx_set_key *key, | |||
648 | mac80211_key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; | 669 | mac80211_key->flags |= IEEE80211_KEY_FLAG_GENERATE_IV; |
649 | break; | 670 | break; |
650 | default: | 671 | default: |
651 | wl12xx_error("Unknown key algo 0x%x", mac80211_key->alg); | 672 | wl1251_error("Unknown key algo 0x%x", mac80211_key->alg); |
652 | return -EOPNOTSUPP; | 673 | return -EOPNOTSUPP; |
653 | } | 674 | } |
654 | 675 | ||
655 | return 0; | 676 | return 0; |
656 | } | 677 | } |
657 | 678 | ||
658 | static int wl12xx_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, | 679 | static int wl1251_op_set_key(struct ieee80211_hw *hw, enum set_key_cmd cmd, |
659 | struct ieee80211_vif *vif, | 680 | struct ieee80211_vif *vif, |
660 | struct ieee80211_sta *sta, | 681 | struct ieee80211_sta *sta, |
661 | struct ieee80211_key_conf *key) | 682 | struct ieee80211_key_conf *key) |
662 | { | 683 | { |
663 | struct wl12xx *wl = hw->priv; | 684 | struct wl1251 *wl = hw->priv; |
664 | struct acx_set_key wl_key; | 685 | struct wl1251_cmd_set_keys *wl_cmd; |
665 | const u8 *addr; | 686 | const u8 *addr; |
666 | int ret; | 687 | int ret; |
667 | 688 | ||
668 | static const u8 bcast_addr[ETH_ALEN] = | 689 | static const u8 bcast_addr[ETH_ALEN] = |
669 | { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; | 690 | { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; |
670 | 691 | ||
671 | wl12xx_debug(DEBUG_MAC80211, "mac80211 set key"); | 692 | wl1251_debug(DEBUG_MAC80211, "mac80211 set key"); |
672 | 693 | ||
673 | memset(&wl_key, 0, sizeof(wl_key)); | 694 | wl_cmd = kzalloc(sizeof(*wl_cmd), GFP_KERNEL); |
695 | if (!wl_cmd) { | ||
696 | ret = -ENOMEM; | ||
697 | goto out; | ||
698 | } | ||
674 | 699 | ||
675 | addr = sta ? sta->addr : bcast_addr; | 700 | addr = sta ? sta->addr : bcast_addr; |
676 | 701 | ||
677 | wl12xx_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd); | 702 | wl1251_debug(DEBUG_CRYPT, "CMD: 0x%x", cmd); |
678 | wl12xx_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN); | 703 | wl1251_dump(DEBUG_CRYPT, "ADDR: ", addr, ETH_ALEN); |
679 | wl12xx_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x", | 704 | wl1251_debug(DEBUG_CRYPT, "Key: algo:0x%x, id:%d, len:%d flags 0x%x", |
680 | key->alg, key->keyidx, key->keylen, key->flags); | 705 | key->alg, key->keyidx, key->keylen, key->flags); |
681 | wl12xx_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen); | 706 | wl1251_dump(DEBUG_CRYPT, "KEY: ", key->key, key->keylen); |
707 | |||
708 | if (is_zero_ether_addr(addr)) { | ||
709 | /* We dont support TX only encryption */ | ||
710 | ret = -EOPNOTSUPP; | ||
711 | goto out; | ||
712 | } | ||
682 | 713 | ||
683 | mutex_lock(&wl->mutex); | 714 | mutex_lock(&wl->mutex); |
684 | 715 | ||
716 | ret = wl1251_ps_elp_wakeup(wl); | ||
717 | if (ret < 0) | ||
718 | goto out_unlock; | ||
719 | |||
685 | switch (cmd) { | 720 | switch (cmd) { |
686 | case SET_KEY: | 721 | case SET_KEY: |
687 | wl_key.key_action = KEY_ADD_OR_REPLACE; | 722 | wl_cmd->key_action = KEY_ADD_OR_REPLACE; |
688 | break; | 723 | break; |
689 | case DISABLE_KEY: | 724 | case DISABLE_KEY: |
690 | wl_key.key_action = KEY_REMOVE; | 725 | wl_cmd->key_action = KEY_REMOVE; |
691 | break; | 726 | break; |
692 | default: | 727 | default: |
693 | wl12xx_error("Unsupported key cmd 0x%x", cmd); | 728 | wl1251_error("Unsupported key cmd 0x%x", cmd); |
694 | break; | 729 | break; |
695 | } | 730 | } |
696 | 731 | ||
697 | ret = wl12xx_set_key_type(wl, &wl_key, cmd, key, addr); | 732 | ret = wl1251_set_key_type(wl, wl_cmd, cmd, key, addr); |
698 | if (ret < 0) { | 733 | if (ret < 0) { |
699 | wl12xx_error("Set KEY type failed"); | 734 | wl1251_error("Set KEY type failed"); |
700 | goto out; | 735 | goto out_sleep; |
701 | } | 736 | } |
702 | 737 | ||
703 | if (wl_key.key_type != KEY_WEP_DEFAULT) | 738 | if (wl_cmd->key_type != KEY_WEP_DEFAULT) |
704 | memcpy(wl_key.addr, addr, ETH_ALEN); | 739 | memcpy(wl_cmd->addr, addr, ETH_ALEN); |
705 | 740 | ||
706 | if ((wl_key.key_type == KEY_TKIP_MIC_GROUP) || | 741 | if ((wl_cmd->key_type == KEY_TKIP_MIC_GROUP) || |
707 | (wl_key.key_type == KEY_TKIP_MIC_PAIRWISE)) { | 742 | (wl_cmd->key_type == KEY_TKIP_MIC_PAIRWISE)) { |
708 | /* | 743 | /* |
709 | * We get the key in the following form: | 744 | * We get the key in the following form: |
710 | * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes) | 745 | * TKIP (16 bytes) - TX MIC (8 bytes) - RX MIC (8 bytes) |
711 | * but the target is expecting: | 746 | * but the target is expecting: |
712 | * TKIP - RX MIC - TX MIC | 747 | * TKIP - RX MIC - TX MIC |
713 | */ | 748 | */ |
714 | memcpy(wl_key.key, key->key, 16); | 749 | memcpy(wl_cmd->key, key->key, 16); |
715 | memcpy(wl_key.key + 16, key->key + 24, 8); | 750 | memcpy(wl_cmd->key + 16, key->key + 24, 8); |
716 | memcpy(wl_key.key + 24, key->key + 16, 8); | 751 | memcpy(wl_cmd->key + 24, key->key + 16, 8); |
717 | 752 | ||
718 | } else { | 753 | } else { |
719 | memcpy(wl_key.key, key->key, key->keylen); | 754 | memcpy(wl_cmd->key, key->key, key->keylen); |
720 | } | 755 | } |
721 | wl_key.key_size = key->keylen; | 756 | wl_cmd->key_size = key->keylen; |
722 | 757 | ||
723 | wl_key.id = key->keyidx; | 758 | wl_cmd->id = key->keyidx; |
724 | wl_key.ssid_profile = 0; | 759 | wl_cmd->ssid_profile = 0; |
725 | 760 | ||
726 | wl12xx_dump(DEBUG_CRYPT, "TARGET KEY: ", &wl_key, sizeof(wl_key)); | 761 | wl1251_dump(DEBUG_CRYPT, "TARGET KEY: ", wl_cmd, sizeof(*wl_cmd)); |
727 | 762 | ||
728 | if (wl12xx_cmd_send(wl, CMD_SET_KEYS, &wl_key, sizeof(wl_key)) < 0) { | 763 | ret = wl1251_cmd_send(wl, CMD_SET_KEYS, wl_cmd, sizeof(*wl_cmd)); |
729 | wl12xx_error("Set KEY failed"); | 764 | if (ret < 0) { |
730 | ret = -EOPNOTSUPP; | 765 | wl1251_warning("could not set keys"); |
731 | goto out; | 766 | goto out_sleep; |
732 | } | 767 | } |
733 | 768 | ||
734 | out: | 769 | out_sleep: |
770 | wl1251_ps_elp_sleep(wl); | ||
771 | |||
772 | out_unlock: | ||
735 | mutex_unlock(&wl->mutex); | 773 | mutex_unlock(&wl->mutex); |
774 | |||
775 | out: | ||
776 | kfree(wl_cmd); | ||
777 | |||
736 | return ret; | 778 | return ret; |
737 | } | 779 | } |
738 | 780 | ||
739 | static int wl12xx_build_basic_rates(char *rates) | 781 | static int wl1251_build_basic_rates(char *rates) |
740 | { | 782 | { |
741 | u8 index = 0; | 783 | u8 index = 0; |
742 | 784 | ||
@@ -748,7 +790,7 @@ static int wl12xx_build_basic_rates(char *rates) | |||
748 | return index; | 790 | return index; |
749 | } | 791 | } |
750 | 792 | ||
751 | static int wl12xx_build_extended_rates(char *rates) | 793 | static int wl1251_build_extended_rates(char *rates) |
752 | { | 794 | { |
753 | u8 index = 0; | 795 | u8 index = 0; |
754 | 796 | ||
@@ -765,7 +807,7 @@ static int wl12xx_build_extended_rates(char *rates) | |||
765 | } | 807 | } |
766 | 808 | ||
767 | 809 | ||
768 | static int wl12xx_build_probe_req(struct wl12xx *wl, u8 *ssid, size_t ssid_len) | 810 | static int wl1251_build_probe_req(struct wl1251 *wl, u8 *ssid, size_t ssid_len) |
769 | { | 811 | { |
770 | struct wl12xx_probe_req_template template; | 812 | struct wl12xx_probe_req_template template; |
771 | struct wl12xx_ie_rates *rates; | 813 | struct wl12xx_ie_rates *rates; |
@@ -792,31 +834,30 @@ static int wl12xx_build_probe_req(struct wl12xx *wl, u8 *ssid, size_t ssid_len) | |||
792 | /* Basic Rates */ | 834 | /* Basic Rates */ |
793 | rates = (struct wl12xx_ie_rates *)ptr; | 835 | rates = (struct wl12xx_ie_rates *)ptr; |
794 | rates->header.id = WLAN_EID_SUPP_RATES; | 836 | rates->header.id = WLAN_EID_SUPP_RATES; |
795 | rates->header.len = wl12xx_build_basic_rates(rates->rates); | 837 | rates->header.len = wl1251_build_basic_rates(rates->rates); |
796 | size += sizeof(struct wl12xx_ie_header) + rates->header.len; | 838 | size += sizeof(struct wl12xx_ie_header) + rates->header.len; |
797 | ptr += sizeof(struct wl12xx_ie_header) + rates->header.len; | 839 | ptr += sizeof(struct wl12xx_ie_header) + rates->header.len; |
798 | 840 | ||
799 | /* Extended rates */ | 841 | /* Extended rates */ |
800 | rates = (struct wl12xx_ie_rates *)ptr; | 842 | rates = (struct wl12xx_ie_rates *)ptr; |
801 | rates->header.id = WLAN_EID_EXT_SUPP_RATES; | 843 | rates->header.id = WLAN_EID_EXT_SUPP_RATES; |
802 | rates->header.len = wl12xx_build_extended_rates(rates->rates); | 844 | rates->header.len = wl1251_build_extended_rates(rates->rates); |
803 | size += sizeof(struct wl12xx_ie_header) + rates->header.len; | 845 | size += sizeof(struct wl12xx_ie_header) + rates->header.len; |
804 | 846 | ||
805 | wl12xx_dump(DEBUG_SCAN, "PROBE REQ: ", &template, size); | 847 | wl1251_dump(DEBUG_SCAN, "PROBE REQ: ", &template, size); |
806 | 848 | ||
807 | return wl12xx_cmd_template_set(wl, CMD_PROBE_REQ, &template, | 849 | return wl1251_cmd_template_set(wl, CMD_PROBE_REQ, &template, |
808 | size); | 850 | size); |
809 | } | 851 | } |
810 | 852 | ||
811 | static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len, | 853 | static int wl1251_hw_scan(struct wl1251 *wl, u8 *ssid, size_t len, |
812 | u8 active_scan, u8 high_prio, u8 num_channels, | 854 | u8 active_scan, u8 high_prio, u8 num_channels, |
813 | u8 probe_requests) | 855 | u8 probe_requests) |
814 | { | 856 | { |
857 | struct wl1251_cmd_trigger_scan_to *trigger = NULL; | ||
858 | struct cmd_scan *params = NULL; | ||
815 | int i, ret; | 859 | int i, ret; |
816 | u32 split_scan = 0; | ||
817 | u16 scan_options = 0; | 860 | u16 scan_options = 0; |
818 | struct cmd_scan *params; | ||
819 | struct wl12xx_command *cmd_answer; | ||
820 | 861 | ||
821 | if (wl->scanning) | 862 | if (wl->scanning) |
822 | return -EINVAL; | 863 | return -EINVAL; |
@@ -864,33 +905,38 @@ static int wl12xx_hw_scan(struct wl12xx *wl, u8 *ssid, size_t len, | |||
864 | memset(params->params.ssid, 0, 32); | 905 | memset(params->params.ssid, 0, 32); |
865 | } | 906 | } |
866 | 907 | ||
867 | ret = wl12xx_build_probe_req(wl, ssid, len); | 908 | ret = wl1251_build_probe_req(wl, ssid, len); |
868 | if (ret < 0) { | 909 | if (ret < 0) { |
869 | wl12xx_error("PROBE request template failed"); | 910 | wl1251_error("PROBE request template failed"); |
870 | goto out; | 911 | goto out; |
871 | } | 912 | } |
872 | 913 | ||
873 | ret = wl12xx_cmd_send(wl, CMD_TRIGGER_SCAN_TO, &split_scan, | 914 | trigger = kzalloc(sizeof(*trigger), GFP_KERNEL); |
874 | sizeof(u32)); | 915 | if (!trigger) |
916 | goto out; | ||
917 | |||
918 | trigger->timeout = 0; | ||
919 | |||
920 | ret = wl1251_cmd_send(wl, CMD_TRIGGER_SCAN_TO, trigger, | ||
921 | sizeof(*trigger)); | ||
875 | if (ret < 0) { | 922 | if (ret < 0) { |
876 | wl12xx_error("Split SCAN failed"); | 923 | wl1251_error("trigger scan to failed for hw scan"); |
877 | goto out; | 924 | goto out; |
878 | } | 925 | } |
879 | 926 | ||
880 | wl12xx_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params)); | 927 | wl1251_dump(DEBUG_SCAN, "SCAN: ", params, sizeof(*params)); |
881 | 928 | ||
882 | wl->scanning = true; | 929 | wl->scanning = true; |
883 | 930 | ||
884 | ret = wl12xx_cmd_send(wl, CMD_SCAN, params, sizeof(*params)); | 931 | ret = wl1251_cmd_send(wl, CMD_SCAN, params, sizeof(*params)); |
885 | if (ret < 0) | 932 | if (ret < 0) |
886 | wl12xx_error("SCAN failed"); | 933 | wl1251_error("SCAN failed"); |
887 | 934 | ||
888 | wl12xx_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params)); | 935 | wl1251_spi_mem_read(wl, wl->cmd_box_addr, params, sizeof(*params)); |
889 | 936 | ||
890 | cmd_answer = (struct wl12xx_command *) params; | 937 | if (params->header.status != CMD_STATUS_SUCCESS) { |
891 | if (cmd_answer->status != CMD_STATUS_SUCCESS) { | 938 | wl1251_error("TEST command answer error: %d", |
892 | wl12xx_error("TEST command answer error: %d", | 939 | params->header.status); |
893 | cmd_answer->status); | ||
894 | wl->scanning = false; | 940 | wl->scanning = false; |
895 | ret = -EIO; | 941 | ret = -EIO; |
896 | goto out; | 942 | goto out; |
@@ -902,15 +948,15 @@ out: | |||
902 | 948 | ||
903 | } | 949 | } |
904 | 950 | ||
905 | static int wl12xx_op_hw_scan(struct ieee80211_hw *hw, | 951 | static int wl1251_op_hw_scan(struct ieee80211_hw *hw, |
906 | struct cfg80211_scan_request *req) | 952 | struct cfg80211_scan_request *req) |
907 | { | 953 | { |
908 | struct wl12xx *wl = hw->priv; | 954 | struct wl1251 *wl = hw->priv; |
909 | int ret; | 955 | int ret; |
910 | u8 *ssid = NULL; | 956 | u8 *ssid = NULL; |
911 | size_t ssid_len = 0; | 957 | size_t ssid_len = 0; |
912 | 958 | ||
913 | wl12xx_debug(DEBUG_MAC80211, "mac80211 hw scan"); | 959 | wl1251_debug(DEBUG_MAC80211, "mac80211 hw scan"); |
914 | 960 | ||
915 | if (req->n_ssids) { | 961 | if (req->n_ssids) { |
916 | ssid = req->ssids[0].ssid; | 962 | ssid = req->ssids[0].ssid; |
@@ -918,85 +964,108 @@ static int wl12xx_op_hw_scan(struct ieee80211_hw *hw, | |||
918 | } | 964 | } |
919 | 965 | ||
920 | mutex_lock(&wl->mutex); | 966 | mutex_lock(&wl->mutex); |
921 | ret = wl12xx_hw_scan(hw->priv, ssid, ssid_len, 1, 0, 13, 3); | 967 | |
968 | ret = wl1251_ps_elp_wakeup(wl); | ||
969 | if (ret < 0) | ||
970 | goto out; | ||
971 | |||
972 | ret = wl1251_hw_scan(hw->priv, ssid, ssid_len, 1, 0, 13, 3); | ||
973 | |||
974 | wl1251_ps_elp_sleep(wl); | ||
975 | |||
976 | out: | ||
922 | mutex_unlock(&wl->mutex); | 977 | mutex_unlock(&wl->mutex); |
923 | 978 | ||
924 | return ret; | 979 | return ret; |
925 | } | 980 | } |
926 | 981 | ||
927 | static int wl12xx_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) | 982 | static int wl1251_op_set_rts_threshold(struct ieee80211_hw *hw, u32 value) |
928 | { | 983 | { |
929 | struct wl12xx *wl = hw->priv; | 984 | struct wl1251 *wl = hw->priv; |
930 | int ret; | 985 | int ret; |
931 | 986 | ||
932 | ret = wl12xx_acx_rts_threshold(wl, (u16) value); | 987 | mutex_lock(&wl->mutex); |
988 | |||
989 | ret = wl1251_ps_elp_wakeup(wl); | ||
990 | if (ret < 0) | ||
991 | goto out; | ||
933 | 992 | ||
993 | ret = wl1251_acx_rts_threshold(wl, (u16) value); | ||
934 | if (ret < 0) | 994 | if (ret < 0) |
935 | wl12xx_warning("wl12xx_op_set_rts_threshold failed: %d", ret); | 995 | wl1251_warning("wl1251_op_set_rts_threshold failed: %d", ret); |
996 | |||
997 | wl1251_ps_elp_sleep(wl); | ||
998 | |||
999 | out: | ||
1000 | mutex_unlock(&wl->mutex); | ||
936 | 1001 | ||
937 | return ret; | 1002 | return ret; |
938 | } | 1003 | } |
939 | 1004 | ||
940 | static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw, | 1005 | static void wl1251_op_bss_info_changed(struct ieee80211_hw *hw, |
941 | struct ieee80211_vif *vif, | 1006 | struct ieee80211_vif *vif, |
942 | struct ieee80211_bss_conf *bss_conf, | 1007 | struct ieee80211_bss_conf *bss_conf, |
943 | u32 changed) | 1008 | u32 changed) |
944 | { | 1009 | { |
945 | enum acx_ps_mode mode; | 1010 | enum wl1251_cmd_ps_mode mode; |
946 | struct wl12xx *wl = hw->priv; | 1011 | struct wl1251 *wl = hw->priv; |
947 | struct sk_buff *beacon; | 1012 | struct sk_buff *beacon; |
948 | int ret; | 1013 | int ret; |
949 | 1014 | ||
950 | wl12xx_debug(DEBUG_MAC80211, "mac80211 bss info changed"); | 1015 | wl1251_debug(DEBUG_MAC80211, "mac80211 bss info changed"); |
951 | 1016 | ||
952 | mutex_lock(&wl->mutex); | 1017 | mutex_lock(&wl->mutex); |
953 | 1018 | ||
1019 | ret = wl1251_ps_elp_wakeup(wl); | ||
1020 | if (ret < 0) | ||
1021 | goto out; | ||
1022 | |||
954 | if (changed & BSS_CHANGED_ASSOC) { | 1023 | if (changed & BSS_CHANGED_ASSOC) { |
955 | if (bss_conf->assoc) { | 1024 | if (bss_conf->assoc) { |
956 | wl->aid = bss_conf->aid; | 1025 | wl->aid = bss_conf->aid; |
957 | 1026 | ||
958 | ret = wl12xx_build_ps_poll(wl, wl->aid); | 1027 | ret = wl1251_build_ps_poll(wl, wl->aid); |
959 | if (ret < 0) | 1028 | if (ret < 0) |
960 | goto out; | 1029 | goto out_sleep; |
961 | 1030 | ||
962 | ret = wl12xx_acx_aid(wl, wl->aid); | 1031 | ret = wl1251_acx_aid(wl, wl->aid); |
963 | if (ret < 0) | 1032 | if (ret < 0) |
964 | goto out; | 1033 | goto out_sleep; |
965 | 1034 | ||
966 | /* If we want to go in PSM but we're not there yet */ | 1035 | /* If we want to go in PSM but we're not there yet */ |
967 | if (wl->psm_requested && !wl->psm) { | 1036 | if (wl->psm_requested && !wl->psm) { |
968 | mode = STATION_POWER_SAVE_MODE; | 1037 | mode = STATION_POWER_SAVE_MODE; |
969 | ret = wl12xx_ps_set_mode(wl, mode); | 1038 | ret = wl1251_ps_set_mode(wl, mode); |
970 | if (ret < 0) | 1039 | if (ret < 0) |
971 | goto out; | 1040 | goto out_sleep; |
972 | } | 1041 | } |
973 | } | 1042 | } |
974 | } | 1043 | } |
975 | if (changed & BSS_CHANGED_ERP_SLOT) { | 1044 | if (changed & BSS_CHANGED_ERP_SLOT) { |
976 | if (bss_conf->use_short_slot) | 1045 | if (bss_conf->use_short_slot) |
977 | ret = wl12xx_acx_slot(wl, SLOT_TIME_SHORT); | 1046 | ret = wl1251_acx_slot(wl, SLOT_TIME_SHORT); |
978 | else | 1047 | else |
979 | ret = wl12xx_acx_slot(wl, SLOT_TIME_LONG); | 1048 | ret = wl1251_acx_slot(wl, SLOT_TIME_LONG); |
980 | if (ret < 0) { | 1049 | if (ret < 0) { |
981 | wl12xx_warning("Set slot time failed %d", ret); | 1050 | wl1251_warning("Set slot time failed %d", ret); |
982 | goto out; | 1051 | goto out_sleep; |
983 | } | 1052 | } |
984 | } | 1053 | } |
985 | 1054 | ||
986 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { | 1055 | if (changed & BSS_CHANGED_ERP_PREAMBLE) { |
987 | if (bss_conf->use_short_preamble) | 1056 | if (bss_conf->use_short_preamble) |
988 | wl12xx_acx_set_preamble(wl, ACX_PREAMBLE_SHORT); | 1057 | wl1251_acx_set_preamble(wl, ACX_PREAMBLE_SHORT); |
989 | else | 1058 | else |
990 | wl12xx_acx_set_preamble(wl, ACX_PREAMBLE_LONG); | 1059 | wl1251_acx_set_preamble(wl, ACX_PREAMBLE_LONG); |
991 | } | 1060 | } |
992 | 1061 | ||
993 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { | 1062 | if (changed & BSS_CHANGED_ERP_CTS_PROT) { |
994 | if (bss_conf->use_cts_prot) | 1063 | if (bss_conf->use_cts_prot) |
995 | ret = wl12xx_acx_cts_protect(wl, CTSPROTECT_ENABLE); | 1064 | ret = wl1251_acx_cts_protect(wl, CTSPROTECT_ENABLE); |
996 | else | 1065 | else |
997 | ret = wl12xx_acx_cts_protect(wl, CTSPROTECT_DISABLE); | 1066 | ret = wl1251_acx_cts_protect(wl, CTSPROTECT_DISABLE); |
998 | if (ret < 0) { | 1067 | if (ret < 0) { |
999 | wl12xx_warning("Set ctsprotect failed %d", ret); | 1068 | wl1251_warning("Set ctsprotect failed %d", ret); |
1000 | goto out; | 1069 | goto out; |
1001 | } | 1070 | } |
1002 | } | 1071 | } |
@@ -1004,20 +1073,22 @@ static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw, | |||
1004 | if (changed & BSS_CHANGED_BSSID) { | 1073 | if (changed & BSS_CHANGED_BSSID) { |
1005 | memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); | 1074 | memcpy(wl->bssid, bss_conf->bssid, ETH_ALEN); |
1006 | 1075 | ||
1007 | ret = wl12xx_build_null_data(wl); | 1076 | ret = wl1251_build_null_data(wl); |
1008 | if (ret < 0) | 1077 | if (ret < 0) |
1009 | goto out; | 1078 | goto out; |
1010 | 1079 | ||
1011 | if (wl->bss_type != BSS_TYPE_IBSS) { | 1080 | if (wl->bss_type != BSS_TYPE_IBSS) { |
1012 | ret = wl12xx_cmd_join(wl, wl->bss_type, 5, 100, 1); | 1081 | ret = wl1251_cmd_join(wl, wl->bss_type, 5, 100, 1); |
1013 | if (ret < 0) | 1082 | if (ret < 0) |
1014 | goto out; | 1083 | goto out_sleep; |
1084 | wl1251_warning("Set ctsprotect failed %d", ret); | ||
1085 | goto out_sleep; | ||
1015 | } | 1086 | } |
1016 | } | 1087 | } |
1017 | 1088 | ||
1018 | if (changed & BSS_CHANGED_BEACON) { | 1089 | if (changed & BSS_CHANGED_BEACON) { |
1019 | beacon = ieee80211_beacon_get(hw, vif); | 1090 | beacon = ieee80211_beacon_get(hw, vif); |
1020 | ret = wl12xx_cmd_template_set(wl, CMD_BEACON, beacon->data, | 1091 | ret = wl1251_cmd_template_set(wl, CMD_BEACON, beacon->data, |
1021 | beacon->len); | 1092 | beacon->len); |
1022 | 1093 | ||
1023 | if (ret < 0) { | 1094 | if (ret < 0) { |
@@ -1025,7 +1096,7 @@ static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw, | |||
1025 | goto out; | 1096 | goto out; |
1026 | } | 1097 | } |
1027 | 1098 | ||
1028 | ret = wl12xx_cmd_template_set(wl, CMD_PROBE_RESP, beacon->data, | 1099 | ret = wl1251_cmd_template_set(wl, CMD_PROBE_RESP, beacon->data, |
1029 | beacon->len); | 1100 | beacon->len); |
1030 | 1101 | ||
1031 | dev_kfree_skb(beacon); | 1102 | dev_kfree_skb(beacon); |
@@ -1033,19 +1104,22 @@ static void wl12xx_op_bss_info_changed(struct ieee80211_hw *hw, | |||
1033 | if (ret < 0) | 1104 | if (ret < 0) |
1034 | goto out; | 1105 | goto out; |
1035 | 1106 | ||
1036 | ret = wl12xx_cmd_join(wl, wl->bss_type, 1, 100, 0); | 1107 | ret = wl->chip.op_cmd_join(wl, wl->bss_type, 1, 100, 0); |
1037 | 1108 | ||
1038 | if (ret < 0) | 1109 | if (ret < 0) |
1039 | goto out; | 1110 | goto out; |
1040 | } | 1111 | } |
1041 | 1112 | ||
1113 | out_sleep: | ||
1114 | wl1251_ps_elp_sleep(wl); | ||
1115 | |||
1042 | out: | 1116 | out: |
1043 | mutex_unlock(&wl->mutex); | 1117 | mutex_unlock(&wl->mutex); |
1044 | } | 1118 | } |
1045 | 1119 | ||
1046 | 1120 | ||
1047 | /* can't be const, mac80211 writes to this */ | 1121 | /* can't be const, mac80211 writes to this */ |
1048 | static struct ieee80211_rate wl12xx_rates[] = { | 1122 | static struct ieee80211_rate wl1251_rates[] = { |
1049 | { .bitrate = 10, | 1123 | { .bitrate = 10, |
1050 | .hw_value = 0x1, | 1124 | .hw_value = 0x1, |
1051 | .hw_value_short = 0x1, }, | 1125 | .hw_value_short = 0x1, }, |
@@ -1088,7 +1162,7 @@ static struct ieee80211_rate wl12xx_rates[] = { | |||
1088 | }; | 1162 | }; |
1089 | 1163 | ||
1090 | /* can't be const, mac80211 writes to this */ | 1164 | /* can't be const, mac80211 writes to this */ |
1091 | static struct ieee80211_channel wl12xx_channels[] = { | 1165 | static struct ieee80211_channel wl1251_channels[] = { |
1092 | { .hw_value = 1, .center_freq = 2412}, | 1166 | { .hw_value = 1, .center_freq = 2412}, |
1093 | { .hw_value = 2, .center_freq = 2417}, | 1167 | { .hw_value = 2, .center_freq = 2417}, |
1094 | { .hw_value = 3, .center_freq = 2422}, | 1168 | { .hw_value = 3, .center_freq = 2422}, |
@@ -1105,28 +1179,28 @@ static struct ieee80211_channel wl12xx_channels[] = { | |||
1105 | }; | 1179 | }; |
1106 | 1180 | ||
1107 | /* can't be const, mac80211 writes to this */ | 1181 | /* can't be const, mac80211 writes to this */ |
1108 | static struct ieee80211_supported_band wl12xx_band_2ghz = { | 1182 | static struct ieee80211_supported_band wl1251_band_2ghz = { |
1109 | .channels = wl12xx_channels, | 1183 | .channels = wl1251_channels, |
1110 | .n_channels = ARRAY_SIZE(wl12xx_channels), | 1184 | .n_channels = ARRAY_SIZE(wl1251_channels), |
1111 | .bitrates = wl12xx_rates, | 1185 | .bitrates = wl1251_rates, |
1112 | .n_bitrates = ARRAY_SIZE(wl12xx_rates), | 1186 | .n_bitrates = ARRAY_SIZE(wl1251_rates), |
1113 | }; | 1187 | }; |
1114 | 1188 | ||
1115 | static const struct ieee80211_ops wl12xx_ops = { | 1189 | static const struct ieee80211_ops wl1251_ops = { |
1116 | .start = wl12xx_op_start, | 1190 | .start = wl1251_op_start, |
1117 | .stop = wl12xx_op_stop, | 1191 | .stop = wl1251_op_stop, |
1118 | .add_interface = wl12xx_op_add_interface, | 1192 | .add_interface = wl1251_op_add_interface, |
1119 | .remove_interface = wl12xx_op_remove_interface, | 1193 | .remove_interface = wl1251_op_remove_interface, |
1120 | .config = wl12xx_op_config, | 1194 | .config = wl1251_op_config, |
1121 | .configure_filter = wl12xx_op_configure_filter, | 1195 | .configure_filter = wl1251_op_configure_filter, |
1122 | .tx = wl12xx_op_tx, | 1196 | .tx = wl1251_op_tx, |
1123 | .set_key = wl12xx_op_set_key, | 1197 | .set_key = wl1251_op_set_key, |
1124 | .hw_scan = wl12xx_op_hw_scan, | 1198 | .hw_scan = wl1251_op_hw_scan, |
1125 | .bss_info_changed = wl12xx_op_bss_info_changed, | 1199 | .bss_info_changed = wl1251_op_bss_info_changed, |
1126 | .set_rts_threshold = wl12xx_op_set_rts_threshold, | 1200 | .set_rts_threshold = wl1251_op_set_rts_threshold, |
1127 | }; | 1201 | }; |
1128 | 1202 | ||
1129 | static int wl12xx_register_hw(struct wl12xx *wl) | 1203 | static int wl1251_register_hw(struct wl1251 *wl) |
1130 | { | 1204 | { |
1131 | int ret; | 1205 | int ret; |
1132 | 1206 | ||
@@ -1137,22 +1211,22 @@ static int wl12xx_register_hw(struct wl12xx *wl) | |||
1137 | 1211 | ||
1138 | ret = ieee80211_register_hw(wl->hw); | 1212 | ret = ieee80211_register_hw(wl->hw); |
1139 | if (ret < 0) { | 1213 | if (ret < 0) { |
1140 | wl12xx_error("unable to register mac80211 hw: %d", ret); | 1214 | wl1251_error("unable to register mac80211 hw: %d", ret); |
1141 | return ret; | 1215 | return ret; |
1142 | } | 1216 | } |
1143 | 1217 | ||
1144 | wl->mac80211_registered = true; | 1218 | wl->mac80211_registered = true; |
1145 | 1219 | ||
1146 | wl12xx_notice("loaded"); | 1220 | wl1251_notice("loaded"); |
1147 | 1221 | ||
1148 | return 0; | 1222 | return 0; |
1149 | } | 1223 | } |
1150 | 1224 | ||
1151 | static int wl12xx_init_ieee80211(struct wl12xx *wl) | 1225 | static int wl1251_init_ieee80211(struct wl1251 *wl) |
1152 | { | 1226 | { |
1153 | /* The tx descriptor buffer and the TKIP space */ | 1227 | /* The tx descriptor buffer and the TKIP space */ |
1154 | wl->hw->extra_tx_headroom = sizeof(struct tx_double_buffer_desc) | 1228 | wl->hw->extra_tx_headroom = sizeof(struct tx_double_buffer_desc) |
1155 | + WL12XX_TKIP_IV_SPACE; | 1229 | + WL1251_TKIP_IV_SPACE; |
1156 | 1230 | ||
1157 | /* unit us */ | 1231 | /* unit us */ |
1158 | /* FIXME: find a proper value */ | 1232 | /* FIXME: find a proper value */ |
@@ -1163,31 +1237,31 @@ static int wl12xx_init_ieee80211(struct wl12xx *wl) | |||
1163 | 1237 | ||
1164 | wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); | 1238 | wl->hw->wiphy->interface_modes = BIT(NL80211_IFTYPE_STATION); |
1165 | wl->hw->wiphy->max_scan_ssids = 1; | 1239 | wl->hw->wiphy->max_scan_ssids = 1; |
1166 | wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl12xx_band_2ghz; | 1240 | wl->hw->wiphy->bands[IEEE80211_BAND_2GHZ] = &wl1251_band_2ghz; |
1167 | 1241 | ||
1168 | SET_IEEE80211_DEV(wl->hw, &wl->spi->dev); | 1242 | SET_IEEE80211_DEV(wl->hw, &wl->spi->dev); |
1169 | 1243 | ||
1170 | return 0; | 1244 | return 0; |
1171 | } | 1245 | } |
1172 | 1246 | ||
1173 | #define WL12XX_DEFAULT_CHANNEL 1 | 1247 | #define WL1251_DEFAULT_CHANNEL 1 |
1174 | static int __devinit wl12xx_probe(struct spi_device *spi) | 1248 | static int __devinit wl1251_probe(struct spi_device *spi) |
1175 | { | 1249 | { |
1176 | struct wl12xx_platform_data *pdata; | 1250 | struct wl12xx_platform_data *pdata; |
1177 | struct ieee80211_hw *hw; | 1251 | struct ieee80211_hw *hw; |
1178 | struct wl12xx *wl; | 1252 | struct wl1251 *wl; |
1179 | int ret, i; | 1253 | int ret, i; |
1180 | static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; | 1254 | static const u8 nokia_oui[3] = {0x00, 0x1f, 0xdf}; |
1181 | 1255 | ||
1182 | pdata = spi->dev.platform_data; | 1256 | pdata = spi->dev.platform_data; |
1183 | if (!pdata) { | 1257 | if (!pdata) { |
1184 | wl12xx_error("no platform data"); | 1258 | wl1251_error("no platform data"); |
1185 | return -ENODEV; | 1259 | return -ENODEV; |
1186 | } | 1260 | } |
1187 | 1261 | ||
1188 | hw = ieee80211_alloc_hw(sizeof(*wl), &wl12xx_ops); | 1262 | hw = ieee80211_alloc_hw(sizeof(*wl), &wl1251_ops); |
1189 | if (!hw) { | 1263 | if (!hw) { |
1190 | wl12xx_error("could not alloc ieee80211_hw"); | 1264 | wl1251_error("could not alloc ieee80211_hw"); |
1191 | return -ENOMEM; | 1265 | return -ENOMEM; |
1192 | } | 1266 | } |
1193 | 1267 | ||
@@ -1202,9 +1276,8 @@ static int __devinit wl12xx_probe(struct spi_device *spi) | |||
1202 | 1276 | ||
1203 | skb_queue_head_init(&wl->tx_queue); | 1277 | skb_queue_head_init(&wl->tx_queue); |
1204 | 1278 | ||
1205 | INIT_WORK(&wl->tx_work, wl12xx_tx_work); | 1279 | INIT_WORK(&wl->filter_work, wl1251_filter_work); |
1206 | INIT_WORK(&wl->filter_work, wl12xx_filter_work); | 1280 | wl->channel = WL1251_DEFAULT_CHANNEL; |
1207 | wl->channel = WL12XX_DEFAULT_CHANNEL; | ||
1208 | wl->scanning = false; | 1281 | wl->scanning = false; |
1209 | wl->default_key = 0; | 1282 | wl->default_key = 0; |
1210 | wl->listen_int = 1; | 1283 | wl->listen_int = 1; |
@@ -1212,17 +1285,17 @@ static int __devinit wl12xx_probe(struct spi_device *spi) | |||
1212 | wl->rx_handled = 0; | 1285 | wl->rx_handled = 0; |
1213 | wl->rx_current_buffer = 0; | 1286 | wl->rx_current_buffer = 0; |
1214 | wl->rx_last_id = 0; | 1287 | wl->rx_last_id = 0; |
1215 | wl->rx_config = WL12XX_DEFAULT_RX_CONFIG; | 1288 | wl->rx_config = WL1251_DEFAULT_RX_CONFIG; |
1216 | wl->rx_filter = WL12XX_DEFAULT_RX_FILTER; | 1289 | wl->rx_filter = WL1251_DEFAULT_RX_FILTER; |
1217 | wl->elp = false; | 1290 | wl->elp = false; |
1218 | wl->psm = 0; | 1291 | wl->psm = 0; |
1219 | wl->psm_requested = false; | 1292 | wl->psm_requested = false; |
1220 | wl->tx_queue_stopped = false; | 1293 | wl->tx_queue_stopped = false; |
1221 | wl->power_level = WL12XX_DEFAULT_POWER_LEVEL; | 1294 | wl->power_level = WL1251_DEFAULT_POWER_LEVEL; |
1222 | 1295 | ||
1223 | /* We use the default power on sleep time until we know which chip | 1296 | /* We use the default power on sleep time until we know which chip |
1224 | * we're using */ | 1297 | * we're using */ |
1225 | wl->chip.power_on_sleep = WL12XX_DEFAULT_POWER_ON_SLEEP; | 1298 | wl->chip.power_on_sleep = WL1251_DEFAULT_POWER_ON_SLEEP; |
1226 | 1299 | ||
1227 | for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++) | 1300 | for (i = 0; i < FW_TX_CMPLT_BLOCK_SIZE; i++) |
1228 | wl->tx_frames[i] = NULL; | 1301 | wl->tx_frames[i] = NULL; |
@@ -1236,37 +1309,46 @@ static int __devinit wl12xx_probe(struct spi_device *spi) | |||
1236 | memcpy(wl->mac_addr, nokia_oui, 3); | 1309 | memcpy(wl->mac_addr, nokia_oui, 3); |
1237 | get_random_bytes(wl->mac_addr + 3, 3); | 1310 | get_random_bytes(wl->mac_addr + 3, 3); |
1238 | 1311 | ||
1239 | wl->state = WL12XX_STATE_OFF; | 1312 | wl->state = WL1251_STATE_OFF; |
1240 | mutex_init(&wl->mutex); | 1313 | mutex_init(&wl->mutex); |
1241 | 1314 | ||
1242 | wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE; | 1315 | wl->tx_mgmt_frm_rate = DEFAULT_HW_GEN_TX_RATE; |
1243 | wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE; | 1316 | wl->tx_mgmt_frm_mod = DEFAULT_HW_GEN_MODULATION_TYPE; |
1244 | 1317 | ||
1318 | wl->rx_descriptor = kmalloc(sizeof(*wl->rx_descriptor), GFP_KERNEL); | ||
1319 | if (!wl->rx_descriptor) { | ||
1320 | wl1251_error("could not allocate memory for rx descriptor"); | ||
1321 | ret = -ENOMEM; | ||
1322 | goto out_free; | ||
1323 | } | ||
1324 | |||
1245 | /* This is the only SPI value that we need to set here, the rest | 1325 | /* This is the only SPI value that we need to set here, the rest |
1246 | * comes from the board-peripherals file */ | 1326 | * comes from the board-peripherals file */ |
1247 | spi->bits_per_word = 32; | 1327 | spi->bits_per_word = 32; |
1248 | 1328 | ||
1249 | ret = spi_setup(spi); | 1329 | ret = spi_setup(spi); |
1250 | if (ret < 0) { | 1330 | if (ret < 0) { |
1251 | wl12xx_error("spi_setup failed"); | 1331 | wl1251_error("spi_setup failed"); |
1252 | goto out_free; | 1332 | goto out_free; |
1253 | } | 1333 | } |
1254 | 1334 | ||
1255 | wl->set_power = pdata->set_power; | 1335 | wl->set_power = pdata->set_power; |
1256 | if (!wl->set_power) { | 1336 | if (!wl->set_power) { |
1257 | wl12xx_error("set power function missing in platform data"); | 1337 | wl1251_error("set power function missing in platform data"); |
1258 | return -ENODEV; | 1338 | ret = -ENODEV; |
1339 | goto out_free; | ||
1259 | } | 1340 | } |
1260 | 1341 | ||
1261 | wl->irq = spi->irq; | 1342 | wl->irq = spi->irq; |
1262 | if (wl->irq < 0) { | 1343 | if (wl->irq < 0) { |
1263 | wl12xx_error("irq missing in platform data"); | 1344 | wl1251_error("irq missing in platform data"); |
1264 | return -ENODEV; | 1345 | ret = -ENODEV; |
1346 | goto out_free; | ||
1265 | } | 1347 | } |
1266 | 1348 | ||
1267 | ret = request_irq(wl->irq, wl12xx_irq, 0, DRIVER_NAME, wl); | 1349 | ret = request_irq(wl->irq, wl1251_irq, 0, DRIVER_NAME, wl); |
1268 | if (ret < 0) { | 1350 | if (ret < 0) { |
1269 | wl12xx_error("request_irq() failed: %d", ret); | 1351 | wl1251_error("request_irq() failed: %d", ret); |
1270 | goto out_free; | 1352 | goto out_free; |
1271 | } | 1353 | } |
1272 | 1354 | ||
@@ -1274,17 +1356,17 @@ static int __devinit wl12xx_probe(struct spi_device *spi) | |||
1274 | 1356 | ||
1275 | disable_irq(wl->irq); | 1357 | disable_irq(wl->irq); |
1276 | 1358 | ||
1277 | ret = wl12xx_init_ieee80211(wl); | 1359 | ret = wl1251_init_ieee80211(wl); |
1278 | if (ret) | 1360 | if (ret) |
1279 | goto out_irq; | 1361 | goto out_irq; |
1280 | 1362 | ||
1281 | ret = wl12xx_register_hw(wl); | 1363 | ret = wl1251_register_hw(wl); |
1282 | if (ret) | 1364 | if (ret) |
1283 | goto out_irq; | 1365 | goto out_irq; |
1284 | 1366 | ||
1285 | wl12xx_debugfs_init(wl); | 1367 | wl1251_debugfs_init(wl); |
1286 | 1368 | ||
1287 | wl12xx_notice("initialized"); | 1369 | wl1251_notice("initialized"); |
1288 | 1370 | ||
1289 | return 0; | 1371 | return 0; |
1290 | 1372 | ||
@@ -1292,18 +1374,21 @@ static int __devinit wl12xx_probe(struct spi_device *spi) | |||
1292 | free_irq(wl->irq, wl); | 1374 | free_irq(wl->irq, wl); |
1293 | 1375 | ||
1294 | out_free: | 1376 | out_free: |
1377 | kfree(wl->rx_descriptor); | ||
1378 | wl->rx_descriptor = NULL; | ||
1379 | |||
1295 | ieee80211_free_hw(hw); | 1380 | ieee80211_free_hw(hw); |
1296 | 1381 | ||
1297 | return ret; | 1382 | return ret; |
1298 | } | 1383 | } |
1299 | 1384 | ||
1300 | static int __devexit wl12xx_remove(struct spi_device *spi) | 1385 | static int __devexit wl1251_remove(struct spi_device *spi) |
1301 | { | 1386 | { |
1302 | struct wl12xx *wl = dev_get_drvdata(&spi->dev); | 1387 | struct wl1251 *wl = dev_get_drvdata(&spi->dev); |
1303 | 1388 | ||
1304 | ieee80211_unregister_hw(wl->hw); | 1389 | ieee80211_unregister_hw(wl->hw); |
1305 | 1390 | ||
1306 | wl12xx_debugfs_exit(wl); | 1391 | wl1251_debugfs_exit(wl); |
1307 | 1392 | ||
1308 | free_irq(wl->irq, wl); | 1393 | free_irq(wl->irq, wl); |
1309 | kfree(wl->target_mem_map); | 1394 | kfree(wl->target_mem_map); |
@@ -1312,30 +1397,35 @@ static int __devexit wl12xx_remove(struct spi_device *spi) | |||
1312 | wl->fw = NULL; | 1397 | wl->fw = NULL; |
1313 | kfree(wl->nvs); | 1398 | kfree(wl->nvs); |
1314 | wl->nvs = NULL; | 1399 | wl->nvs = NULL; |
1400 | |||
1401 | kfree(wl->rx_descriptor); | ||
1402 | wl->rx_descriptor = NULL; | ||
1403 | |||
1315 | ieee80211_free_hw(wl->hw); | 1404 | ieee80211_free_hw(wl->hw); |
1316 | 1405 | ||
1317 | return 0; | 1406 | return 0; |
1318 | } | 1407 | } |
1319 | 1408 | ||
1320 | 1409 | ||
1321 | static struct spi_driver wl12xx_spi_driver = { | 1410 | static struct spi_driver wl1251_spi_driver = { |
1322 | .driver = { | 1411 | .driver = { |
1412 | /* FIXME: use wl12xx name to not break the user space */ | ||
1323 | .name = "wl12xx", | 1413 | .name = "wl12xx", |
1324 | .bus = &spi_bus_type, | 1414 | .bus = &spi_bus_type, |
1325 | .owner = THIS_MODULE, | 1415 | .owner = THIS_MODULE, |
1326 | }, | 1416 | }, |
1327 | 1417 | ||
1328 | .probe = wl12xx_probe, | 1418 | .probe = wl1251_probe, |
1329 | .remove = __devexit_p(wl12xx_remove), | 1419 | .remove = __devexit_p(wl1251_remove), |
1330 | }; | 1420 | }; |
1331 | 1421 | ||
1332 | static int __init wl12xx_init(void) | 1422 | static int __init wl1251_init(void) |
1333 | { | 1423 | { |
1334 | int ret; | 1424 | int ret; |
1335 | 1425 | ||
1336 | ret = spi_register_driver(&wl12xx_spi_driver); | 1426 | ret = spi_register_driver(&wl1251_spi_driver); |
1337 | if (ret < 0) { | 1427 | if (ret < 0) { |
1338 | wl12xx_error("failed to register spi driver: %d", ret); | 1428 | wl1251_error("failed to register spi driver: %d", ret); |
1339 | goto out; | 1429 | goto out; |
1340 | } | 1430 | } |
1341 | 1431 | ||
@@ -1343,15 +1433,15 @@ out: | |||
1343 | return ret; | 1433 | return ret; |
1344 | } | 1434 | } |
1345 | 1435 | ||
1346 | static void __exit wl12xx_exit(void) | 1436 | static void __exit wl1251_exit(void) |
1347 | { | 1437 | { |
1348 | spi_unregister_driver(&wl12xx_spi_driver); | 1438 | spi_unregister_driver(&wl1251_spi_driver); |
1349 | 1439 | ||
1350 | wl12xx_notice("unloaded"); | 1440 | wl1251_notice("unloaded"); |
1351 | } | 1441 | } |
1352 | 1442 | ||
1353 | module_init(wl12xx_init); | 1443 | module_init(wl1251_init); |
1354 | module_exit(wl12xx_exit); | 1444 | module_exit(wl1251_exit); |
1355 | 1445 | ||
1356 | MODULE_LICENSE("GPL"); | 1446 | MODULE_LICENSE("GPL"); |
1357 | MODULE_AUTHOR("Kalle Valo <Kalle.Valo@nokia.com>, " | 1447 | MODULE_AUTHOR("Kalle Valo <Kalle.Valo@nokia.com>, " |
diff --git a/drivers/net/wireless/wl12xx/wl1251_netlink.c b/drivers/net/wireless/wl12xx/wl1251_netlink.c new file mode 100644 index 000000000000..67d3d5a3b519 --- /dev/null +++ b/drivers/net/wireless/wl12xx/wl1251_netlink.c | |||
@@ -0,0 +1,679 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * Contact: Kalle Valo <kalle.valo@nokia.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * version 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
20 | * 02110-1301 USA | ||
21 | * | ||
22 | */ | ||
23 | #include "wl1251_netlink.h" | ||
24 | |||
25 | #include <linux/mutex.h> | ||
26 | #include <linux/socket.h> | ||
27 | #include <net/net_namespace.h> | ||
28 | #include <net/sock.h> | ||
29 | #include <net/genetlink.h> | ||
30 | #include <net/wireless.h> | ||
31 | #include <net/mac80211.h> | ||
32 | |||
33 | #include "wl1251.h" | ||
34 | #include "wl1251_spi.h" | ||
35 | #include "wl1251_acx.h" | ||
36 | |||
37 | /* FIXME: this should be changed as soon as user space catches up */ | ||
38 | #define WL1251_NL_NAME "wl1251" | ||
39 | #define WL1251_NL_VERSION 1 | ||
40 | |||
41 | #define WL1251_MAX_TEST_LENGTH 1024 | ||
42 | #define WL1251_MAX_NVS_LENGTH 1024 | ||
43 | |||
44 | enum wl1251_nl_commands { | ||
45 | WL1251_NL_CMD_UNSPEC, | ||
46 | WL1251_NL_CMD_TEST, | ||
47 | WL1251_NL_CMD_INTERROGATE, | ||
48 | WL1251_NL_CMD_CONFIGURE, | ||
49 | WL1251_NL_CMD_PHY_REG_READ, | ||
50 | WL1251_NL_CMD_NVS_PUSH, | ||
51 | WL1251_NL_CMD_REG_WRITE, | ||
52 | WL1251_NL_CMD_REG_READ, | ||
53 | WL1251_NL_CMD_SET_PLT_MODE, | ||
54 | |||
55 | __WL1251_NL_CMD_AFTER_LAST | ||
56 | }; | ||
57 | #define WL1251_NL_CMD_MAX (__WL1251_NL_CMD_AFTER_LAST - 1) | ||
58 | |||
59 | enum wl1251_nl_attrs { | ||
60 | WL1251_NL_ATTR_UNSPEC, | ||
61 | WL1251_NL_ATTR_IFNAME, | ||
62 | WL1251_NL_ATTR_CMD_TEST_PARAM, | ||
63 | WL1251_NL_ATTR_CMD_TEST_ANSWER, | ||
64 | WL1251_NL_ATTR_CMD_IE, | ||
65 | WL1251_NL_ATTR_CMD_IE_LEN, | ||
66 | WL1251_NL_ATTR_CMD_IE_BUFFER, | ||
67 | WL1251_NL_ATTR_CMD_IE_ANSWER, | ||
68 | WL1251_NL_ATTR_REG_ADDR, | ||
69 | WL1251_NL_ATTR_REG_VAL, | ||
70 | WL1251_NL_ATTR_NVS_BUFFER, | ||
71 | WL1251_NL_ATTR_NVS_LEN, | ||
72 | WL1251_NL_ATTR_PLT_MODE, | ||
73 | |||
74 | __WL1251_NL_ATTR_AFTER_LAST | ||
75 | }; | ||
76 | #define WL1251_NL_ATTR_MAX (__WL1251_NL_ATTR_AFTER_LAST - 1) | ||
77 | |||
78 | static struct genl_family wl1251_nl_family = { | ||
79 | .id = GENL_ID_GENERATE, | ||
80 | .name = WL1251_NL_NAME, | ||
81 | .hdrsize = 0, | ||
82 | .version = WL1251_NL_VERSION, | ||
83 | .maxattr = WL1251_NL_ATTR_MAX, | ||
84 | }; | ||
85 | |||
86 | static struct net_device *ifname_to_netdev(struct net *net, | ||
87 | struct genl_info *info) | ||
88 | { | ||
89 | char *ifname; | ||
90 | |||
91 | if (!info->attrs[WL1251_NL_ATTR_IFNAME]) | ||
92 | return NULL; | ||
93 | |||
94 | ifname = nla_data(info->attrs[WL1251_NL_ATTR_IFNAME]); | ||
95 | |||
96 | wl1251_debug(DEBUG_NETLINK, "Looking for %s", ifname); | ||
97 | |||
98 | return dev_get_by_name(net, ifname); | ||
99 | } | ||
100 | |||
101 | static struct wl1251 *ifname_to_wl1251(struct net *net, struct genl_info *info) | ||
102 | { | ||
103 | struct net_device *netdev; | ||
104 | struct wireless_dev *wdev; | ||
105 | struct wiphy *wiphy; | ||
106 | struct ieee80211_hw *hw; | ||
107 | |||
108 | netdev = ifname_to_netdev(net, info); | ||
109 | if (netdev == NULL) { | ||
110 | wl1251_error("Wrong interface"); | ||
111 | return NULL; | ||
112 | } | ||
113 | |||
114 | wdev = netdev->ieee80211_ptr; | ||
115 | if (wdev == NULL) { | ||
116 | wl1251_error("ieee80211_ptr is NULL"); | ||
117 | return NULL; | ||
118 | } | ||
119 | |||
120 | wiphy = wdev->wiphy; | ||
121 | if (wiphy == NULL) { | ||
122 | wl1251_error("wiphy is NULL"); | ||
123 | return NULL; | ||
124 | } | ||
125 | |||
126 | hw = wiphy_priv(wiphy); | ||
127 | if (hw == NULL) { | ||
128 | wl1251_error("hw is NULL"); | ||
129 | return NULL; | ||
130 | } | ||
131 | |||
132 | dev_put(netdev); | ||
133 | |||
134 | return hw->priv; | ||
135 | } | ||
136 | |||
137 | static int wl1251_nl_test_cmd(struct sk_buff *skb, struct genl_info *info) | ||
138 | { | ||
139 | struct wl1251 *wl; | ||
140 | struct wl1251_command *cmd; | ||
141 | char *buf; | ||
142 | int buf_len, ret, cmd_len; | ||
143 | u8 answer; | ||
144 | |||
145 | if (!info->attrs[WL1251_NL_ATTR_CMD_TEST_PARAM]) | ||
146 | return -EINVAL; | ||
147 | |||
148 | wl = ifname_to_wl1251(&init_net, info); | ||
149 | if (wl == NULL) { | ||
150 | wl1251_error("wl1251 not found"); | ||
151 | return -EINVAL; | ||
152 | } | ||
153 | |||
154 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
155 | if (!cmd) | ||
156 | return -ENOMEM; | ||
157 | |||
158 | buf = nla_data(info->attrs[WL1251_NL_ATTR_CMD_TEST_PARAM]); | ||
159 | buf_len = nla_len(info->attrs[WL1251_NL_ATTR_CMD_TEST_PARAM]); | ||
160 | answer = nla_get_u8(info->attrs[WL1251_NL_ATTR_CMD_TEST_ANSWER]); | ||
161 | |||
162 | cmd->header.id = CMD_TEST; | ||
163 | memcpy(cmd->parameters, buf, buf_len); | ||
164 | cmd_len = sizeof(struct wl1251_cmd_header) + buf_len; | ||
165 | |||
166 | mutex_lock(&wl->mutex); | ||
167 | ret = wl1251_cmd_test(wl, cmd, cmd_len, answer); | ||
168 | mutex_unlock(&wl->mutex); | ||
169 | |||
170 | if (ret < 0) { | ||
171 | wl1251_error("%s() failed", __func__); | ||
172 | goto out; | ||
173 | } | ||
174 | |||
175 | if (answer) { | ||
176 | struct sk_buff *msg; | ||
177 | void *hdr; | ||
178 | |||
179 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
180 | if (!msg) { | ||
181 | ret = -ENOMEM; | ||
182 | goto out; | ||
183 | } | ||
184 | |||
185 | hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, | ||
186 | &wl1251_nl_family, 0, WL1251_NL_CMD_TEST); | ||
187 | if (IS_ERR(hdr)) { | ||
188 | ret = PTR_ERR(hdr); | ||
189 | goto nla_put_failure; | ||
190 | } | ||
191 | |||
192 | NLA_PUT_STRING(msg, WL1251_NL_ATTR_IFNAME, | ||
193 | nla_data(info->attrs[WL1251_NL_ATTR_IFNAME])); | ||
194 | NLA_PUT(msg, WL1251_NL_ATTR_CMD_TEST_ANSWER, | ||
195 | sizeof(*cmd), cmd); | ||
196 | |||
197 | ret = genlmsg_end(msg, hdr); | ||
198 | if (ret < 0) { | ||
199 | wl1251_error("%s() failed", __func__); | ||
200 | goto nla_put_failure; | ||
201 | } | ||
202 | |||
203 | wl1251_debug(DEBUG_NETLINK, "TEST cmd sent, answer"); | ||
204 | ret = genlmsg_reply(msg, info); | ||
205 | goto out; | ||
206 | |||
207 | nla_put_failure: | ||
208 | nlmsg_free(msg); | ||
209 | } else | ||
210 | wl1251_debug(DEBUG_NETLINK, "TEST cmd sent"); | ||
211 | |||
212 | out: | ||
213 | kfree(cmd); | ||
214 | return ret; | ||
215 | } | ||
216 | |||
217 | static int wl1251_nl_interrogate(struct sk_buff *skb, struct genl_info *info) | ||
218 | { | ||
219 | struct wl1251 *wl; | ||
220 | struct sk_buff *msg; | ||
221 | int ret = -ENOBUFS, cmd_ie, cmd_ie_len; | ||
222 | struct wl1251_command *cmd; | ||
223 | void *hdr; | ||
224 | |||
225 | if (!info->attrs[WL1251_NL_ATTR_CMD_IE]) | ||
226 | return -EINVAL; | ||
227 | |||
228 | if (!info->attrs[WL1251_NL_ATTR_CMD_IE_LEN]) | ||
229 | return -EINVAL; | ||
230 | |||
231 | cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); | ||
232 | if (!cmd) | ||
233 | return -ENOMEM; | ||
234 | |||
235 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
236 | if (!msg) | ||
237 | return -ENOMEM; | ||
238 | |||
239 | wl = ifname_to_wl1251(&init_net, info); | ||
240 | if (wl == NULL) { | ||
241 | wl1251_error("wl1251 not found"); | ||
242 | ret = -EINVAL; | ||
243 | goto nla_put_failure; | ||
244 | } | ||
245 | |||
246 | /* acx id */ | ||
247 | cmd_ie = nla_get_u32(info->attrs[WL1251_NL_ATTR_CMD_IE]); | ||
248 | |||
249 | /* maximum length of acx, including all headers */ | ||
250 | cmd_ie_len = nla_get_u32(info->attrs[WL1251_NL_ATTR_CMD_IE_LEN]); | ||
251 | |||
252 | wl1251_debug(DEBUG_NETLINK, "Getting IE 0x%x (len %d)", | ||
253 | cmd_ie, cmd_ie_len); | ||
254 | |||
255 | mutex_lock(&wl->mutex); | ||
256 | ret = wl1251_cmd_interrogate(wl, cmd_ie, cmd, cmd_ie_len); | ||
257 | mutex_unlock(&wl->mutex); | ||
258 | |||
259 | if (ret < 0) { | ||
260 | wl1251_error("%s() failed", __func__); | ||
261 | goto nla_put_failure; | ||
262 | } | ||
263 | |||
264 | hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, | ||
265 | &wl1251_nl_family, 0, WL1251_NL_CMD_INTERROGATE); | ||
266 | if (IS_ERR(hdr)) { | ||
267 | ret = PTR_ERR(hdr); | ||
268 | goto nla_put_failure; | ||
269 | } | ||
270 | |||
271 | NLA_PUT_STRING(msg, WL1251_NL_ATTR_IFNAME, | ||
272 | nla_data(info->attrs[WL1251_NL_ATTR_IFNAME])); | ||
273 | NLA_PUT(msg, WL1251_NL_ATTR_CMD_IE_ANSWER, cmd_ie_len, cmd); | ||
274 | |||
275 | ret = genlmsg_end(msg, hdr); | ||
276 | if (ret < 0) { | ||
277 | wl1251_error("%s() failed", __func__); | ||
278 | goto nla_put_failure; | ||
279 | } | ||
280 | |||
281 | kfree(cmd); | ||
282 | return genlmsg_reply(msg, info); | ||
283 | |||
284 | nla_put_failure: | ||
285 | kfree(cmd); | ||
286 | nlmsg_free(msg); | ||
287 | |||
288 | return ret; | ||
289 | } | ||
290 | |||
291 | static int wl1251_nl_configure(struct sk_buff *skb, struct genl_info *info) | ||
292 | { | ||
293 | int ret = 0, cmd_ie_len, acx_len; | ||
294 | struct acx_header *acx = NULL; | ||
295 | struct sk_buff *msg; | ||
296 | struct wl1251 *wl; | ||
297 | void *cmd_ie; | ||
298 | u16 *id; | ||
299 | |||
300 | if (!info->attrs[WL1251_NL_ATTR_CMD_IE_BUFFER]) | ||
301 | return -EINVAL; | ||
302 | |||
303 | if (!info->attrs[WL1251_NL_ATTR_CMD_IE_LEN]) | ||
304 | return -EINVAL; | ||
305 | |||
306 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
307 | if (!msg) | ||
308 | return -ENOMEM; | ||
309 | |||
310 | wl = ifname_to_wl1251(&init_net, info); | ||
311 | if (wl == NULL) { | ||
312 | wl1251_error("wl1251 not found"); | ||
313 | ret = -EINVAL; | ||
314 | goto nla_put_failure; | ||
315 | } | ||
316 | |||
317 | /* contains the acx header but not the cmd header */ | ||
318 | cmd_ie = nla_data(info->attrs[WL1251_NL_ATTR_CMD_IE_BUFFER]); | ||
319 | |||
320 | cmd_ie_len = nla_get_u32(info->attrs[WL1251_NL_ATTR_CMD_IE_LEN]); | ||
321 | |||
322 | /* acx id is in the first two bytes */ | ||
323 | id = cmd_ie; | ||
324 | |||
325 | /* need to add acx_header before cmd_ie, so create a new command */ | ||
326 | acx_len = sizeof(struct acx_header) + cmd_ie_len; | ||
327 | acx = kzalloc(acx_len, GFP_KERNEL); | ||
328 | if (!acx) { | ||
329 | ret = -ENOMEM; | ||
330 | goto nla_put_failure; | ||
331 | } | ||
332 | |||
333 | /* copy the acx header and the payload */ | ||
334 | memcpy(&acx->id, cmd_ie, cmd_ie_len); | ||
335 | |||
336 | mutex_lock(&wl->mutex); | ||
337 | ret = wl1251_cmd_configure(wl, *id, acx, acx_len); | ||
338 | mutex_unlock(&wl->mutex); | ||
339 | |||
340 | if (ret < 0) { | ||
341 | wl1251_error("%s() failed", __func__); | ||
342 | goto nla_put_failure; | ||
343 | } | ||
344 | |||
345 | wl1251_debug(DEBUG_NETLINK, "CONFIGURE cmd sent"); | ||
346 | |||
347 | nla_put_failure: | ||
348 | kfree(acx); | ||
349 | nlmsg_free(msg); | ||
350 | |||
351 | return ret; | ||
352 | } | ||
353 | |||
354 | static int wl1251_nl_phy_reg_read(struct sk_buff *skb, struct genl_info *info) | ||
355 | { | ||
356 | struct wl1251 *wl; | ||
357 | struct sk_buff *msg; | ||
358 | u32 reg_addr, *reg_value = NULL; | ||
359 | int ret = 0; | ||
360 | void *hdr; | ||
361 | |||
362 | if (!info->attrs[WL1251_NL_ATTR_REG_ADDR]) | ||
363 | return -EINVAL; | ||
364 | |||
365 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
366 | if (!msg) | ||
367 | return -ENOMEM; | ||
368 | |||
369 | wl = ifname_to_wl1251(&init_net, info); | ||
370 | if (wl == NULL) { | ||
371 | wl1251_error("wl1251 not found"); | ||
372 | ret = -EINVAL; | ||
373 | goto nla_put_failure; | ||
374 | } | ||
375 | |||
376 | reg_value = kmalloc(sizeof(*reg_value), GFP_KERNEL); | ||
377 | if (!reg_value) { | ||
378 | ret = -ENOMEM; | ||
379 | goto nla_put_failure; | ||
380 | } | ||
381 | |||
382 | reg_addr = nla_get_u32(info->attrs[WL1251_NL_ATTR_REG_ADDR]); | ||
383 | |||
384 | wl1251_debug(DEBUG_NETLINK, "Reading PHY reg 0x%x", reg_addr); | ||
385 | |||
386 | mutex_lock(&wl->mutex); | ||
387 | ret = wl1251_cmd_read_memory(wl, reg_addr, reg_value, | ||
388 | sizeof(*reg_value)); | ||
389 | mutex_unlock(&wl->mutex); | ||
390 | |||
391 | if (ret < 0) { | ||
392 | wl1251_error("%s() failed", __func__); | ||
393 | goto nla_put_failure; | ||
394 | } | ||
395 | |||
396 | |||
397 | hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, | ||
398 | &wl1251_nl_family, 0, WL1251_NL_CMD_PHY_REG_READ); | ||
399 | if (IS_ERR(hdr)) { | ||
400 | ret = PTR_ERR(hdr); | ||
401 | goto nla_put_failure; | ||
402 | } | ||
403 | |||
404 | NLA_PUT_STRING(msg, WL1251_NL_ATTR_IFNAME, | ||
405 | nla_data(info->attrs[WL1251_NL_ATTR_IFNAME])); | ||
406 | |||
407 | NLA_PUT_U32(msg, WL1251_NL_ATTR_REG_VAL, *reg_value); | ||
408 | |||
409 | ret = genlmsg_end(msg, hdr); | ||
410 | if (ret < 0) { | ||
411 | wl1251_error("%s() failed", __func__); | ||
412 | goto nla_put_failure; | ||
413 | } | ||
414 | |||
415 | kfree(reg_value); | ||
416 | |||
417 | return genlmsg_reply(msg, info); | ||
418 | |||
419 | nla_put_failure: | ||
420 | nlmsg_free(msg); | ||
421 | kfree(reg_value); | ||
422 | |||
423 | return ret; | ||
424 | } | ||
425 | |||
426 | static int wl1251_nl_nvs_push(struct sk_buff *skb, struct genl_info *info) | ||
427 | { | ||
428 | struct wl1251 *wl; | ||
429 | int ret = 0; | ||
430 | |||
431 | if (!info->attrs[WL1251_NL_ATTR_NVS_BUFFER]) | ||
432 | return -EINVAL; | ||
433 | |||
434 | if (!info->attrs[WL1251_NL_ATTR_NVS_LEN]) | ||
435 | return -EINVAL; | ||
436 | |||
437 | wl = ifname_to_wl1251(&init_net, info); | ||
438 | if (wl == NULL) { | ||
439 | wl1251_error("wl1251 not found"); | ||
440 | return -EINVAL; | ||
441 | } | ||
442 | |||
443 | mutex_lock(&wl->mutex); | ||
444 | wl->nvs_len = nla_get_u32(info->attrs[WL1251_NL_ATTR_NVS_LEN]); | ||
445 | if (wl->nvs_len % 4) { | ||
446 | wl1251_error("NVS size is not multiple of 32: %d", wl->nvs_len); | ||
447 | ret = -EILSEQ; | ||
448 | goto out; | ||
449 | } | ||
450 | |||
451 | /* If we already have an NVS, we should free it */ | ||
452 | kfree(wl->nvs); | ||
453 | |||
454 | wl->nvs = kzalloc(wl->nvs_len, GFP_KERNEL); | ||
455 | if (wl->nvs == NULL) { | ||
456 | wl1251_error("Can't allocate NVS"); | ||
457 | ret = -ENOMEM; | ||
458 | goto out; | ||
459 | } | ||
460 | |||
461 | memcpy(wl->nvs, | ||
462 | nla_data(info->attrs[WL1251_NL_ATTR_NVS_BUFFER]), | ||
463 | wl->nvs_len); | ||
464 | |||
465 | wl1251_debug(DEBUG_NETLINK, "got NVS from userspace, %d bytes", | ||
466 | wl->nvs_len); | ||
467 | |||
468 | out: | ||
469 | mutex_unlock(&wl->mutex); | ||
470 | |||
471 | return ret; | ||
472 | } | ||
473 | |||
474 | static int wl1251_nl_reg_read(struct sk_buff *skb, struct genl_info *info) | ||
475 | { | ||
476 | struct wl1251 *wl; | ||
477 | u32 addr, val; | ||
478 | int ret = 0; | ||
479 | struct sk_buff *msg; | ||
480 | void *hdr; | ||
481 | |||
482 | if (!info->attrs[WL1251_NL_ATTR_REG_ADDR]) | ||
483 | return -EINVAL; | ||
484 | |||
485 | msg = nlmsg_new(NLMSG_GOODSIZE, GFP_KERNEL); | ||
486 | if (!msg) | ||
487 | return -ENOMEM; | ||
488 | |||
489 | wl = ifname_to_wl1251(&init_net, info); | ||
490 | if (wl == NULL) { | ||
491 | wl1251_error("wl1251 not found"); | ||
492 | return -EINVAL; | ||
493 | } | ||
494 | |||
495 | addr = nla_get_u32(info->attrs[WL1251_NL_ATTR_REG_ADDR]); | ||
496 | |||
497 | mutex_lock(&wl->mutex); | ||
498 | val = wl1251_reg_read32(wl, addr); | ||
499 | mutex_unlock(&wl->mutex); | ||
500 | |||
501 | hdr = genlmsg_put(msg, info->snd_pid, info->snd_seq, | ||
502 | &wl1251_nl_family, 0, WL1251_NL_CMD_PHY_REG_READ); | ||
503 | if (IS_ERR(hdr)) { | ||
504 | ret = PTR_ERR(hdr); | ||
505 | goto nla_put_failure; | ||
506 | } | ||
507 | |||
508 | NLA_PUT_STRING(msg, WL1251_NL_ATTR_IFNAME, | ||
509 | nla_data(info->attrs[WL1251_NL_ATTR_IFNAME])); | ||
510 | |||
511 | NLA_PUT_U32(msg, WL1251_NL_ATTR_REG_VAL, val); | ||
512 | |||
513 | ret = genlmsg_end(msg, hdr); | ||
514 | if (ret < 0) { | ||
515 | wl1251_error("%s() failed", __func__); | ||
516 | goto nla_put_failure; | ||
517 | } | ||
518 | |||
519 | return genlmsg_reply(msg, info); | ||
520 | |||
521 | nla_put_failure: | ||
522 | nlmsg_free(msg); | ||
523 | |||
524 | return ret; | ||
525 | } | ||
526 | |||
527 | static int wl1251_nl_reg_write(struct sk_buff *skb, struct genl_info *info) | ||
528 | { | ||
529 | struct wl1251 *wl; | ||
530 | u32 addr, val; | ||
531 | |||
532 | if (!info->attrs[WL1251_NL_ATTR_REG_ADDR]) | ||
533 | return -EINVAL; | ||
534 | |||
535 | if (!info->attrs[WL1251_NL_ATTR_REG_VAL]) | ||
536 | return -EINVAL; | ||
537 | |||
538 | wl = ifname_to_wl1251(&init_net, info); | ||
539 | if (wl == NULL) { | ||
540 | wl1251_error("wl1251 not found"); | ||
541 | return -EINVAL; | ||
542 | } | ||
543 | |||
544 | addr = nla_get_u32(info->attrs[WL1251_NL_ATTR_REG_ADDR]); | ||
545 | val = nla_get_u32(info->attrs[WL1251_NL_ATTR_REG_VAL]); | ||
546 | |||
547 | mutex_lock(&wl->mutex); | ||
548 | wl1251_reg_write32(wl, addr, val); | ||
549 | mutex_unlock(&wl->mutex); | ||
550 | |||
551 | return 0; | ||
552 | } | ||
553 | |||
554 | static int wl1251_nl_set_plt_mode(struct sk_buff *skb, struct genl_info *info) | ||
555 | { | ||
556 | struct wl1251 *wl; | ||
557 | u32 val; | ||
558 | int ret; | ||
559 | |||
560 | if (!info->attrs[WL1251_NL_ATTR_PLT_MODE]) | ||
561 | return -EINVAL; | ||
562 | |||
563 | wl = ifname_to_wl1251(&init_net, info); | ||
564 | if (wl == NULL) { | ||
565 | wl1251_error("wl1251 not found"); | ||
566 | return -EINVAL; | ||
567 | } | ||
568 | |||
569 | val = nla_get_u32(info->attrs[WL1251_NL_ATTR_PLT_MODE]); | ||
570 | |||
571 | switch (val) { | ||
572 | case 0: | ||
573 | ret = wl1251_plt_stop(wl); | ||
574 | break; | ||
575 | case 1: | ||
576 | ret = wl1251_plt_start(wl); | ||
577 | break; | ||
578 | default: | ||
579 | ret = -EINVAL; | ||
580 | break; | ||
581 | } | ||
582 | |||
583 | return ret; | ||
584 | } | ||
585 | |||
586 | static struct nla_policy wl1251_nl_policy[WL1251_NL_ATTR_MAX + 1] = { | ||
587 | [WL1251_NL_ATTR_IFNAME] = { .type = NLA_NUL_STRING, | ||
588 | .len = IFNAMSIZ-1 }, | ||
589 | [WL1251_NL_ATTR_CMD_TEST_PARAM] = { .type = NLA_BINARY, | ||
590 | .len = WL1251_MAX_TEST_LENGTH }, | ||
591 | [WL1251_NL_ATTR_CMD_TEST_ANSWER] = { .type = NLA_U8 }, | ||
592 | [WL1251_NL_ATTR_CMD_IE] = { .type = NLA_U32 }, | ||
593 | [WL1251_NL_ATTR_CMD_IE_LEN] = { .type = NLA_U32 }, | ||
594 | [WL1251_NL_ATTR_CMD_IE_BUFFER] = { .type = NLA_BINARY, | ||
595 | .len = WL1251_MAX_TEST_LENGTH }, | ||
596 | [WL1251_NL_ATTR_CMD_IE_ANSWER] = { .type = NLA_BINARY, | ||
597 | .len = WL1251_MAX_TEST_LENGTH }, | ||
598 | [WL1251_NL_ATTR_REG_ADDR] = { .type = NLA_U32 }, | ||
599 | [WL1251_NL_ATTR_REG_VAL] = { .type = NLA_U32 }, | ||
600 | [WL1251_NL_ATTR_NVS_BUFFER] = { .type = NLA_BINARY, | ||
601 | .len = WL1251_MAX_NVS_LENGTH }, | ||
602 | [WL1251_NL_ATTR_NVS_LEN] = { .type = NLA_U32 }, | ||
603 | [WL1251_NL_ATTR_PLT_MODE] = { .type = NLA_U32 }, | ||
604 | }; | ||
605 | |||
606 | static struct genl_ops wl1251_nl_ops[] = { | ||
607 | { | ||
608 | .cmd = WL1251_NL_CMD_TEST, | ||
609 | .doit = wl1251_nl_test_cmd, | ||
610 | .policy = wl1251_nl_policy, | ||
611 | .flags = GENL_ADMIN_PERM, | ||
612 | }, | ||
613 | { | ||
614 | .cmd = WL1251_NL_CMD_INTERROGATE, | ||
615 | .doit = wl1251_nl_interrogate, | ||
616 | .policy = wl1251_nl_policy, | ||
617 | .flags = GENL_ADMIN_PERM, | ||
618 | }, | ||
619 | { | ||
620 | .cmd = WL1251_NL_CMD_CONFIGURE, | ||
621 | .doit = wl1251_nl_configure, | ||
622 | .policy = wl1251_nl_policy, | ||
623 | .flags = GENL_ADMIN_PERM, | ||
624 | }, | ||
625 | { | ||
626 | .cmd = WL1251_NL_CMD_PHY_REG_READ, | ||
627 | .doit = wl1251_nl_phy_reg_read, | ||
628 | .policy = wl1251_nl_policy, | ||
629 | .flags = GENL_ADMIN_PERM, | ||
630 | }, | ||
631 | { | ||
632 | .cmd = WL1251_NL_CMD_NVS_PUSH, | ||
633 | .doit = wl1251_nl_nvs_push, | ||
634 | .policy = wl1251_nl_policy, | ||
635 | .flags = GENL_ADMIN_PERM, | ||
636 | }, | ||
637 | { | ||
638 | .cmd = WL1251_NL_CMD_REG_WRITE, | ||
639 | .doit = wl1251_nl_reg_write, | ||
640 | .policy = wl1251_nl_policy, | ||
641 | .flags = GENL_ADMIN_PERM, | ||
642 | }, | ||
643 | { | ||
644 | .cmd = WL1251_NL_CMD_REG_READ, | ||
645 | .doit = wl1251_nl_reg_read, | ||
646 | .policy = wl1251_nl_policy, | ||
647 | .flags = GENL_ADMIN_PERM, | ||
648 | }, | ||
649 | { | ||
650 | .cmd = WL1251_NL_CMD_SET_PLT_MODE, | ||
651 | .doit = wl1251_nl_set_plt_mode, | ||
652 | .policy = wl1251_nl_policy, | ||
653 | .flags = GENL_ADMIN_PERM, | ||
654 | }, | ||
655 | }; | ||
656 | |||
657 | int wl1251_nl_register(void) | ||
658 | { | ||
659 | int err, i; | ||
660 | |||
661 | err = genl_register_family(&wl1251_nl_family); | ||
662 | if (err) | ||
663 | return err; | ||
664 | |||
665 | for (i = 0; i < ARRAY_SIZE(wl1251_nl_ops); i++) { | ||
666 | err = genl_register_ops(&wl1251_nl_family, &wl1251_nl_ops[i]); | ||
667 | if (err) | ||
668 | goto err_out; | ||
669 | } | ||
670 | return 0; | ||
671 | err_out: | ||
672 | genl_unregister_family(&wl1251_nl_family); | ||
673 | return err; | ||
674 | } | ||
675 | |||
676 | void wl1251_nl_unregister(void) | ||
677 | { | ||
678 | genl_unregister_family(&wl1251_nl_family); | ||
679 | } | ||
diff --git a/drivers/net/wireless/wl12xx/wl1251_netlink.h b/drivers/net/wireless/wl12xx/wl1251_netlink.h new file mode 100644 index 000000000000..ee36695e134e --- /dev/null +++ b/drivers/net/wireless/wl12xx/wl1251_netlink.h | |||
@@ -0,0 +1,30 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2009 Nokia Corporation | ||
5 | * | ||
6 | * Contact: Kalle Valo <kalle.valo@nokia.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * version 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
20 | * 02110-1301 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __WL1251_NETLINK_H__ | ||
25 | #define __WL1251_NETLINK_H__ | ||
26 | |||
27 | int wl1251_nl_register(void); | ||
28 | void wl1251_nl_unregister(void); | ||
29 | |||
30 | #endif /* __WL1251_NETLINK_H__ */ | ||
diff --git a/drivers/net/wireless/wl12xx/wl1251.c b/drivers/net/wireless/wl12xx/wl1251_ops.c index ce1561a41fa4..96a45f595297 100644 --- a/drivers/net/wireless/wl12xx/wl1251.c +++ b/drivers/net/wireless/wl12xx/wl1251_ops.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2008-2009 Nokia Corporation | 4 | * Copyright (C) 2008-2009 Nokia Corporation |
5 | * | 5 | * |
@@ -24,18 +24,18 @@ | |||
24 | #include <linux/kernel.h> | 24 | #include <linux/kernel.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | 26 | ||
27 | #include "wl1251.h" | 27 | #include "wl1251_ops.h" |
28 | #include "reg.h" | 28 | #include "reg.h" |
29 | #include "spi.h" | 29 | #include "wl1251_spi.h" |
30 | #include "boot.h" | 30 | #include "wl1251_boot.h" |
31 | #include "event.h" | 31 | #include "wl1251_event.h" |
32 | #include "acx.h" | 32 | #include "wl1251_acx.h" |
33 | #include "tx.h" | 33 | #include "wl1251_tx.h" |
34 | #include "rx.h" | 34 | #include "wl1251_rx.h" |
35 | #include "ps.h" | 35 | #include "wl1251_ps.h" |
36 | #include "init.h" | 36 | #include "wl1251_init.h" |
37 | 37 | ||
38 | static struct wl12xx_partition_set wl1251_part_table[PART_TABLE_LEN] = { | 38 | static struct wl1251_partition_set wl1251_part_table[PART_TABLE_LEN] = { |
39 | [PART_DOWN] = { | 39 | [PART_DOWN] = { |
40 | .mem = { | 40 | .mem = { |
41 | .start = 0x00000000, | 41 | .start = 0x00000000, |
@@ -75,31 +75,31 @@ static enum wl12xx_acx_int_reg wl1251_acx_reg_table[ACX_REG_TABLE_LEN] = { | |||
75 | [ACX_REG_ECPU_CONTROL] = (REGISTERS_BASE + 0x0804) | 75 | [ACX_REG_ECPU_CONTROL] = (REGISTERS_BASE + 0x0804) |
76 | }; | 76 | }; |
77 | 77 | ||
78 | static int wl1251_upload_firmware(struct wl12xx *wl) | 78 | static int wl1251_upload_firmware(struct wl1251 *wl) |
79 | { | 79 | { |
80 | struct wl12xx_partition_set *p_table = wl->chip.p_table; | 80 | struct wl1251_partition_set *p_table = wl->chip.p_table; |
81 | int addr, chunk_num, partition_limit; | 81 | int addr, chunk_num, partition_limit; |
82 | size_t fw_data_len; | 82 | size_t fw_data_len; |
83 | u8 *p; | 83 | u8 *p; |
84 | 84 | ||
85 | /* whal_FwCtrl_LoadFwImageSm() */ | 85 | /* whal_FwCtrl_LoadFwImageSm() */ |
86 | 86 | ||
87 | wl12xx_debug(DEBUG_BOOT, "chip id before fw upload: 0x%x", | 87 | wl1251_debug(DEBUG_BOOT, "chip id before fw upload: 0x%x", |
88 | wl12xx_reg_read32(wl, CHIP_ID_B)); | 88 | wl1251_reg_read32(wl, CHIP_ID_B)); |
89 | 89 | ||
90 | /* 10.0 check firmware length and set partition */ | 90 | /* 10.0 check firmware length and set partition */ |
91 | fw_data_len = (wl->fw[4] << 24) | (wl->fw[5] << 16) | | 91 | fw_data_len = (wl->fw[4] << 24) | (wl->fw[5] << 16) | |
92 | (wl->fw[6] << 8) | (wl->fw[7]); | 92 | (wl->fw[6] << 8) | (wl->fw[7]); |
93 | 93 | ||
94 | wl12xx_debug(DEBUG_BOOT, "fw_data_len %zu chunk_size %d", fw_data_len, | 94 | wl1251_debug(DEBUG_BOOT, "fw_data_len %zu chunk_size %d", fw_data_len, |
95 | CHUNK_SIZE); | 95 | CHUNK_SIZE); |
96 | 96 | ||
97 | if ((fw_data_len % 4) != 0) { | 97 | if ((fw_data_len % 4) != 0) { |
98 | wl12xx_error("firmware length not multiple of four"); | 98 | wl1251_error("firmware length not multiple of four"); |
99 | return -EIO; | 99 | return -EIO; |
100 | } | 100 | } |
101 | 101 | ||
102 | wl12xx_set_partition(wl, | 102 | wl1251_set_partition(wl, |
103 | p_table[PART_DOWN].mem.start, | 103 | p_table[PART_DOWN].mem.start, |
104 | p_table[PART_DOWN].mem.size, | 104 | p_table[PART_DOWN].mem.size, |
105 | p_table[PART_DOWN].reg.start, | 105 | p_table[PART_DOWN].reg.start, |
@@ -118,7 +118,7 @@ static int wl1251_upload_firmware(struct wl12xx *wl) | |||
118 | chunk_num * CHUNK_SIZE; | 118 | chunk_num * CHUNK_SIZE; |
119 | partition_limit = chunk_num * CHUNK_SIZE + | 119 | partition_limit = chunk_num * CHUNK_SIZE + |
120 | p_table[PART_DOWN].mem.size; | 120 | p_table[PART_DOWN].mem.size; |
121 | wl12xx_set_partition(wl, | 121 | wl1251_set_partition(wl, |
122 | addr, | 122 | addr, |
123 | p_table[PART_DOWN].mem.size, | 123 | p_table[PART_DOWN].mem.size, |
124 | p_table[PART_DOWN].reg.start, | 124 | p_table[PART_DOWN].reg.start, |
@@ -128,9 +128,9 @@ static int wl1251_upload_firmware(struct wl12xx *wl) | |||
128 | /* 10.3 upload the chunk */ | 128 | /* 10.3 upload the chunk */ |
129 | addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE; | 129 | addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE; |
130 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; | 130 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; |
131 | wl12xx_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x", | 131 | wl1251_debug(DEBUG_BOOT, "uploading fw chunk 0x%p to 0x%x", |
132 | p, addr); | 132 | p, addr); |
133 | wl12xx_spi_mem_write(wl, addr, p, CHUNK_SIZE); | 133 | wl1251_spi_mem_write(wl, addr, p, CHUNK_SIZE); |
134 | 134 | ||
135 | chunk_num++; | 135 | chunk_num++; |
136 | } | 136 | } |
@@ -138,14 +138,14 @@ static int wl1251_upload_firmware(struct wl12xx *wl) | |||
138 | /* 10.4 upload the last chunk */ | 138 | /* 10.4 upload the last chunk */ |
139 | addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE; | 139 | addr = p_table[PART_DOWN].mem.start + chunk_num * CHUNK_SIZE; |
140 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; | 140 | p = wl->fw + FW_HDR_SIZE + chunk_num * CHUNK_SIZE; |
141 | wl12xx_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x", | 141 | wl1251_debug(DEBUG_BOOT, "uploading fw last chunk (%zu B) 0x%p to 0x%x", |
142 | fw_data_len % CHUNK_SIZE, p, addr); | 142 | fw_data_len % CHUNK_SIZE, p, addr); |
143 | wl12xx_spi_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE); | 143 | wl1251_spi_mem_write(wl, addr, p, fw_data_len % CHUNK_SIZE); |
144 | 144 | ||
145 | return 0; | 145 | return 0; |
146 | } | 146 | } |
147 | 147 | ||
148 | static int wl1251_upload_nvs(struct wl12xx *wl) | 148 | static int wl1251_upload_nvs(struct wl1251 *wl) |
149 | { | 149 | { |
150 | size_t nvs_len, nvs_bytes_written, burst_len; | 150 | size_t nvs_len, nvs_bytes_written, burst_len; |
151 | int nvs_start, i; | 151 | int nvs_start, i; |
@@ -181,10 +181,10 @@ static int wl1251_upload_nvs(struct wl12xx *wl) | |||
181 | val = (nvs_ptr[0] | (nvs_ptr[1] << 8) | 181 | val = (nvs_ptr[0] | (nvs_ptr[1] << 8) |
182 | | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); | 182 | | (nvs_ptr[2] << 16) | (nvs_ptr[3] << 24)); |
183 | 183 | ||
184 | wl12xx_debug(DEBUG_BOOT, | 184 | wl1251_debug(DEBUG_BOOT, |
185 | "nvs burst write 0x%x: 0x%x", | 185 | "nvs burst write 0x%x: 0x%x", |
186 | dest_addr, val); | 186 | dest_addr, val); |
187 | wl12xx_mem_write32(wl, dest_addr, val); | 187 | wl1251_mem_write32(wl, dest_addr, val); |
188 | 188 | ||
189 | nvs_ptr += 4; | 189 | nvs_ptr += 4; |
190 | dest_addr += 4; | 190 | dest_addr += 4; |
@@ -200,7 +200,7 @@ static int wl1251_upload_nvs(struct wl12xx *wl) | |||
200 | nvs_len = ALIGN(nvs_len, 4); | 200 | nvs_len = ALIGN(nvs_len, 4); |
201 | 201 | ||
202 | /* Now we must set the partition correctly */ | 202 | /* Now we must set the partition correctly */ |
203 | wl12xx_set_partition(wl, nvs_start, | 203 | wl1251_set_partition(wl, nvs_start, |
204 | wl->chip.p_table[PART_DOWN].mem.size, | 204 | wl->chip.p_table[PART_DOWN].mem.size, |
205 | wl->chip.p_table[PART_DOWN].reg.start, | 205 | wl->chip.p_table[PART_DOWN].reg.start, |
206 | wl->chip.p_table[PART_DOWN].reg.size); | 206 | wl->chip.p_table[PART_DOWN].reg.size); |
@@ -213,10 +213,10 @@ static int wl1251_upload_nvs(struct wl12xx *wl) | |||
213 | 213 | ||
214 | val = cpu_to_le32(val); | 214 | val = cpu_to_le32(val); |
215 | 215 | ||
216 | wl12xx_debug(DEBUG_BOOT, | 216 | wl1251_debug(DEBUG_BOOT, |
217 | "nvs write table 0x%x: 0x%x", | 217 | "nvs write table 0x%x: 0x%x", |
218 | nvs_start, val); | 218 | nvs_start, val); |
219 | wl12xx_mem_write32(wl, nvs_start, val); | 219 | wl1251_mem_write32(wl, nvs_start, val); |
220 | 220 | ||
221 | nvs_ptr += 4; | 221 | nvs_ptr += 4; |
222 | nvs_bytes_written += 4; | 222 | nvs_bytes_written += 4; |
@@ -226,12 +226,12 @@ static int wl1251_upload_nvs(struct wl12xx *wl) | |||
226 | return 0; | 226 | return 0; |
227 | } | 227 | } |
228 | 228 | ||
229 | static int wl1251_boot(struct wl12xx *wl) | 229 | static int wl1251_boot(struct wl1251 *wl) |
230 | { | 230 | { |
231 | int ret = 0, minor_minor_e2_ver; | 231 | int ret = 0, minor_minor_e2_ver; |
232 | u32 tmp, boot_data; | 232 | u32 tmp, boot_data; |
233 | 233 | ||
234 | ret = wl12xx_boot_soft_reset(wl); | 234 | ret = wl1251_boot_soft_reset(wl); |
235 | if (ret < 0) | 235 | if (ret < 0) |
236 | goto out; | 236 | goto out; |
237 | 237 | ||
@@ -242,39 +242,39 @@ static int wl1251_boot(struct wl12xx *wl) | |||
242 | 242 | ||
243 | /* write firmware's last address (ie. it's length) to | 243 | /* write firmware's last address (ie. it's length) to |
244 | * ACX_EEPROMLESS_IND_REG */ | 244 | * ACX_EEPROMLESS_IND_REG */ |
245 | wl12xx_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len); | 245 | wl1251_reg_write32(wl, ACX_EEPROMLESS_IND_REG, wl->fw_len); |
246 | 246 | ||
247 | /* 6. read the EEPROM parameters */ | 247 | /* 6. read the EEPROM parameters */ |
248 | tmp = wl12xx_reg_read32(wl, SCR_PAD2); | 248 | tmp = wl1251_reg_read32(wl, SCR_PAD2); |
249 | 249 | ||
250 | /* 7. read bootdata */ | 250 | /* 7. read bootdata */ |
251 | wl->boot_attr.radio_type = (tmp & 0x0000FF00) >> 8; | 251 | wl->boot_attr.radio_type = (tmp & 0x0000FF00) >> 8; |
252 | wl->boot_attr.major = (tmp & 0x00FF0000) >> 16; | 252 | wl->boot_attr.major = (tmp & 0x00FF0000) >> 16; |
253 | tmp = wl12xx_reg_read32(wl, SCR_PAD3); | 253 | tmp = wl1251_reg_read32(wl, SCR_PAD3); |
254 | 254 | ||
255 | /* 8. check bootdata and call restart sequence */ | 255 | /* 8. check bootdata and call restart sequence */ |
256 | wl->boot_attr.minor = (tmp & 0x00FF0000) >> 16; | 256 | wl->boot_attr.minor = (tmp & 0x00FF0000) >> 16; |
257 | minor_minor_e2_ver = (tmp & 0xFF000000) >> 24; | 257 | minor_minor_e2_ver = (tmp & 0xFF000000) >> 24; |
258 | 258 | ||
259 | wl12xx_debug(DEBUG_BOOT, "radioType 0x%x majorE2Ver 0x%x " | 259 | wl1251_debug(DEBUG_BOOT, "radioType 0x%x majorE2Ver 0x%x " |
260 | "minorE2Ver 0x%x minor_minor_e2_ver 0x%x", | 260 | "minorE2Ver 0x%x minor_minor_e2_ver 0x%x", |
261 | wl->boot_attr.radio_type, wl->boot_attr.major, | 261 | wl->boot_attr.radio_type, wl->boot_attr.major, |
262 | wl->boot_attr.minor, minor_minor_e2_ver); | 262 | wl->boot_attr.minor, minor_minor_e2_ver); |
263 | 263 | ||
264 | ret = wl12xx_boot_init_seq(wl); | 264 | ret = wl1251_boot_init_seq(wl); |
265 | if (ret < 0) | 265 | if (ret < 0) |
266 | goto out; | 266 | goto out; |
267 | 267 | ||
268 | /* 9. NVS processing done */ | 268 | /* 9. NVS processing done */ |
269 | boot_data = wl12xx_reg_read32(wl, ACX_REG_ECPU_CONTROL); | 269 | boot_data = wl1251_reg_read32(wl, ACX_REG_ECPU_CONTROL); |
270 | 270 | ||
271 | wl12xx_debug(DEBUG_BOOT, "halt boot_data 0x%x", boot_data); | 271 | wl1251_debug(DEBUG_BOOT, "halt boot_data 0x%x", boot_data); |
272 | 272 | ||
273 | /* 10. check that ECPU_CONTROL_HALT bits are set in | 273 | /* 10. check that ECPU_CONTROL_HALT bits are set in |
274 | * pWhalBus->uBootData and start uploading firmware | 274 | * pWhalBus->uBootData and start uploading firmware |
275 | */ | 275 | */ |
276 | if ((boot_data & ECPU_CONTROL_HALT) == 0) { | 276 | if ((boot_data & ECPU_CONTROL_HALT) == 0) { |
277 | wl12xx_error("boot failed, ECPU_CONTROL_HALT not set"); | 277 | wl1251_error("boot failed, ECPU_CONTROL_HALT not set"); |
278 | ret = -EIO; | 278 | ret = -EIO; |
279 | goto out; | 279 | goto out; |
280 | } | 280 | } |
@@ -284,62 +284,62 @@ static int wl1251_boot(struct wl12xx *wl) | |||
284 | goto out; | 284 | goto out; |
285 | 285 | ||
286 | /* 10.5 start firmware */ | 286 | /* 10.5 start firmware */ |
287 | ret = wl12xx_boot_run_firmware(wl); | 287 | ret = wl1251_boot_run_firmware(wl); |
288 | if (ret < 0) | 288 | if (ret < 0) |
289 | goto out; | 289 | goto out; |
290 | 290 | ||
291 | /* Get and save the firmware version */ | ||
292 | wl12xx_acx_fw_version(wl, wl->chip.fw_ver, sizeof(wl->chip.fw_ver)); | ||
293 | |||
294 | out: | 291 | out: |
295 | return ret; | 292 | return ret; |
296 | } | 293 | } |
297 | 294 | ||
298 | static int wl1251_mem_cfg(struct wl12xx *wl) | 295 | static int wl1251_mem_cfg(struct wl1251 *wl) |
299 | { | 296 | { |
300 | struct wl1251_acx_config_memory mem_conf; | 297 | struct wl1251_acx_config_memory *mem_conf; |
301 | int ret, i; | 298 | int ret, i; |
302 | 299 | ||
303 | wl12xx_debug(DEBUG_ACX, "wl1251 mem cfg"); | 300 | wl1251_debug(DEBUG_ACX, "wl1251 mem cfg"); |
301 | |||
302 | mem_conf = kzalloc(sizeof(*mem_conf), GFP_KERNEL); | ||
303 | if (!mem_conf) { | ||
304 | ret = -ENOMEM; | ||
305 | goto out; | ||
306 | } | ||
304 | 307 | ||
305 | /* memory config */ | 308 | /* memory config */ |
306 | mem_conf.mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS); | 309 | mem_conf->mem_config.num_stations = cpu_to_le16(DEFAULT_NUM_STATIONS); |
307 | mem_conf.mem_config.rx_mem_block_num = 35; | 310 | mem_conf->mem_config.rx_mem_block_num = 35; |
308 | mem_conf.mem_config.tx_min_mem_block_num = 64; | 311 | mem_conf->mem_config.tx_min_mem_block_num = 64; |
309 | mem_conf.mem_config.num_tx_queues = MAX_TX_QUEUES; | 312 | mem_conf->mem_config.num_tx_queues = MAX_TX_QUEUES; |
310 | mem_conf.mem_config.host_if_options = HOSTIF_PKT_RING; | 313 | mem_conf->mem_config.host_if_options = HOSTIF_PKT_RING; |
311 | mem_conf.mem_config.num_ssid_profiles = 1; | 314 | mem_conf->mem_config.num_ssid_profiles = 1; |
312 | mem_conf.mem_config.debug_buffer_size = | 315 | mem_conf->mem_config.debug_buffer_size = |
313 | cpu_to_le16(TRACE_BUFFER_MAX_SIZE); | 316 | cpu_to_le16(TRACE_BUFFER_MAX_SIZE); |
314 | 317 | ||
315 | /* RX queue config */ | 318 | /* RX queue config */ |
316 | mem_conf.rx_queue_config.dma_address = 0; | 319 | mem_conf->rx_queue_config.dma_address = 0; |
317 | mem_conf.rx_queue_config.num_descs = ACX_RX_DESC_DEF; | 320 | mem_conf->rx_queue_config.num_descs = ACX_RX_DESC_DEF; |
318 | mem_conf.rx_queue_config.priority = DEFAULT_RXQ_PRIORITY; | 321 | mem_conf->rx_queue_config.priority = DEFAULT_RXQ_PRIORITY; |
319 | mem_conf.rx_queue_config.type = DEFAULT_RXQ_TYPE; | 322 | mem_conf->rx_queue_config.type = DEFAULT_RXQ_TYPE; |
320 | 323 | ||
321 | /* TX queue config */ | 324 | /* TX queue config */ |
322 | for (i = 0; i < MAX_TX_QUEUES; i++) { | 325 | for (i = 0; i < MAX_TX_QUEUES; i++) { |
323 | mem_conf.tx_queue_config[i].num_descs = ACX_TX_DESC_DEF; | 326 | mem_conf->tx_queue_config[i].num_descs = ACX_TX_DESC_DEF; |
324 | mem_conf.tx_queue_config[i].attributes = i; | 327 | mem_conf->tx_queue_config[i].attributes = i; |
325 | } | 328 | } |
326 | 329 | ||
327 | mem_conf.header.id = ACX_MEM_CFG; | 330 | ret = wl1251_cmd_configure(wl, ACX_MEM_CFG, mem_conf, |
328 | mem_conf.header.len = sizeof(struct wl1251_acx_config_memory) - | 331 | sizeof(*mem_conf)); |
329 | sizeof(struct acx_header); | 332 | if (ret < 0) { |
330 | mem_conf.header.len -= | 333 | wl1251_warning("wl1251 mem config failed: %d", ret); |
331 | (MAX_TX_QUEUE_CONFIGS - mem_conf.mem_config.num_tx_queues) * | 334 | goto out; |
332 | sizeof(struct wl1251_acx_tx_queue_config); | 335 | } |
333 | |||
334 | ret = wl12xx_cmd_configure(wl, &mem_conf, | ||
335 | sizeof(struct wl1251_acx_config_memory)); | ||
336 | if (ret < 0) | ||
337 | wl12xx_warning("wl1251 mem config failed: %d", ret); | ||
338 | 336 | ||
337 | out: | ||
338 | kfree(mem_conf); | ||
339 | return ret; | 339 | return ret; |
340 | } | 340 | } |
341 | 341 | ||
342 | static int wl1251_hw_init_mem_config(struct wl12xx *wl) | 342 | static int wl1251_hw_init_mem_config(struct wl1251 *wl) |
343 | { | 343 | { |
344 | int ret; | 344 | int ret; |
345 | 345 | ||
@@ -350,15 +350,15 @@ static int wl1251_hw_init_mem_config(struct wl12xx *wl) | |||
350 | wl->target_mem_map = kzalloc(sizeof(struct wl1251_acx_mem_map), | 350 | wl->target_mem_map = kzalloc(sizeof(struct wl1251_acx_mem_map), |
351 | GFP_KERNEL); | 351 | GFP_KERNEL); |
352 | if (!wl->target_mem_map) { | 352 | if (!wl->target_mem_map) { |
353 | wl12xx_error("couldn't allocate target memory map"); | 353 | wl1251_error("couldn't allocate target memory map"); |
354 | return -ENOMEM; | 354 | return -ENOMEM; |
355 | } | 355 | } |
356 | 356 | ||
357 | /* we now ask for the firmware built memory map */ | 357 | /* we now ask for the firmware built memory map */ |
358 | ret = wl12xx_acx_mem_map(wl, wl->target_mem_map, | 358 | ret = wl1251_acx_mem_map(wl, wl->target_mem_map, |
359 | sizeof(struct wl1251_acx_mem_map)); | 359 | sizeof(struct wl1251_acx_mem_map)); |
360 | if (ret < 0) { | 360 | if (ret < 0) { |
361 | wl12xx_error("couldn't retrieve firmware memory map"); | 361 | wl1251_error("couldn't retrieve firmware memory map"); |
362 | kfree(wl->target_mem_map); | 362 | kfree(wl->target_mem_map); |
363 | wl->target_mem_map = NULL; | 363 | wl->target_mem_map = NULL; |
364 | return ret; | 364 | return ret; |
@@ -367,19 +367,19 @@ static int wl1251_hw_init_mem_config(struct wl12xx *wl) | |||
367 | return 0; | 367 | return 0; |
368 | } | 368 | } |
369 | 369 | ||
370 | static void wl1251_set_ecpu_ctrl(struct wl12xx *wl, u32 flag) | 370 | static void wl1251_set_ecpu_ctrl(struct wl1251 *wl, u32 flag) |
371 | { | 371 | { |
372 | u32 cpu_ctrl; | 372 | u32 cpu_ctrl; |
373 | 373 | ||
374 | /* 10.5.0 run the firmware (I) */ | 374 | /* 10.5.0 run the firmware (I) */ |
375 | cpu_ctrl = wl12xx_reg_read32(wl, ACX_REG_ECPU_CONTROL); | 375 | cpu_ctrl = wl1251_reg_read32(wl, ACX_REG_ECPU_CONTROL); |
376 | 376 | ||
377 | /* 10.5.1 run the firmware (II) */ | 377 | /* 10.5.1 run the firmware (II) */ |
378 | cpu_ctrl &= ~flag; | 378 | cpu_ctrl &= ~flag; |
379 | wl12xx_reg_write32(wl, ACX_REG_ECPU_CONTROL, cpu_ctrl); | 379 | wl1251_reg_write32(wl, ACX_REG_ECPU_CONTROL, cpu_ctrl); |
380 | } | 380 | } |
381 | 381 | ||
382 | static void wl1251_target_enable_interrupts(struct wl12xx *wl) | 382 | static void wl1251_target_enable_interrupts(struct wl1251 *wl) |
383 | { | 383 | { |
384 | /* Enable target's interrupts */ | 384 | /* Enable target's interrupts */ |
385 | wl->intr_mask = WL1251_ACX_INTR_RX0_DATA | | 385 | wl->intr_mask = WL1251_ACX_INTR_RX0_DATA | |
@@ -388,52 +388,60 @@ static void wl1251_target_enable_interrupts(struct wl12xx *wl) | |||
388 | WL1251_ACX_INTR_EVENT_A | | 388 | WL1251_ACX_INTR_EVENT_A | |
389 | WL1251_ACX_INTR_EVENT_B | | 389 | WL1251_ACX_INTR_EVENT_B | |
390 | WL1251_ACX_INTR_INIT_COMPLETE; | 390 | WL1251_ACX_INTR_INIT_COMPLETE; |
391 | wl12xx_boot_target_enable_interrupts(wl); | 391 | wl1251_boot_target_enable_interrupts(wl); |
392 | } | ||
393 | |||
394 | static void wl1251_fw_version(struct wl1251 *wl) | ||
395 | { | ||
396 | wl1251_acx_fw_version(wl, wl->chip.fw_ver, sizeof(wl->chip.fw_ver)); | ||
392 | } | 397 | } |
393 | 398 | ||
394 | static void wl1251_irq_work(struct work_struct *work) | 399 | static void wl1251_irq_work(struct work_struct *work) |
395 | { | 400 | { |
396 | u32 intr; | 401 | u32 intr; |
397 | struct wl12xx *wl = | 402 | struct wl1251 *wl = |
398 | container_of(work, struct wl12xx, irq_work); | 403 | container_of(work, struct wl1251, irq_work); |
404 | int ret; | ||
399 | 405 | ||
400 | mutex_lock(&wl->mutex); | 406 | mutex_lock(&wl->mutex); |
401 | 407 | ||
402 | wl12xx_debug(DEBUG_IRQ, "IRQ work"); | 408 | wl1251_debug(DEBUG_IRQ, "IRQ work"); |
403 | 409 | ||
404 | if (wl->state == WL12XX_STATE_OFF) | 410 | if (wl->state == WL1251_STATE_OFF) |
405 | goto out; | 411 | goto out; |
406 | 412 | ||
407 | wl12xx_ps_elp_wakeup(wl); | 413 | ret = wl1251_ps_elp_wakeup(wl); |
414 | if (ret < 0) | ||
415 | goto out; | ||
408 | 416 | ||
409 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, WL1251_ACX_INTR_ALL); | 417 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, WL1251_ACX_INTR_ALL); |
410 | 418 | ||
411 | intr = wl12xx_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR); | 419 | intr = wl1251_reg_read32(wl, ACX_REG_INTERRUPT_CLEAR); |
412 | wl12xx_debug(DEBUG_IRQ, "intr: 0x%x", intr); | 420 | wl1251_debug(DEBUG_IRQ, "intr: 0x%x", intr); |
413 | 421 | ||
414 | if (wl->data_path) { | 422 | if (wl->data_path) { |
415 | wl12xx_spi_mem_read(wl, wl->data_path->rx_control_addr, | 423 | wl->rx_counter = |
416 | &wl->rx_counter, sizeof(u32)); | 424 | wl1251_mem_read32(wl, wl->data_path->rx_control_addr); |
417 | 425 | ||
418 | /* We handle a frmware bug here */ | 426 | /* We handle a frmware bug here */ |
419 | switch ((wl->rx_counter - wl->rx_handled) & 0xf) { | 427 | switch ((wl->rx_counter - wl->rx_handled) & 0xf) { |
420 | case 0: | 428 | case 0: |
421 | wl12xx_debug(DEBUG_IRQ, "RX: FW and host in sync"); | 429 | wl1251_debug(DEBUG_IRQ, "RX: FW and host in sync"); |
422 | intr &= ~WL1251_ACX_INTR_RX0_DATA; | 430 | intr &= ~WL1251_ACX_INTR_RX0_DATA; |
423 | intr &= ~WL1251_ACX_INTR_RX1_DATA; | 431 | intr &= ~WL1251_ACX_INTR_RX1_DATA; |
424 | break; | 432 | break; |
425 | case 1: | 433 | case 1: |
426 | wl12xx_debug(DEBUG_IRQ, "RX: FW +1"); | 434 | wl1251_debug(DEBUG_IRQ, "RX: FW +1"); |
427 | intr |= WL1251_ACX_INTR_RX0_DATA; | 435 | intr |= WL1251_ACX_INTR_RX0_DATA; |
428 | intr &= ~WL1251_ACX_INTR_RX1_DATA; | 436 | intr &= ~WL1251_ACX_INTR_RX1_DATA; |
429 | break; | 437 | break; |
430 | case 2: | 438 | case 2: |
431 | wl12xx_debug(DEBUG_IRQ, "RX: FW +2"); | 439 | wl1251_debug(DEBUG_IRQ, "RX: FW +2"); |
432 | intr |= WL1251_ACX_INTR_RX0_DATA; | 440 | intr |= WL1251_ACX_INTR_RX0_DATA; |
433 | intr |= WL1251_ACX_INTR_RX1_DATA; | 441 | intr |= WL1251_ACX_INTR_RX1_DATA; |
434 | break; | 442 | break; |
435 | default: | 443 | default: |
436 | wl12xx_warning("RX: FW and host out of sync: %d", | 444 | wl1251_warning("RX: FW and host out of sync: %d", |
437 | wl->rx_counter - wl->rx_handled); | 445 | wl->rx_counter - wl->rx_handled); |
438 | break; | 446 | break; |
439 | } | 447 | } |
@@ -441,49 +449,50 @@ static void wl1251_irq_work(struct work_struct *work) | |||
441 | wl->rx_handled = wl->rx_counter; | 449 | wl->rx_handled = wl->rx_counter; |
442 | 450 | ||
443 | 451 | ||
444 | wl12xx_debug(DEBUG_IRQ, "RX counter: %d", wl->rx_counter); | 452 | wl1251_debug(DEBUG_IRQ, "RX counter: %d", wl->rx_counter); |
445 | } | 453 | } |
446 | 454 | ||
447 | intr &= wl->intr_mask; | 455 | intr &= wl->intr_mask; |
448 | 456 | ||
449 | if (intr == 0) { | 457 | if (intr == 0) { |
450 | wl12xx_debug(DEBUG_IRQ, "INTR is 0"); | 458 | wl1251_debug(DEBUG_IRQ, "INTR is 0"); |
451 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, | 459 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, |
452 | ~(wl->intr_mask)); | 460 | ~(wl->intr_mask)); |
453 | 461 | ||
454 | goto out_sleep; | 462 | goto out_sleep; |
455 | } | 463 | } |
456 | 464 | ||
457 | if (intr & WL1251_ACX_INTR_RX0_DATA) { | 465 | if (intr & WL1251_ACX_INTR_RX0_DATA) { |
458 | wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX0_DATA"); | 466 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX0_DATA"); |
459 | wl12xx_rx(wl); | 467 | wl1251_rx(wl); |
460 | } | 468 | } |
461 | 469 | ||
462 | if (intr & WL1251_ACX_INTR_RX1_DATA) { | 470 | if (intr & WL1251_ACX_INTR_RX1_DATA) { |
463 | wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX1_DATA"); | 471 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_RX1_DATA"); |
464 | wl12xx_rx(wl); | 472 | wl1251_rx(wl); |
465 | } | 473 | } |
466 | 474 | ||
467 | if (intr & WL1251_ACX_INTR_TX_RESULT) { | 475 | if (intr & WL1251_ACX_INTR_TX_RESULT) { |
468 | wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_TX_RESULT"); | 476 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_TX_RESULT"); |
469 | wl12xx_tx_complete(wl); | 477 | wl1251_tx_complete(wl); |
470 | } | 478 | } |
471 | 479 | ||
472 | if (intr & (WL1251_ACX_INTR_EVENT_A | WL1251_ACX_INTR_EVENT_B)) { | 480 | if (intr & (WL1251_ACX_INTR_EVENT_A | WL1251_ACX_INTR_EVENT_B)) { |
473 | wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT (0x%x)", intr); | 481 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_EVENT (0x%x)", intr); |
474 | if (intr & WL1251_ACX_INTR_EVENT_A) | 482 | if (intr & WL1251_ACX_INTR_EVENT_A) |
475 | wl12xx_event_handle(wl, 0); | 483 | wl1251_event_handle(wl, 0); |
476 | else | 484 | else |
477 | wl12xx_event_handle(wl, 1); | 485 | wl1251_event_handle(wl, 1); |
478 | } | 486 | } |
479 | 487 | ||
480 | if (intr & WL1251_ACX_INTR_INIT_COMPLETE) | 488 | if (intr & WL1251_ACX_INTR_INIT_COMPLETE) |
481 | wl12xx_debug(DEBUG_IRQ, "WL1251_ACX_INTR_INIT_COMPLETE"); | 489 | wl1251_debug(DEBUG_IRQ, "WL1251_ACX_INTR_INIT_COMPLETE"); |
482 | 490 | ||
483 | wl12xx_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); | 491 | wl1251_reg_write32(wl, ACX_REG_INTERRUPT_MASK, ~(wl->intr_mask)); |
484 | 492 | ||
485 | out_sleep: | 493 | out_sleep: |
486 | wl12xx_ps_elp_sleep(wl); | 494 | wl1251_ps_elp_sleep(wl); |
495 | |||
487 | out: | 496 | out: |
488 | mutex_unlock(&wl->mutex); | 497 | mutex_unlock(&wl->mutex); |
489 | } | 498 | } |
@@ -520,40 +529,45 @@ static int wl1251_hw_init_txq_fill(u8 qid, | |||
520 | (QOS_TX_LOW_VO_DEF * num_blocks) / 100; | 529 | (QOS_TX_LOW_VO_DEF * num_blocks) / 100; |
521 | break; | 530 | break; |
522 | default: | 531 | default: |
523 | wl12xx_error("Invalid TX queue id: %d", qid); | 532 | wl1251_error("Invalid TX queue id: %d", qid); |
524 | return -EINVAL; | 533 | return -EINVAL; |
525 | } | 534 | } |
526 | 535 | ||
527 | return 0; | 536 | return 0; |
528 | } | 537 | } |
529 | 538 | ||
530 | static int wl1251_hw_init_tx_queue_config(struct wl12xx *wl) | 539 | static int wl1251_hw_init_tx_queue_config(struct wl1251 *wl) |
531 | { | 540 | { |
532 | struct acx_tx_queue_qos_config config; | 541 | struct acx_tx_queue_qos_config *config; |
533 | struct wl1251_acx_mem_map *wl_mem_map = wl->target_mem_map; | 542 | struct wl1251_acx_mem_map *wl_mem_map = wl->target_mem_map; |
534 | int ret, i; | 543 | int ret, i; |
535 | 544 | ||
536 | wl12xx_debug(DEBUG_ACX, "acx tx queue config"); | 545 | wl1251_debug(DEBUG_ACX, "acx tx queue config"); |
537 | 546 | ||
538 | config.header.id = ACX_TX_QUEUE_CFG; | 547 | config = kzalloc(sizeof(*config), GFP_KERNEL); |
539 | config.header.len = sizeof(struct acx_tx_queue_qos_config) - | 548 | if (!config) { |
540 | sizeof(struct acx_header); | 549 | ret = -ENOMEM; |
550 | goto out; | ||
551 | } | ||
541 | 552 | ||
542 | for (i = 0; i < MAX_NUM_OF_AC; i++) { | 553 | for (i = 0; i < MAX_NUM_OF_AC; i++) { |
543 | ret = wl1251_hw_init_txq_fill(i, &config, | 554 | ret = wl1251_hw_init_txq_fill(i, config, |
544 | wl_mem_map->num_tx_mem_blocks); | 555 | wl_mem_map->num_tx_mem_blocks); |
545 | if (ret < 0) | 556 | if (ret < 0) |
546 | return ret; | 557 | goto out; |
547 | 558 | ||
548 | ret = wl12xx_cmd_configure(wl, &config, sizeof(config)); | 559 | ret = wl1251_cmd_configure(wl, ACX_TX_QUEUE_CFG, |
560 | config, sizeof(*config)); | ||
549 | if (ret < 0) | 561 | if (ret < 0) |
550 | return ret; | 562 | goto out; |
551 | } | 563 | } |
552 | 564 | ||
553 | return 0; | 565 | out: |
566 | kfree(config); | ||
567 | return ret; | ||
554 | } | 568 | } |
555 | 569 | ||
556 | static int wl1251_hw_init_data_path_config(struct wl12xx *wl) | 570 | static int wl1251_hw_init_data_path_config(struct wl1251 *wl) |
557 | { | 571 | { |
558 | int ret; | 572 | int ret; |
559 | 573 | ||
@@ -561,11 +575,11 @@ static int wl1251_hw_init_data_path_config(struct wl12xx *wl) | |||
561 | wl->data_path = kzalloc(sizeof(struct acx_data_path_params_resp), | 575 | wl->data_path = kzalloc(sizeof(struct acx_data_path_params_resp), |
562 | GFP_KERNEL); | 576 | GFP_KERNEL); |
563 | if (!wl->data_path) { | 577 | if (!wl->data_path) { |
564 | wl12xx_error("Couldnt allocate data path parameters"); | 578 | wl1251_error("Couldnt allocate data path parameters"); |
565 | return -ENOMEM; | 579 | return -ENOMEM; |
566 | } | 580 | } |
567 | 581 | ||
568 | ret = wl12xx_acx_data_path_params(wl, wl->data_path); | 582 | ret = wl1251_acx_data_path_params(wl, wl->data_path); |
569 | if (ret < 0) { | 583 | if (ret < 0) { |
570 | kfree(wl->data_path); | 584 | kfree(wl->data_path); |
571 | wl->data_path = NULL; | 585 | wl->data_path = NULL; |
@@ -575,17 +589,17 @@ static int wl1251_hw_init_data_path_config(struct wl12xx *wl) | |||
575 | return 0; | 589 | return 0; |
576 | } | 590 | } |
577 | 591 | ||
578 | static int wl1251_hw_init(struct wl12xx *wl) | 592 | static int wl1251_hw_init(struct wl1251 *wl) |
579 | { | 593 | { |
580 | struct wl1251_acx_mem_map *wl_mem_map; | 594 | struct wl1251_acx_mem_map *wl_mem_map; |
581 | int ret; | 595 | int ret; |
582 | 596 | ||
583 | ret = wl12xx_hw_init_hwenc_config(wl); | 597 | ret = wl1251_hw_init_hwenc_config(wl); |
584 | if (ret < 0) | 598 | if (ret < 0) |
585 | return ret; | 599 | return ret; |
586 | 600 | ||
587 | /* Template settings */ | 601 | /* Template settings */ |
588 | ret = wl12xx_hw_init_templates_config(wl); | 602 | ret = wl1251_hw_init_templates_config(wl); |
589 | if (ret < 0) | 603 | if (ret < 0) |
590 | return ret; | 604 | return ret; |
591 | 605 | ||
@@ -600,7 +614,7 @@ static int wl1251_hw_init(struct wl12xx *wl) | |||
600 | goto out_free_memmap; | 614 | goto out_free_memmap; |
601 | 615 | ||
602 | /* RX config */ | 616 | /* RX config */ |
603 | ret = wl12xx_hw_init_rx_config(wl, | 617 | ret = wl1251_hw_init_rx_config(wl, |
604 | RX_CFG_PROMISCUOUS | RX_CFG_TSF, | 618 | RX_CFG_PROMISCUOUS | RX_CFG_TSF, |
605 | RX_FILTER_OPTION_DEF); | 619 | RX_FILTER_OPTION_DEF); |
606 | /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS, | 620 | /* RX_CONFIG_OPTION_ANY_DST_ANY_BSS, |
@@ -614,42 +628,42 @@ static int wl1251_hw_init(struct wl12xx *wl) | |||
614 | goto out_free_data_path; | 628 | goto out_free_data_path; |
615 | 629 | ||
616 | /* PHY layer config */ | 630 | /* PHY layer config */ |
617 | ret = wl12xx_hw_init_phy_config(wl); | 631 | ret = wl1251_hw_init_phy_config(wl); |
618 | if (ret < 0) | 632 | if (ret < 0) |
619 | goto out_free_data_path; | 633 | goto out_free_data_path; |
620 | 634 | ||
621 | /* Beacon filtering */ | 635 | /* Beacon filtering */ |
622 | ret = wl12xx_hw_init_beacon_filter(wl); | 636 | ret = wl1251_hw_init_beacon_filter(wl); |
623 | if (ret < 0) | 637 | if (ret < 0) |
624 | goto out_free_data_path; | 638 | goto out_free_data_path; |
625 | 639 | ||
626 | /* Bluetooth WLAN coexistence */ | 640 | /* Bluetooth WLAN coexistence */ |
627 | ret = wl12xx_hw_init_pta(wl); | 641 | ret = wl1251_hw_init_pta(wl); |
628 | if (ret < 0) | 642 | if (ret < 0) |
629 | goto out_free_data_path; | 643 | goto out_free_data_path; |
630 | 644 | ||
631 | /* Energy detection */ | 645 | /* Energy detection */ |
632 | ret = wl12xx_hw_init_energy_detection(wl); | 646 | ret = wl1251_hw_init_energy_detection(wl); |
633 | if (ret < 0) | 647 | if (ret < 0) |
634 | goto out_free_data_path; | 648 | goto out_free_data_path; |
635 | 649 | ||
636 | /* Beacons and boradcast settings */ | 650 | /* Beacons and boradcast settings */ |
637 | ret = wl12xx_hw_init_beacon_broadcast(wl); | 651 | ret = wl1251_hw_init_beacon_broadcast(wl); |
638 | if (ret < 0) | 652 | if (ret < 0) |
639 | goto out_free_data_path; | 653 | goto out_free_data_path; |
640 | 654 | ||
641 | /* Enable data path */ | 655 | /* Enable data path */ |
642 | ret = wl12xx_cmd_data_path(wl, wl->channel, 1); | 656 | ret = wl1251_cmd_data_path(wl, wl->channel, 1); |
643 | if (ret < 0) | 657 | if (ret < 0) |
644 | goto out_free_data_path; | 658 | goto out_free_data_path; |
645 | 659 | ||
646 | /* Default power state */ | 660 | /* Default power state */ |
647 | ret = wl12xx_hw_init_power_auth(wl); | 661 | ret = wl1251_hw_init_power_auth(wl); |
648 | if (ret < 0) | 662 | if (ret < 0) |
649 | goto out_free_data_path; | 663 | goto out_free_data_path; |
650 | 664 | ||
651 | wl_mem_map = wl->target_mem_map; | 665 | wl_mem_map = wl->target_mem_map; |
652 | wl12xx_info("%d tx blocks at 0x%x, %d rx blocks at 0x%x", | 666 | wl1251_info("%d tx blocks at 0x%x, %d rx blocks at 0x%x", |
653 | wl_mem_map->num_tx_mem_blocks, | 667 | wl_mem_map->num_tx_mem_blocks, |
654 | wl->data_path->tx_control_addr, | 668 | wl->data_path->tx_control_addr, |
655 | wl_mem_map->num_rx_mem_blocks, | 669 | wl_mem_map->num_rx_mem_blocks, |
@@ -666,7 +680,7 @@ static int wl1251_hw_init(struct wl12xx *wl) | |||
666 | return ret; | 680 | return ret; |
667 | } | 681 | } |
668 | 682 | ||
669 | static int wl1251_plt_init(struct wl12xx *wl) | 683 | static int wl1251_plt_init(struct wl1251 *wl) |
670 | { | 684 | { |
671 | int ret; | 685 | int ret; |
672 | 686 | ||
@@ -674,14 +688,14 @@ static int wl1251_plt_init(struct wl12xx *wl) | |||
674 | if (ret < 0) | 688 | if (ret < 0) |
675 | return ret; | 689 | return ret; |
676 | 690 | ||
677 | ret = wl12xx_cmd_data_path(wl, wl->channel, 1); | 691 | ret = wl1251_cmd_data_path(wl, wl->channel, 1); |
678 | if (ret < 0) | 692 | if (ret < 0) |
679 | return ret; | 693 | return ret; |
680 | 694 | ||
681 | return 0; | 695 | return 0; |
682 | } | 696 | } |
683 | 697 | ||
684 | void wl1251_setup(struct wl12xx *wl) | 698 | void wl1251_setup(struct wl1251 *wl) |
685 | { | 699 | { |
686 | /* FIXME: Is it better to use strncpy here or is this ok? */ | 700 | /* FIXME: Is it better to use strncpy here or is this ok? */ |
687 | wl->chip.fw_filename = WL1251_FW_NAME; | 701 | wl->chip.fw_filename = WL1251_FW_NAME; |
@@ -701,9 +715,14 @@ void wl1251_setup(struct wl12xx *wl) | |||
701 | wl->chip.op_target_enable_interrupts = wl1251_target_enable_interrupts; | 715 | wl->chip.op_target_enable_interrupts = wl1251_target_enable_interrupts; |
702 | wl->chip.op_hw_init = wl1251_hw_init; | 716 | wl->chip.op_hw_init = wl1251_hw_init; |
703 | wl->chip.op_plt_init = wl1251_plt_init; | 717 | wl->chip.op_plt_init = wl1251_plt_init; |
718 | wl->chip.op_fw_version = wl1251_fw_version; | ||
719 | wl->chip.op_tx_flush = wl1251_tx_flush; | ||
720 | wl->chip.op_cmd_join = wl1251_cmd_join; | ||
704 | 721 | ||
705 | wl->chip.p_table = wl1251_part_table; | 722 | wl->chip.p_table = wl1251_part_table; |
706 | wl->chip.acx_reg_table = wl1251_acx_reg_table; | 723 | wl->chip.acx_reg_table = wl1251_acx_reg_table; |
707 | 724 | ||
708 | INIT_WORK(&wl->irq_work, wl1251_irq_work); | 725 | INIT_WORK(&wl->irq_work, wl1251_irq_work); |
726 | INIT_WORK(&wl->tx_work, wl1251_tx_work); | ||
727 | |||
709 | } | 728 | } |
diff --git a/drivers/net/wireless/wl12xx/wl1251_ops.h b/drivers/net/wireless/wl12xx/wl1251_ops.h new file mode 100644 index 000000000000..68183c472e43 --- /dev/null +++ b/drivers/net/wireless/wl12xx/wl1251_ops.h | |||
@@ -0,0 +1,165 @@ | |||
1 | /* | ||
2 | * This file is part of wl1251 | ||
3 | * | ||
4 | * Copyright (C) 2008 Nokia Corporation | ||
5 | * | ||
6 | * Contact: Kalle Valo <kalle.valo@nokia.com> | ||
7 | * | ||
8 | * This program is free software; you can redistribute it and/or | ||
9 | * modify it under the terms of the GNU General Public License | ||
10 | * version 2 as published by the Free Software Foundation. | ||
11 | * | ||
12 | * This program is distributed in the hope that it will be useful, but | ||
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
15 | * General Public License for more details. | ||
16 | * | ||
17 | * You should have received a copy of the GNU General Public License | ||
18 | * along with this program; if not, write to the Free Software | ||
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
20 | * 02110-1301 USA | ||
21 | * | ||
22 | */ | ||
23 | |||
24 | #ifndef __WL1251_OPS_H__ | ||
25 | #define __WL1251_OPS_H__ | ||
26 | |||
27 | #include <linux/bitops.h> | ||
28 | |||
29 | #include "wl1251.h" | ||
30 | #include "wl1251_acx.h" | ||
31 | |||
32 | #define WL1251_FW_NAME "wl1251-fw.bin" | ||
33 | #define WL1251_NVS_NAME "wl1251-nvs.bin" | ||
34 | |||
35 | #define WL1251_POWER_ON_SLEEP 10 /* in miliseconds */ | ||
36 | |||
37 | void wl1251_setup(struct wl1251 *wl); | ||
38 | |||
39 | |||
40 | struct wl1251_acx_memory { | ||
41 | __le16 num_stations; /* number of STAs to be supported. */ | ||
42 | u16 reserved_1; | ||
43 | |||
44 | /* | ||
45 | * Nmber of memory buffers for the RX mem pool. | ||
46 | * The actual number may be less if there are | ||
47 | * not enough blocks left for the minimum num | ||
48 | * of TX ones. | ||
49 | */ | ||
50 | u8 rx_mem_block_num; | ||
51 | u8 reserved_2; | ||
52 | u8 num_tx_queues; /* From 1 to 16 */ | ||
53 | u8 host_if_options; /* HOST_IF* */ | ||
54 | u8 tx_min_mem_block_num; | ||
55 | u8 num_ssid_profiles; | ||
56 | __le16 debug_buffer_size; | ||
57 | } __attribute__ ((packed)); | ||
58 | |||
59 | |||
60 | #define ACX_RX_DESC_MIN 1 | ||
61 | #define ACX_RX_DESC_MAX 127 | ||
62 | #define ACX_RX_DESC_DEF 32 | ||
63 | struct wl1251_acx_rx_queue_config { | ||
64 | u8 num_descs; | ||
65 | u8 pad; | ||
66 | u8 type; | ||
67 | u8 priority; | ||
68 | __le32 dma_address; | ||
69 | } __attribute__ ((packed)); | ||
70 | |||
71 | #define ACX_TX_DESC_MIN 1 | ||
72 | #define ACX_TX_DESC_MAX 127 | ||
73 | #define ACX_TX_DESC_DEF 16 | ||
74 | struct wl1251_acx_tx_queue_config { | ||
75 | u8 num_descs; | ||
76 | u8 pad[2]; | ||
77 | u8 attributes; | ||
78 | } __attribute__ ((packed)); | ||
79 | |||
80 | #define MAX_TX_QUEUE_CONFIGS 5 | ||
81 | #define MAX_TX_QUEUES 4 | ||
82 | struct wl1251_acx_config_memory { | ||
83 | struct acx_header header; | ||
84 | |||
85 | struct wl1251_acx_memory mem_config; | ||
86 | struct wl1251_acx_rx_queue_config rx_queue_config; | ||
87 | struct wl1251_acx_tx_queue_config tx_queue_config[MAX_TX_QUEUE_CONFIGS]; | ||
88 | } __attribute__ ((packed)); | ||
89 | |||
90 | struct wl1251_acx_mem_map { | ||
91 | struct acx_header header; | ||
92 | |||
93 | void *code_start; | ||
94 | void *code_end; | ||
95 | |||
96 | void *wep_defkey_start; | ||
97 | void *wep_defkey_end; | ||
98 | |||
99 | void *sta_table_start; | ||
100 | void *sta_table_end; | ||
101 | |||
102 | void *packet_template_start; | ||
103 | void *packet_template_end; | ||
104 | |||
105 | void *queue_memory_start; | ||
106 | void *queue_memory_end; | ||
107 | |||
108 | void *packet_memory_pool_start; | ||
109 | void *packet_memory_pool_end; | ||
110 | |||
111 | void *debug_buffer1_start; | ||
112 | void *debug_buffer1_end; | ||
113 | |||
114 | void *debug_buffer2_start; | ||
115 | void *debug_buffer2_end; | ||
116 | |||
117 | /* Number of blocks FW allocated for TX packets */ | ||
118 | u32 num_tx_mem_blocks; | ||
119 | |||
120 | /* Number of blocks FW allocated for RX packets */ | ||
121 | u32 num_rx_mem_blocks; | ||
122 | } __attribute__ ((packed)); | ||
123 | |||
124 | /************************************************************************* | ||
125 | |||
126 | Host Interrupt Register (WiLink -> Host) | ||
127 | |||
128 | **************************************************************************/ | ||
129 | |||
130 | /* RX packet is ready in Xfer buffer #0 */ | ||
131 | #define WL1251_ACX_INTR_RX0_DATA BIT(0) | ||
132 | |||
133 | /* TX result(s) are in the TX complete buffer */ | ||
134 | #define WL1251_ACX_INTR_TX_RESULT BIT(1) | ||
135 | |||
136 | /* OBSOLETE */ | ||
137 | #define WL1251_ACX_INTR_TX_XFR BIT(2) | ||
138 | |||
139 | /* RX packet is ready in Xfer buffer #1 */ | ||
140 | #define WL1251_ACX_INTR_RX1_DATA BIT(3) | ||
141 | |||
142 | /* Event was entered to Event MBOX #A */ | ||
143 | #define WL1251_ACX_INTR_EVENT_A BIT(4) | ||
144 | |||
145 | /* Event was entered to Event MBOX #B */ | ||
146 | #define WL1251_ACX_INTR_EVENT_B BIT(5) | ||
147 | |||
148 | /* OBSOLETE */ | ||
149 | #define WL1251_ACX_INTR_WAKE_ON_HOST BIT(6) | ||
150 | |||
151 | /* Trace meassge on MBOX #A */ | ||
152 | #define WL1251_ACX_INTR_TRACE_A BIT(7) | ||
153 | |||
154 | /* Trace meassge on MBOX #B */ | ||
155 | #define WL1251_ACX_INTR_TRACE_B BIT(8) | ||
156 | |||
157 | /* Command processing completion */ | ||
158 | #define WL1251_ACX_INTR_CMD_COMPLETE BIT(9) | ||
159 | |||
160 | /* Init sequence is done */ | ||
161 | #define WL1251_ACX_INTR_INIT_COMPLETE BIT(14) | ||
162 | |||
163 | #define WL1251_ACX_INTR_ALL 0xFFFFFFFF | ||
164 | |||
165 | #endif | ||
diff --git a/drivers/net/wireless/wl12xx/ps.c b/drivers/net/wireless/wl12xx/wl1251_ps.c index 83a10117330b..68ff7f1900ed 100644 --- a/drivers/net/wireless/wl12xx/ps.c +++ b/drivers/net/wireless/wl12xx/wl1251_ps.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Nokia Corporation | 4 | * Copyright (C) 2008 Nokia Corporation |
5 | * | 5 | * |
@@ -22,25 +22,25 @@ | |||
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include "reg.h" | 24 | #include "reg.h" |
25 | #include "ps.h" | 25 | #include "wl1251_ps.h" |
26 | #include "spi.h" | 26 | #include "wl1251_spi.h" |
27 | 27 | ||
28 | #define WL12XX_WAKEUP_TIMEOUT 2000 | 28 | #define WL1251_WAKEUP_TIMEOUT 2000 |
29 | 29 | ||
30 | /* Routines to toggle sleep mode while in ELP */ | 30 | /* Routines to toggle sleep mode while in ELP */ |
31 | void wl12xx_ps_elp_sleep(struct wl12xx *wl) | 31 | void wl1251_ps_elp_sleep(struct wl1251 *wl) |
32 | { | 32 | { |
33 | if (wl->elp || !wl->psm) | 33 | if (wl->elp || !wl->psm) |
34 | return; | 34 | return; |
35 | 35 | ||
36 | wl12xx_debug(DEBUG_PSM, "chip to elp"); | 36 | wl1251_debug(DEBUG_PSM, "chip to elp"); |
37 | 37 | ||
38 | wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); | 38 | wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_SLEEP); |
39 | 39 | ||
40 | wl->elp = true; | 40 | wl->elp = true; |
41 | } | 41 | } |
42 | 42 | ||
43 | int wl12xx_ps_elp_wakeup(struct wl12xx *wl) | 43 | int wl1251_ps_elp_wakeup(struct wl1251 *wl) |
44 | { | 44 | { |
45 | unsigned long timeout; | 45 | unsigned long timeout; |
46 | u32 elp_reg; | 46 | u32 elp_reg; |
@@ -48,13 +48,13 @@ int wl12xx_ps_elp_wakeup(struct wl12xx *wl) | |||
48 | if (!wl->elp) | 48 | if (!wl->elp) |
49 | return 0; | 49 | return 0; |
50 | 50 | ||
51 | wl12xx_debug(DEBUG_PSM, "waking up chip from elp"); | 51 | wl1251_debug(DEBUG_PSM, "waking up chip from elp"); |
52 | 52 | ||
53 | timeout = jiffies + msecs_to_jiffies(WL12XX_WAKEUP_TIMEOUT); | 53 | timeout = jiffies + msecs_to_jiffies(WL1251_WAKEUP_TIMEOUT); |
54 | 54 | ||
55 | wl12xx_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP); | 55 | wl1251_write32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR, ELPCTRL_WAKE_UP); |
56 | 56 | ||
57 | elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); | 57 | elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); |
58 | 58 | ||
59 | /* | 59 | /* |
60 | * FIXME: we should wait for irq from chip but, as a temporary | 60 | * FIXME: we should wait for irq from chip but, as a temporary |
@@ -62,40 +62,36 @@ int wl12xx_ps_elp_wakeup(struct wl12xx *wl) | |||
62 | */ | 62 | */ |
63 | while (!(elp_reg & ELPCTRL_WLAN_READY)) { | 63 | while (!(elp_reg & ELPCTRL_WLAN_READY)) { |
64 | if (time_after(jiffies, timeout)) { | 64 | if (time_after(jiffies, timeout)) { |
65 | wl12xx_error("elp wakeup timeout"); | 65 | wl1251_error("elp wakeup timeout"); |
66 | return -ETIMEDOUT; | 66 | return -ETIMEDOUT; |
67 | } | 67 | } |
68 | msleep(1); | 68 | msleep(1); |
69 | elp_reg = wl12xx_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); | 69 | elp_reg = wl1251_read32(wl, HW_ACCESS_ELP_CTRL_REG_ADDR); |
70 | } | 70 | } |
71 | 71 | ||
72 | wl12xx_debug(DEBUG_PSM, "wakeup time: %u ms", | 72 | wl1251_debug(DEBUG_PSM, "wakeup time: %u ms", |
73 | jiffies_to_msecs(jiffies) - | 73 | jiffies_to_msecs(jiffies) - |
74 | (jiffies_to_msecs(timeout) - WL12XX_WAKEUP_TIMEOUT)); | 74 | (jiffies_to_msecs(timeout) - WL1251_WAKEUP_TIMEOUT)); |
75 | 75 | ||
76 | wl->elp = false; | 76 | wl->elp = false; |
77 | 77 | ||
78 | return 0; | 78 | return 0; |
79 | } | 79 | } |
80 | 80 | ||
81 | static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable) | 81 | static int wl1251_ps_set_elp(struct wl1251 *wl, bool enable) |
82 | { | 82 | { |
83 | int ret; | 83 | int ret; |
84 | 84 | ||
85 | if (enable) { | 85 | if (enable) { |
86 | wl12xx_debug(DEBUG_PSM, "sleep auth psm/elp"); | 86 | wl1251_debug(DEBUG_PSM, "sleep auth psm/elp"); |
87 | 87 | ||
88 | /* | 88 | ret = wl1251_acx_sleep_auth(wl, WL1251_PSM_ELP); |
89 | * FIXME: we should PSM_ELP, but because of firmware wakeup | ||
90 | * problems let's use only PSM_PS | ||
91 | */ | ||
92 | ret = wl12xx_acx_sleep_auth(wl, WL12XX_PSM_PS); | ||
93 | if (ret < 0) | 89 | if (ret < 0) |
94 | return ret; | 90 | return ret; |
95 | 91 | ||
96 | wl12xx_ps_elp_sleep(wl); | 92 | wl1251_ps_elp_sleep(wl); |
97 | } else { | 93 | } else { |
98 | wl12xx_debug(DEBUG_PSM, "sleep auth cam"); | 94 | wl1251_debug(DEBUG_PSM, "sleep auth cam"); |
99 | 95 | ||
100 | /* | 96 | /* |
101 | * When the target is in ELP, we can only | 97 | * When the target is in ELP, we can only |
@@ -104,9 +100,9 @@ static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable) | |||
104 | * changing the power authorization. | 100 | * changing the power authorization. |
105 | */ | 101 | */ |
106 | 102 | ||
107 | wl12xx_ps_elp_wakeup(wl); | 103 | wl1251_ps_elp_wakeup(wl); |
108 | 104 | ||
109 | ret = wl12xx_acx_sleep_auth(wl, WL12XX_PSM_CAM); | 105 | ret = wl1251_acx_sleep_auth(wl, WL1251_PSM_CAM); |
110 | if (ret < 0) | 106 | if (ret < 0) |
111 | return ret; | 107 | return ret; |
112 | } | 108 | } |
@@ -114,18 +110,18 @@ static int wl12xx_ps_set_elp(struct wl12xx *wl, bool enable) | |||
114 | return 0; | 110 | return 0; |
115 | } | 111 | } |
116 | 112 | ||
117 | int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode) | 113 | int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode) |
118 | { | 114 | { |
119 | int ret; | 115 | int ret; |
120 | 116 | ||
121 | switch (mode) { | 117 | switch (mode) { |
122 | case STATION_POWER_SAVE_MODE: | 118 | case STATION_POWER_SAVE_MODE: |
123 | wl12xx_debug(DEBUG_PSM, "entering psm"); | 119 | wl1251_debug(DEBUG_PSM, "entering psm"); |
124 | ret = wl12xx_cmd_ps_mode(wl, STATION_POWER_SAVE_MODE); | 120 | ret = wl1251_cmd_ps_mode(wl, STATION_POWER_SAVE_MODE); |
125 | if (ret < 0) | 121 | if (ret < 0) |
126 | return ret; | 122 | return ret; |
127 | 123 | ||
128 | ret = wl12xx_ps_set_elp(wl, true); | 124 | ret = wl1251_ps_set_elp(wl, true); |
129 | if (ret < 0) | 125 | if (ret < 0) |
130 | return ret; | 126 | return ret; |
131 | 127 | ||
@@ -133,12 +129,12 @@ int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode) | |||
133 | break; | 129 | break; |
134 | case STATION_ACTIVE_MODE: | 130 | case STATION_ACTIVE_MODE: |
135 | default: | 131 | default: |
136 | wl12xx_debug(DEBUG_PSM, "leaving psm"); | 132 | wl1251_debug(DEBUG_PSM, "leaving psm"); |
137 | ret = wl12xx_ps_set_elp(wl, false); | 133 | ret = wl1251_ps_set_elp(wl, false); |
138 | if (ret < 0) | 134 | if (ret < 0) |
139 | return ret; | 135 | return ret; |
140 | 136 | ||
141 | ret = wl12xx_cmd_ps_mode(wl, STATION_ACTIVE_MODE); | 137 | ret = wl1251_cmd_ps_mode(wl, STATION_ACTIVE_MODE); |
142 | if (ret < 0) | 138 | if (ret < 0) |
143 | return ret; | 139 | return ret; |
144 | 140 | ||
diff --git a/drivers/net/wireless/wl12xx/ps.h b/drivers/net/wireless/wl12xx/wl1251_ps.h index 5d7c52553830..db036fe12f25 100644 --- a/drivers/net/wireless/wl12xx/ps.h +++ b/drivers/net/wireless/wl12xx/wl1251_ps.h | |||
@@ -1,8 +1,8 @@ | |||
1 | #ifndef __WL12XX_PS_H__ | 1 | #ifndef __WL1251_PS_H__ |
2 | #define __WL12XX_PS_H__ | 2 | #define __WL1251_PS_H__ |
3 | 3 | ||
4 | /* | 4 | /* |
5 | * This file is part of wl12xx | 5 | * This file is part of wl1251 |
6 | * | 6 | * |
7 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 7 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
8 | * Copyright (C) 2008 Nokia Corporation | 8 | * Copyright (C) 2008 Nokia Corporation |
@@ -25,12 +25,12 @@ | |||
25 | * | 25 | * |
26 | */ | 26 | */ |
27 | 27 | ||
28 | #include "wl12xx.h" | 28 | #include "wl1251.h" |
29 | #include "acx.h" | 29 | #include "wl1251_acx.h" |
30 | 30 | ||
31 | int wl12xx_ps_set_mode(struct wl12xx *wl, enum acx_ps_mode mode); | 31 | int wl1251_ps_set_mode(struct wl1251 *wl, enum wl1251_cmd_ps_mode mode); |
32 | void wl12xx_ps_elp_sleep(struct wl12xx *wl); | 32 | void wl1251_ps_elp_sleep(struct wl1251 *wl); |
33 | int wl12xx_ps_elp_wakeup(struct wl12xx *wl); | 33 | int wl1251_ps_elp_wakeup(struct wl1251 *wl); |
34 | 34 | ||
35 | 35 | ||
36 | #endif /* __WL12XX_PS_H__ */ | 36 | #endif /* __WL1251_PS_H__ */ |
diff --git a/drivers/net/wireless/wl12xx/rx.c b/drivers/net/wireless/wl12xx/wl1251_rx.c index 981ea259eb89..0dbb483a0973 100644 --- a/drivers/net/wireless/wl12xx/rx.c +++ b/drivers/net/wireless/wl12xx/wl1251_rx.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -25,13 +25,14 @@ | |||
25 | #include <linux/skbuff.h> | 25 | #include <linux/skbuff.h> |
26 | #include <net/mac80211.h> | 26 | #include <net/mac80211.h> |
27 | 27 | ||
28 | #include "wl12xx.h" | 28 | #include "wl1251.h" |
29 | #include "reg.h" | 29 | #include "reg.h" |
30 | #include "spi.h" | 30 | #include "wl1251_spi.h" |
31 | #include "rx.h" | 31 | #include "wl1251_rx.h" |
32 | #include "wl1251_acx.h" | ||
32 | 33 | ||
33 | static void wl12xx_rx_header(struct wl12xx *wl, | 34 | static void wl1251_rx_header(struct wl1251 *wl, |
34 | struct wl12xx_rx_descriptor *desc) | 35 | struct wl1251_rx_descriptor *desc) |
35 | { | 36 | { |
36 | u32 rx_packet_ring_addr; | 37 | u32 rx_packet_ring_addr; |
37 | 38 | ||
@@ -39,15 +40,17 @@ static void wl12xx_rx_header(struct wl12xx *wl, | |||
39 | if (wl->rx_current_buffer) | 40 | if (wl->rx_current_buffer) |
40 | rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; | 41 | rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; |
41 | 42 | ||
42 | wl12xx_spi_mem_read(wl, rx_packet_ring_addr, desc, | 43 | wl1251_spi_mem_read(wl, rx_packet_ring_addr, desc, sizeof(*desc)); |
43 | sizeof(struct wl12xx_rx_descriptor)); | ||
44 | } | 44 | } |
45 | 45 | ||
46 | static void wl12xx_rx_status(struct wl12xx *wl, | 46 | static void wl1251_rx_status(struct wl1251 *wl, |
47 | struct wl12xx_rx_descriptor *desc, | 47 | struct wl1251_rx_descriptor *desc, |
48 | struct ieee80211_rx_status *status, | 48 | struct ieee80211_rx_status *status, |
49 | u8 beacon) | 49 | u8 beacon) |
50 | { | 50 | { |
51 | u64 mactime; | ||
52 | int ret; | ||
53 | |||
51 | memset(status, 0, sizeof(struct ieee80211_rx_status)); | 54 | memset(status, 0, sizeof(struct ieee80211_rx_status)); |
52 | 55 | ||
53 | status->band = IEEE80211_BAND_2GHZ; | 56 | status->band = IEEE80211_BAND_2GHZ; |
@@ -62,32 +65,14 @@ static void wl12xx_rx_status(struct wl12xx *wl, | |||
62 | * this one must be atomic, while our SPI routines can sleep. | 65 | * this one must be atomic, while our SPI routines can sleep. |
63 | */ | 66 | */ |
64 | if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) { | 67 | if ((wl->bss_type == BSS_TYPE_IBSS) && beacon) { |
65 | u64 mactime; | 68 | ret = wl1251_acx_tsf_info(wl, &mactime); |
66 | int ret; | 69 | if (ret == 0) |
67 | struct wl12xx_command cmd; | 70 | status->mactime = mactime; |
68 | struct acx_tsf_info *tsf_info; | ||
69 | |||
70 | memset(&cmd, 0, sizeof(cmd)); | ||
71 | |||
72 | ret = wl12xx_cmd_interrogate(wl, ACX_TSF_INFO, | ||
73 | sizeof(struct acx_tsf_info), | ||
74 | &cmd); | ||
75 | if (ret < 0) { | ||
76 | wl12xx_warning("ACX_FW_REV interrogate failed"); | ||
77 | return; | ||
78 | } | ||
79 | |||
80 | tsf_info = (struct acx_tsf_info *)&(cmd.parameters); | ||
81 | |||
82 | mactime = tsf_info->current_tsf_lsb | | ||
83 | (tsf_info->current_tsf_msb << 31); | ||
84 | |||
85 | status->mactime = mactime; | ||
86 | } | 71 | } |
87 | 72 | ||
88 | status->signal = desc->rssi; | 73 | status->signal = desc->rssi; |
89 | status->qual = (desc->rssi - WL12XX_RX_MIN_RSSI) * 100 / | 74 | status->qual = (desc->rssi - WL1251_RX_MIN_RSSI) * 100 / |
90 | (WL12XX_RX_MAX_RSSI - WL12XX_RX_MIN_RSSI); | 75 | (WL1251_RX_MAX_RSSI - WL1251_RX_MIN_RSSI); |
91 | status->qual = min(status->qual, 100); | 76 | status->qual = min(status->qual, 100); |
92 | status->qual = max(status->qual, 0); | 77 | status->qual = max(status->qual, 0); |
93 | 78 | ||
@@ -118,8 +103,8 @@ static void wl12xx_rx_status(struct wl12xx *wl, | |||
118 | /* FIXME: set status->rate_idx */ | 103 | /* FIXME: set status->rate_idx */ |
119 | } | 104 | } |
120 | 105 | ||
121 | static void wl12xx_rx_body(struct wl12xx *wl, | 106 | static void wl1251_rx_body(struct wl1251 *wl, |
122 | struct wl12xx_rx_descriptor *desc) | 107 | struct wl1251_rx_descriptor *desc) |
123 | { | 108 | { |
124 | struct sk_buff *skb; | 109 | struct sk_buff *skb; |
125 | struct ieee80211_rx_status status; | 110 | struct ieee80211_rx_status status; |
@@ -127,12 +112,12 @@ static void wl12xx_rx_body(struct wl12xx *wl, | |||
127 | u16 length, *fc; | 112 | u16 length, *fc; |
128 | u32 curr_id, last_id_inc, rx_packet_ring_addr; | 113 | u32 curr_id, last_id_inc, rx_packet_ring_addr; |
129 | 114 | ||
130 | length = WL12XX_RX_ALIGN(desc->length - PLCP_HEADER_LENGTH); | 115 | length = WL1251_RX_ALIGN(desc->length - PLCP_HEADER_LENGTH); |
131 | curr_id = (desc->flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT; | 116 | curr_id = (desc->flags & RX_DESC_SEQNUM_MASK) >> RX_DESC_PACKETID_SHIFT; |
132 | last_id_inc = (wl->rx_last_id + 1) % (RX_MAX_PACKET_ID + 1); | 117 | last_id_inc = (wl->rx_last_id + 1) % (RX_MAX_PACKET_ID + 1); |
133 | 118 | ||
134 | if (last_id_inc != curr_id) { | 119 | if (last_id_inc != curr_id) { |
135 | wl12xx_warning("curr ID:%d, last ID inc:%d", | 120 | wl1251_warning("curr ID:%d, last ID inc:%d", |
136 | curr_id, last_id_inc); | 121 | curr_id, last_id_inc); |
137 | wl->rx_last_id = curr_id; | 122 | wl->rx_last_id = curr_id; |
138 | } else { | 123 | } else { |
@@ -140,18 +125,18 @@ static void wl12xx_rx_body(struct wl12xx *wl, | |||
140 | } | 125 | } |
141 | 126 | ||
142 | rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr + | 127 | rx_packet_ring_addr = wl->data_path->rx_packet_ring_addr + |
143 | sizeof(struct wl12xx_rx_descriptor) + 20; | 128 | sizeof(struct wl1251_rx_descriptor) + 20; |
144 | if (wl->rx_current_buffer) | 129 | if (wl->rx_current_buffer) |
145 | rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; | 130 | rx_packet_ring_addr += wl->data_path->rx_packet_ring_chunk_size; |
146 | 131 | ||
147 | skb = dev_alloc_skb(length); | 132 | skb = dev_alloc_skb(length); |
148 | if (!skb) { | 133 | if (!skb) { |
149 | wl12xx_error("Couldn't allocate RX frame"); | 134 | wl1251_error("Couldn't allocate RX frame"); |
150 | return; | 135 | return; |
151 | } | 136 | } |
152 | 137 | ||
153 | rx_buffer = skb_put(skb, length); | 138 | rx_buffer = skb_put(skb, length); |
154 | wl12xx_spi_mem_read(wl, rx_packet_ring_addr, rx_buffer, length); | 139 | wl1251_spi_mem_read(wl, rx_packet_ring_addr, rx_buffer, length); |
155 | 140 | ||
156 | /* The actual lenght doesn't include the target's alignment */ | 141 | /* The actual lenght doesn't include the target's alignment */ |
157 | skb->len = desc->length - PLCP_HEADER_LENGTH; | 142 | skb->len = desc->length - PLCP_HEADER_LENGTH; |
@@ -161,15 +146,16 @@ static void wl12xx_rx_body(struct wl12xx *wl, | |||
161 | if ((*fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) | 146 | if ((*fc & IEEE80211_FCTL_STYPE) == IEEE80211_STYPE_BEACON) |
162 | beacon = 1; | 147 | beacon = 1; |
163 | 148 | ||
164 | wl12xx_rx_status(wl, desc, &status, beacon); | 149 | wl1251_rx_status(wl, desc, &status, beacon); |
165 | 150 | ||
166 | wl12xx_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len, | 151 | wl1251_debug(DEBUG_RX, "rx skb 0x%p: %d B %s", skb, skb->len, |
167 | beacon ? "beacon" : ""); | 152 | beacon ? "beacon" : ""); |
168 | 153 | ||
169 | ieee80211_rx(wl->hw, skb, &status); | 154 | memcpy(IEEE80211_SKB_RXCB(skb), &status, sizeof(status)); |
155 | ieee80211_rx(wl->hw, skb); | ||
170 | } | 156 | } |
171 | 157 | ||
172 | static void wl12xx_rx_ack(struct wl12xx *wl) | 158 | static void wl1251_rx_ack(struct wl1251 *wl) |
173 | { | 159 | { |
174 | u32 data, addr; | 160 | u32 data, addr; |
175 | 161 | ||
@@ -181,28 +167,30 @@ static void wl12xx_rx_ack(struct wl12xx *wl) | |||
181 | data = INTR_TRIG_RX_PROC0; | 167 | data = INTR_TRIG_RX_PROC0; |
182 | } | 168 | } |
183 | 169 | ||
184 | wl12xx_reg_write32(wl, addr, data); | 170 | wl1251_reg_write32(wl, addr, data); |
185 | 171 | ||
186 | /* Toggle buffer ring */ | 172 | /* Toggle buffer ring */ |
187 | wl->rx_current_buffer = !wl->rx_current_buffer; | 173 | wl->rx_current_buffer = !wl->rx_current_buffer; |
188 | } | 174 | } |
189 | 175 | ||
190 | 176 | ||
191 | void wl12xx_rx(struct wl12xx *wl) | 177 | void wl1251_rx(struct wl1251 *wl) |
192 | { | 178 | { |
193 | struct wl12xx_rx_descriptor rx_desc; | 179 | struct wl1251_rx_descriptor *rx_desc; |
194 | 180 | ||
195 | if (wl->state != WL12XX_STATE_ON) | 181 | if (wl->state != WL1251_STATE_ON) |
196 | return; | 182 | return; |
197 | 183 | ||
184 | rx_desc = wl->rx_descriptor; | ||
185 | |||
198 | /* We first read the frame's header */ | 186 | /* We first read the frame's header */ |
199 | wl12xx_rx_header(wl, &rx_desc); | 187 | wl1251_rx_header(wl, rx_desc); |
200 | 188 | ||
201 | /* Now we can read the body */ | 189 | /* Now we can read the body */ |
202 | wl12xx_rx_body(wl, &rx_desc); | 190 | wl1251_rx_body(wl, rx_desc); |
203 | 191 | ||
204 | /* Finally, we need to ACK the RX */ | 192 | /* Finally, we need to ACK the RX */ |
205 | wl12xx_rx_ack(wl); | 193 | wl1251_rx_ack(wl); |
206 | 194 | ||
207 | return; | 195 | return; |
208 | } | 196 | } |
diff --git a/drivers/net/wireless/wl12xx/rx.h b/drivers/net/wireless/wl12xx/wl1251_rx.h index 8a23fdea5016..81156b9c4758 100644 --- a/drivers/net/wireless/wl12xx/rx.h +++ b/drivers/net/wireless/wl12xx/wl1251_rx.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -22,11 +22,13 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef __WL12XX_RX_H__ | 25 | #ifndef __WL1251_RX_H__ |
26 | #define __WL12XX_RX_H__ | 26 | #define __WL1251_RX_H__ |
27 | 27 | ||
28 | #include <linux/bitops.h> | 28 | #include <linux/bitops.h> |
29 | 29 | ||
30 | #include "wl1251.h" | ||
31 | |||
30 | /* | 32 | /* |
31 | * RX PATH | 33 | * RX PATH |
32 | * | 34 | * |
@@ -43,12 +45,12 @@ | |||
43 | * 4) The target prepares the next RX packet. | 45 | * 4) The target prepares the next RX packet. |
44 | */ | 46 | */ |
45 | 47 | ||
46 | #define WL12XX_RX_MAX_RSSI -30 | 48 | #define WL1251_RX_MAX_RSSI -30 |
47 | #define WL12XX_RX_MIN_RSSI -95 | 49 | #define WL1251_RX_MIN_RSSI -95 |
48 | 50 | ||
49 | #define WL12XX_RX_ALIGN_TO 4 | 51 | #define WL1251_RX_ALIGN_TO 4 |
50 | #define WL12XX_RX_ALIGN(len) (((len) + WL12XX_RX_ALIGN_TO - 1) & \ | 52 | #define WL1251_RX_ALIGN(len) (((len) + WL1251_RX_ALIGN_TO - 1) & \ |
51 | ~(WL12XX_RX_ALIGN_TO - 1)) | 53 | ~(WL1251_RX_ALIGN_TO - 1)) |
52 | 54 | ||
53 | #define SHORT_PREAMBLE_BIT BIT(0) | 55 | #define SHORT_PREAMBLE_BIT BIT(0) |
54 | #define OFDM_RATE_BIT BIT(6) | 56 | #define OFDM_RATE_BIT BIT(6) |
@@ -72,7 +74,7 @@ | |||
72 | #define RX_DESC_MIC_FAIL 0x2000 | 74 | #define RX_DESC_MIC_FAIL 0x2000 |
73 | #define RX_DESC_DECRYPT_FAIL 0x4000 | 75 | #define RX_DESC_DECRYPT_FAIL 0x4000 |
74 | 76 | ||
75 | struct wl12xx_rx_descriptor { | 77 | struct wl1251_rx_descriptor { |
76 | u32 timestamp; /* In microseconds */ | 78 | u32 timestamp; /* In microseconds */ |
77 | u16 length; /* Paylod length, including headers */ | 79 | u16 length; /* Paylod length, including headers */ |
78 | u16 flags; | 80 | u16 flags; |
@@ -117,6 +119,6 @@ struct wl12xx_rx_descriptor { | |||
117 | u8 snr; /* in dB */ | 119 | u8 snr; /* in dB */ |
118 | } __attribute__ ((packed)); | 120 | } __attribute__ ((packed)); |
119 | 121 | ||
120 | void wl12xx_rx(struct wl12xx *wl); | 122 | void wl1251_rx(struct wl1251 *wl); |
121 | 123 | ||
122 | #endif | 124 | #endif |
diff --git a/drivers/net/wireless/wl12xx/spi.c b/drivers/net/wireless/wl12xx/wl1251_spi.c index abdf171a47e7..c5da79dbc49c 100644 --- a/drivers/net/wireless/wl12xx/spi.c +++ b/drivers/net/wireless/wl12xx/wl1251_spi.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (C) 2008 Nokia Corporation | 4 | * Copyright (C) 2008 Nokia Corporation |
5 | * | 5 | * |
@@ -25,13 +25,11 @@ | |||
25 | #include <linux/crc7.h> | 25 | #include <linux/crc7.h> |
26 | #include <linux/spi/spi.h> | 26 | #include <linux/spi/spi.h> |
27 | 27 | ||
28 | #include "wl12xx.h" | 28 | #include "wl1251.h" |
29 | #include "wl12xx_80211.h" | ||
30 | #include "reg.h" | 29 | #include "reg.h" |
31 | #include "spi.h" | 30 | #include "wl1251_spi.h" |
32 | #include "ps.h" | ||
33 | 31 | ||
34 | static int wl12xx_translate_reg_addr(struct wl12xx *wl, int addr) | 32 | static int wl1251_translate_reg_addr(struct wl1251 *wl, int addr) |
35 | { | 33 | { |
36 | /* If the address is lower than REGISTERS_BASE, it means that this is | 34 | /* If the address is lower than REGISTERS_BASE, it means that this is |
37 | * a chip-specific register address, so look it up in the registers | 35 | * a chip-specific register address, so look it up in the registers |
@@ -39,7 +37,7 @@ static int wl12xx_translate_reg_addr(struct wl12xx *wl, int addr) | |||
39 | if (addr < REGISTERS_BASE) { | 37 | if (addr < REGISTERS_BASE) { |
40 | /* Make sure we don't go over the table */ | 38 | /* Make sure we don't go over the table */ |
41 | if (addr >= ACX_REG_TABLE_LEN) { | 39 | if (addr >= ACX_REG_TABLE_LEN) { |
42 | wl12xx_error("address out of range (%d)", addr); | 40 | wl1251_error("address out of range (%d)", addr); |
43 | return -EINVAL; | 41 | return -EINVAL; |
44 | } | 42 | } |
45 | addr = wl->chip.acx_reg_table[addr]; | 43 | addr = wl->chip.acx_reg_table[addr]; |
@@ -48,13 +46,13 @@ static int wl12xx_translate_reg_addr(struct wl12xx *wl, int addr) | |||
48 | return addr - wl->physical_reg_addr + wl->virtual_reg_addr; | 46 | return addr - wl->physical_reg_addr + wl->virtual_reg_addr; |
49 | } | 47 | } |
50 | 48 | ||
51 | static int wl12xx_translate_mem_addr(struct wl12xx *wl, int addr) | 49 | static int wl1251_translate_mem_addr(struct wl1251 *wl, int addr) |
52 | { | 50 | { |
53 | return addr - wl->physical_mem_addr + wl->virtual_mem_addr; | 51 | return addr - wl->physical_mem_addr + wl->virtual_mem_addr; |
54 | } | 52 | } |
55 | 53 | ||
56 | 54 | ||
57 | void wl12xx_spi_reset(struct wl12xx *wl) | 55 | void wl1251_spi_reset(struct wl1251 *wl) |
58 | { | 56 | { |
59 | u8 *cmd; | 57 | u8 *cmd; |
60 | struct spi_transfer t; | 58 | struct spi_transfer t; |
@@ -62,7 +60,7 @@ void wl12xx_spi_reset(struct wl12xx *wl) | |||
62 | 60 | ||
63 | cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); | 61 | cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); |
64 | if (!cmd) { | 62 | if (!cmd) { |
65 | wl12xx_error("could not allocate cmd for spi reset"); | 63 | wl1251_error("could not allocate cmd for spi reset"); |
66 | return; | 64 | return; |
67 | } | 65 | } |
68 | 66 | ||
@@ -77,10 +75,10 @@ void wl12xx_spi_reset(struct wl12xx *wl) | |||
77 | 75 | ||
78 | spi_sync(wl->spi, &m); | 76 | spi_sync(wl->spi, &m); |
79 | 77 | ||
80 | wl12xx_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); | 78 | wl1251_dump(DEBUG_SPI, "spi reset -> ", cmd, WSPI_INIT_CMD_LEN); |
81 | } | 79 | } |
82 | 80 | ||
83 | void wl12xx_spi_init(struct wl12xx *wl) | 81 | void wl1251_spi_init(struct wl1251 *wl) |
84 | { | 82 | { |
85 | u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; | 83 | u8 crc[WSPI_INIT_CMD_CRC_LEN], *cmd; |
86 | struct spi_transfer t; | 84 | struct spi_transfer t; |
@@ -88,7 +86,7 @@ void wl12xx_spi_init(struct wl12xx *wl) | |||
88 | 86 | ||
89 | cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); | 87 | cmd = kzalloc(WSPI_INIT_CMD_LEN, GFP_KERNEL); |
90 | if (!cmd) { | 88 | if (!cmd) { |
91 | wl12xx_error("could not allocate cmd for spi init"); | 89 | wl1251_error("could not allocate cmd for spi init"); |
92 | return; | 90 | return; |
93 | } | 91 | } |
94 | 92 | ||
@@ -131,7 +129,7 @@ void wl12xx_spi_init(struct wl12xx *wl) | |||
131 | 129 | ||
132 | spi_sync(wl->spi, &m); | 130 | spi_sync(wl->spi, &m); |
133 | 131 | ||
134 | wl12xx_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); | 132 | wl1251_dump(DEBUG_SPI, "spi init -> ", cmd, WSPI_INIT_CMD_LEN); |
135 | } | 133 | } |
136 | 134 | ||
137 | /* Set the SPI partitions to access the chip addresses | 135 | /* Set the SPI partitions to access the chip addresses |
@@ -167,45 +165,47 @@ void wl12xx_spi_init(struct wl12xx *wl) | |||
167 | * | | | 165 | * | | |
168 | * | 166 | * |
169 | */ | 167 | */ |
170 | void wl12xx_set_partition(struct wl12xx *wl, | 168 | int wl1251_set_partition(struct wl1251 *wl, |
171 | u32 mem_start, u32 mem_size, | 169 | u32 mem_start, u32 mem_size, |
172 | u32 reg_start, u32 reg_size) | 170 | u32 reg_start, u32 reg_size) |
173 | { | 171 | { |
174 | u8 tx_buf[sizeof(u32) + 2 * sizeof(struct wl12xx_partition)]; | 172 | struct wl1251_partition *partition; |
175 | struct wl12xx_partition *partition; | ||
176 | struct spi_transfer t; | 173 | struct spi_transfer t; |
177 | struct spi_message m; | 174 | struct spi_message m; |
175 | size_t len, cmd_len; | ||
178 | u32 *cmd; | 176 | u32 *cmd; |
179 | size_t len; | ||
180 | int addr; | 177 | int addr; |
181 | 178 | ||
179 | cmd_len = sizeof(u32) + 2 * sizeof(struct wl1251_partition); | ||
180 | cmd = kzalloc(cmd_len, GFP_KERNEL); | ||
181 | if (!cmd) | ||
182 | return -ENOMEM; | ||
183 | |||
182 | spi_message_init(&m); | 184 | spi_message_init(&m); |
183 | memset(&t, 0, sizeof(t)); | 185 | memset(&t, 0, sizeof(t)); |
184 | memset(tx_buf, 0, sizeof(tx_buf)); | ||
185 | 186 | ||
186 | cmd = (u32 *) tx_buf; | 187 | partition = (struct wl1251_partition *) (cmd + 1); |
187 | partition = (struct wl12xx_partition *) (tx_buf + sizeof(u32)); | ||
188 | addr = HW_ACCESS_PART0_SIZE_ADDR; | 188 | addr = HW_ACCESS_PART0_SIZE_ADDR; |
189 | len = 2 * sizeof(struct wl12xx_partition); | 189 | len = 2 * sizeof(struct wl1251_partition); |
190 | 190 | ||
191 | *cmd |= WSPI_CMD_WRITE; | 191 | *cmd |= WSPI_CMD_WRITE; |
192 | *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; | 192 | *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; |
193 | *cmd |= addr & WSPI_CMD_BYTE_ADDR; | 193 | *cmd |= addr & WSPI_CMD_BYTE_ADDR; |
194 | 194 | ||
195 | wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", | 195 | wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", |
196 | mem_start, mem_size); | 196 | mem_start, mem_size); |
197 | wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", | 197 | wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", |
198 | reg_start, reg_size); | 198 | reg_start, reg_size); |
199 | 199 | ||
200 | /* Make sure that the two partitions together don't exceed the | 200 | /* Make sure that the two partitions together don't exceed the |
201 | * address range */ | 201 | * address range */ |
202 | if ((mem_size + reg_size) > HW_ACCESS_MEMORY_MAX_RANGE) { | 202 | if ((mem_size + reg_size) > HW_ACCESS_MEMORY_MAX_RANGE) { |
203 | wl12xx_debug(DEBUG_SPI, "Total size exceeds maximum virtual" | 203 | wl1251_debug(DEBUG_SPI, "Total size exceeds maximum virtual" |
204 | " address range. Truncating partition[0]."); | 204 | " address range. Truncating partition[0]."); |
205 | mem_size = HW_ACCESS_MEMORY_MAX_RANGE - reg_size; | 205 | mem_size = HW_ACCESS_MEMORY_MAX_RANGE - reg_size; |
206 | wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", | 206 | wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", |
207 | mem_start, mem_size); | 207 | mem_start, mem_size); |
208 | wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", | 208 | wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", |
209 | reg_start, reg_size); | 209 | reg_start, reg_size); |
210 | } | 210 | } |
211 | 211 | ||
@@ -213,23 +213,23 @@ void wl12xx_set_partition(struct wl12xx *wl, | |||
213 | ((mem_start + mem_size) > reg_start)) { | 213 | ((mem_start + mem_size) > reg_start)) { |
214 | /* Guarantee that the memory partition doesn't overlap the | 214 | /* Guarantee that the memory partition doesn't overlap the |
215 | * registers partition */ | 215 | * registers partition */ |
216 | wl12xx_debug(DEBUG_SPI, "End of partition[0] is " | 216 | wl1251_debug(DEBUG_SPI, "End of partition[0] is " |
217 | "overlapping partition[1]. Adjusted."); | 217 | "overlapping partition[1]. Adjusted."); |
218 | mem_size = reg_start - mem_start; | 218 | mem_size = reg_start - mem_start; |
219 | wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", | 219 | wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", |
220 | mem_start, mem_size); | 220 | mem_start, mem_size); |
221 | wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", | 221 | wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", |
222 | reg_start, reg_size); | 222 | reg_start, reg_size); |
223 | } else if ((reg_start < mem_start) && | 223 | } else if ((reg_start < mem_start) && |
224 | ((reg_start + reg_size) > mem_start)) { | 224 | ((reg_start + reg_size) > mem_start)) { |
225 | /* Guarantee that the register partition doesn't overlap the | 225 | /* Guarantee that the register partition doesn't overlap the |
226 | * memory partition */ | 226 | * memory partition */ |
227 | wl12xx_debug(DEBUG_SPI, "End of partition[1] is" | 227 | wl1251_debug(DEBUG_SPI, "End of partition[1] is" |
228 | " overlapping partition[0]. Adjusted."); | 228 | " overlapping partition[0]. Adjusted."); |
229 | reg_size = mem_start - reg_start; | 229 | reg_size = mem_start - reg_start; |
230 | wl12xx_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", | 230 | wl1251_debug(DEBUG_SPI, "mem_start %08X mem_size %08X", |
231 | mem_start, mem_size); | 231 | mem_start, mem_size); |
232 | wl12xx_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", | 232 | wl1251_debug(DEBUG_SPI, "reg_start %08X reg_size %08X", |
233 | reg_start, reg_size); | 233 | reg_start, reg_size); |
234 | } | 234 | } |
235 | 235 | ||
@@ -244,36 +244,46 @@ void wl12xx_set_partition(struct wl12xx *wl, | |||
244 | wl->virtual_mem_addr = 0; | 244 | wl->virtual_mem_addr = 0; |
245 | wl->virtual_reg_addr = mem_size; | 245 | wl->virtual_reg_addr = mem_size; |
246 | 246 | ||
247 | t.tx_buf = tx_buf; | 247 | t.tx_buf = cmd; |
248 | t.len = sizeof(tx_buf); | 248 | t.len = cmd_len; |
249 | spi_message_add_tail(&t, &m); | 249 | spi_message_add_tail(&t, &m); |
250 | 250 | ||
251 | spi_sync(wl->spi, &m); | 251 | spi_sync(wl->spi, &m); |
252 | |||
253 | kfree(cmd); | ||
254 | |||
255 | return 0; | ||
252 | } | 256 | } |
253 | 257 | ||
254 | void wl12xx_spi_read(struct wl12xx *wl, int addr, void *buf, | 258 | void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, |
255 | size_t len) | 259 | size_t len, bool fixed) |
256 | { | 260 | { |
257 | struct spi_transfer t[3]; | 261 | struct spi_transfer t[3]; |
258 | struct spi_message m; | 262 | struct spi_message m; |
259 | char busy_buf[TNETWIF_READ_OFFSET_BYTES]; | 263 | u8 *busy_buf; |
260 | u32 cmd; | 264 | u32 *cmd; |
265 | |||
266 | cmd = &wl->buffer_cmd; | ||
267 | busy_buf = wl->buffer_busyword; | ||
268 | |||
269 | *cmd = 0; | ||
270 | *cmd |= WSPI_CMD_READ; | ||
271 | *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; | ||
272 | *cmd |= addr & WSPI_CMD_BYTE_ADDR; | ||
261 | 273 | ||
262 | cmd = 0; | 274 | if (fixed) |
263 | cmd |= WSPI_CMD_READ; | 275 | *cmd |= WSPI_CMD_FIXED; |
264 | cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; | ||
265 | cmd |= addr & WSPI_CMD_BYTE_ADDR; | ||
266 | 276 | ||
267 | spi_message_init(&m); | 277 | spi_message_init(&m); |
268 | memset(t, 0, sizeof(t)); | 278 | memset(t, 0, sizeof(t)); |
269 | 279 | ||
270 | t[0].tx_buf = &cmd; | 280 | t[0].tx_buf = cmd; |
271 | t[0].len = 4; | 281 | t[0].len = 4; |
272 | spi_message_add_tail(&t[0], &m); | 282 | spi_message_add_tail(&t[0], &m); |
273 | 283 | ||
274 | /* Busy and non busy words read */ | 284 | /* Busy and non busy words read */ |
275 | t[1].rx_buf = busy_buf; | 285 | t[1].rx_buf = busy_buf; |
276 | t[1].len = TNETWIF_READ_OFFSET_BYTES; | 286 | t[1].len = WL1251_BUSY_WORD_LEN; |
277 | spi_message_add_tail(&t[1], &m); | 287 | spi_message_add_tail(&t[1], &m); |
278 | 288 | ||
279 | t[2].rx_buf = buf; | 289 | t[2].rx_buf = buf; |
@@ -284,27 +294,32 @@ void wl12xx_spi_read(struct wl12xx *wl, int addr, void *buf, | |||
284 | 294 | ||
285 | /* FIXME: check busy words */ | 295 | /* FIXME: check busy words */ |
286 | 296 | ||
287 | wl12xx_dump(DEBUG_SPI, "spi_read cmd -> ", &cmd, sizeof(cmd)); | 297 | wl1251_dump(DEBUG_SPI, "spi_read cmd -> ", cmd, sizeof(*cmd)); |
288 | wl12xx_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); | 298 | wl1251_dump(DEBUG_SPI, "spi_read buf <- ", buf, len); |
289 | } | 299 | } |
290 | 300 | ||
291 | void wl12xx_spi_write(struct wl12xx *wl, int addr, void *buf, | 301 | void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, |
292 | size_t len) | 302 | size_t len, bool fixed) |
293 | { | 303 | { |
294 | struct spi_transfer t[2]; | 304 | struct spi_transfer t[2]; |
295 | struct spi_message m; | 305 | struct spi_message m; |
296 | u32 cmd; | 306 | u32 *cmd; |
307 | |||
308 | cmd = &wl->buffer_cmd; | ||
297 | 309 | ||
298 | cmd = 0; | 310 | *cmd = 0; |
299 | cmd |= WSPI_CMD_WRITE; | 311 | *cmd |= WSPI_CMD_WRITE; |
300 | cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; | 312 | *cmd |= (len << WSPI_CMD_BYTE_LENGTH_OFFSET) & WSPI_CMD_BYTE_LENGTH; |
301 | cmd |= addr & WSPI_CMD_BYTE_ADDR; | 313 | *cmd |= addr & WSPI_CMD_BYTE_ADDR; |
314 | |||
315 | if (fixed) | ||
316 | *cmd |= WSPI_CMD_FIXED; | ||
302 | 317 | ||
303 | spi_message_init(&m); | 318 | spi_message_init(&m); |
304 | memset(t, 0, sizeof(t)); | 319 | memset(t, 0, sizeof(t)); |
305 | 320 | ||
306 | t[0].tx_buf = &cmd; | 321 | t[0].tx_buf = cmd; |
307 | t[0].len = sizeof(cmd); | 322 | t[0].len = sizeof(*cmd); |
308 | spi_message_add_tail(&t[0], &m); | 323 | spi_message_add_tail(&t[0], &m); |
309 | 324 | ||
310 | t[1].tx_buf = buf; | 325 | t[1].tx_buf = buf; |
@@ -313,46 +328,66 @@ void wl12xx_spi_write(struct wl12xx *wl, int addr, void *buf, | |||
313 | 328 | ||
314 | spi_sync(wl->spi, &m); | 329 | spi_sync(wl->spi, &m); |
315 | 330 | ||
316 | wl12xx_dump(DEBUG_SPI, "spi_write cmd -> ", &cmd, sizeof(cmd)); | 331 | wl1251_dump(DEBUG_SPI, "spi_write cmd -> ", cmd, sizeof(*cmd)); |
317 | wl12xx_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); | 332 | wl1251_dump(DEBUG_SPI, "spi_write buf -> ", buf, len); |
318 | } | 333 | } |
319 | 334 | ||
320 | void wl12xx_spi_mem_read(struct wl12xx *wl, int addr, void *buf, | 335 | void wl1251_spi_mem_read(struct wl1251 *wl, int addr, void *buf, |
321 | size_t len) | 336 | size_t len) |
322 | { | 337 | { |
323 | int physical; | 338 | int physical; |
324 | 339 | ||
325 | physical = wl12xx_translate_mem_addr(wl, addr); | 340 | physical = wl1251_translate_mem_addr(wl, addr); |
326 | 341 | ||
327 | wl12xx_spi_read(wl, physical, buf, len); | 342 | wl1251_spi_read(wl, physical, buf, len, false); |
328 | } | 343 | } |
329 | 344 | ||
330 | void wl12xx_spi_mem_write(struct wl12xx *wl, int addr, void *buf, | 345 | void wl1251_spi_mem_write(struct wl1251 *wl, int addr, void *buf, |
331 | size_t len) | 346 | size_t len) |
332 | { | 347 | { |
333 | int physical; | 348 | int physical; |
334 | 349 | ||
335 | physical = wl12xx_translate_mem_addr(wl, addr); | 350 | physical = wl1251_translate_mem_addr(wl, addr); |
351 | |||
352 | wl1251_spi_write(wl, physical, buf, len, false); | ||
353 | } | ||
354 | |||
355 | void wl1251_spi_reg_read(struct wl1251 *wl, int addr, void *buf, size_t len, | ||
356 | bool fixed) | ||
357 | { | ||
358 | int physical; | ||
359 | |||
360 | physical = wl1251_translate_reg_addr(wl, addr); | ||
361 | |||
362 | wl1251_spi_read(wl, physical, buf, len, fixed); | ||
363 | } | ||
364 | |||
365 | void wl1251_spi_reg_write(struct wl1251 *wl, int addr, void *buf, size_t len, | ||
366 | bool fixed) | ||
367 | { | ||
368 | int physical; | ||
369 | |||
370 | physical = wl1251_translate_reg_addr(wl, addr); | ||
336 | 371 | ||
337 | wl12xx_spi_write(wl, physical, buf, len); | 372 | wl1251_spi_write(wl, physical, buf, len, fixed); |
338 | } | 373 | } |
339 | 374 | ||
340 | u32 wl12xx_mem_read32(struct wl12xx *wl, int addr) | 375 | u32 wl1251_mem_read32(struct wl1251 *wl, int addr) |
341 | { | 376 | { |
342 | return wl12xx_read32(wl, wl12xx_translate_mem_addr(wl, addr)); | 377 | return wl1251_read32(wl, wl1251_translate_mem_addr(wl, addr)); |
343 | } | 378 | } |
344 | 379 | ||
345 | void wl12xx_mem_write32(struct wl12xx *wl, int addr, u32 val) | 380 | void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val) |
346 | { | 381 | { |
347 | wl12xx_write32(wl, wl12xx_translate_mem_addr(wl, addr), val); | 382 | wl1251_write32(wl, wl1251_translate_mem_addr(wl, addr), val); |
348 | } | 383 | } |
349 | 384 | ||
350 | u32 wl12xx_reg_read32(struct wl12xx *wl, int addr) | 385 | u32 wl1251_reg_read32(struct wl1251 *wl, int addr) |
351 | { | 386 | { |
352 | return wl12xx_read32(wl, wl12xx_translate_reg_addr(wl, addr)); | 387 | return wl1251_read32(wl, wl1251_translate_reg_addr(wl, addr)); |
353 | } | 388 | } |
354 | 389 | ||
355 | void wl12xx_reg_write32(struct wl12xx *wl, int addr, u32 val) | 390 | void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val) |
356 | { | 391 | { |
357 | wl12xx_write32(wl, wl12xx_translate_reg_addr(wl, addr), val); | 392 | wl1251_write32(wl, wl1251_translate_reg_addr(wl, addr), val); |
358 | } | 393 | } |
diff --git a/drivers/net/wireless/wl12xx/spi.h b/drivers/net/wireless/wl12xx/wl1251_spi.h index fd3227e904a8..6e8daf4e1085 100644 --- a/drivers/net/wireless/wl12xx/spi.h +++ b/drivers/net/wireless/wl12xx/wl1251_spi.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -22,11 +22,11 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef __WL12XX_SPI_H__ | 25 | #ifndef __WL1251_SPI_H__ |
26 | #define __WL12XX_SPI_H__ | 26 | #define __WL1251_SPI_H__ |
27 | 27 | ||
28 | #include "cmd.h" | 28 | #include "wl1251_cmd.h" |
29 | #include "acx.h" | 29 | #include "wl1251_acx.h" |
30 | #include "reg.h" | 30 | #include "reg.h" |
31 | 31 | ||
32 | #define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0 | 32 | #define HW_ACCESS_MEMORY_MAX_RANGE 0x1FFC0 |
@@ -65,45 +65,51 @@ | |||
65 | 65 | ||
66 | #define WSPI_INIT_CMD_LEN 8 | 66 | #define WSPI_INIT_CMD_LEN 8 |
67 | 67 | ||
68 | #define TNETWIF_READ_OFFSET_BYTES 8 | ||
69 | #define HW_ACCESS_WSPI_FIXED_BUSY_LEN \ | 68 | #define HW_ACCESS_WSPI_FIXED_BUSY_LEN \ |
70 | ((TNETWIF_READ_OFFSET_BYTES - 4) / sizeof(u32)) | 69 | ((WL1251_BUSY_WORD_LEN - 4) / sizeof(u32)) |
71 | #define HW_ACCESS_WSPI_INIT_CMD_MASK 0 | 70 | #define HW_ACCESS_WSPI_INIT_CMD_MASK 0 |
72 | 71 | ||
73 | 72 | ||
74 | /* Raw target IO, address is not translated */ | 73 | /* Raw target IO, address is not translated */ |
75 | void wl12xx_spi_read(struct wl12xx *wl, int addr, void *buf, size_t len); | 74 | void wl1251_spi_write(struct wl1251 *wl, int addr, void *buf, |
76 | void wl12xx_spi_write(struct wl12xx *wl, int addr, void *buf, size_t len); | 75 | size_t len, bool fixed); |
76 | void wl1251_spi_read(struct wl1251 *wl, int addr, void *buf, | ||
77 | size_t len, bool fixed); | ||
77 | 78 | ||
78 | /* Memory target IO, address is tranlated to partition 0 */ | 79 | /* Memory target IO, address is tranlated to partition 0 */ |
79 | void wl12xx_spi_mem_read(struct wl12xx *wl, int addr, void *buf, size_t len); | 80 | void wl1251_spi_mem_read(struct wl1251 *wl, int addr, void *buf, size_t len); |
80 | void wl12xx_spi_mem_write(struct wl12xx *wl, int addr, void *buf, size_t len); | 81 | void wl1251_spi_mem_write(struct wl1251 *wl, int addr, void *buf, size_t len); |
81 | u32 wl12xx_mem_read32(struct wl12xx *wl, int addr); | 82 | u32 wl1251_mem_read32(struct wl1251 *wl, int addr); |
82 | void wl12xx_mem_write32(struct wl12xx *wl, int addr, u32 val); | 83 | void wl1251_mem_write32(struct wl1251 *wl, int addr, u32 val); |
83 | 84 | ||
84 | /* Registers IO */ | 85 | /* Registers IO */ |
85 | u32 wl12xx_reg_read32(struct wl12xx *wl, int addr); | 86 | void wl1251_spi_reg_read(struct wl1251 *wl, int addr, void *buf, size_t len, |
86 | void wl12xx_reg_write32(struct wl12xx *wl, int addr, u32 val); | 87 | bool fixed); |
88 | void wl1251_spi_reg_write(struct wl1251 *wl, int addr, void *buf, size_t len, | ||
89 | bool fixed); | ||
90 | u32 wl1251_reg_read32(struct wl1251 *wl, int addr); | ||
91 | void wl1251_reg_write32(struct wl1251 *wl, int addr, u32 val); | ||
87 | 92 | ||
88 | /* INIT and RESET words */ | 93 | /* INIT and RESET words */ |
89 | void wl12xx_spi_reset(struct wl12xx *wl); | 94 | void wl1251_spi_reset(struct wl1251 *wl); |
90 | void wl12xx_spi_init(struct wl12xx *wl); | 95 | void wl1251_spi_init(struct wl1251 *wl); |
91 | void wl12xx_set_partition(struct wl12xx *wl, | 96 | int wl1251_set_partition(struct wl1251 *wl, |
92 | u32 part_start, u32 part_size, | 97 | u32 part_start, u32 part_size, |
93 | u32 reg_start, u32 reg_size); | 98 | u32 reg_start, u32 reg_size); |
94 | 99 | ||
95 | static inline u32 wl12xx_read32(struct wl12xx *wl, int addr) | 100 | static inline u32 wl1251_read32(struct wl1251 *wl, int addr) |
96 | { | 101 | { |
97 | u32 response; | 102 | wl1251_spi_read(wl, addr, &wl->buffer_32, |
103 | sizeof(wl->buffer_32), false); | ||
98 | 104 | ||
99 | wl12xx_spi_read(wl, addr, &response, sizeof(u32)); | 105 | return wl->buffer_32; |
100 | |||
101 | return response; | ||
102 | } | 106 | } |
103 | 107 | ||
104 | static inline void wl12xx_write32(struct wl12xx *wl, int addr, u32 val) | 108 | static inline void wl1251_write32(struct wl1251 *wl, int addr, u32 val) |
105 | { | 109 | { |
106 | wl12xx_spi_write(wl, addr, &val, sizeof(u32)); | 110 | wl->buffer_32 = val; |
111 | wl1251_spi_write(wl, addr, &wl->buffer_32, | ||
112 | sizeof(wl->buffer_32), false); | ||
107 | } | 113 | } |
108 | 114 | ||
109 | #endif /* __WL12XX_SPI_H__ */ | 115 | #endif /* __WL1251_SPI_H__ */ |
diff --git a/drivers/net/wireless/wl12xx/tx.c b/drivers/net/wireless/wl12xx/wl1251_tx.c index 62145e205a8c..2652a222383a 100644 --- a/drivers/net/wireless/wl12xx/tx.c +++ b/drivers/net/wireless/wl12xx/wl1251_tx.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -25,13 +25,13 @@ | |||
25 | #include <linux/kernel.h> | 25 | #include <linux/kernel.h> |
26 | #include <linux/module.h> | 26 | #include <linux/module.h> |
27 | 27 | ||
28 | #include "wl12xx.h" | 28 | #include "wl1251.h" |
29 | #include "reg.h" | 29 | #include "reg.h" |
30 | #include "spi.h" | 30 | #include "wl1251_spi.h" |
31 | #include "tx.h" | 31 | #include "wl1251_tx.h" |
32 | #include "ps.h" | 32 | #include "wl1251_ps.h" |
33 | 33 | ||
34 | static bool wl12xx_tx_double_buffer_busy(struct wl12xx *wl, u32 data_out_count) | 34 | static bool wl1251_tx_double_buffer_busy(struct wl1251 *wl, u32 data_out_count) |
35 | { | 35 | { |
36 | int used, data_in_count; | 36 | int used, data_in_count; |
37 | 37 | ||
@@ -52,15 +52,15 @@ static bool wl12xx_tx_double_buffer_busy(struct wl12xx *wl, u32 data_out_count) | |||
52 | return false; | 52 | return false; |
53 | } | 53 | } |
54 | 54 | ||
55 | static int wl12xx_tx_path_status(struct wl12xx *wl) | 55 | static int wl1251_tx_path_status(struct wl1251 *wl) |
56 | { | 56 | { |
57 | u32 status, addr, data_out_count; | 57 | u32 status, addr, data_out_count; |
58 | bool busy; | 58 | bool busy; |
59 | 59 | ||
60 | addr = wl->data_path->tx_control_addr; | 60 | addr = wl->data_path->tx_control_addr; |
61 | status = wl12xx_mem_read32(wl, addr); | 61 | status = wl1251_mem_read32(wl, addr); |
62 | data_out_count = status & TX_STATUS_DATA_OUT_COUNT_MASK; | 62 | data_out_count = status & TX_STATUS_DATA_OUT_COUNT_MASK; |
63 | busy = wl12xx_tx_double_buffer_busy(wl, data_out_count); | 63 | busy = wl1251_tx_double_buffer_busy(wl, data_out_count); |
64 | 64 | ||
65 | if (busy) | 65 | if (busy) |
66 | return -EBUSY; | 66 | return -EBUSY; |
@@ -68,7 +68,7 @@ static int wl12xx_tx_path_status(struct wl12xx *wl) | |||
68 | return 0; | 68 | return 0; |
69 | } | 69 | } |
70 | 70 | ||
71 | static int wl12xx_tx_id(struct wl12xx *wl, struct sk_buff *skb) | 71 | static int wl1251_tx_id(struct wl1251 *wl, struct sk_buff *skb) |
72 | { | 72 | { |
73 | int i; | 73 | int i; |
74 | 74 | ||
@@ -81,7 +81,7 @@ static int wl12xx_tx_id(struct wl12xx *wl, struct sk_buff *skb) | |||
81 | return -EBUSY; | 81 | return -EBUSY; |
82 | } | 82 | } |
83 | 83 | ||
84 | static void wl12xx_tx_control(struct tx_double_buffer_desc *tx_hdr, | 84 | static void wl1251_tx_control(struct tx_double_buffer_desc *tx_hdr, |
85 | struct ieee80211_tx_info *control, u16 fc) | 85 | struct ieee80211_tx_info *control, u16 fc) |
86 | { | 86 | { |
87 | *(u16 *)&tx_hdr->control = 0; | 87 | *(u16 *)&tx_hdr->control = 0; |
@@ -109,7 +109,7 @@ static void wl12xx_tx_control(struct tx_double_buffer_desc *tx_hdr, | |||
109 | #define MAX_MPDU_HEADER_AND_SECURITY (MAX_MPDU_SECURITY_LENGTH + \ | 109 | #define MAX_MPDU_HEADER_AND_SECURITY (MAX_MPDU_SECURITY_LENGTH + \ |
110 | WLAN_QOS_HDR_LEN) | 110 | WLAN_QOS_HDR_LEN) |
111 | #define HW_BLOCK_SIZE 252 | 111 | #define HW_BLOCK_SIZE 252 |
112 | static void wl12xx_tx_frag_block_num(struct tx_double_buffer_desc *tx_hdr) | 112 | static void wl1251_tx_frag_block_num(struct tx_double_buffer_desc *tx_hdr) |
113 | { | 113 | { |
114 | u16 payload_len, frag_threshold, mem_blocks; | 114 | u16 payload_len, frag_threshold, mem_blocks; |
115 | u16 num_mpdus, mem_blocks_per_frag; | 115 | u16 num_mpdus, mem_blocks_per_frag; |
@@ -142,7 +142,7 @@ static void wl12xx_tx_frag_block_num(struct tx_double_buffer_desc *tx_hdr) | |||
142 | tx_hdr->num_mem_blocks = mem_blocks; | 142 | tx_hdr->num_mem_blocks = mem_blocks; |
143 | } | 143 | } |
144 | 144 | ||
145 | static int wl12xx_tx_fill_hdr(struct wl12xx *wl, struct sk_buff *skb, | 145 | static int wl1251_tx_fill_hdr(struct wl1251 *wl, struct sk_buff *skb, |
146 | struct ieee80211_tx_info *control) | 146 | struct ieee80211_tx_info *control) |
147 | { | 147 | { |
148 | struct tx_double_buffer_desc *tx_hdr; | 148 | struct tx_double_buffer_desc *tx_hdr; |
@@ -153,7 +153,7 @@ static int wl12xx_tx_fill_hdr(struct wl12xx *wl, struct sk_buff *skb, | |||
153 | if (!skb) | 153 | if (!skb) |
154 | return -EINVAL; | 154 | return -EINVAL; |
155 | 155 | ||
156 | id = wl12xx_tx_id(wl, skb); | 156 | id = wl1251_tx_id(wl, skb); |
157 | if (id < 0) | 157 | if (id < 0) |
158 | return id; | 158 | return id; |
159 | 159 | ||
@@ -170,14 +170,14 @@ static int wl12xx_tx_fill_hdr(struct wl12xx *wl, struct sk_buff *skb, | |||
170 | /* FIXME: how to get the correct queue id? */ | 170 | /* FIXME: how to get the correct queue id? */ |
171 | tx_hdr->xmit_queue = 0; | 171 | tx_hdr->xmit_queue = 0; |
172 | 172 | ||
173 | wl12xx_tx_control(tx_hdr, control, fc); | 173 | wl1251_tx_control(tx_hdr, control, fc); |
174 | wl12xx_tx_frag_block_num(tx_hdr); | 174 | wl1251_tx_frag_block_num(tx_hdr); |
175 | 175 | ||
176 | return 0; | 176 | return 0; |
177 | } | 177 | } |
178 | 178 | ||
179 | /* We copy the packet to the target */ | 179 | /* We copy the packet to the target */ |
180 | static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb, | 180 | static int wl1251_tx_send_packet(struct wl1251 *wl, struct sk_buff *skb, |
181 | struct ieee80211_tx_info *control) | 181 | struct ieee80211_tx_info *control) |
182 | { | 182 | { |
183 | struct tx_double_buffer_desc *tx_hdr; | 183 | struct tx_double_buffer_desc *tx_hdr; |
@@ -196,12 +196,12 @@ static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb, | |||
196 | u8 *pos; | 196 | u8 *pos; |
197 | 197 | ||
198 | fc = *(u16 *)(skb->data + sizeof(*tx_hdr)); | 198 | fc = *(u16 *)(skb->data + sizeof(*tx_hdr)); |
199 | tx_hdr->length += WL12XX_TKIP_IV_SPACE; | 199 | tx_hdr->length += WL1251_TKIP_IV_SPACE; |
200 | 200 | ||
201 | hdrlen = ieee80211_hdrlen(fc); | 201 | hdrlen = ieee80211_hdrlen(fc); |
202 | 202 | ||
203 | pos = skb_push(skb, WL12XX_TKIP_IV_SPACE); | 203 | pos = skb_push(skb, WL1251_TKIP_IV_SPACE); |
204 | memmove(pos, pos + WL12XX_TKIP_IV_SPACE, | 204 | memmove(pos, pos + WL1251_TKIP_IV_SPACE, |
205 | sizeof(*tx_hdr) + hdrlen); | 205 | sizeof(*tx_hdr) + hdrlen); |
206 | } | 206 | } |
207 | 207 | ||
@@ -211,7 +211,7 @@ static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb, | |||
211 | */ | 211 | */ |
212 | if (unlikely((long)skb->data & 0x03)) { | 212 | if (unlikely((long)skb->data & 0x03)) { |
213 | int offset = (4 - (long)skb->data) & 0x03; | 213 | int offset = (4 - (long)skb->data) & 0x03; |
214 | wl12xx_debug(DEBUG_TX, "skb offset %d", offset); | 214 | wl1251_debug(DEBUG_TX, "skb offset %d", offset); |
215 | 215 | ||
216 | /* check whether the current skb can be used */ | 216 | /* check whether the current skb can be used */ |
217 | if (!skb_cloned(skb) && (skb_tailroom(skb) >= offset)) { | 217 | if (!skb_cloned(skb) && (skb_tailroom(skb) >= offset)) { |
@@ -221,13 +221,13 @@ static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb, | |||
221 | skb_reserve(skb, offset); | 221 | skb_reserve(skb, offset); |
222 | memmove(skb->data, src, skb->len); | 222 | memmove(skb->data, src, skb->len); |
223 | } else { | 223 | } else { |
224 | wl12xx_info("No handler, fixme!"); | 224 | wl1251_info("No handler, fixme!"); |
225 | return -EINVAL; | 225 | return -EINVAL; |
226 | } | 226 | } |
227 | } | 227 | } |
228 | 228 | ||
229 | /* Our skb->data at this point includes the HW header */ | 229 | /* Our skb->data at this point includes the HW header */ |
230 | len = WL12XX_TX_ALIGN(skb->len); | 230 | len = WL1251_TX_ALIGN(skb->len); |
231 | 231 | ||
232 | if (wl->data_in_count & 0x1) | 232 | if (wl->data_in_count & 0x1) |
233 | addr = wl->data_path->tx_packet_ring_addr + | 233 | addr = wl->data_path->tx_packet_ring_addr + |
@@ -235,15 +235,15 @@ static int wl12xx_tx_send_packet(struct wl12xx *wl, struct sk_buff *skb, | |||
235 | else | 235 | else |
236 | addr = wl->data_path->tx_packet_ring_addr; | 236 | addr = wl->data_path->tx_packet_ring_addr; |
237 | 237 | ||
238 | wl12xx_spi_mem_write(wl, addr, skb->data, len); | 238 | wl1251_spi_mem_write(wl, addr, skb->data, len); |
239 | 239 | ||
240 | wl12xx_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u rate 0x%x", | 240 | wl1251_debug(DEBUG_TX, "tx id %u skb 0x%p payload %u rate 0x%x", |
241 | tx_hdr->id, skb, tx_hdr->length, tx_hdr->rate); | 241 | tx_hdr->id, skb, tx_hdr->length, tx_hdr->rate); |
242 | 242 | ||
243 | return 0; | 243 | return 0; |
244 | } | 244 | } |
245 | 245 | ||
246 | static void wl12xx_tx_trigger(struct wl12xx *wl) | 246 | static void wl1251_tx_trigger(struct wl1251 *wl) |
247 | { | 247 | { |
248 | u32 data, addr; | 248 | u32 data, addr; |
249 | 249 | ||
@@ -255,7 +255,7 @@ static void wl12xx_tx_trigger(struct wl12xx *wl) | |||
255 | data = INTR_TRIG_TX_PROC0; | 255 | data = INTR_TRIG_TX_PROC0; |
256 | } | 256 | } |
257 | 257 | ||
258 | wl12xx_reg_write32(wl, addr, data); | 258 | wl1251_reg_write32(wl, addr, data); |
259 | 259 | ||
260 | /* Bumping data in */ | 260 | /* Bumping data in */ |
261 | wl->data_in_count = (wl->data_in_count + 1) & | 261 | wl->data_in_count = (wl->data_in_count + 1) & |
@@ -263,7 +263,7 @@ static void wl12xx_tx_trigger(struct wl12xx *wl) | |||
263 | } | 263 | } |
264 | 264 | ||
265 | /* caller must hold wl->mutex */ | 265 | /* caller must hold wl->mutex */ |
266 | static int wl12xx_tx_frame(struct wl12xx *wl, struct sk_buff *skb) | 266 | static int wl1251_tx_frame(struct wl1251 *wl, struct sk_buff *skb) |
267 | { | 267 | { |
268 | struct ieee80211_tx_info *info; | 268 | struct ieee80211_tx_info *info; |
269 | int ret = 0; | 269 | int ret = 0; |
@@ -274,51 +274,53 @@ static int wl12xx_tx_frame(struct wl12xx *wl, struct sk_buff *skb) | |||
274 | if (info->control.hw_key) { | 274 | if (info->control.hw_key) { |
275 | idx = info->control.hw_key->hw_key_idx; | 275 | idx = info->control.hw_key->hw_key_idx; |
276 | if (unlikely(wl->default_key != idx)) { | 276 | if (unlikely(wl->default_key != idx)) { |
277 | ret = wl12xx_acx_default_key(wl, idx); | 277 | ret = wl1251_acx_default_key(wl, idx); |
278 | if (ret < 0) | 278 | if (ret < 0) |
279 | return ret; | 279 | return ret; |
280 | } | 280 | } |
281 | } | 281 | } |
282 | 282 | ||
283 | ret = wl12xx_tx_path_status(wl); | 283 | ret = wl1251_tx_path_status(wl); |
284 | if (ret < 0) | 284 | if (ret < 0) |
285 | return ret; | 285 | return ret; |
286 | 286 | ||
287 | ret = wl12xx_tx_fill_hdr(wl, skb, info); | 287 | ret = wl1251_tx_fill_hdr(wl, skb, info); |
288 | if (ret < 0) | 288 | if (ret < 0) |
289 | return ret; | 289 | return ret; |
290 | 290 | ||
291 | ret = wl12xx_tx_send_packet(wl, skb, info); | 291 | ret = wl1251_tx_send_packet(wl, skb, info); |
292 | if (ret < 0) | 292 | if (ret < 0) |
293 | return ret; | 293 | return ret; |
294 | 294 | ||
295 | wl12xx_tx_trigger(wl); | 295 | wl1251_tx_trigger(wl); |
296 | 296 | ||
297 | return ret; | 297 | return ret; |
298 | } | 298 | } |
299 | 299 | ||
300 | void wl12xx_tx_work(struct work_struct *work) | 300 | void wl1251_tx_work(struct work_struct *work) |
301 | { | 301 | { |
302 | struct wl12xx *wl = container_of(work, struct wl12xx, tx_work); | 302 | struct wl1251 *wl = container_of(work, struct wl1251, tx_work); |
303 | struct sk_buff *skb; | 303 | struct sk_buff *skb; |
304 | bool woken_up = false; | 304 | bool woken_up = false; |
305 | int ret; | 305 | int ret; |
306 | 306 | ||
307 | mutex_lock(&wl->mutex); | 307 | mutex_lock(&wl->mutex); |
308 | 308 | ||
309 | if (unlikely(wl->state == WL12XX_STATE_OFF)) | 309 | if (unlikely(wl->state == WL1251_STATE_OFF)) |
310 | goto out; | 310 | goto out; |
311 | 311 | ||
312 | while ((skb = skb_dequeue(&wl->tx_queue))) { | 312 | while ((skb = skb_dequeue(&wl->tx_queue))) { |
313 | if (!woken_up) { | 313 | if (!woken_up) { |
314 | wl12xx_ps_elp_wakeup(wl); | 314 | ret = wl1251_ps_elp_wakeup(wl); |
315 | if (ret < 0) | ||
316 | goto out; | ||
315 | woken_up = true; | 317 | woken_up = true; |
316 | } | 318 | } |
317 | 319 | ||
318 | ret = wl12xx_tx_frame(wl, skb); | 320 | ret = wl1251_tx_frame(wl, skb); |
319 | if (ret == -EBUSY) { | 321 | if (ret == -EBUSY) { |
320 | /* firmware buffer is full, stop queues */ | 322 | /* firmware buffer is full, stop queues */ |
321 | wl12xx_debug(DEBUG_TX, "tx_work: fw buffer full, " | 323 | wl1251_debug(DEBUG_TX, "tx_work: fw buffer full, " |
322 | "stop queues"); | 324 | "stop queues"); |
323 | ieee80211_stop_queues(wl->hw); | 325 | ieee80211_stop_queues(wl->hw); |
324 | wl->tx_queue_stopped = true; | 326 | wl->tx_queue_stopped = true; |
@@ -332,12 +334,12 @@ void wl12xx_tx_work(struct work_struct *work) | |||
332 | 334 | ||
333 | out: | 335 | out: |
334 | if (woken_up) | 336 | if (woken_up) |
335 | wl12xx_ps_elp_sleep(wl); | 337 | wl1251_ps_elp_sleep(wl); |
336 | 338 | ||
337 | mutex_unlock(&wl->mutex); | 339 | mutex_unlock(&wl->mutex); |
338 | } | 340 | } |
339 | 341 | ||
340 | static const char *wl12xx_tx_parse_status(u8 status) | 342 | static const char *wl1251_tx_parse_status(u8 status) |
341 | { | 343 | { |
342 | /* 8 bit status field, one character per bit plus null */ | 344 | /* 8 bit status field, one character per bit plus null */ |
343 | static char buf[9]; | 345 | static char buf[9]; |
@@ -365,7 +367,7 @@ static const char *wl12xx_tx_parse_status(u8 status) | |||
365 | return buf; | 367 | return buf; |
366 | } | 368 | } |
367 | 369 | ||
368 | static void wl12xx_tx_packet_cb(struct wl12xx *wl, | 370 | static void wl1251_tx_packet_cb(struct wl1251 *wl, |
369 | struct tx_result *result) | 371 | struct tx_result *result) |
370 | { | 372 | { |
371 | struct ieee80211_tx_info *info; | 373 | struct ieee80211_tx_info *info; |
@@ -375,7 +377,7 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl, | |||
375 | 377 | ||
376 | skb = wl->tx_frames[result->id]; | 378 | skb = wl->tx_frames[result->id]; |
377 | if (skb == NULL) { | 379 | if (skb == NULL) { |
378 | wl12xx_error("SKB for packet %d is NULL", result->id); | 380 | wl1251_error("SKB for packet %d is NULL", result->id); |
379 | return; | 381 | return; |
380 | } | 382 | } |
381 | 383 | ||
@@ -396,14 +398,14 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl, | |||
396 | if (info->control.hw_key && | 398 | if (info->control.hw_key && |
397 | info->control.hw_key->alg == ALG_TKIP) { | 399 | info->control.hw_key->alg == ALG_TKIP) { |
398 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); | 400 | hdrlen = ieee80211_get_hdrlen_from_skb(skb); |
399 | memmove(frame + WL12XX_TKIP_IV_SPACE, frame, hdrlen); | 401 | memmove(frame + WL1251_TKIP_IV_SPACE, frame, hdrlen); |
400 | skb_pull(skb, WL12XX_TKIP_IV_SPACE); | 402 | skb_pull(skb, WL1251_TKIP_IV_SPACE); |
401 | } | 403 | } |
402 | 404 | ||
403 | wl12xx_debug(DEBUG_TX, "tx status id %u skb 0x%p failures %u rate 0x%x" | 405 | wl1251_debug(DEBUG_TX, "tx status id %u skb 0x%p failures %u rate 0x%x" |
404 | " status 0x%x (%s)", | 406 | " status 0x%x (%s)", |
405 | result->id, skb, result->ack_failures, result->rate, | 407 | result->id, skb, result->ack_failures, result->rate, |
406 | result->status, wl12xx_tx_parse_status(result->status)); | 408 | result->status, wl1251_tx_parse_status(result->status)); |
407 | 409 | ||
408 | 410 | ||
409 | ieee80211_tx_status(wl->hw, skb); | 411 | ieee80211_tx_status(wl->hw, skb); |
@@ -411,7 +413,7 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl, | |||
411 | wl->tx_frames[result->id] = NULL; | 413 | wl->tx_frames[result->id] = NULL; |
412 | 414 | ||
413 | if (wl->tx_queue_stopped) { | 415 | if (wl->tx_queue_stopped) { |
414 | wl12xx_debug(DEBUG_TX, "cb: queue was stopped"); | 416 | wl1251_debug(DEBUG_TX, "cb: queue was stopped"); |
415 | 417 | ||
416 | skb = skb_dequeue(&wl->tx_queue); | 418 | skb = skb_dequeue(&wl->tx_queue); |
417 | 419 | ||
@@ -420,10 +422,10 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl, | |||
420 | queue empty */ | 422 | queue empty */ |
421 | 423 | ||
422 | if (skb) { | 424 | if (skb) { |
423 | ret = wl12xx_tx_frame(wl, skb); | 425 | ret = wl1251_tx_frame(wl, skb); |
424 | if (ret == -EBUSY) { | 426 | if (ret == -EBUSY) { |
425 | /* firmware buffer is still full */ | 427 | /* firmware buffer is still full */ |
426 | wl12xx_debug(DEBUG_TX, "cb: fw buffer " | 428 | wl1251_debug(DEBUG_TX, "cb: fw buffer " |
427 | "still full"); | 429 | "still full"); |
428 | skb_queue_head(&wl->tx_queue, skb); | 430 | skb_queue_head(&wl->tx_queue, skb); |
429 | return; | 431 | return; |
@@ -433,23 +435,23 @@ static void wl12xx_tx_packet_cb(struct wl12xx *wl, | |||
433 | } | 435 | } |
434 | } | 436 | } |
435 | 437 | ||
436 | wl12xx_debug(DEBUG_TX, "cb: waking queues"); | 438 | wl1251_debug(DEBUG_TX, "cb: waking queues"); |
437 | ieee80211_wake_queues(wl->hw); | 439 | ieee80211_wake_queues(wl->hw); |
438 | wl->tx_queue_stopped = false; | 440 | wl->tx_queue_stopped = false; |
439 | } | 441 | } |
440 | } | 442 | } |
441 | 443 | ||
442 | /* Called upon reception of a TX complete interrupt */ | 444 | /* Called upon reception of a TX complete interrupt */ |
443 | void wl12xx_tx_complete(struct wl12xx *wl) | 445 | void wl1251_tx_complete(struct wl1251 *wl) |
444 | { | 446 | { |
445 | int i, result_index, num_complete = 0; | 447 | int i, result_index, num_complete = 0; |
446 | struct tx_result result[FW_TX_CMPLT_BLOCK_SIZE], *result_ptr; | 448 | struct tx_result result[FW_TX_CMPLT_BLOCK_SIZE], *result_ptr; |
447 | 449 | ||
448 | if (unlikely(wl->state != WL12XX_STATE_ON)) | 450 | if (unlikely(wl->state != WL1251_STATE_ON)) |
449 | return; | 451 | return; |
450 | 452 | ||
451 | /* First we read the result */ | 453 | /* First we read the result */ |
452 | wl12xx_spi_mem_read(wl, wl->data_path->tx_complete_addr, | 454 | wl1251_spi_mem_read(wl, wl->data_path->tx_complete_addr, |
453 | result, sizeof(result)); | 455 | result, sizeof(result)); |
454 | 456 | ||
455 | result_index = wl->next_tx_complete; | 457 | result_index = wl->next_tx_complete; |
@@ -459,7 +461,7 @@ void wl12xx_tx_complete(struct wl12xx *wl) | |||
459 | 461 | ||
460 | if (result_ptr->done_1 == 1 && | 462 | if (result_ptr->done_1 == 1 && |
461 | result_ptr->done_2 == 1) { | 463 | result_ptr->done_2 == 1) { |
462 | wl12xx_tx_packet_cb(wl, result_ptr); | 464 | wl1251_tx_packet_cb(wl, result_ptr); |
463 | 465 | ||
464 | result_ptr->done_1 = 0; | 466 | result_ptr->done_1 = 0; |
465 | result_ptr->done_2 = 0; | 467 | result_ptr->done_2 = 0; |
@@ -480,7 +482,7 @@ void wl12xx_tx_complete(struct wl12xx *wl) | |||
480 | */ | 482 | */ |
481 | if (result_index > wl->next_tx_complete) { | 483 | if (result_index > wl->next_tx_complete) { |
482 | /* Only 1 write is needed */ | 484 | /* Only 1 write is needed */ |
483 | wl12xx_spi_mem_write(wl, | 485 | wl1251_spi_mem_write(wl, |
484 | wl->data_path->tx_complete_addr + | 486 | wl->data_path->tx_complete_addr + |
485 | (wl->next_tx_complete * | 487 | (wl->next_tx_complete * |
486 | sizeof(struct tx_result)), | 488 | sizeof(struct tx_result)), |
@@ -491,7 +493,7 @@ void wl12xx_tx_complete(struct wl12xx *wl) | |||
491 | 493 | ||
492 | } else if (result_index < wl->next_tx_complete) { | 494 | } else if (result_index < wl->next_tx_complete) { |
493 | /* 2 writes are needed */ | 495 | /* 2 writes are needed */ |
494 | wl12xx_spi_mem_write(wl, | 496 | wl1251_spi_mem_write(wl, |
495 | wl->data_path->tx_complete_addr + | 497 | wl->data_path->tx_complete_addr + |
496 | (wl->next_tx_complete * | 498 | (wl->next_tx_complete * |
497 | sizeof(struct tx_result)), | 499 | sizeof(struct tx_result)), |
@@ -500,7 +502,7 @@ void wl12xx_tx_complete(struct wl12xx *wl) | |||
500 | wl->next_tx_complete) * | 502 | wl->next_tx_complete) * |
501 | sizeof(struct tx_result)); | 503 | sizeof(struct tx_result)); |
502 | 504 | ||
503 | wl12xx_spi_mem_write(wl, | 505 | wl1251_spi_mem_write(wl, |
504 | wl->data_path->tx_complete_addr, | 506 | wl->data_path->tx_complete_addr, |
505 | result, | 507 | result, |
506 | (num_complete - | 508 | (num_complete - |
@@ -510,7 +512,7 @@ void wl12xx_tx_complete(struct wl12xx *wl) | |||
510 | 512 | ||
511 | } else { | 513 | } else { |
512 | /* We have to write the whole array */ | 514 | /* We have to write the whole array */ |
513 | wl12xx_spi_mem_write(wl, | 515 | wl1251_spi_mem_write(wl, |
514 | wl->data_path->tx_complete_addr, | 516 | wl->data_path->tx_complete_addr, |
515 | result, | 517 | result, |
516 | FW_TX_CMPLT_BLOCK_SIZE * | 518 | FW_TX_CMPLT_BLOCK_SIZE * |
@@ -523,7 +525,7 @@ void wl12xx_tx_complete(struct wl12xx *wl) | |||
523 | } | 525 | } |
524 | 526 | ||
525 | /* caller must hold wl->mutex */ | 527 | /* caller must hold wl->mutex */ |
526 | void wl12xx_tx_flush(struct wl12xx *wl) | 528 | void wl1251_tx_flush(struct wl1251 *wl) |
527 | { | 529 | { |
528 | int i; | 530 | int i; |
529 | struct sk_buff *skb; | 531 | struct sk_buff *skb; |
@@ -535,7 +537,7 @@ void wl12xx_tx_flush(struct wl12xx *wl) | |||
535 | while ((skb = skb_dequeue(&wl->tx_queue))) { | 537 | while ((skb = skb_dequeue(&wl->tx_queue))) { |
536 | info = IEEE80211_SKB_CB(skb); | 538 | info = IEEE80211_SKB_CB(skb); |
537 | 539 | ||
538 | wl12xx_debug(DEBUG_TX, "flushing skb 0x%p", skb); | 540 | wl1251_debug(DEBUG_TX, "flushing skb 0x%p", skb); |
539 | 541 | ||
540 | if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) | 542 | if (!(info->flags & IEEE80211_TX_CTL_REQ_TX_STATUS)) |
541 | continue; | 543 | continue; |
diff --git a/drivers/net/wireless/wl12xx/tx.h b/drivers/net/wireless/wl12xx/wl1251_tx.h index dc82691f4c14..7c1c1665c810 100644 --- a/drivers/net/wireless/wl12xx/tx.h +++ b/drivers/net/wireless/wl12xx/wl1251_tx.h | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * This file is part of wl12xx | 2 | * This file is part of wl1251 |
3 | * | 3 | * |
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | 4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated |
5 | * Copyright (C) 2008 Nokia Corporation | 5 | * Copyright (C) 2008 Nokia Corporation |
@@ -22,8 +22,8 @@ | |||
22 | * | 22 | * |
23 | */ | 23 | */ |
24 | 24 | ||
25 | #ifndef __WL12XX_TX_H__ | 25 | #ifndef __WL1251_TX_H__ |
26 | #define __WL12XX_TX_H__ | 26 | #define __WL1251_TX_H__ |
27 | 27 | ||
28 | #include <linux/bitops.h> | 28 | #include <linux/bitops.h> |
29 | 29 | ||
@@ -73,10 +73,11 @@ | |||
73 | 73 | ||
74 | #define TX_COMPLETE_REQUIRED_BIT 0x80 | 74 | #define TX_COMPLETE_REQUIRED_BIT 0x80 |
75 | #define TX_STATUS_DATA_OUT_COUNT_MASK 0xf | 75 | #define TX_STATUS_DATA_OUT_COUNT_MASK 0xf |
76 | #define WL12XX_TX_ALIGN_TO 4 | 76 | |
77 | #define WL12XX_TX_ALIGN(len) (((len) + WL12XX_TX_ALIGN_TO - 1) & \ | 77 | #define WL1251_TX_ALIGN_TO 4 |
78 | ~(WL12XX_TX_ALIGN_TO - 1)) | 78 | #define WL1251_TX_ALIGN(len) (((len) + WL1251_TX_ALIGN_TO - 1) & \ |
79 | #define WL12XX_TKIP_IV_SPACE 4 | 79 | ~(WL1251_TX_ALIGN_TO - 1)) |
80 | #define WL1251_TKIP_IV_SPACE 4 | ||
80 | 81 | ||
81 | struct tx_control { | 82 | struct tx_control { |
82 | /* Rate Policy (class) index */ | 83 | /* Rate Policy (class) index */ |
@@ -208,8 +209,8 @@ struct tx_result { | |||
208 | u8 done_2; | 209 | u8 done_2; |
209 | } __attribute__ ((packed)); | 210 | } __attribute__ ((packed)); |
210 | 211 | ||
211 | void wl12xx_tx_work(struct work_struct *work); | 212 | void wl1251_tx_work(struct work_struct *work); |
212 | void wl12xx_tx_complete(struct wl12xx *wl); | 213 | void wl1251_tx_complete(struct wl1251 *wl); |
213 | void wl12xx_tx_flush(struct wl12xx *wl); | 214 | void wl1251_tx_flush(struct wl1251 *wl); |
214 | 215 | ||
215 | #endif | 216 | #endif |
diff --git a/drivers/net/wireless/wl12xx/wl12xx.h b/drivers/net/wireless/wl12xx/wl12xx.h deleted file mode 100644 index 48641437414b..000000000000 --- a/drivers/net/wireless/wl12xx/wl12xx.h +++ /dev/null | |||
@@ -1,409 +0,0 @@ | |||
1 | /* | ||
2 | * This file is part of wl12xx | ||
3 | * | ||
4 | * Copyright (c) 1998-2007 Texas Instruments Incorporated | ||
5 | * Copyright (C) 2008-2009 Nokia Corporation | ||
6 | * | ||
7 | * Contact: Kalle Valo <kalle.valo@nokia.com> | ||
8 | * | ||
9 | * This program is free software; you can redistribute it and/or | ||
10 | * modify it under the terms of the GNU General Public License | ||
11 | * version 2 as published by the Free Software Foundation. | ||
12 | * | ||
13 | * This program is distributed in the hope that it will be useful, but | ||
14 | * WITHOUT ANY WARRANTY; without even the implied warranty of | ||
15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
16 | * General Public License for more details. | ||
17 | * | ||
18 | * You should have received a copy of the GNU General Public License | ||
19 | * along with this program; if not, write to the Free Software | ||
20 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
21 | * 02110-1301 USA | ||
22 | * | ||
23 | */ | ||
24 | |||
25 | #ifndef __WL12XX_H__ | ||
26 | #define __WL12XX_H__ | ||
27 | |||
28 | #include <linux/mutex.h> | ||
29 | #include <linux/list.h> | ||
30 | #include <linux/bitops.h> | ||
31 | #include <net/mac80211.h> | ||
32 | |||
33 | #define DRIVER_NAME "wl12xx" | ||
34 | #define DRIVER_PREFIX DRIVER_NAME ": " | ||
35 | |||
36 | enum { | ||
37 | DEBUG_NONE = 0, | ||
38 | DEBUG_IRQ = BIT(0), | ||
39 | DEBUG_SPI = BIT(1), | ||
40 | DEBUG_BOOT = BIT(2), | ||
41 | DEBUG_MAILBOX = BIT(3), | ||
42 | DEBUG_NETLINK = BIT(4), | ||
43 | DEBUG_EVENT = BIT(5), | ||
44 | DEBUG_TX = BIT(6), | ||
45 | DEBUG_RX = BIT(7), | ||
46 | DEBUG_SCAN = BIT(8), | ||
47 | DEBUG_CRYPT = BIT(9), | ||
48 | DEBUG_PSM = BIT(10), | ||
49 | DEBUG_MAC80211 = BIT(11), | ||
50 | DEBUG_CMD = BIT(12), | ||
51 | DEBUG_ACX = BIT(13), | ||
52 | DEBUG_ALL = ~0, | ||
53 | }; | ||
54 | |||
55 | #define DEBUG_LEVEL (DEBUG_NONE) | ||
56 | |||
57 | #define DEBUG_DUMP_LIMIT 1024 | ||
58 | |||
59 | #define wl12xx_error(fmt, arg...) \ | ||
60 | printk(KERN_ERR DRIVER_PREFIX "ERROR " fmt "\n", ##arg) | ||
61 | |||
62 | #define wl12xx_warning(fmt, arg...) \ | ||
63 | printk(KERN_WARNING DRIVER_PREFIX "WARNING " fmt "\n", ##arg) | ||
64 | |||
65 | #define wl12xx_notice(fmt, arg...) \ | ||
66 | printk(KERN_INFO DRIVER_PREFIX fmt "\n", ##arg) | ||
67 | |||
68 | #define wl12xx_info(fmt, arg...) \ | ||
69 | printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg) | ||
70 | |||
71 | #define wl12xx_debug(level, fmt, arg...) \ | ||
72 | do { \ | ||
73 | if (level & DEBUG_LEVEL) \ | ||
74 | printk(KERN_DEBUG DRIVER_PREFIX fmt "\n", ##arg); \ | ||
75 | } while (0) | ||
76 | |||
77 | #define wl12xx_dump(level, prefix, buf, len) \ | ||
78 | do { \ | ||
79 | if (level & DEBUG_LEVEL) \ | ||
80 | print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ | ||
81 | DUMP_PREFIX_OFFSET, 16, 1, \ | ||
82 | buf, \ | ||
83 | min_t(size_t, len, DEBUG_DUMP_LIMIT), \ | ||
84 | 0); \ | ||
85 | } while (0) | ||
86 | |||
87 | #define wl12xx_dump_ascii(level, prefix, buf, len) \ | ||
88 | do { \ | ||
89 | if (level & DEBUG_LEVEL) \ | ||
90 | print_hex_dump(KERN_DEBUG, DRIVER_PREFIX prefix, \ | ||
91 | DUMP_PREFIX_OFFSET, 16, 1, \ | ||
92 | buf, \ | ||
93 | min_t(size_t, len, DEBUG_DUMP_LIMIT), \ | ||
94 | true); \ | ||
95 | } while (0) | ||
96 | |||
97 | #define WL12XX_DEFAULT_RX_CONFIG (CFG_UNI_FILTER_EN | \ | ||
98 | CFG_BSSID_FILTER_EN) | ||
99 | |||
100 | #define WL12XX_DEFAULT_RX_FILTER (CFG_RX_PRSP_EN | \ | ||
101 | CFG_RX_MGMT_EN | \ | ||
102 | CFG_RX_DATA_EN | \ | ||
103 | CFG_RX_CTL_EN | \ | ||
104 | CFG_RX_BCN_EN | \ | ||
105 | CFG_RX_AUTH_EN | \ | ||
106 | CFG_RX_ASSOC_EN) | ||
107 | |||
108 | |||
109 | struct boot_attr { | ||
110 | u32 radio_type; | ||
111 | u8 mac_clock; | ||
112 | u8 arm_clock; | ||
113 | int firmware_debug; | ||
114 | u32 minor; | ||
115 | u32 major; | ||
116 | u32 bugfix; | ||
117 | }; | ||
118 | |||
119 | enum wl12xx_state { | ||
120 | WL12XX_STATE_OFF, | ||
121 | WL12XX_STATE_ON, | ||
122 | WL12XX_STATE_PLT, | ||
123 | }; | ||
124 | |||
125 | enum wl12xx_partition_type { | ||
126 | PART_DOWN, | ||
127 | PART_WORK, | ||
128 | PART_DRPW, | ||
129 | |||
130 | PART_TABLE_LEN | ||
131 | }; | ||
132 | |||
133 | struct wl12xx_partition { | ||
134 | u32 size; | ||
135 | u32 start; | ||
136 | }; | ||
137 | |||
138 | struct wl12xx_partition_set { | ||
139 | struct wl12xx_partition mem; | ||
140 | struct wl12xx_partition reg; | ||
141 | }; | ||
142 | |||
143 | struct wl12xx; | ||
144 | |||
145 | /* FIXME: I'm not sure about this structure name */ | ||
146 | struct wl12xx_chip { | ||
147 | u32 id; | ||
148 | |||
149 | const char *fw_filename; | ||
150 | const char *nvs_filename; | ||
151 | |||
152 | char fw_ver[21]; | ||
153 | |||
154 | unsigned int power_on_sleep; | ||
155 | int intr_cmd_complete; | ||
156 | int intr_init_complete; | ||
157 | |||
158 | int (*op_upload_fw)(struct wl12xx *wl); | ||
159 | int (*op_upload_nvs)(struct wl12xx *wl); | ||
160 | int (*op_boot)(struct wl12xx *wl); | ||
161 | void (*op_set_ecpu_ctrl)(struct wl12xx *wl, u32 flag); | ||
162 | void (*op_target_enable_interrupts)(struct wl12xx *wl); | ||
163 | int (*op_hw_init)(struct wl12xx *wl); | ||
164 | int (*op_plt_init)(struct wl12xx *wl); | ||
165 | |||
166 | struct wl12xx_partition_set *p_table; | ||
167 | enum wl12xx_acx_int_reg *acx_reg_table; | ||
168 | }; | ||
169 | |||
170 | struct wl12xx_stats { | ||
171 | struct acx_statistics *fw_stats; | ||
172 | unsigned long fw_stats_update; | ||
173 | |||
174 | unsigned int retry_count; | ||
175 | unsigned int excessive_retries; | ||
176 | }; | ||
177 | |||
178 | struct wl12xx_debugfs { | ||
179 | struct dentry *rootdir; | ||
180 | struct dentry *fw_statistics; | ||
181 | |||
182 | struct dentry *tx_internal_desc_overflow; | ||
183 | |||
184 | struct dentry *rx_out_of_mem; | ||
185 | struct dentry *rx_hdr_overflow; | ||
186 | struct dentry *rx_hw_stuck; | ||
187 | struct dentry *rx_dropped; | ||
188 | struct dentry *rx_fcs_err; | ||
189 | struct dentry *rx_xfr_hint_trig; | ||
190 | struct dentry *rx_path_reset; | ||
191 | struct dentry *rx_reset_counter; | ||
192 | |||
193 | struct dentry *dma_rx_requested; | ||
194 | struct dentry *dma_rx_errors; | ||
195 | struct dentry *dma_tx_requested; | ||
196 | struct dentry *dma_tx_errors; | ||
197 | |||
198 | struct dentry *isr_cmd_cmplt; | ||
199 | struct dentry *isr_fiqs; | ||
200 | struct dentry *isr_rx_headers; | ||
201 | struct dentry *isr_rx_mem_overflow; | ||
202 | struct dentry *isr_rx_rdys; | ||
203 | struct dentry *isr_irqs; | ||
204 | struct dentry *isr_tx_procs; | ||
205 | struct dentry *isr_decrypt_done; | ||
206 | struct dentry *isr_dma0_done; | ||
207 | struct dentry *isr_dma1_done; | ||
208 | struct dentry *isr_tx_exch_complete; | ||
209 | struct dentry *isr_commands; | ||
210 | struct dentry *isr_rx_procs; | ||
211 | struct dentry *isr_hw_pm_mode_changes; | ||
212 | struct dentry *isr_host_acknowledges; | ||
213 | struct dentry *isr_pci_pm; | ||
214 | struct dentry *isr_wakeups; | ||
215 | struct dentry *isr_low_rssi; | ||
216 | |||
217 | struct dentry *wep_addr_key_count; | ||
218 | struct dentry *wep_default_key_count; | ||
219 | /* skipping wep.reserved */ | ||
220 | struct dentry *wep_key_not_found; | ||
221 | struct dentry *wep_decrypt_fail; | ||
222 | struct dentry *wep_packets; | ||
223 | struct dentry *wep_interrupt; | ||
224 | |||
225 | struct dentry *pwr_ps_enter; | ||
226 | struct dentry *pwr_elp_enter; | ||
227 | struct dentry *pwr_missing_bcns; | ||
228 | struct dentry *pwr_wake_on_host; | ||
229 | struct dentry *pwr_wake_on_timer_exp; | ||
230 | struct dentry *pwr_tx_with_ps; | ||
231 | struct dentry *pwr_tx_without_ps; | ||
232 | struct dentry *pwr_rcvd_beacons; | ||
233 | struct dentry *pwr_power_save_off; | ||
234 | struct dentry *pwr_enable_ps; | ||
235 | struct dentry *pwr_disable_ps; | ||
236 | struct dentry *pwr_fix_tsf_ps; | ||
237 | /* skipping cont_miss_bcns_spread for now */ | ||
238 | struct dentry *pwr_rcvd_awake_beacons; | ||
239 | |||
240 | struct dentry *mic_rx_pkts; | ||
241 | struct dentry *mic_calc_failure; | ||
242 | |||
243 | struct dentry *aes_encrypt_fail; | ||
244 | struct dentry *aes_decrypt_fail; | ||
245 | struct dentry *aes_encrypt_packets; | ||
246 | struct dentry *aes_decrypt_packets; | ||
247 | struct dentry *aes_encrypt_interrupt; | ||
248 | struct dentry *aes_decrypt_interrupt; | ||
249 | |||
250 | struct dentry *event_heart_beat; | ||
251 | struct dentry *event_calibration; | ||
252 | struct dentry *event_rx_mismatch; | ||
253 | struct dentry *event_rx_mem_empty; | ||
254 | struct dentry *event_rx_pool; | ||
255 | struct dentry *event_oom_late; | ||
256 | struct dentry *event_phy_transmit_error; | ||
257 | struct dentry *event_tx_stuck; | ||
258 | |||
259 | struct dentry *ps_pspoll_timeouts; | ||
260 | struct dentry *ps_upsd_timeouts; | ||
261 | struct dentry *ps_upsd_max_sptime; | ||
262 | struct dentry *ps_upsd_max_apturn; | ||
263 | struct dentry *ps_pspoll_max_apturn; | ||
264 | struct dentry *ps_pspoll_utilization; | ||
265 | struct dentry *ps_upsd_utilization; | ||
266 | |||
267 | struct dentry *rxpipe_rx_prep_beacon_drop; | ||
268 | struct dentry *rxpipe_descr_host_int_trig_rx_data; | ||
269 | struct dentry *rxpipe_beacon_buffer_thres_host_int_trig_rx_data; | ||
270 | struct dentry *rxpipe_missed_beacon_host_int_trig_rx_data; | ||
271 | struct dentry *rxpipe_tx_xfr_host_int_trig_rx_data; | ||
272 | |||
273 | struct dentry *tx_queue_len; | ||
274 | |||
275 | struct dentry *retry_count; | ||
276 | struct dentry *excessive_retries; | ||
277 | }; | ||
278 | |||
279 | struct wl12xx { | ||
280 | struct ieee80211_hw *hw; | ||
281 | bool mac80211_registered; | ||
282 | |||
283 | struct spi_device *spi; | ||
284 | |||
285 | void (*set_power)(bool enable); | ||
286 | int irq; | ||
287 | |||
288 | enum wl12xx_state state; | ||
289 | struct mutex mutex; | ||
290 | |||
291 | int physical_mem_addr; | ||
292 | int physical_reg_addr; | ||
293 | int virtual_mem_addr; | ||
294 | int virtual_reg_addr; | ||
295 | |||
296 | struct wl12xx_chip chip; | ||
297 | |||
298 | int cmd_box_addr; | ||
299 | int event_box_addr; | ||
300 | struct boot_attr boot_attr; | ||
301 | |||
302 | u8 *fw; | ||
303 | size_t fw_len; | ||
304 | u8 *nvs; | ||
305 | size_t nvs_len; | ||
306 | |||
307 | u8 bssid[ETH_ALEN]; | ||
308 | u8 mac_addr[ETH_ALEN]; | ||
309 | u8 bss_type; | ||
310 | u8 listen_int; | ||
311 | int channel; | ||
312 | |||
313 | void *target_mem_map; | ||
314 | struct acx_data_path_params_resp *data_path; | ||
315 | |||
316 | /* Number of TX packets transferred to the FW, modulo 16 */ | ||
317 | u32 data_in_count; | ||
318 | |||
319 | /* Frames scheduled for transmission, not handled yet */ | ||
320 | struct sk_buff_head tx_queue; | ||
321 | bool tx_queue_stopped; | ||
322 | |||
323 | struct work_struct tx_work; | ||
324 | struct work_struct filter_work; | ||
325 | |||
326 | /* Pending TX frames */ | ||
327 | struct sk_buff *tx_frames[16]; | ||
328 | |||
329 | /* | ||
330 | * Index pointing to the next TX complete entry | ||
331 | * in the cyclic XT complete array we get from | ||
332 | * the FW. | ||
333 | */ | ||
334 | u32 next_tx_complete; | ||
335 | |||
336 | /* FW Rx counter */ | ||
337 | u32 rx_counter; | ||
338 | |||
339 | /* Rx frames handled */ | ||
340 | u32 rx_handled; | ||
341 | |||
342 | /* Current double buffer */ | ||
343 | u32 rx_current_buffer; | ||
344 | u32 rx_last_id; | ||
345 | |||
346 | /* The target interrupt mask */ | ||
347 | u32 intr_mask; | ||
348 | struct work_struct irq_work; | ||
349 | |||
350 | /* The mbox event mask */ | ||
351 | u32 event_mask; | ||
352 | |||
353 | /* Mailbox pointers */ | ||
354 | u32 mbox_ptr[2]; | ||
355 | |||
356 | /* Are we currently scanning */ | ||
357 | bool scanning; | ||
358 | |||
359 | /* Our association ID */ | ||
360 | u16 aid; | ||
361 | |||
362 | /* Default key (for WEP) */ | ||
363 | u32 default_key; | ||
364 | |||
365 | unsigned int tx_mgmt_frm_rate; | ||
366 | unsigned int tx_mgmt_frm_mod; | ||
367 | |||
368 | unsigned int rx_config; | ||
369 | unsigned int rx_filter; | ||
370 | |||
371 | /* is firmware in elp mode */ | ||
372 | bool elp; | ||
373 | |||
374 | /* we can be in psm, but not in elp, we have to differentiate */ | ||
375 | bool psm; | ||
376 | |||
377 | /* PSM mode requested */ | ||
378 | bool psm_requested; | ||
379 | |||
380 | /* in dBm */ | ||
381 | int power_level; | ||
382 | |||
383 | struct wl12xx_stats stats; | ||
384 | struct wl12xx_debugfs debugfs; | ||
385 | }; | ||
386 | |||
387 | int wl12xx_plt_start(struct wl12xx *wl); | ||
388 | int wl12xx_plt_stop(struct wl12xx *wl); | ||
389 | |||
390 | #define DEFAULT_HW_GEN_MODULATION_TYPE CCK_LONG /* Long Preamble */ | ||
391 | #define DEFAULT_HW_GEN_TX_RATE RATE_2MBPS | ||
392 | #define JOIN_TIMEOUT 5000 /* 5000 milliseconds to join */ | ||
393 | |||
394 | #define WL12XX_DEFAULT_POWER_LEVEL 20 | ||
395 | |||
396 | #define WL12XX_TX_QUEUE_MAX_LENGTH 20 | ||
397 | |||
398 | /* Different chips need different sleep times after power on. WL1271 needs | ||
399 | * 200ms, WL1251 needs only 10ms. By default we use 200ms, but as soon as we | ||
400 | * know the chip ID, we change the sleep value in the wl12xx chip structure, | ||
401 | * so in subsequent power ons, we don't waste more time then needed. */ | ||
402 | #define WL12XX_DEFAULT_POWER_ON_SLEEP 200 | ||
403 | |||
404 | #define CHIP_ID_1251_PG10 (0x7010101) | ||
405 | #define CHIP_ID_1251_PG11 (0x7020101) | ||
406 | #define CHIP_ID_1251_PG12 (0x7030101) | ||
407 | #define CHIP_ID_1271_PG10 (0x4030101) | ||
408 | |||
409 | #endif | ||
diff --git a/drivers/net/wireless/wl3501_cs.c b/drivers/net/wireless/wl3501_cs.c index e3e96bb2c246..a83a5621ec44 100644 --- a/drivers/net/wireless/wl3501_cs.c +++ b/drivers/net/wireless/wl3501_cs.c | |||
@@ -1348,7 +1348,6 @@ static int wl3501_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1348 | if (rc) { | 1348 | if (rc) { |
1349 | ++dev->stats.tx_dropped; | 1349 | ++dev->stats.tx_dropped; |
1350 | netif_stop_queue(dev); | 1350 | netif_stop_queue(dev); |
1351 | rc = NETDEV_TX_OK; | ||
1352 | } else { | 1351 | } else { |
1353 | ++dev->stats.tx_packets; | 1352 | ++dev->stats.tx_packets; |
1354 | dev->stats.tx_bytes += skb->len; | 1353 | dev->stats.tx_bytes += skb->len; |
@@ -1358,7 +1357,7 @@ static int wl3501_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
1358 | netif_stop_queue(dev); | 1357 | netif_stop_queue(dev); |
1359 | } | 1358 | } |
1360 | spin_unlock_irqrestore(&this->lock, flags); | 1359 | spin_unlock_irqrestore(&this->lock, flags); |
1361 | return rc; | 1360 | return NETDEV_TX_OK; |
1362 | } | 1361 | } |
1363 | 1362 | ||
1364 | static int wl3501_open(struct net_device *dev) | 1363 | static int wl3501_open(struct net_device *dev) |
diff --git a/drivers/net/wireless/zd1201.c b/drivers/net/wireless/zd1201.c index 4430b8d92e21..dae1bfb7655e 100644 --- a/drivers/net/wireless/zd1201.c +++ b/drivers/net/wireless/zd1201.c | |||
@@ -789,7 +789,7 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
789 | if (!zd->mac_enabled || zd->monitor) { | 789 | if (!zd->mac_enabled || zd->monitor) { |
790 | dev->stats.tx_dropped++; | 790 | dev->stats.tx_dropped++; |
791 | kfree_skb(skb); | 791 | kfree_skb(skb); |
792 | return 0; | 792 | return NETDEV_TX_OK; |
793 | } | 793 | } |
794 | netif_stop_queue(dev); | 794 | netif_stop_queue(dev); |
795 | 795 | ||
@@ -826,7 +826,7 @@ static int zd1201_hard_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
826 | } | 826 | } |
827 | kfree_skb(skb); | 827 | kfree_skb(skb); |
828 | 828 | ||
829 | return 0; | 829 | return NETDEV_TX_OK; |
830 | } | 830 | } |
831 | 831 | ||
832 | static void zd1201_tx_timeout(struct net_device *dev) | 832 | static void zd1201_tx_timeout(struct net_device *dev) |
diff --git a/drivers/net/wireless/zd1211rw/zd_mac.c b/drivers/net/wireless/zd1211rw/zd_mac.c index 40b07b988224..9600b72495da 100644 --- a/drivers/net/wireless/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zd1211rw/zd_mac.c | |||
@@ -711,7 +711,8 @@ int zd_mac_rx(struct ieee80211_hw *hw, const u8 *buffer, unsigned int length) | |||
711 | 711 | ||
712 | memcpy(skb_put(skb, length), buffer, length); | 712 | memcpy(skb_put(skb, length), buffer, length); |
713 | 713 | ||
714 | ieee80211_rx_irqsafe(hw, skb, &stats); | 714 | memcpy(IEEE80211_SKB_RXCB(skb), &stats, sizeof(stats)); |
715 | ieee80211_rx_irqsafe(hw, skb); | ||
715 | return 0; | 716 | return 0; |
716 | } | 717 | } |
717 | 718 | ||
diff --git a/drivers/net/wireless/zd1211rw/zd_usb.c b/drivers/net/wireless/zd1211rw/zd_usb.c index 0e6e44689cc6..07d7ab674a0f 100644 --- a/drivers/net/wireless/zd1211rw/zd_usb.c +++ b/drivers/net/wireless/zd1211rw/zd_usb.c | |||
@@ -36,58 +36,59 @@ | |||
36 | 36 | ||
37 | static struct usb_device_id usb_ids[] = { | 37 | static struct usb_device_id usb_ids[] = { |
38 | /* ZD1211 */ | 38 | /* ZD1211 */ |
39 | { USB_DEVICE(0x0105, 0x145f), .driver_info = DEVICE_ZD1211 }, | ||
40 | { USB_DEVICE(0x0586, 0x3401), .driver_info = DEVICE_ZD1211 }, | ||
41 | { USB_DEVICE(0x0586, 0x3402), .driver_info = DEVICE_ZD1211 }, | ||
42 | { USB_DEVICE(0x0586, 0x3407), .driver_info = DEVICE_ZD1211 }, | ||
43 | { USB_DEVICE(0x0586, 0x3409), .driver_info = DEVICE_ZD1211 }, | ||
44 | { USB_DEVICE(0x079b, 0x004a), .driver_info = DEVICE_ZD1211 }, | ||
45 | { USB_DEVICE(0x07b8, 0x6001), .driver_info = DEVICE_ZD1211 }, | ||
39 | { USB_DEVICE(0x0ace, 0x1211), .driver_info = DEVICE_ZD1211 }, | 46 | { USB_DEVICE(0x0ace, 0x1211), .driver_info = DEVICE_ZD1211 }, |
40 | { USB_DEVICE(0x0ace, 0xa211), .driver_info = DEVICE_ZD1211 }, | 47 | { USB_DEVICE(0x0ace, 0xa211), .driver_info = DEVICE_ZD1211 }, |
41 | { USB_DEVICE(0x126f, 0xa006), .driver_info = DEVICE_ZD1211 }, | 48 | { USB_DEVICE(0x0b05, 0x170c), .driver_info = DEVICE_ZD1211 }, |
42 | { USB_DEVICE(0x6891, 0xa727), .driver_info = DEVICE_ZD1211 }, | 49 | { USB_DEVICE(0x0b3b, 0x1630), .driver_info = DEVICE_ZD1211 }, |
50 | { USB_DEVICE(0x0b3b, 0x5630), .driver_info = DEVICE_ZD1211 }, | ||
43 | { USB_DEVICE(0x0df6, 0x9071), .driver_info = DEVICE_ZD1211 }, | 51 | { USB_DEVICE(0x0df6, 0x9071), .driver_info = DEVICE_ZD1211 }, |
44 | { USB_DEVICE(0x0df6, 0x9075), .driver_info = DEVICE_ZD1211 }, | 52 | { USB_DEVICE(0x0df6, 0x9075), .driver_info = DEVICE_ZD1211 }, |
45 | { USB_DEVICE(0x157e, 0x300b), .driver_info = DEVICE_ZD1211 }, | 53 | { USB_DEVICE(0x126f, 0xa006), .driver_info = DEVICE_ZD1211 }, |
46 | { USB_DEVICE(0x079b, 0x004a), .driver_info = DEVICE_ZD1211 }, | 54 | { USB_DEVICE(0x129b, 0x1666), .driver_info = DEVICE_ZD1211 }, |
47 | { USB_DEVICE(0x1740, 0x2000), .driver_info = DEVICE_ZD1211 }, | 55 | { USB_DEVICE(0x13b1, 0x001e), .driver_info = DEVICE_ZD1211 }, |
48 | { USB_DEVICE(0x157e, 0x3204), .driver_info = DEVICE_ZD1211 }, | ||
49 | { USB_DEVICE(0x0586, 0x3402), .driver_info = DEVICE_ZD1211 }, | ||
50 | { USB_DEVICE(0x0b3b, 0x5630), .driver_info = DEVICE_ZD1211 }, | ||
51 | { USB_DEVICE(0x0b05, 0x170c), .driver_info = DEVICE_ZD1211 }, | ||
52 | { USB_DEVICE(0x1435, 0x0711), .driver_info = DEVICE_ZD1211 }, | 56 | { USB_DEVICE(0x1435, 0x0711), .driver_info = DEVICE_ZD1211 }, |
53 | { USB_DEVICE(0x0586, 0x3409), .driver_info = DEVICE_ZD1211 }, | ||
54 | { USB_DEVICE(0x0b3b, 0x1630), .driver_info = DEVICE_ZD1211 }, | ||
55 | { USB_DEVICE(0x0586, 0x3401), .driver_info = DEVICE_ZD1211 }, | ||
56 | { USB_DEVICE(0x14ea, 0xab13), .driver_info = DEVICE_ZD1211 }, | 57 | { USB_DEVICE(0x14ea, 0xab13), .driver_info = DEVICE_ZD1211 }, |
57 | { USB_DEVICE(0x13b1, 0x001e), .driver_info = DEVICE_ZD1211 }, | ||
58 | { USB_DEVICE(0x0586, 0x3407), .driver_info = DEVICE_ZD1211 }, | ||
59 | { USB_DEVICE(0x129b, 0x1666), .driver_info = DEVICE_ZD1211 }, | ||
60 | { USB_DEVICE(0x157e, 0x300a), .driver_info = DEVICE_ZD1211 }, | 58 | { USB_DEVICE(0x157e, 0x300a), .driver_info = DEVICE_ZD1211 }, |
61 | { USB_DEVICE(0x0105, 0x145f), .driver_info = DEVICE_ZD1211 }, | 59 | { USB_DEVICE(0x157e, 0x300b), .driver_info = DEVICE_ZD1211 }, |
60 | { USB_DEVICE(0x157e, 0x3204), .driver_info = DEVICE_ZD1211 }, | ||
61 | { USB_DEVICE(0x1740, 0x2000), .driver_info = DEVICE_ZD1211 }, | ||
62 | { USB_DEVICE(0x6891, 0xa727), .driver_info = DEVICE_ZD1211 }, | ||
62 | /* ZD1211B */ | 63 | /* ZD1211B */ |
64 | { USB_DEVICE(0x0053, 0x5301), .driver_info = DEVICE_ZD1211B }, | ||
65 | { USB_DEVICE(0x0411, 0x00da), .driver_info = DEVICE_ZD1211B }, | ||
66 | { USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B }, | ||
67 | { USB_DEVICE(0x0471, 0x1237), .driver_info = DEVICE_ZD1211B }, | ||
68 | { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B }, | ||
63 | { USB_DEVICE(0x054c, 0x0257), .driver_info = DEVICE_ZD1211B }, | 69 | { USB_DEVICE(0x054c, 0x0257), .driver_info = DEVICE_ZD1211B }, |
64 | { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B }, | 70 | { USB_DEVICE(0x0586, 0x340a), .driver_info = DEVICE_ZD1211B }, |
65 | { USB_DEVICE(0x0ace, 0xb215), .driver_info = DEVICE_ZD1211B }, | 71 | { USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B }, |
66 | { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B }, | 72 | { USB_DEVICE(0x0586, 0x3410), .driver_info = DEVICE_ZD1211B }, |
73 | { USB_DEVICE(0x0586, 0x3412), .driver_info = DEVICE_ZD1211B }, | ||
74 | { USB_DEVICE(0x0586, 0x3413), .driver_info = DEVICE_ZD1211B }, | ||
67 | { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B }, | 75 | { USB_DEVICE(0x079b, 0x0062), .driver_info = DEVICE_ZD1211B }, |
68 | { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B }, | 76 | { USB_DEVICE(0x07b8, 0x6001), .driver_info = DEVICE_ZD1211B }, |
69 | { USB_DEVICE(0x050d, 0x705c), .driver_info = DEVICE_ZD1211B }, | 77 | { USB_DEVICE(0x07fa, 0x1196), .driver_info = DEVICE_ZD1211B }, |
78 | { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B }, | ||
70 | { USB_DEVICE(0x083a, 0xe503), .driver_info = DEVICE_ZD1211B }, | 79 | { USB_DEVICE(0x083a, 0xe503), .driver_info = DEVICE_ZD1211B }, |
71 | { USB_DEVICE(0x083a, 0xe506), .driver_info = DEVICE_ZD1211B }, | 80 | { USB_DEVICE(0x083a, 0xe506), .driver_info = DEVICE_ZD1211B }, |
72 | { USB_DEVICE(0x083a, 0x4505), .driver_info = DEVICE_ZD1211B }, | 81 | { USB_DEVICE(0x0ace, 0x1215), .driver_info = DEVICE_ZD1211B }, |
73 | { USB_DEVICE(0x0471, 0x1236), .driver_info = DEVICE_ZD1211B }, | 82 | { USB_DEVICE(0x0ace, 0xb215), .driver_info = DEVICE_ZD1211B }, |
74 | { USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B }, | ||
75 | { USB_DEVICE(0x0586, 0x340f), .driver_info = DEVICE_ZD1211B }, | ||
76 | { USB_DEVICE(0x0b05, 0x171b), .driver_info = DEVICE_ZD1211B }, | 83 | { USB_DEVICE(0x0b05, 0x171b), .driver_info = DEVICE_ZD1211B }, |
77 | { USB_DEVICE(0x0586, 0x3410), .driver_info = DEVICE_ZD1211B }, | ||
78 | { USB_DEVICE(0x0baf, 0x0121), .driver_info = DEVICE_ZD1211B }, | 84 | { USB_DEVICE(0x0baf, 0x0121), .driver_info = DEVICE_ZD1211B }, |
79 | { USB_DEVICE(0x0586, 0x3412), .driver_info = DEVICE_ZD1211B }, | ||
80 | { USB_DEVICE(0x0586, 0x3413), .driver_info = DEVICE_ZD1211B }, | ||
81 | { USB_DEVICE(0x0053, 0x5301), .driver_info = DEVICE_ZD1211B }, | ||
82 | { USB_DEVICE(0x0411, 0x00da), .driver_info = DEVICE_ZD1211B }, | ||
83 | { USB_DEVICE(0x2019, 0x5303), .driver_info = DEVICE_ZD1211B }, | ||
84 | { USB_DEVICE(0x129b, 0x1667), .driver_info = DEVICE_ZD1211B }, | ||
85 | { USB_DEVICE(0x0cde, 0x001a), .driver_info = DEVICE_ZD1211B }, | 85 | { USB_DEVICE(0x0cde, 0x001a), .driver_info = DEVICE_ZD1211B }, |
86 | { USB_DEVICE(0x0586, 0x340a), .driver_info = DEVICE_ZD1211B }, | ||
87 | { USB_DEVICE(0x0471, 0x1237), .driver_info = DEVICE_ZD1211B }, | ||
88 | { USB_DEVICE(0x07fa, 0x1196), .driver_info = DEVICE_ZD1211B }, | ||
89 | { USB_DEVICE(0x0df6, 0x0036), .driver_info = DEVICE_ZD1211B }, | 86 | { USB_DEVICE(0x0df6, 0x0036), .driver_info = DEVICE_ZD1211B }, |
90 | { USB_DEVICE(0x07b8, 0x6001), .driver_info = DEVICE_ZD1211B }, | 87 | { USB_DEVICE(0x129b, 0x1667), .driver_info = DEVICE_ZD1211B }, |
88 | { USB_DEVICE(0x13b1, 0x0024), .driver_info = DEVICE_ZD1211B }, | ||
89 | { USB_DEVICE(0x157e, 0x300d), .driver_info = DEVICE_ZD1211B }, | ||
90 | { USB_DEVICE(0x1582, 0x6003), .driver_info = DEVICE_ZD1211B }, | ||
91 | { USB_DEVICE(0x2019, 0x5303), .driver_info = DEVICE_ZD1211B }, | ||
91 | /* "Driverless" devices that need ejecting */ | 92 | /* "Driverless" devices that need ejecting */ |
92 | { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, | 93 | { USB_DEVICE(0x0ace, 0x2011), .driver_info = DEVICE_INSTALLER }, |
93 | { USB_DEVICE(0x0ace, 0x20ff), .driver_info = DEVICE_INSTALLER }, | 94 | { USB_DEVICE(0x0ace, 0x20ff), .driver_info = DEVICE_INSTALLER }, |
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c index 8d88daeed0c6..3700c49d76ca 100644 --- a/drivers/net/xen-netfront.c +++ b/drivers/net/xen-netfront.c | |||
@@ -558,12 +558,12 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
558 | 558 | ||
559 | spin_unlock_irq(&np->tx_lock); | 559 | spin_unlock_irq(&np->tx_lock); |
560 | 560 | ||
561 | return 0; | 561 | return NETDEV_TX_OK; |
562 | 562 | ||
563 | drop: | 563 | drop: |
564 | dev->stats.tx_dropped++; | 564 | dev->stats.tx_dropped++; |
565 | dev_kfree_skb(skb); | 565 | dev_kfree_skb(skb); |
566 | return 0; | 566 | return NETDEV_TX_OK; |
567 | } | 567 | } |
568 | 568 | ||
569 | static int xennet_close(struct net_device *dev) | 569 | static int xennet_close(struct net_device *dev) |
diff --git a/drivers/net/yellowfin.c b/drivers/net/yellowfin.c index 3c7a5053f1da..c3722b40a651 100644 --- a/drivers/net/yellowfin.c +++ b/drivers/net/yellowfin.c | |||
@@ -827,7 +827,7 @@ static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
827 | if (skb_padto(skb, len)) { | 827 | if (skb_padto(skb, len)) { |
828 | yp->tx_skbuff[entry] = NULL; | 828 | yp->tx_skbuff[entry] = NULL; |
829 | netif_wake_queue(dev); | 829 | netif_wake_queue(dev); |
830 | return 0; | 830 | return NETDEV_TX_OK; |
831 | } | 831 | } |
832 | } | 832 | } |
833 | } | 833 | } |
@@ -881,7 +881,7 @@ static int yellowfin_start_xmit(struct sk_buff *skb, struct net_device *dev) | |||
881 | printk(KERN_DEBUG "%s: Yellowfin transmit frame #%d queued in slot %d.\n", | 881 | printk(KERN_DEBUG "%s: Yellowfin transmit frame #%d queued in slot %d.\n", |
882 | dev->name, yp->cur_tx, entry); | 882 | dev->name, yp->cur_tx, entry); |
883 | } | 883 | } |
884 | return 0; | 884 | return NETDEV_TX_OK; |
885 | } | 885 | } |
886 | 886 | ||
887 | /* The interrupt handler does all of the Rx thread work and cleans up | 887 | /* The interrupt handler does all of the Rx thread work and cleans up |
diff --git a/drivers/net/znet.c b/drivers/net/znet.c index 0a6992d8611b..7f9e14131a5c 100644 --- a/drivers/net/znet.c +++ b/drivers/net/znet.c | |||
@@ -546,7 +546,7 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
546 | 546 | ||
547 | if (length < ETH_ZLEN) { | 547 | if (length < ETH_ZLEN) { |
548 | if (skb_padto(skb, ETH_ZLEN)) | 548 | if (skb_padto(skb, ETH_ZLEN)) |
549 | return 0; | 549 | return NETDEV_TX_OK; |
550 | length = ETH_ZLEN; | 550 | length = ETH_ZLEN; |
551 | } | 551 | } |
552 | 552 | ||
@@ -600,7 +600,7 @@ static int znet_send_packet(struct sk_buff *skb, struct net_device *dev) | |||
600 | printk(KERN_DEBUG "%s: Transmitter queued, length %d.\n", dev->name, length); | 600 | printk(KERN_DEBUG "%s: Transmitter queued, length %d.\n", dev->name, length); |
601 | } | 601 | } |
602 | dev_kfree_skb(skb); | 602 | dev_kfree_skb(skb); |
603 | return 0; | 603 | return NETDEV_TX_OK; |
604 | } | 604 | } |
605 | 605 | ||
606 | /* The ZNET interrupt handler. */ | 606 | /* The ZNET interrupt handler. */ |