aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_main.c26
-rw-r--r--drivers/net/can/Kconfig2
-rw-r--r--drivers/net/can/dev.c15
-rw-r--r--drivers/net/can/flexcan.c7
-rw-r--r--drivers/net/can/janz-ican3.c20
-rw-r--r--drivers/net/can/vcan.c9
-rw-r--r--drivers/net/ethernet/3com/3c59x.c2
-rw-r--r--drivers/net/ethernet/allwinner/sun4i-emac.c3
-rw-r--r--drivers/net/ethernet/atheros/alx/main.c1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c12
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c6
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c17
-rw-r--r--drivers/net/ethernet/ethoc.c138
-rw-r--r--drivers/net/ethernet/intel/e100.c2
-rw-r--r--drivers/net/ethernet/mellanox/mlx5/core/Kconfig2
-rw-r--r--drivers/net/ethernet/neterion/vxge/vxge-main.c6
-rw-r--r--drivers/net/ethernet/sfc/tx.c2
-rw-r--r--drivers/net/ethernet/ti/cpsw.c14
-rw-r--r--drivers/net/irda/Kconfig7
-rw-r--r--drivers/net/irda/Makefile1
-rw-r--r--drivers/net/irda/ep7211-sir.c70
-rw-r--r--drivers/net/phy/dp83640.c19
-rw-r--r--drivers/net/phy/mdio-sun4i.c3
-rw-r--r--drivers/net/phy/phy_device.c38
-rw-r--r--drivers/net/usb/Kconfig16
-rw-r--r--drivers/net/usb/Makefile1
-rw-r--r--drivers/net/usb/hso.c32
-rw-r--r--drivers/net/usb/qmi_wwan.c2
-rw-r--r--drivers/net/usb/r8152.c17
-rw-r--r--drivers/net/usb/sr9800.c870
-rw-r--r--drivers/net/usb/sr9800.h202
-rw-r--r--drivers/net/vxlan.c3
-rw-r--r--drivers/net/wan/dlci.c5
-rw-r--r--drivers/net/wireless/ath/ar5523/ar5523.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/ar9003_eeprom.c4
-rw-r--r--drivers/net/wireless/ath/ath9k/htc.h2
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_init.c8
-rw-r--r--drivers/net/wireless/ath/ath9k/htc_drv_main.c63
-rw-r--r--drivers/net/wireless/ath/ath9k/hw.c5
-rw-r--r--drivers/net/wireless/ath/ath9k/init.c8
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-nvm-parse.c5
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h4
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/scan.c5
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/sta.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/tx.c73
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/utils.c2
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c7
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c5
-rw-r--r--drivers/net/wireless/rt2x00/rt2500usb.c5
-rw-r--r--drivers/net/wireless/rt2x00/rt2800lib.c5
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180/dev.c23
-rw-r--r--drivers/net/xen-netback/common.h6
-rw-r--r--drivers/net/xen-netback/interface.c1
-rw-r--r--drivers/net/xen-netback/netback.c16
-rw-r--r--drivers/net/xen-netfront.c5
58 files changed, 1526 insertions, 306 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 4c08018d7333..71ba18efa15b 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1270,9 +1270,13 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1270 1270
1271 if (slave_ops->ndo_set_mac_address == NULL) { 1271 if (slave_ops->ndo_set_mac_address == NULL) {
1272 if (!bond_has_slaves(bond)) { 1272 if (!bond_has_slaves(bond)) {
1273 pr_warning("%s: Warning: The first slave device specified does not support setting the MAC address. Setting fail_over_mac to active.", 1273 pr_warn("%s: Warning: The first slave device specified does not support setting the MAC address.\n",
1274 bond_dev->name); 1274 bond_dev->name);
1275 bond->params.fail_over_mac = BOND_FOM_ACTIVE; 1275 if (bond->params.mode == BOND_MODE_ACTIVEBACKUP) {
1276 bond->params.fail_over_mac = BOND_FOM_ACTIVE;
1277 pr_warn("%s: Setting fail_over_mac to active for active-backup mode.\n",
1278 bond_dev->name);
1279 }
1276 } else if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) { 1280 } else if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) {
1277 pr_err("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active.\n", 1281 pr_err("%s: Error: The slave device specified does not support setting the MAC address, but fail_over_mac is not set to active.\n",
1278 bond_dev->name); 1282 bond_dev->name);
@@ -1315,7 +1319,8 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1315 */ 1319 */
1316 memcpy(new_slave->perm_hwaddr, slave_dev->dev_addr, ETH_ALEN); 1320 memcpy(new_slave->perm_hwaddr, slave_dev->dev_addr, ETH_ALEN);
1317 1321
1318 if (!bond->params.fail_over_mac) { 1322 if (!bond->params.fail_over_mac ||
1323 bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
1319 /* 1324 /*
1320 * Set slave to master's mac address. The application already 1325 * Set slave to master's mac address. The application already
1321 * set the master's mac address to that of the first slave 1326 * set the master's mac address to that of the first slave
@@ -1505,7 +1510,6 @@ int bond_enslave(struct net_device *bond_dev, struct net_device *slave_dev)
1505 slave_dev->npinfo = bond->dev->npinfo; 1510 slave_dev->npinfo = bond->dev->npinfo;
1506 if (slave_dev->npinfo) { 1511 if (slave_dev->npinfo) {
1507 if (slave_enable_netpoll(new_slave)) { 1512 if (slave_enable_netpoll(new_slave)) {
1508 read_unlock(&bond->lock);
1509 pr_info("Error, %s: master_dev is using netpoll, " 1513 pr_info("Error, %s: master_dev is using netpoll, "
1510 "but new slave device does not support netpoll.\n", 1514 "but new slave device does not support netpoll.\n",
1511 bond_dev->name); 1515 bond_dev->name);
@@ -1579,7 +1583,8 @@ err_close:
1579 dev_close(slave_dev); 1583 dev_close(slave_dev);
1580 1584
1581err_restore_mac: 1585err_restore_mac:
1582 if (!bond->params.fail_over_mac) { 1586 if (!bond->params.fail_over_mac ||
1587 bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
1583 /* XXX TODO - fom follow mode needs to change master's 1588 /* XXX TODO - fom follow mode needs to change master's
1584 * MAC if this slave's MAC is in use by the bond, or at 1589 * MAC if this slave's MAC is in use by the bond, or at
1585 * least print a warning. 1590 * least print a warning.
@@ -1672,7 +1677,8 @@ static int __bond_release_one(struct net_device *bond_dev,
1672 1677
1673 bond->current_arp_slave = NULL; 1678 bond->current_arp_slave = NULL;
1674 1679
1675 if (!all && !bond->params.fail_over_mac) { 1680 if (!all && (!bond->params.fail_over_mac ||
1681 bond->params.mode != BOND_MODE_ACTIVEBACKUP)) {
1676 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) && 1682 if (ether_addr_equal_64bits(bond_dev->dev_addr, slave->perm_hwaddr) &&
1677 bond_has_slaves(bond)) 1683 bond_has_slaves(bond))
1678 pr_warn("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s. Set the HWaddr of %s to a different address to avoid conflicts.\n", 1684 pr_warn("%s: Warning: the permanent HWaddr of %s - %pM - is still in use by %s. Set the HWaddr of %s to a different address to avoid conflicts.\n",
@@ -1769,7 +1775,8 @@ static int __bond_release_one(struct net_device *bond_dev,
1769 /* close slave before restoring its mac address */ 1775 /* close slave before restoring its mac address */
1770 dev_close(slave_dev); 1776 dev_close(slave_dev);
1771 1777
1772 if (bond->params.fail_over_mac != BOND_FOM_ACTIVE) { 1778 if (bond->params.fail_over_mac != BOND_FOM_ACTIVE ||
1779 bond->params.mode != BOND_MODE_ACTIVEBACKUP) {
1773 /* restore original ("permanent") mac address */ 1780 /* restore original ("permanent") mac address */
1774 memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN); 1781 memcpy(addr.sa_data, slave->perm_hwaddr, ETH_ALEN);
1775 addr.sa_family = slave_dev->type; 1782 addr.sa_family = slave_dev->type;
@@ -3431,7 +3438,8 @@ static int bond_set_mac_address(struct net_device *bond_dev, void *addr)
3431 /* If fail_over_mac is enabled, do nothing and return success. 3438 /* If fail_over_mac is enabled, do nothing and return success.
3432 * Returning an error causes ifenslave to fail. 3439 * Returning an error causes ifenslave to fail.
3433 */ 3440 */
3434 if (bond->params.fail_over_mac) 3441 if (bond->params.fail_over_mac &&
3442 bond->params.mode == BOND_MODE_ACTIVEBACKUP)
3435 return 0; 3443 return 0;
3436 3444
3437 if (!is_valid_ether_addr(sa->sa_data)) 3445 if (!is_valid_ether_addr(sa->sa_data))
diff --git a/drivers/net/can/Kconfig b/drivers/net/can/Kconfig
index d447b881bbde..9e7d95dae2c7 100644
--- a/drivers/net/can/Kconfig
+++ b/drivers/net/can/Kconfig
@@ -104,7 +104,7 @@ config CAN_JANZ_ICAN3
104 104
105config CAN_FLEXCAN 105config CAN_FLEXCAN
106 tristate "Support for Freescale FLEXCAN based chips" 106 tristate "Support for Freescale FLEXCAN based chips"
107 depends on (ARM && CPU_LITTLE_ENDIAN) || PPC 107 depends on ARM || PPC
108 ---help--- 108 ---help---
109 Say Y here if you want to support for Freescale FlexCAN. 109 Say Y here if you want to support for Freescale FlexCAN.
110 110
diff --git a/drivers/net/can/dev.c b/drivers/net/can/dev.c
index 13a909822e25..fc59bc6f040b 100644
--- a/drivers/net/can/dev.c
+++ b/drivers/net/can/dev.c
@@ -323,19 +323,10 @@ void can_put_echo_skb(struct sk_buff *skb, struct net_device *dev,
323 } 323 }
324 324
325 if (!priv->echo_skb[idx]) { 325 if (!priv->echo_skb[idx]) {
326 struct sock *srcsk = skb->sk;
327 326
328 if (atomic_read(&skb->users) != 1) { 327 skb = can_create_echo_skb(skb);
329 struct sk_buff *old_skb = skb; 328 if (!skb)
330 329 return;
331 skb = skb_clone(old_skb, GFP_ATOMIC);
332 kfree_skb(old_skb);
333 if (!skb)
334 return;
335 } else
336 skb_orphan(skb);
337
338 skb->sk = srcsk;
339 330
340 /* make settings for echo to reduce code in irq context */ 331 /* make settings for echo to reduce code in irq context */
341 skb->protocol = htons(ETH_P_CAN); 332 skb->protocol = htons(ETH_P_CAN);
diff --git a/drivers/net/can/flexcan.c b/drivers/net/can/flexcan.c
index aaed97bee471..320bef2dba42 100644
--- a/drivers/net/can/flexcan.c
+++ b/drivers/net/can/flexcan.c
@@ -235,9 +235,12 @@ static const struct can_bittiming_const flexcan_bittiming_const = {
235}; 235};
236 236
237/* 237/*
238 * Abstract off the read/write for arm versus ppc. 238 * Abstract off the read/write for arm versus ppc. This
239 * assumes that PPC uses big-endian registers and everything
240 * else uses little-endian registers, independent of CPU
241 * endianess.
239 */ 242 */
240#if defined(__BIG_ENDIAN) 243#if defined(CONFIG_PPC)
241static inline u32 flexcan_read(void __iomem *addr) 244static inline u32 flexcan_read(void __iomem *addr)
242{ 245{
243 return in_be32(addr); 246 return in_be32(addr);
diff --git a/drivers/net/can/janz-ican3.c b/drivers/net/can/janz-ican3.c
index e24e6690d672..71594e5676fd 100644
--- a/drivers/net/can/janz-ican3.c
+++ b/drivers/net/can/janz-ican3.c
@@ -18,6 +18,7 @@
18#include <linux/netdevice.h> 18#include <linux/netdevice.h>
19#include <linux/can.h> 19#include <linux/can.h>
20#include <linux/can/dev.h> 20#include <linux/can/dev.h>
21#include <linux/can/skb.h>
21#include <linux/can/error.h> 22#include <linux/can/error.h>
22 23
23#include <linux/mfd/janz.h> 24#include <linux/mfd/janz.h>
@@ -1133,20 +1134,9 @@ static void ican3_handle_message(struct ican3_dev *mod, struct ican3_msg *msg)
1133 */ 1134 */
1134static void ican3_put_echo_skb(struct ican3_dev *mod, struct sk_buff *skb) 1135static void ican3_put_echo_skb(struct ican3_dev *mod, struct sk_buff *skb)
1135{ 1136{
1136 struct sock *srcsk = skb->sk; 1137 skb = can_create_echo_skb(skb);
1137 1138 if (!skb)
1138 if (atomic_read(&skb->users) != 1) { 1139 return;
1139 struct sk_buff *old_skb = skb;
1140
1141 skb = skb_clone(old_skb, GFP_ATOMIC);
1142 kfree_skb(old_skb);
1143 if (!skb)
1144 return;
1145 } else {
1146 skb_orphan(skb);
1147 }
1148
1149 skb->sk = srcsk;
1150 1140
1151 /* save this skb for tx interrupt echo handling */ 1141 /* save this skb for tx interrupt echo handling */
1152 skb_queue_tail(&mod->echoq, skb); 1142 skb_queue_tail(&mod->echoq, skb);
@@ -1322,7 +1312,7 @@ static int ican3_napi(struct napi_struct *napi, int budget)
1322 1312
1323 /* process all communication messages */ 1313 /* process all communication messages */
1324 while (true) { 1314 while (true) {
1325 struct ican3_msg msg; 1315 struct ican3_msg uninitialized_var(msg);
1326 ret = ican3_recv_msg(mod, &msg); 1316 ret = ican3_recv_msg(mod, &msg);
1327 if (ret) 1317 if (ret)
1328 break; 1318 break;
diff --git a/drivers/net/can/vcan.c b/drivers/net/can/vcan.c
index 0a2a5ee79a17..4e94057ef5cf 100644
--- a/drivers/net/can/vcan.c
+++ b/drivers/net/can/vcan.c
@@ -46,6 +46,7 @@
46#include <linux/if_ether.h> 46#include <linux/if_ether.h>
47#include <linux/can.h> 47#include <linux/can.h>
48#include <linux/can/dev.h> 48#include <linux/can/dev.h>
49#include <linux/can/skb.h>
49#include <linux/slab.h> 50#include <linux/slab.h>
50#include <net/rtnetlink.h> 51#include <net/rtnetlink.h>
51 52
@@ -109,25 +110,23 @@ static netdev_tx_t vcan_tx(struct sk_buff *skb, struct net_device *dev)
109 stats->rx_packets++; 110 stats->rx_packets++;
110 stats->rx_bytes += cfd->len; 111 stats->rx_bytes += cfd->len;
111 } 112 }
112 kfree_skb(skb); 113 consume_skb(skb);
113 return NETDEV_TX_OK; 114 return NETDEV_TX_OK;
114 } 115 }
115 116
116 /* perform standard echo handling for CAN network interfaces */ 117 /* perform standard echo handling for CAN network interfaces */
117 118
118 if (loop) { 119 if (loop) {
119 struct sock *srcsk = skb->sk;
120 120
121 skb = skb_share_check(skb, GFP_ATOMIC); 121 skb = can_create_echo_skb(skb);
122 if (!skb) 122 if (!skb)
123 return NETDEV_TX_OK; 123 return NETDEV_TX_OK;
124 124
125 /* receive with packet counting */ 125 /* receive with packet counting */
126 skb->sk = srcsk;
127 vcan_rx(skb, dev); 126 vcan_rx(skb, dev);
128 } else { 127 } else {
129 /* no looped packets => no counting */ 128 /* no looped packets => no counting */
130 kfree_skb(skb); 129 consume_skb(skb);
131 } 130 }
132 return NETDEV_TX_OK; 131 return NETDEV_TX_OK;
133} 132}
diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
index 0f4241c6e97e..238ccea965c8 100644
--- a/drivers/net/ethernet/3com/3c59x.c
+++ b/drivers/net/ethernet/3com/3c59x.c
@@ -3294,7 +3294,6 @@ static int __init vortex_init(void)
3294 3294
3295static void __exit vortex_eisa_cleanup(void) 3295static void __exit vortex_eisa_cleanup(void)
3296{ 3296{
3297 struct vortex_private *vp;
3298 void __iomem *ioaddr; 3297 void __iomem *ioaddr;
3299 3298
3300#ifdef CONFIG_EISA 3299#ifdef CONFIG_EISA
@@ -3303,7 +3302,6 @@ static void __exit vortex_eisa_cleanup(void)
3303#endif 3302#endif
3304 3303
3305 if (compaq_net_device) { 3304 if (compaq_net_device) {
3306 vp = netdev_priv(compaq_net_device);
3307 ioaddr = ioport_map(compaq_net_device->base_addr, 3305 ioaddr = ioport_map(compaq_net_device->base_addr,
3308 VORTEX_TOTAL_SIZE); 3306 VORTEX_TOTAL_SIZE);
3309 3307
diff --git a/drivers/net/ethernet/allwinner/sun4i-emac.c b/drivers/net/ethernet/allwinner/sun4i-emac.c
index 0cc21437478c..511f6eecd58b 100644
--- a/drivers/net/ethernet/allwinner/sun4i-emac.c
+++ b/drivers/net/ethernet/allwinner/sun4i-emac.c
@@ -929,6 +929,9 @@ static int emac_resume(struct platform_device *dev)
929} 929}
930 930
931static const struct of_device_id emac_of_match[] = { 931static const struct of_device_id emac_of_match[] = {
932 {.compatible = "allwinner,sun4i-a10-emac",},
933
934 /* Deprecated */
932 {.compatible = "allwinner,sun4i-emac",}, 935 {.compatible = "allwinner,sun4i-emac",},
933 {}, 936 {},
934}; 937};
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index e92ffd6e1c15..2e45f6ec1bf0 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -1292,6 +1292,7 @@ static int alx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
1292 alx = netdev_priv(netdev); 1292 alx = netdev_priv(netdev);
1293 spin_lock_init(&alx->hw.mdio_lock); 1293 spin_lock_init(&alx->hw.mdio_lock);
1294 spin_lock_init(&alx->irq_lock); 1294 spin_lock_init(&alx->irq_lock);
1295 spin_lock_init(&alx->stats_lock);
1295 alx->dev = netdev; 1296 alx->dev = netdev;
1296 alx->hw.pdev = pdev; 1297 alx->hw.pdev = pdev;
1297 alx->msg_enable = NETIF_MSG_LINK | NETIF_MSG_HW | NETIF_MSG_IFUP | 1298 alx->msg_enable = NETIF_MSG_LINK | NETIF_MSG_HW | NETIF_MSG_IFUP |
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index 9d2dedadf2df..cda25ac45b47 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -85,7 +85,7 @@ MODULE_FIRMWARE(FW_RV2P_FILE_09_Ax);
85 85
86static int disable_msi = 0; 86static int disable_msi = 0;
87 87
88module_param(disable_msi, int, 0); 88module_param(disable_msi, int, S_IRUGO);
89MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)"); 89MODULE_PARM_DESC(disable_msi, "Disable Message Signaled Interrupt (MSI)");
90 90
91typedef enum { 91typedef enum {
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
index 17d1689aec6b..bfc58d488bb5 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h
@@ -936,7 +936,7 @@ static inline int bnx2x_func_start(struct bnx2x *bp)
936 else /* CHIP_IS_E1X */ 936 else /* CHIP_IS_E1X */
937 start_params->network_cos_mode = FW_WRR; 937 start_params->network_cos_mode = FW_WRR;
938 938
939 start_params->gre_tunnel_mode = IPGRE_TUNNEL; 939 start_params->gre_tunnel_mode = L2GRE_TUNNEL;
940 start_params->gre_tunnel_rss = GRE_INNER_HEADERS_RSS; 940 start_params->gre_tunnel_rss = GRE_INNER_HEADERS_RSS;
941 941
942 return bnx2x_func_state_change(bp, &func_params); 942 return bnx2x_func_state_change(bp, &func_params);
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index c9c445e7b4a5..7d4382286457 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -95,29 +95,29 @@ MODULE_FIRMWARE(FW_FILE_NAME_E1H);
95MODULE_FIRMWARE(FW_FILE_NAME_E2); 95MODULE_FIRMWARE(FW_FILE_NAME_E2);
96 96
97int bnx2x_num_queues; 97int bnx2x_num_queues;
98module_param_named(num_queues, bnx2x_num_queues, int, 0); 98module_param_named(num_queues, bnx2x_num_queues, int, S_IRUGO);
99MODULE_PARM_DESC(num_queues, 99MODULE_PARM_DESC(num_queues,
100 " Set number of queues (default is as a number of CPUs)"); 100 " Set number of queues (default is as a number of CPUs)");
101 101
102static int disable_tpa; 102static int disable_tpa;
103module_param(disable_tpa, int, 0); 103module_param(disable_tpa, int, S_IRUGO);
104MODULE_PARM_DESC(disable_tpa, " Disable the TPA (LRO) feature"); 104MODULE_PARM_DESC(disable_tpa, " Disable the TPA (LRO) feature");
105 105
106static int int_mode; 106static int int_mode;
107module_param(int_mode, int, 0); 107module_param(int_mode, int, S_IRUGO);
108MODULE_PARM_DESC(int_mode, " Force interrupt mode other than MSI-X " 108MODULE_PARM_DESC(int_mode, " Force interrupt mode other than MSI-X "
109 "(1 INT#x; 2 MSI)"); 109 "(1 INT#x; 2 MSI)");
110 110
111static int dropless_fc; 111static int dropless_fc;
112module_param(dropless_fc, int, 0); 112module_param(dropless_fc, int, S_IRUGO);
113MODULE_PARM_DESC(dropless_fc, " Pause on exhausted host ring"); 113MODULE_PARM_DESC(dropless_fc, " Pause on exhausted host ring");
114 114
115static int mrrs = -1; 115static int mrrs = -1;
116module_param(mrrs, int, 0); 116module_param(mrrs, int, S_IRUGO);
117MODULE_PARM_DESC(mrrs, " Force Max Read Req Size (0..3) (for debug)"); 117MODULE_PARM_DESC(mrrs, " Force Max Read Req Size (0..3) (for debug)");
118 118
119static int debug; 119static int debug;
120module_param(debug, int, 0); 120module_param(debug, int, S_IRUGO);
121MODULE_PARM_DESC(debug, " Default debug msglevel"); 121MODULE_PARM_DESC(debug, " Default debug msglevel");
122 122
123struct workqueue_struct *bnx2x_wq; 123struct workqueue_struct *bnx2x_wq;
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
index aec5ef2ed7ce..e42f48df6e94 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
@@ -1446,12 +1446,12 @@ static void bnx2x_vf_igu_reset(struct bnx2x *bp, struct bnx2x_virtf *vf)
1446 if (vf->cfg_flags & VF_CFG_INT_SIMD) 1446 if (vf->cfg_flags & VF_CFG_INT_SIMD)
1447 val |= IGU_VF_CONF_SINGLE_ISR_EN; 1447 val |= IGU_VF_CONF_SINGLE_ISR_EN;
1448 val &= ~IGU_VF_CONF_PARENT_MASK; 1448 val &= ~IGU_VF_CONF_PARENT_MASK;
1449 val |= BP_FUNC(bp) << IGU_VF_CONF_PARENT_SHIFT; /* parent PF */ 1449 val |= (BP_ABS_FUNC(bp) >> 1) << IGU_VF_CONF_PARENT_SHIFT;
1450 REG_WR(bp, IGU_REG_VF_CONFIGURATION, val); 1450 REG_WR(bp, IGU_REG_VF_CONFIGURATION, val);
1451 1451
1452 DP(BNX2X_MSG_IOV, 1452 DP(BNX2X_MSG_IOV,
1453 "value in IGU_REG_VF_CONFIGURATION of vf %d after write %x\n", 1453 "value in IGU_REG_VF_CONFIGURATION of vf %d after write is 0x%08x\n",
1454 vf->abs_vfid, REG_RD(bp, IGU_REG_VF_CONFIGURATION)); 1454 vf->abs_vfid, val);
1455 1455
1456 bnx2x_pretend_func(bp, BP_ABS_FUNC(bp)); 1456 bnx2x_pretend_func(bp, BP_ABS_FUNC(bp));
1457 1457
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index e2ca03e23dc1..3167ed6593b0 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -2609,13 +2609,14 @@ static int tg3_phy_reset_5703_4_5(struct tg3 *tp)
2609 2609
2610 tg3_writephy(tp, MII_CTRL1000, phy9_orig); 2610 tg3_writephy(tp, MII_CTRL1000, phy9_orig);
2611 2611
2612 if (!tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32)) { 2612 err = tg3_readphy(tp, MII_TG3_EXT_CTRL, &reg32);
2613 reg32 &= ~0x3000; 2613 if (err)
2614 tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32); 2614 return err;
2615 } else if (!err)
2616 err = -EBUSY;
2617 2615
2618 return err; 2616 reg32 &= ~0x3000;
2617 tg3_writephy(tp, MII_TG3_EXT_CTRL, reg32);
2618
2619 return 0;
2619} 2620}
2620 2621
2621static void tg3_carrier_off(struct tg3 *tp) 2622static void tg3_carrier_off(struct tg3 *tp)
@@ -14113,12 +14114,12 @@ static int tg3_change_mtu(struct net_device *dev, int new_mtu)
14113 14114
14114 tg3_netif_stop(tp); 14115 tg3_netif_stop(tp);
14115 14116
14117 tg3_set_mtu(dev, tp, new_mtu);
14118
14116 tg3_full_lock(tp, 1); 14119 tg3_full_lock(tp, 1);
14117 14120
14118 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1); 14121 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
14119 14122
14120 tg3_set_mtu(dev, tp, new_mtu);
14121
14122 /* Reset PHY, otherwise the read DMA engine will be in a mode that 14123 /* Reset PHY, otherwise the read DMA engine will be in a mode that
14123 * breaks all requests to 256 bytes. 14124 * breaks all requests to 256 bytes.
14124 */ 14125 */
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c
index 4de8cfd149cf..55e0fa03dc90 100644
--- a/drivers/net/ethernet/ethoc.c
+++ b/drivers/net/ethernet/ethoc.c
@@ -13,6 +13,7 @@
13 13
14#include <linux/dma-mapping.h> 14#include <linux/dma-mapping.h>
15#include <linux/etherdevice.h> 15#include <linux/etherdevice.h>
16#include <linux/clk.h>
16#include <linux/crc32.h> 17#include <linux/crc32.h>
17#include <linux/interrupt.h> 18#include <linux/interrupt.h>
18#include <linux/io.h> 19#include <linux/io.h>
@@ -51,6 +52,7 @@ MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size");
51#define ETH_HASH0 0x48 52#define ETH_HASH0 0x48
52#define ETH_HASH1 0x4c 53#define ETH_HASH1 0x4c
53#define ETH_TXCTRL 0x50 54#define ETH_TXCTRL 0x50
55#define ETH_END 0x54
54 56
55/* mode register */ 57/* mode register */
56#define MODER_RXEN (1 << 0) /* receive enable */ 58#define MODER_RXEN (1 << 0) /* receive enable */
@@ -179,6 +181,7 @@ MODULE_PARM_DESC(buffer_size, "DMA buffer allocation size");
179 * @membase: pointer to buffer memory region 181 * @membase: pointer to buffer memory region
180 * @dma_alloc: dma allocated buffer size 182 * @dma_alloc: dma allocated buffer size
181 * @io_region_size: I/O memory region size 183 * @io_region_size: I/O memory region size
184 * @num_bd: number of buffer descriptors
182 * @num_tx: number of send buffers 185 * @num_tx: number of send buffers
183 * @cur_tx: last send buffer written 186 * @cur_tx: last send buffer written
184 * @dty_tx: last buffer actually sent 187 * @dty_tx: last buffer actually sent
@@ -199,6 +202,7 @@ struct ethoc {
199 int dma_alloc; 202 int dma_alloc;
200 resource_size_t io_region_size; 203 resource_size_t io_region_size;
201 204
205 unsigned int num_bd;
202 unsigned int num_tx; 206 unsigned int num_tx;
203 unsigned int cur_tx; 207 unsigned int cur_tx;
204 unsigned int dty_tx; 208 unsigned int dty_tx;
@@ -216,6 +220,7 @@ struct ethoc {
216 220
217 struct phy_device *phy; 221 struct phy_device *phy;
218 struct mii_bus *mdio; 222 struct mii_bus *mdio;
223 struct clk *clk;
219 s8 phy_id; 224 s8 phy_id;
220}; 225};
221 226
@@ -688,6 +693,11 @@ static int ethoc_mdio_probe(struct net_device *dev)
688 } 693 }
689 694
690 priv->phy = phy; 695 priv->phy = phy;
696 phy->advertising &= ~(ADVERTISED_1000baseT_Full |
697 ADVERTISED_1000baseT_Half);
698 phy->supported &= ~(SUPPORTED_1000baseT_Full |
699 SUPPORTED_1000baseT_Half);
700
691 return 0; 701 return 0;
692} 702}
693 703
@@ -890,6 +900,102 @@ out:
890 return NETDEV_TX_OK; 900 return NETDEV_TX_OK;
891} 901}
892 902
903static int ethoc_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
904{
905 struct ethoc *priv = netdev_priv(dev);
906 struct phy_device *phydev = priv->phy;
907
908 if (!phydev)
909 return -EOPNOTSUPP;
910
911 return phy_ethtool_gset(phydev, cmd);
912}
913
914static int ethoc_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
915{
916 struct ethoc *priv = netdev_priv(dev);
917 struct phy_device *phydev = priv->phy;
918
919 if (!phydev)
920 return -EOPNOTSUPP;
921
922 return phy_ethtool_sset(phydev, cmd);
923}
924
925static int ethoc_get_regs_len(struct net_device *netdev)
926{
927 return ETH_END;
928}
929
930static void ethoc_get_regs(struct net_device *dev, struct ethtool_regs *regs,
931 void *p)
932{
933 struct ethoc *priv = netdev_priv(dev);
934 u32 *regs_buff = p;
935 unsigned i;
936
937 regs->version = 0;
938 for (i = 0; i < ETH_END / sizeof(u32); ++i)
939 regs_buff[i] = ethoc_read(priv, i * sizeof(u32));
940}
941
942static void ethoc_get_ringparam(struct net_device *dev,
943 struct ethtool_ringparam *ring)
944{
945 struct ethoc *priv = netdev_priv(dev);
946
947 ring->rx_max_pending = priv->num_bd - 1;
948 ring->rx_mini_max_pending = 0;
949 ring->rx_jumbo_max_pending = 0;
950 ring->tx_max_pending = priv->num_bd - 1;
951
952 ring->rx_pending = priv->num_rx;
953 ring->rx_mini_pending = 0;
954 ring->rx_jumbo_pending = 0;
955 ring->tx_pending = priv->num_tx;
956}
957
958static int ethoc_set_ringparam(struct net_device *dev,
959 struct ethtool_ringparam *ring)
960{
961 struct ethoc *priv = netdev_priv(dev);
962
963 if (ring->tx_pending < 1 || ring->rx_pending < 1 ||
964 ring->tx_pending + ring->rx_pending > priv->num_bd)
965 return -EINVAL;
966 if (ring->rx_mini_pending || ring->rx_jumbo_pending)
967 return -EINVAL;
968
969 if (netif_running(dev)) {
970 netif_tx_disable(dev);
971 ethoc_disable_rx_and_tx(priv);
972 ethoc_disable_irq(priv, INT_MASK_TX | INT_MASK_RX);
973 synchronize_irq(dev->irq);
974 }
975
976 priv->num_tx = rounddown_pow_of_two(ring->tx_pending);
977 priv->num_rx = ring->rx_pending;
978 ethoc_init_ring(priv, dev->mem_start);
979
980 if (netif_running(dev)) {
981 ethoc_enable_irq(priv, INT_MASK_TX | INT_MASK_RX);
982 ethoc_enable_rx_and_tx(priv);
983 netif_wake_queue(dev);
984 }
985 return 0;
986}
987
988const struct ethtool_ops ethoc_ethtool_ops = {
989 .get_settings = ethoc_get_settings,
990 .set_settings = ethoc_set_settings,
991 .get_regs_len = ethoc_get_regs_len,
992 .get_regs = ethoc_get_regs,
993 .get_link = ethtool_op_get_link,
994 .get_ringparam = ethoc_get_ringparam,
995 .set_ringparam = ethoc_set_ringparam,
996 .get_ts_info = ethtool_op_get_ts_info,
997};
998
893static const struct net_device_ops ethoc_netdev_ops = { 999static const struct net_device_ops ethoc_netdev_ops = {
894 .ndo_open = ethoc_open, 1000 .ndo_open = ethoc_open,
895 .ndo_stop = ethoc_stop, 1001 .ndo_stop = ethoc_stop,
@@ -917,6 +1023,8 @@ static int ethoc_probe(struct platform_device *pdev)
917 int num_bd; 1023 int num_bd;
918 int ret = 0; 1024 int ret = 0;
919 bool random_mac = false; 1025 bool random_mac = false;
1026 struct ethoc_platform_data *pdata = dev_get_platdata(&pdev->dev);
1027 u32 eth_clkfreq = pdata ? pdata->eth_clkfreq : 0;
920 1028
921 /* allocate networking device */ 1029 /* allocate networking device */
922 netdev = alloc_etherdev(sizeof(struct ethoc)); 1030 netdev = alloc_etherdev(sizeof(struct ethoc));
@@ -1016,6 +1124,7 @@ static int ethoc_probe(struct platform_device *pdev)
1016 ret = -ENODEV; 1124 ret = -ENODEV;
1017 goto error; 1125 goto error;
1018 } 1126 }
1127 priv->num_bd = num_bd;
1019 /* num_tx must be a power of two */ 1128 /* num_tx must be a power of two */
1020 priv->num_tx = rounddown_pow_of_two(num_bd >> 1); 1129 priv->num_tx = rounddown_pow_of_two(num_bd >> 1);
1021 priv->num_rx = num_bd - priv->num_tx; 1130 priv->num_rx = num_bd - priv->num_tx;
@@ -1030,8 +1139,7 @@ static int ethoc_probe(struct platform_device *pdev)
1030 } 1139 }
1031 1140
1032 /* Allow the platform setup code to pass in a MAC address. */ 1141 /* Allow the platform setup code to pass in a MAC address. */
1033 if (dev_get_platdata(&pdev->dev)) { 1142 if (pdata) {
1034 struct ethoc_platform_data *pdata = dev_get_platdata(&pdev->dev);
1035 memcpy(netdev->dev_addr, pdata->hwaddr, IFHWADDRLEN); 1143 memcpy(netdev->dev_addr, pdata->hwaddr, IFHWADDRLEN);
1036 priv->phy_id = pdata->phy_id; 1144 priv->phy_id = pdata->phy_id;
1037 } else { 1145 } else {
@@ -1069,6 +1177,27 @@ static int ethoc_probe(struct platform_device *pdev)
1069 if (random_mac) 1177 if (random_mac)
1070 netdev->addr_assign_type = NET_ADDR_RANDOM; 1178 netdev->addr_assign_type = NET_ADDR_RANDOM;
1071 1179
1180 /* Allow the platform setup code to adjust MII management bus clock. */
1181 if (!eth_clkfreq) {
1182 struct clk *clk = devm_clk_get(&pdev->dev, NULL);
1183
1184 if (!IS_ERR(clk)) {
1185 priv->clk = clk;
1186 clk_prepare_enable(clk);
1187 eth_clkfreq = clk_get_rate(clk);
1188 }
1189 }
1190 if (eth_clkfreq) {
1191 u32 clkdiv = MIIMODER_CLKDIV(eth_clkfreq / 2500000 + 1);
1192
1193 if (!clkdiv)
1194 clkdiv = 2;
1195 dev_dbg(&pdev->dev, "setting MII clkdiv to %u\n", clkdiv);
1196 ethoc_write(priv, MIIMODER,
1197 (ethoc_read(priv, MIIMODER) & MIIMODER_NOPRE) |
1198 clkdiv);
1199 }
1200
1072 /* register MII bus */ 1201 /* register MII bus */
1073 priv->mdio = mdiobus_alloc(); 1202 priv->mdio = mdiobus_alloc();
1074 if (!priv->mdio) { 1203 if (!priv->mdio) {
@@ -1111,6 +1240,7 @@ static int ethoc_probe(struct platform_device *pdev)
1111 netdev->netdev_ops = &ethoc_netdev_ops; 1240 netdev->netdev_ops = &ethoc_netdev_ops;
1112 netdev->watchdog_timeo = ETHOC_TIMEOUT; 1241 netdev->watchdog_timeo = ETHOC_TIMEOUT;
1113 netdev->features |= 0; 1242 netdev->features |= 0;
1243 netdev->ethtool_ops = &ethoc_ethtool_ops;
1114 1244
1115 /* setup NAPI */ 1245 /* setup NAPI */
1116 netif_napi_add(netdev, &priv->napi, ethoc_poll, 64); 1246 netif_napi_add(netdev, &priv->napi, ethoc_poll, 64);
@@ -1133,6 +1263,8 @@ free_mdio:
1133 kfree(priv->mdio->irq); 1263 kfree(priv->mdio->irq);
1134 mdiobus_free(priv->mdio); 1264 mdiobus_free(priv->mdio);
1135free: 1265free:
1266 if (priv->clk)
1267 clk_disable_unprepare(priv->clk);
1136 free_netdev(netdev); 1268 free_netdev(netdev);
1137out: 1269out:
1138 return ret; 1270 return ret;
@@ -1157,6 +1289,8 @@ static int ethoc_remove(struct platform_device *pdev)
1157 kfree(priv->mdio->irq); 1289 kfree(priv->mdio->irq);
1158 mdiobus_free(priv->mdio); 1290 mdiobus_free(priv->mdio);
1159 } 1291 }
1292 if (priv->clk)
1293 clk_disable_unprepare(priv->clk);
1160 unregister_netdev(netdev); 1294 unregister_netdev(netdev);
1161 free_netdev(netdev); 1295 free_netdev(netdev);
1162 } 1296 }
diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index cbaba4442d4b..bf7a01ef9a57 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -3034,7 +3034,7 @@ static void __e100_shutdown(struct pci_dev *pdev, bool *enable_wake)
3034 *enable_wake = false; 3034 *enable_wake = false;
3035 } 3035 }
3036 3036
3037 pci_disable_device(pdev); 3037 pci_clear_master(pdev);
3038} 3038}
3039 3039
3040static int __e100_power_off(struct pci_dev *pdev, bool wake) 3040static int __e100_power_off(struct pci_dev *pdev, bool wake)
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
index 157fe8df2c3e..8ff57e8e3e91 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
+++ b/drivers/net/ethernet/mellanox/mlx5/core/Kconfig
@@ -4,5 +4,5 @@
4 4
5config MLX5_CORE 5config MLX5_CORE
6 tristate 6 tristate
7 depends on PCI && X86 7 depends on PCI
8 default n 8 default n
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c
index 1ded50ca1600..e46e8698e630 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-main.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c
@@ -726,9 +726,6 @@ static int vxge_learn_mac(struct vxgedev *vdev, u8 *mac_header)
726 int vpath_idx = 0; 726 int vpath_idx = 0;
727 enum vxge_hw_status status = VXGE_HW_OK; 727 enum vxge_hw_status status = VXGE_HW_OK;
728 struct vxge_vpath *vpath = NULL; 728 struct vxge_vpath *vpath = NULL;
729 struct __vxge_hw_device *hldev;
730
731 hldev = pci_get_drvdata(vdev->pdev);
732 729
733 mac_address = (u8 *)&mac_addr; 730 mac_address = (u8 *)&mac_addr;
734 memcpy(mac_address, mac_header, ETH_ALEN); 731 memcpy(mac_address, mac_header, ETH_ALEN);
@@ -2443,9 +2440,6 @@ static void vxge_rem_msix_isr(struct vxgedev *vdev)
2443 2440
2444static void vxge_rem_isr(struct vxgedev *vdev) 2441static void vxge_rem_isr(struct vxgedev *vdev)
2445{ 2442{
2446 struct __vxge_hw_device *hldev;
2447 hldev = pci_get_drvdata(vdev->pdev);
2448
2449#ifdef CONFIG_PCI_MSI 2443#ifdef CONFIG_PCI_MSI
2450 if (vdev->config.intr_type == MSI_X) { 2444 if (vdev->config.intr_type == MSI_X) {
2451 vxge_rem_msix_isr(vdev); 2445 vxge_rem_msix_isr(vdev);
diff --git a/drivers/net/ethernet/sfc/tx.c b/drivers/net/ethernet/sfc/tx.c
index c49d1fb16965..75d11fa4eb0a 100644
--- a/drivers/net/ethernet/sfc/tx.c
+++ b/drivers/net/ethernet/sfc/tx.c
@@ -429,7 +429,9 @@ netdev_tx_t efx_enqueue_skb(struct efx_tx_queue *tx_queue, struct sk_buff *skb)
429 } 429 }
430 430
431 /* Transfer ownership of the skb to the final buffer */ 431 /* Transfer ownership of the skb to the final buffer */
432#ifdef EFX_USE_PIO
432finish_packet: 433finish_packet:
434#endif
433 buffer->skb = skb; 435 buffer->skb = skb;
434 buffer->flags = EFX_TX_BUF_SKB | dma_flags; 436 buffer->flags = EFX_TX_BUF_SKB | dma_flags;
435 437
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index bde63e3af96f..1d860ce914ed 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -1878,8 +1878,18 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data,
1878 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); 1878 mdio_node = of_find_node_by_phandle(be32_to_cpup(parp));
1879 phyid = be32_to_cpup(parp+1); 1879 phyid = be32_to_cpup(parp+1);
1880 mdio = of_find_device_by_node(mdio_node); 1880 mdio = of_find_device_by_node(mdio_node);
1881 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), 1881
1882 PHY_ID_FMT, mdio->name, phyid); 1882 if (strncmp(mdio->name, "gpio", 4) == 0) {
1883 /* GPIO bitbang MDIO driver attached */
1884 struct mii_bus *bus = dev_get_drvdata(&mdio->dev);
1885
1886 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
1887 PHY_ID_FMT, bus->id, phyid);
1888 } else {
1889 /* davinci MDIO driver attached */
1890 snprintf(slave_data->phy_id, sizeof(slave_data->phy_id),
1891 PHY_ID_FMT, mdio->name, phyid);
1892 }
1883 1893
1884 mac_addr = of_get_mac_address(slave_node); 1894 mac_addr = of_get_mac_address(slave_node);
1885 if (mac_addr) 1895 if (mac_addr)
diff --git a/drivers/net/irda/Kconfig b/drivers/net/irda/Kconfig
index 2dc82f1d2e70..3da44d5d9149 100644
--- a/drivers/net/irda/Kconfig
+++ b/drivers/net/irda/Kconfig
@@ -210,13 +210,6 @@ config KINGSUN_DONGLE
210 To compile it as a module, choose M here: the module will be called 210 To compile it as a module, choose M here: the module will be called
211 kingsun-sir. 211 kingsun-sir.
212 212
213config EP7211_DONGLE
214 tristate "Cirrus Logic clps711x I/R support"
215 depends on IRTTY_SIR && ARCH_CLPS711X && IRDA
216 help
217 Say Y here if you want to build support for the Cirrus logic
218 EP7211 chipset's infrared module.
219
220config KSDAZZLE_DONGLE 213config KSDAZZLE_DONGLE
221 tristate "KingSun Dazzle IrDA-USB dongle" 214 tristate "KingSun Dazzle IrDA-USB dongle"
222 depends on IRDA && USB 215 depends on IRDA && USB
diff --git a/drivers/net/irda/Makefile b/drivers/net/irda/Makefile
index dfc64537f62f..be8ab5b9a4a2 100644
--- a/drivers/net/irda/Makefile
+++ b/drivers/net/irda/Makefile
@@ -35,7 +35,6 @@ obj-$(CONFIG_MCP2120_DONGLE) += mcp2120-sir.o
35obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o 35obj-$(CONFIG_ACT200L_DONGLE) += act200l-sir.o
36obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o 36obj-$(CONFIG_MA600_DONGLE) += ma600-sir.o
37obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o 37obj-$(CONFIG_TOIM3232_DONGLE) += toim3232-sir.o
38obj-$(CONFIG_EP7211_DONGLE) += ep7211-sir.o
39obj-$(CONFIG_KINGSUN_DONGLE) += kingsun-sir.o 38obj-$(CONFIG_KINGSUN_DONGLE) += kingsun-sir.o
40obj-$(CONFIG_KSDAZZLE_DONGLE) += ksdazzle-sir.o 39obj-$(CONFIG_KSDAZZLE_DONGLE) += ksdazzle-sir.o
41obj-$(CONFIG_KS959_DONGLE) += ks959-sir.o 40obj-$(CONFIG_KS959_DONGLE) += ks959-sir.o
diff --git a/drivers/net/irda/ep7211-sir.c b/drivers/net/irda/ep7211-sir.c
deleted file mode 100644
index 5fe1f4dd3369..000000000000
--- a/drivers/net/irda/ep7211-sir.c
+++ /dev/null
@@ -1,70 +0,0 @@
1/*
2 * IR port driver for the Cirrus Logic CLPS711X processors
3 *
4 * Copyright 2001, Blue Mug Inc. All rights reserved.
5 * Copyright 2007, Samuel Ortiz <samuel@sortiz.org>
6 */
7
8#include <linux/module.h>
9#include <linux/platform_device.h>
10
11#include <mach/hardware.h>
12
13#include "sir-dev.h"
14
15static int clps711x_dongle_open(struct sir_dev *dev)
16{
17 unsigned int syscon;
18
19 /* Turn on the SIR encoder. */
20 syscon = clps_readl(SYSCON1);
21 syscon |= SYSCON1_SIREN;
22 clps_writel(syscon, SYSCON1);
23
24 return 0;
25}
26
27static int clps711x_dongle_close(struct sir_dev *dev)
28{
29 unsigned int syscon;
30
31 /* Turn off the SIR encoder. */
32 syscon = clps_readl(SYSCON1);
33 syscon &= ~SYSCON1_SIREN;
34 clps_writel(syscon, SYSCON1);
35
36 return 0;
37}
38
39static struct dongle_driver clps711x_dongle = {
40 .owner = THIS_MODULE,
41 .driver_name = "EP7211 IR driver",
42 .type = IRDA_EP7211_DONGLE,
43 .open = clps711x_dongle_open,
44 .close = clps711x_dongle_close,
45};
46
47static int clps711x_sir_probe(struct platform_device *pdev)
48{
49 return irda_register_dongle(&clps711x_dongle);
50}
51
52static int clps711x_sir_remove(struct platform_device *pdev)
53{
54 return irda_unregister_dongle(&clps711x_dongle);
55}
56
57static struct platform_driver clps711x_sir_driver = {
58 .driver = {
59 .name = "sir-clps711x",
60 .owner = THIS_MODULE,
61 },
62 .probe = clps711x_sir_probe,
63 .remove = clps711x_sir_remove,
64};
65module_platform_driver(clps711x_sir_driver);
66
67MODULE_AUTHOR("Samuel Ortiz <samuel@sortiz.org>");
68MODULE_DESCRIPTION("EP7211 IR dongle driver");
69MODULE_LICENSE("GPL");
70MODULE_ALIAS("irda-dongle-13"); /* IRDA_EP7211_DONGLE */
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c
index 547725fa8671..9414fa272160 100644
--- a/drivers/net/phy/dp83640.c
+++ b/drivers/net/phy/dp83640.c
@@ -437,7 +437,10 @@ static int ptp_dp83640_enable(struct ptp_clock_info *ptp,
437 if (on) { 437 if (on) {
438 gpio_num = gpio_tab[EXTTS0_GPIO + index]; 438 gpio_num = gpio_tab[EXTTS0_GPIO + index];
439 evnt |= (gpio_num & EVNT_GPIO_MASK) << EVNT_GPIO_SHIFT; 439 evnt |= (gpio_num & EVNT_GPIO_MASK) << EVNT_GPIO_SHIFT;
440 evnt |= EVNT_RISE; 440 if (rq->extts.flags & PTP_FALLING_EDGE)
441 evnt |= EVNT_FALL;
442 else
443 evnt |= EVNT_RISE;
441 } 444 }
442 ext_write(0, phydev, PAGE5, PTP_EVNT, evnt); 445 ext_write(0, phydev, PAGE5, PTP_EVNT, evnt);
443 return 0; 446 return 0;
@@ -1058,6 +1061,13 @@ static void dp83640_remove(struct phy_device *phydev)
1058 kfree(dp83640); 1061 kfree(dp83640);
1059} 1062}
1060 1063
1064static int dp83640_config_init(struct phy_device *phydev)
1065{
1066 enable_status_frames(phydev, true);
1067 ext_write(0, phydev, PAGE4, PTP_CTL, PTP_ENABLE);
1068 return 0;
1069}
1070
1061static int dp83640_ack_interrupt(struct phy_device *phydev) 1071static int dp83640_ack_interrupt(struct phy_device *phydev)
1062{ 1072{
1063 int err = phy_read(phydev, MII_DP83640_MISR); 1073 int err = phy_read(phydev, MII_DP83640_MISR);
@@ -1195,11 +1205,6 @@ static int dp83640_hwtstamp(struct phy_device *phydev, struct ifreq *ifr)
1195 1205
1196 mutex_lock(&dp83640->clock->extreg_lock); 1206 mutex_lock(&dp83640->clock->extreg_lock);
1197 1207
1198 if (dp83640->hwts_tx_en || dp83640->hwts_rx_en) {
1199 enable_status_frames(phydev, true);
1200 ext_write(0, phydev, PAGE4, PTP_CTL, PTP_ENABLE);
1201 }
1202
1203 ext_write(0, phydev, PAGE5, PTP_TXCFG0, txcfg0); 1208 ext_write(0, phydev, PAGE5, PTP_TXCFG0, txcfg0);
1204 ext_write(0, phydev, PAGE5, PTP_RXCFG0, rxcfg0); 1209 ext_write(0, phydev, PAGE5, PTP_RXCFG0, rxcfg0);
1205 1210
@@ -1281,6 +1286,7 @@ static void dp83640_txtstamp(struct phy_device *phydev,
1281 } 1286 }
1282 /* fall through */ 1287 /* fall through */
1283 case HWTSTAMP_TX_ON: 1288 case HWTSTAMP_TX_ON:
1289 skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
1284 skb_queue_tail(&dp83640->tx_queue, skb); 1290 skb_queue_tail(&dp83640->tx_queue, skb);
1285 schedule_work(&dp83640->ts_work); 1291 schedule_work(&dp83640->ts_work);
1286 break; 1292 break;
@@ -1330,6 +1336,7 @@ static struct phy_driver dp83640_driver = {
1330 .flags = PHY_HAS_INTERRUPT, 1336 .flags = PHY_HAS_INTERRUPT,
1331 .probe = dp83640_probe, 1337 .probe = dp83640_probe,
1332 .remove = dp83640_remove, 1338 .remove = dp83640_remove,
1339 .config_init = dp83640_config_init,
1333 .config_aneg = genphy_config_aneg, 1340 .config_aneg = genphy_config_aneg,
1334 .read_status = genphy_read_status, 1341 .read_status = genphy_read_status,
1335 .ack_interrupt = dp83640_ack_interrupt, 1342 .ack_interrupt = dp83640_ack_interrupt,
diff --git a/drivers/net/phy/mdio-sun4i.c b/drivers/net/phy/mdio-sun4i.c
index bb88bc7d81fb..9367acc84fbb 100644
--- a/drivers/net/phy/mdio-sun4i.c
+++ b/drivers/net/phy/mdio-sun4i.c
@@ -170,6 +170,9 @@ static int sun4i_mdio_remove(struct platform_device *pdev)
170} 170}
171 171
172static const struct of_device_id sun4i_mdio_dt_ids[] = { 172static const struct of_device_id sun4i_mdio_dt_ids[] = {
173 { .compatible = "allwinner,sun4i-a10-mdio" },
174
175 /* Deprecated */
173 { .compatible = "allwinner,sun4i-mdio" }, 176 { .compatible = "allwinner,sun4i-mdio" },
174 { } 177 { }
175}; 178};
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c
index 4b03e63639b7..82514e72b3d8 100644
--- a/drivers/net/phy/phy_device.c
+++ b/drivers/net/phy/phy_device.c
@@ -719,7 +719,7 @@ int phy_resume(struct phy_device *phydev)
719static int genphy_config_advert(struct phy_device *phydev) 719static int genphy_config_advert(struct phy_device *phydev)
720{ 720{
721 u32 advertise; 721 u32 advertise;
722 int oldadv, adv; 722 int oldadv, adv, bmsr;
723 int err, changed = 0; 723 int err, changed = 0;
724 724
725 /* Only allow advertising what this PHY supports */ 725 /* Only allow advertising what this PHY supports */
@@ -744,26 +744,36 @@ static int genphy_config_advert(struct phy_device *phydev)
744 changed = 1; 744 changed = 1;
745 } 745 }
746 746
747 bmsr = phy_read(phydev, MII_BMSR);
748 if (bmsr < 0)
749 return bmsr;
750
751 /* Per 802.3-2008, Section 22.2.4.2.16 Extended status all
752 * 1000Mbits/sec capable PHYs shall have the BMSR_ESTATEN bit set to a
753 * logical 1.
754 */
755 if (!(bmsr & BMSR_ESTATEN))
756 return changed;
757
747 /* Configure gigabit if it's supported */ 758 /* Configure gigabit if it's supported */
759 adv = phy_read(phydev, MII_CTRL1000);
760 if (adv < 0)
761 return adv;
762
763 oldadv = adv;
764 adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
765
748 if (phydev->supported & (SUPPORTED_1000baseT_Half | 766 if (phydev->supported & (SUPPORTED_1000baseT_Half |
749 SUPPORTED_1000baseT_Full)) { 767 SUPPORTED_1000baseT_Full)) {
750 adv = phy_read(phydev, MII_CTRL1000);
751 if (adv < 0)
752 return adv;
753
754 oldadv = adv;
755 adv &= ~(ADVERTISE_1000FULL | ADVERTISE_1000HALF);
756 adv |= ethtool_adv_to_mii_ctrl1000_t(advertise); 768 adv |= ethtool_adv_to_mii_ctrl1000_t(advertise);
757 769 if (adv != oldadv)
758 if (adv != oldadv) {
759 err = phy_write(phydev, MII_CTRL1000, adv);
760
761 if (err < 0)
762 return err;
763 changed = 1; 770 changed = 1;
764 }
765 } 771 }
766 772
773 err = phy_write(phydev, MII_CTRL1000, adv);
774 if (err < 0)
775 return err;
776
767 return changed; 777 return changed;
768} 778}
769 779
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 6b638a066c1d..409499fdb157 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -292,6 +292,22 @@ config USB_NET_SR9700
292 This option adds support for CoreChip-sz SR9700 based USB 1.1 292 This option adds support for CoreChip-sz SR9700 based USB 1.1
293 10/100 Ethernet adapters. 293 10/100 Ethernet adapters.
294 294
295config USB_NET_SR9800
296 tristate "CoreChip-sz SR9800 based USB 2.0 10/100 ethernet devices"
297 depends on USB_USBNET
298 select CRC32
299 default y
300 ---help---
301 Say Y if you want to use one of the following 100Mbps USB Ethernet
302 device based on the CoreChip-sz SR9800 chip.
303
304 This driver makes the adapter appear as a normal Ethernet interface,
305 typically on eth0, if it is the only ethernet device, or perhaps on
306 eth1, if you have a PCI or ISA ethernet card installed.
307
308 To compile this driver as a module, choose M here: the
309 module will be called sr9800.
310
295config USB_NET_SMSC75XX 311config USB_NET_SMSC75XX
296 tristate "SMSC LAN75XX based USB 2.0 gigabit ethernet devices" 312 tristate "SMSC LAN75XX based USB 2.0 gigabit ethernet devices"
297 depends on USB_USBNET 313 depends on USB_USBNET
diff --git a/drivers/net/usb/Makefile b/drivers/net/usb/Makefile
index b17b5e88bbaf..433f0a00c683 100644
--- a/drivers/net/usb/Makefile
+++ b/drivers/net/usb/Makefile
@@ -15,6 +15,7 @@ obj-$(CONFIG_USB_NET_CDCETHER) += cdc_ether.o r815x.o
15obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o 15obj-$(CONFIG_USB_NET_CDC_EEM) += cdc_eem.o
16obj-$(CONFIG_USB_NET_DM9601) += dm9601.o 16obj-$(CONFIG_USB_NET_DM9601) += dm9601.o
17obj-$(CONFIG_USB_NET_SR9700) += sr9700.o 17obj-$(CONFIG_USB_NET_SR9700) += sr9700.o
18obj-$(CONFIG_USB_NET_SR9800) += sr9800.o
18obj-$(CONFIG_USB_NET_SMSC75XX) += smsc75xx.o 19obj-$(CONFIG_USB_NET_SMSC75XX) += smsc75xx.o
19obj-$(CONFIG_USB_NET_SMSC95XX) += smsc95xx.o 20obj-$(CONFIG_USB_NET_SMSC95XX) += smsc95xx.o
20obj-$(CONFIG_USB_NET_GL620A) += gl620a.o 21obj-$(CONFIG_USB_NET_GL620A) += gl620a.o
diff --git a/drivers/net/usb/hso.c b/drivers/net/usb/hso.c
index 1a482344b3f5..660bd5ea9fc0 100644
--- a/drivers/net/usb/hso.c
+++ b/drivers/net/usb/hso.c
@@ -1201,16 +1201,18 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
1201 struct hso_serial *serial = urb->context; 1201 struct hso_serial *serial = urb->context;
1202 int status = urb->status; 1202 int status = urb->status;
1203 1203
1204 D4("\n--- Got serial_read_bulk callback %02x ---", status);
1205
1204 /* sanity check */ 1206 /* sanity check */
1205 if (!serial) { 1207 if (!serial) {
1206 D1("serial == NULL"); 1208 D1("serial == NULL");
1207 return; 1209 return;
1208 } else if (status) { 1210 }
1211 if (status) {
1209 handle_usb_error(status, __func__, serial->parent); 1212 handle_usb_error(status, __func__, serial->parent);
1210 return; 1213 return;
1211 } 1214 }
1212 1215
1213 D4("\n--- Got serial_read_bulk callback %02x ---", status);
1214 D1("Actual length = %d\n", urb->actual_length); 1216 D1("Actual length = %d\n", urb->actual_length);
1215 DUMP1(urb->transfer_buffer, urb->actual_length); 1217 DUMP1(urb->transfer_buffer, urb->actual_length);
1216 1218
@@ -1218,25 +1220,13 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
1218 if (serial->port.count == 0) 1220 if (serial->port.count == 0)
1219 return; 1221 return;
1220 1222
1221 if (status == 0) { 1223 if (serial->parent->port_spec & HSO_INFO_CRC_BUG)
1222 if (serial->parent->port_spec & HSO_INFO_CRC_BUG) 1224 fix_crc_bug(urb, serial->in_endp->wMaxPacketSize);
1223 fix_crc_bug(urb, serial->in_endp->wMaxPacketSize); 1225 /* Valid data, handle RX data */
1224 /* Valid data, handle RX data */ 1226 spin_lock(&serial->serial_lock);
1225 spin_lock(&serial->serial_lock); 1227 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1;
1226 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1; 1228 put_rxbuf_data_and_resubmit_bulk_urb(serial);
1227 put_rxbuf_data_and_resubmit_bulk_urb(serial); 1229 spin_unlock(&serial->serial_lock);
1228 spin_unlock(&serial->serial_lock);
1229 } else if (status == -ENOENT || status == -ECONNRESET) {
1230 /* Unlinked - check for throttled port. */
1231 D2("Port %d, successfully unlinked urb", serial->minor);
1232 spin_lock(&serial->serial_lock);
1233 serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 0;
1234 hso_resubmit_rx_bulk_urb(serial, urb);
1235 spin_unlock(&serial->serial_lock);
1236 } else {
1237 D2("Port %d, status = %d for read urb", serial->minor, status);
1238 return;
1239 }
1240} 1230}
1241 1231
1242/* 1232/*
diff --git a/drivers/net/usb/qmi_wwan.c b/drivers/net/usb/qmi_wwan.c
index 23bdd5b9274d..ff5c87128ffe 100644
--- a/drivers/net/usb/qmi_wwan.c
+++ b/drivers/net/usb/qmi_wwan.c
@@ -712,6 +712,7 @@ static const struct usb_device_id products[] = {
712 {QMI_FIXED_INTF(0x19d2, 0x1255, 3)}, 712 {QMI_FIXED_INTF(0x19d2, 0x1255, 3)},
713 {QMI_FIXED_INTF(0x19d2, 0x1255, 4)}, 713 {QMI_FIXED_INTF(0x19d2, 0x1255, 4)},
714 {QMI_FIXED_INTF(0x19d2, 0x1256, 4)}, 714 {QMI_FIXED_INTF(0x19d2, 0x1256, 4)},
715 {QMI_FIXED_INTF(0x19d2, 0x1270, 5)}, /* ZTE MF667 */
715 {QMI_FIXED_INTF(0x19d2, 0x1401, 2)}, 716 {QMI_FIXED_INTF(0x19d2, 0x1401, 2)},
716 {QMI_FIXED_INTF(0x19d2, 0x1402, 2)}, /* ZTE MF60 */ 717 {QMI_FIXED_INTF(0x19d2, 0x1402, 2)}, /* ZTE MF60 */
717 {QMI_FIXED_INTF(0x19d2, 0x1424, 2)}, 718 {QMI_FIXED_INTF(0x19d2, 0x1424, 2)},
@@ -723,6 +724,7 @@ static const struct usb_device_id products[] = {
723 {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */ 724 {QMI_FIXED_INTF(0x1199, 0x68a2, 8)}, /* Sierra Wireless MC7710 in QMI mode */
724 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */ 725 {QMI_FIXED_INTF(0x1199, 0x68a2, 19)}, /* Sierra Wireless MC7710 in QMI mode */
725 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */ 726 {QMI_FIXED_INTF(0x1199, 0x901c, 8)}, /* Sierra Wireless EM7700 */
727 {QMI_FIXED_INTF(0x1199, 0x9051, 8)}, /* Netgear AirCard 340U */
726 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */ 728 {QMI_FIXED_INTF(0x1bbb, 0x011e, 4)}, /* Telekom Speedstick LTE II (Alcatel One Touch L100V LTE) */
727 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */ 729 {QMI_FIXED_INTF(0x2357, 0x0201, 4)}, /* TP-LINK HSUPA Modem MA180 */
728 {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */ 730 {QMI_FIXED_INTF(0x2357, 0x9000, 4)}, /* TP-LINK MA260 */
diff --git a/drivers/net/usb/r8152.c b/drivers/net/usb/r8152.c
index e8fac732c6f1..d89dbe395ad2 100644
--- a/drivers/net/usb/r8152.c
+++ b/drivers/net/usb/r8152.c
@@ -2273,22 +2273,21 @@ static int rtl8152_open(struct net_device *netdev)
2273 struct r8152 *tp = netdev_priv(netdev); 2273 struct r8152 *tp = netdev_priv(netdev);
2274 int res = 0; 2274 int res = 0;
2275 2275
2276 rtl8152_set_speed(tp, AUTONEG_ENABLE,
2277 tp->mii.supports_gmii ? SPEED_1000 : SPEED_100,
2278 DUPLEX_FULL);
2279 tp->speed = 0;
2280 netif_carrier_off(netdev);
2281 netif_start_queue(netdev);
2282 set_bit(WORK_ENABLE, &tp->flags);
2276 res = usb_submit_urb(tp->intr_urb, GFP_KERNEL); 2283 res = usb_submit_urb(tp->intr_urb, GFP_KERNEL);
2277 if (res) { 2284 if (res) {
2278 if (res == -ENODEV) 2285 if (res == -ENODEV)
2279 netif_device_detach(tp->netdev); 2286 netif_device_detach(tp->netdev);
2280 netif_warn(tp, ifup, netdev, "intr_urb submit failed: %d\n", 2287 netif_warn(tp, ifup, netdev, "intr_urb submit failed: %d\n",
2281 res); 2288 res);
2282 return res;
2283 } 2289 }
2284 2290
2285 rtl8152_set_speed(tp, AUTONEG_ENABLE,
2286 tp->mii.supports_gmii ? SPEED_1000 : SPEED_100,
2287 DUPLEX_FULL);
2288 tp->speed = 0;
2289 netif_carrier_off(netdev);
2290 netif_start_queue(netdev);
2291 set_bit(WORK_ENABLE, &tp->flags);
2292 2291
2293 return res; 2292 return res;
2294} 2293}
@@ -2298,8 +2297,8 @@ static int rtl8152_close(struct net_device *netdev)
2298 struct r8152 *tp = netdev_priv(netdev); 2297 struct r8152 *tp = netdev_priv(netdev);
2299 int res = 0; 2298 int res = 0;
2300 2299
2301 usb_kill_urb(tp->intr_urb);
2302 clear_bit(WORK_ENABLE, &tp->flags); 2300 clear_bit(WORK_ENABLE, &tp->flags);
2301 usb_kill_urb(tp->intr_urb);
2303 cancel_delayed_work_sync(&tp->schedule); 2302 cancel_delayed_work_sync(&tp->schedule);
2304 netif_stop_queue(netdev); 2303 netif_stop_queue(netdev);
2305 tasklet_disable(&tp->tl); 2304 tasklet_disable(&tp->tl);
diff --git a/drivers/net/usb/sr9800.c b/drivers/net/usb/sr9800.c
new file mode 100644
index 000000000000..4175eb9fdeca
--- /dev/null
+++ b/drivers/net/usb/sr9800.c
@@ -0,0 +1,870 @@
1/* CoreChip-sz SR9800 one chip USB 2.0 Ethernet Devices
2 *
3 * Author : Liu Junliang <liujunliang_ljl@163.com>
4 *
5 * Based on asix_common.c, asix_devices.c
6 *
7 * This file is licensed under the terms of the GNU General Public License
8 * version 2. This program is licensed "as is" without any warranty of any
9 * kind, whether express or implied.*
10 */
11
12#include <linux/module.h>
13#include <linux/kmod.h>
14#include <linux/init.h>
15#include <linux/netdevice.h>
16#include <linux/etherdevice.h>
17#include <linux/ethtool.h>
18#include <linux/workqueue.h>
19#include <linux/mii.h>
20#include <linux/usb.h>
21#include <linux/crc32.h>
22#include <linux/usb/usbnet.h>
23#include <linux/slab.h>
24#include <linux/if_vlan.h>
25
26#include "sr9800.h"
27
28static int sr_read_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
29 u16 size, void *data)
30{
31 int err;
32
33 err = usbnet_read_cmd(dev, cmd, SR_REQ_RD_REG, value, index,
34 data, size);
35 if ((err != size) && (err >= 0))
36 err = -EINVAL;
37
38 return err;
39}
40
41static int sr_write_cmd(struct usbnet *dev, u8 cmd, u16 value, u16 index,
42 u16 size, void *data)
43{
44 int err;
45
46 err = usbnet_write_cmd(dev, cmd, SR_REQ_WR_REG, value, index,
47 data, size);
48 if ((err != size) && (err >= 0))
49 err = -EINVAL;
50
51 return err;
52}
53
54static void
55sr_write_cmd_async(struct usbnet *dev, u8 cmd, u16 value, u16 index,
56 u16 size, void *data)
57{
58 usbnet_write_cmd_async(dev, cmd, SR_REQ_WR_REG, value, index, data,
59 size);
60}
61
62static int sr_rx_fixup(struct usbnet *dev, struct sk_buff *skb)
63{
64 int offset = 0;
65
66 while (offset + sizeof(u32) < skb->len) {
67 struct sk_buff *sr_skb;
68 u16 size;
69 u32 header = get_unaligned_le32(skb->data + offset);
70
71 offset += sizeof(u32);
72 /* get the packet length */
73 size = (u16) (header & 0x7ff);
74 if (size != ((~header >> 16) & 0x07ff)) {
75 netdev_err(dev->net, "%s : Bad Header Length\n",
76 __func__);
77 return 0;
78 }
79
80 if ((size > dev->net->mtu + ETH_HLEN + VLAN_HLEN) ||
81 (size + offset > skb->len)) {
82 netdev_err(dev->net, "%s : Bad RX Length %d\n",
83 __func__, size);
84 return 0;
85 }
86 sr_skb = netdev_alloc_skb_ip_align(dev->net, size);
87 if (!sr_skb)
88 return 0;
89
90 skb_put(sr_skb, size);
91 memcpy(sr_skb->data, skb->data + offset, size);
92 usbnet_skb_return(dev, sr_skb);
93
94 offset += (size + 1) & 0xfffe;
95 }
96
97 if (skb->len != offset) {
98 netdev_err(dev->net, "%s : Bad SKB Length %d\n", __func__,
99 skb->len);
100 return 0;
101 }
102
103 return 1;
104}
105
106static struct sk_buff *sr_tx_fixup(struct usbnet *dev, struct sk_buff *skb,
107 gfp_t flags)
108{
109 int headroom = skb_headroom(skb);
110 int tailroom = skb_tailroom(skb);
111 u32 padbytes = 0xffff0000;
112 u32 packet_len;
113 int padlen;
114
115 padlen = ((skb->len + 4) % (dev->maxpacket - 1)) ? 0 : 4;
116
117 if ((!skb_cloned(skb)) && ((headroom + tailroom) >= (4 + padlen))) {
118 if ((headroom < 4) || (tailroom < padlen)) {
119 skb->data = memmove(skb->head + 4, skb->data,
120 skb->len);
121 skb_set_tail_pointer(skb, skb->len);
122 }
123 } else {
124 struct sk_buff *skb2;
125 skb2 = skb_copy_expand(skb, 4, padlen, flags);
126 dev_kfree_skb_any(skb);
127 skb = skb2;
128 if (!skb)
129 return NULL;
130 }
131
132 skb_push(skb, 4);
133 packet_len = (((skb->len - 4) ^ 0x0000ffff) << 16) + (skb->len - 4);
134 cpu_to_le32s(&packet_len);
135 skb_copy_to_linear_data(skb, &packet_len, sizeof(packet_len));
136
137 if (padlen) {
138 cpu_to_le32s(&padbytes);
139 memcpy(skb_tail_pointer(skb), &padbytes, sizeof(padbytes));
140 skb_put(skb, sizeof(padbytes));
141 }
142
143 return skb;
144}
145
146static void sr_status(struct usbnet *dev, struct urb *urb)
147{
148 struct sr9800_int_data *event;
149 int link;
150
151 if (urb->actual_length < 8)
152 return;
153
154 event = urb->transfer_buffer;
155 link = event->link & 0x01;
156 if (netif_carrier_ok(dev->net) != link) {
157 usbnet_link_change(dev, link, 1);
158 netdev_dbg(dev->net, "Link Status is: %d\n", link);
159 }
160
161 return;
162}
163
164static inline int sr_set_sw_mii(struct usbnet *dev)
165{
166 int ret;
167
168 ret = sr_write_cmd(dev, SR_CMD_SET_SW_MII, 0x0000, 0, 0, NULL);
169 if (ret < 0)
170 netdev_err(dev->net, "Failed to enable software MII access\n");
171 return ret;
172}
173
174static inline int sr_set_hw_mii(struct usbnet *dev)
175{
176 int ret;
177
178 ret = sr_write_cmd(dev, SR_CMD_SET_HW_MII, 0x0000, 0, 0, NULL);
179 if (ret < 0)
180 netdev_err(dev->net, "Failed to enable hardware MII access\n");
181 return ret;
182}
183
184static inline int sr_get_phy_addr(struct usbnet *dev)
185{
186 u8 buf[2];
187 int ret;
188
189 ret = sr_read_cmd(dev, SR_CMD_READ_PHY_ID, 0, 0, 2, buf);
190 if (ret < 0) {
191 netdev_err(dev->net, "%s : Error reading PHYID register:%02x\n",
192 __func__, ret);
193 goto out;
194 }
195 netdev_dbg(dev->net, "%s : returning 0x%04x\n", __func__,
196 *((__le16 *)buf));
197
198 ret = buf[1];
199
200out:
201 return ret;
202}
203
204static int sr_sw_reset(struct usbnet *dev, u8 flags)
205{
206 int ret;
207
208 ret = sr_write_cmd(dev, SR_CMD_SW_RESET, flags, 0, 0, NULL);
209 if (ret < 0)
210 netdev_err(dev->net, "Failed to send software reset:%02x\n",
211 ret);
212
213 return ret;
214}
215
216static u16 sr_read_rx_ctl(struct usbnet *dev)
217{
218 __le16 v;
219 int ret;
220
221 ret = sr_read_cmd(dev, SR_CMD_READ_RX_CTL, 0, 0, 2, &v);
222 if (ret < 0) {
223 netdev_err(dev->net, "Error reading RX_CTL register:%02x\n",
224 ret);
225 goto out;
226 }
227
228 ret = le16_to_cpu(v);
229out:
230 return ret;
231}
232
233static int sr_write_rx_ctl(struct usbnet *dev, u16 mode)
234{
235 int ret;
236
237 netdev_dbg(dev->net, "%s : mode = 0x%04x\n", __func__, mode);
238 ret = sr_write_cmd(dev, SR_CMD_WRITE_RX_CTL, mode, 0, 0, NULL);
239 if (ret < 0)
240 netdev_err(dev->net,
241 "Failed to write RX_CTL mode to 0x%04x:%02x\n",
242 mode, ret);
243
244 return ret;
245}
246
247static u16 sr_read_medium_status(struct usbnet *dev)
248{
249 __le16 v;
250 int ret;
251
252 ret = sr_read_cmd(dev, SR_CMD_READ_MEDIUM_STATUS, 0, 0, 2, &v);
253 if (ret < 0) {
254 netdev_err(dev->net,
255 "Error reading Medium Status register:%02x\n", ret);
256 return ret; /* TODO: callers not checking for error ret */
257 }
258
259 return le16_to_cpu(v);
260}
261
262static int sr_write_medium_mode(struct usbnet *dev, u16 mode)
263{
264 int ret;
265
266 netdev_dbg(dev->net, "%s : mode = 0x%04x\n", __func__, mode);
267 ret = sr_write_cmd(dev, SR_CMD_WRITE_MEDIUM_MODE, mode, 0, 0, NULL);
268 if (ret < 0)
269 netdev_err(dev->net,
270 "Failed to write Medium Mode mode to 0x%04x:%02x\n",
271 mode, ret);
272 return ret;
273}
274
275static int sr_write_gpio(struct usbnet *dev, u16 value, int sleep)
276{
277 int ret;
278
279 netdev_dbg(dev->net, "%s : value = 0x%04x\n", __func__, value);
280 ret = sr_write_cmd(dev, SR_CMD_WRITE_GPIOS, value, 0, 0, NULL);
281 if (ret < 0)
282 netdev_err(dev->net, "Failed to write GPIO value 0x%04x:%02x\n",
283 value, ret);
284 if (sleep)
285 msleep(sleep);
286
287 return ret;
288}
289
290/* SR9800 have a 16-bit RX_CTL value */
291static void sr_set_multicast(struct net_device *net)
292{
293 struct usbnet *dev = netdev_priv(net);
294 struct sr_data *data = (struct sr_data *)&dev->data;
295 u16 rx_ctl = SR_DEFAULT_RX_CTL;
296
297 if (net->flags & IFF_PROMISC) {
298 rx_ctl |= SR_RX_CTL_PRO;
299 } else if (net->flags & IFF_ALLMULTI ||
300 netdev_mc_count(net) > SR_MAX_MCAST) {
301 rx_ctl |= SR_RX_CTL_AMALL;
302 } else if (netdev_mc_empty(net)) {
303 /* just broadcast and directed */
304 } else {
305 /* We use the 20 byte dev->data
306 * for our 8 byte filter buffer
307 * to avoid allocating memory that
308 * is tricky to free later
309 */
310 struct netdev_hw_addr *ha;
311 u32 crc_bits;
312
313 memset(data->multi_filter, 0, SR_MCAST_FILTER_SIZE);
314
315 /* Build the multicast hash filter. */
316 netdev_for_each_mc_addr(ha, net) {
317 crc_bits = ether_crc(ETH_ALEN, ha->addr) >> 26;
318 data->multi_filter[crc_bits >> 3] |=
319 1 << (crc_bits & 7);
320 }
321
322 sr_write_cmd_async(dev, SR_CMD_WRITE_MULTI_FILTER, 0, 0,
323 SR_MCAST_FILTER_SIZE, data->multi_filter);
324
325 rx_ctl |= SR_RX_CTL_AM;
326 }
327
328 sr_write_cmd_async(dev, SR_CMD_WRITE_RX_CTL, rx_ctl, 0, 0, NULL);
329}
330
331static int sr_mdio_read(struct net_device *net, int phy_id, int loc)
332{
333 struct usbnet *dev = netdev_priv(net);
334 __le16 res;
335
336 mutex_lock(&dev->phy_mutex);
337 sr_set_sw_mii(dev);
338 sr_read_cmd(dev, SR_CMD_READ_MII_REG, phy_id, (__u16)loc, 2, &res);
339 sr_set_hw_mii(dev);
340 mutex_unlock(&dev->phy_mutex);
341
342 netdev_dbg(dev->net,
343 "%s : phy_id=0x%02x, loc=0x%02x, returns=0x%04x\n", __func__,
344 phy_id, loc, le16_to_cpu(res));
345
346 return le16_to_cpu(res);
347}
348
349static void
350sr_mdio_write(struct net_device *net, int phy_id, int loc, int val)
351{
352 struct usbnet *dev = netdev_priv(net);
353 __le16 res = cpu_to_le16(val);
354
355 netdev_dbg(dev->net,
356 "%s : phy_id=0x%02x, loc=0x%02x, val=0x%04x\n", __func__,
357 phy_id, loc, val);
358 mutex_lock(&dev->phy_mutex);
359 sr_set_sw_mii(dev);
360 sr_write_cmd(dev, SR_CMD_WRITE_MII_REG, phy_id, (__u16)loc, 2, &res);
361 sr_set_hw_mii(dev);
362 mutex_unlock(&dev->phy_mutex);
363}
364
365/* Get the PHY Identifier from the PHYSID1 & PHYSID2 MII registers */
366static u32 sr_get_phyid(struct usbnet *dev)
367{
368 int phy_reg;
369 u32 phy_id;
370 int i;
371
372 /* Poll for the rare case the FW or phy isn't ready yet. */
373 for (i = 0; i < 100; i++) {
374 phy_reg = sr_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID1);
375 if (phy_reg != 0 && phy_reg != 0xFFFF)
376 break;
377 mdelay(1);
378 }
379
380 if (phy_reg <= 0 || phy_reg == 0xFFFF)
381 return 0;
382
383 phy_id = (phy_reg & 0xffff) << 16;
384
385 phy_reg = sr_mdio_read(dev->net, dev->mii.phy_id, MII_PHYSID2);
386 if (phy_reg < 0)
387 return 0;
388
389 phy_id |= (phy_reg & 0xffff);
390
391 return phy_id;
392}
393
394static void
395sr_get_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
396{
397 struct usbnet *dev = netdev_priv(net);
398 u8 opt;
399
400 if (sr_read_cmd(dev, SR_CMD_READ_MONITOR_MODE, 0, 0, 1, &opt) < 0) {
401 wolinfo->supported = 0;
402 wolinfo->wolopts = 0;
403 return;
404 }
405 wolinfo->supported = WAKE_PHY | WAKE_MAGIC;
406 wolinfo->wolopts = 0;
407 if (opt & SR_MONITOR_LINK)
408 wolinfo->wolopts |= WAKE_PHY;
409 if (opt & SR_MONITOR_MAGIC)
410 wolinfo->wolopts |= WAKE_MAGIC;
411}
412
413static int
414sr_set_wol(struct net_device *net, struct ethtool_wolinfo *wolinfo)
415{
416 struct usbnet *dev = netdev_priv(net);
417 u8 opt = 0;
418
419 if (wolinfo->wolopts & WAKE_PHY)
420 opt |= SR_MONITOR_LINK;
421 if (wolinfo->wolopts & WAKE_MAGIC)
422 opt |= SR_MONITOR_MAGIC;
423
424 if (sr_write_cmd(dev, SR_CMD_WRITE_MONITOR_MODE,
425 opt, 0, 0, NULL) < 0)
426 return -EINVAL;
427
428 return 0;
429}
430
431static int sr_get_eeprom_len(struct net_device *net)
432{
433 struct usbnet *dev = netdev_priv(net);
434 struct sr_data *data = (struct sr_data *)&dev->data;
435
436 return data->eeprom_len;
437}
438
439static int sr_get_eeprom(struct net_device *net,
440 struct ethtool_eeprom *eeprom, u8 *data)
441{
442 struct usbnet *dev = netdev_priv(net);
443 __le16 *ebuf = (__le16 *)data;
444 int ret;
445 int i;
446
447 /* Crude hack to ensure that we don't overwrite memory
448 * if an odd length is supplied
449 */
450 if (eeprom->len % 2)
451 return -EINVAL;
452
453 eeprom->magic = SR_EEPROM_MAGIC;
454
455 /* sr9800 returns 2 bytes from eeprom on read */
456 for (i = 0; i < eeprom->len / 2; i++) {
457 ret = sr_read_cmd(dev, SR_CMD_READ_EEPROM, eeprom->offset + i,
458 0, 2, &ebuf[i]);
459 if (ret < 0)
460 return -EINVAL;
461 }
462 return 0;
463}
464
465static void sr_get_drvinfo(struct net_device *net,
466 struct ethtool_drvinfo *info)
467{
468 struct usbnet *dev = netdev_priv(net);
469 struct sr_data *data = (struct sr_data *)&dev->data;
470
471 /* Inherit standard device info */
472 usbnet_get_drvinfo(net, info);
473 strncpy(info->driver, DRIVER_NAME, sizeof(info->driver));
474 strncpy(info->version, DRIVER_VERSION, sizeof(info->version));
475 info->eedump_len = data->eeprom_len;
476}
477
478static u32 sr_get_link(struct net_device *net)
479{
480 struct usbnet *dev = netdev_priv(net);
481
482 return mii_link_ok(&dev->mii);
483}
484
485static int sr_ioctl(struct net_device *net, struct ifreq *rq, int cmd)
486{
487 struct usbnet *dev = netdev_priv(net);
488
489 return generic_mii_ioctl(&dev->mii, if_mii(rq), cmd, NULL);
490}
491
492static int sr_set_mac_address(struct net_device *net, void *p)
493{
494 struct usbnet *dev = netdev_priv(net);
495 struct sr_data *data = (struct sr_data *)&dev->data;
496 struct sockaddr *addr = p;
497
498 if (netif_running(net))
499 return -EBUSY;
500 if (!is_valid_ether_addr(addr->sa_data))
501 return -EADDRNOTAVAIL;
502
503 memcpy(net->dev_addr, addr->sa_data, ETH_ALEN);
504
505 /* We use the 20 byte dev->data
506 * for our 6 byte mac buffer
507 * to avoid allocating memory that
508 * is tricky to free later
509 */
510 memcpy(data->mac_addr, addr->sa_data, ETH_ALEN);
511 sr_write_cmd_async(dev, SR_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
512 data->mac_addr);
513
514 return 0;
515}
516
517static const struct ethtool_ops sr9800_ethtool_ops = {
518 .get_drvinfo = sr_get_drvinfo,
519 .get_link = sr_get_link,
520 .get_msglevel = usbnet_get_msglevel,
521 .set_msglevel = usbnet_set_msglevel,
522 .get_wol = sr_get_wol,
523 .set_wol = sr_set_wol,
524 .get_eeprom_len = sr_get_eeprom_len,
525 .get_eeprom = sr_get_eeprom,
526 .get_settings = usbnet_get_settings,
527 .set_settings = usbnet_set_settings,
528 .nway_reset = usbnet_nway_reset,
529};
530
531static int sr9800_link_reset(struct usbnet *dev)
532{
533 struct ethtool_cmd ecmd = { .cmd = ETHTOOL_GSET };
534 u16 mode;
535
536 mii_check_media(&dev->mii, 1, 1);
537 mii_ethtool_gset(&dev->mii, &ecmd);
538 mode = SR9800_MEDIUM_DEFAULT;
539
540 if (ethtool_cmd_speed(&ecmd) != SPEED_100)
541 mode &= ~SR_MEDIUM_PS;
542
543 if (ecmd.duplex != DUPLEX_FULL)
544 mode &= ~SR_MEDIUM_FD;
545
546 netdev_dbg(dev->net, "%s : speed: %u duplex: %d mode: 0x%04x\n",
547 __func__, ethtool_cmd_speed(&ecmd), ecmd.duplex, mode);
548
549 sr_write_medium_mode(dev, mode);
550
551 return 0;
552}
553
554
555static int sr9800_set_default_mode(struct usbnet *dev)
556{
557 u16 rx_ctl;
558 int ret;
559
560 sr_mdio_write(dev->net, dev->mii.phy_id, MII_BMCR, BMCR_RESET);
561 sr_mdio_write(dev->net, dev->mii.phy_id, MII_ADVERTISE,
562 ADVERTISE_ALL | ADVERTISE_CSMA);
563 mii_nway_restart(&dev->mii);
564
565 ret = sr_write_medium_mode(dev, SR9800_MEDIUM_DEFAULT);
566 if (ret < 0)
567 goto out;
568
569 ret = sr_write_cmd(dev, SR_CMD_WRITE_IPG012,
570 SR9800_IPG0_DEFAULT | SR9800_IPG1_DEFAULT,
571 SR9800_IPG2_DEFAULT, 0, NULL);
572 if (ret < 0) {
573 netdev_dbg(dev->net, "Write IPG,IPG1,IPG2 failed: %d\n", ret);
574 goto out;
575 }
576
577 /* Set RX_CTL to default values with 2k buffer, and enable cactus */
578 ret = sr_write_rx_ctl(dev, SR_DEFAULT_RX_CTL);
579 if (ret < 0)
580 goto out;
581
582 rx_ctl = sr_read_rx_ctl(dev);
583 netdev_dbg(dev->net, "RX_CTL is 0x%04x after all initializations\n",
584 rx_ctl);
585
586 rx_ctl = sr_read_medium_status(dev);
587 netdev_dbg(dev->net, "Medium Status:0x%04x after all initializations\n",
588 rx_ctl);
589
590 return 0;
591out:
592 return ret;
593}
594
595static int sr9800_reset(struct usbnet *dev)
596{
597 struct sr_data *data = (struct sr_data *)&dev->data;
598 int ret, embd_phy;
599 u16 rx_ctl;
600
601 ret = sr_write_gpio(dev,
602 SR_GPIO_RSE | SR_GPIO_GPO_2 | SR_GPIO_GPO2EN, 5);
603 if (ret < 0)
604 goto out;
605
606 embd_phy = ((sr_get_phy_addr(dev) & 0x1f) == 0x10 ? 1 : 0);
607
608 ret = sr_write_cmd(dev, SR_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
609 if (ret < 0) {
610 netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
611 goto out;
612 }
613
614 ret = sr_sw_reset(dev, SR_SWRESET_IPPD | SR_SWRESET_PRL);
615 if (ret < 0)
616 goto out;
617
618 msleep(150);
619
620 ret = sr_sw_reset(dev, SR_SWRESET_CLEAR);
621 if (ret < 0)
622 goto out;
623
624 msleep(150);
625
626 if (embd_phy) {
627 ret = sr_sw_reset(dev, SR_SWRESET_IPRL);
628 if (ret < 0)
629 goto out;
630 } else {
631 ret = sr_sw_reset(dev, SR_SWRESET_PRTE);
632 if (ret < 0)
633 goto out;
634 }
635
636 msleep(150);
637 rx_ctl = sr_read_rx_ctl(dev);
638 netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl);
639 ret = sr_write_rx_ctl(dev, 0x0000);
640 if (ret < 0)
641 goto out;
642
643 rx_ctl = sr_read_rx_ctl(dev);
644 netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);
645
646 ret = sr_sw_reset(dev, SR_SWRESET_PRL);
647 if (ret < 0)
648 goto out;
649
650 msleep(150);
651
652 ret = sr_sw_reset(dev, SR_SWRESET_IPRL | SR_SWRESET_PRL);
653 if (ret < 0)
654 goto out;
655
656 msleep(150);
657
658 ret = sr9800_set_default_mode(dev);
659 if (ret < 0)
660 goto out;
661
662 /* Rewrite MAC address */
663 memcpy(data->mac_addr, dev->net->dev_addr, ETH_ALEN);
664 ret = sr_write_cmd(dev, SR_CMD_WRITE_NODE_ID, 0, 0, ETH_ALEN,
665 data->mac_addr);
666 if (ret < 0)
667 goto out;
668
669 return 0;
670
671out:
672 return ret;
673}
674
675static const struct net_device_ops sr9800_netdev_ops = {
676 .ndo_open = usbnet_open,
677 .ndo_stop = usbnet_stop,
678 .ndo_start_xmit = usbnet_start_xmit,
679 .ndo_tx_timeout = usbnet_tx_timeout,
680 .ndo_change_mtu = usbnet_change_mtu,
681 .ndo_set_mac_address = sr_set_mac_address,
682 .ndo_validate_addr = eth_validate_addr,
683 .ndo_do_ioctl = sr_ioctl,
684 .ndo_set_rx_mode = sr_set_multicast,
685};
686
687static int sr9800_phy_powerup(struct usbnet *dev)
688{
689 int ret;
690
691 /* set the embedded Ethernet PHY in power-down state */
692 ret = sr_sw_reset(dev, SR_SWRESET_IPPD | SR_SWRESET_IPRL);
693 if (ret < 0) {
694 netdev_err(dev->net, "Failed to power down PHY : %d\n", ret);
695 return ret;
696 }
697 msleep(20);
698
699 /* set the embedded Ethernet PHY in power-up state */
700 ret = sr_sw_reset(dev, SR_SWRESET_IPRL);
701 if (ret < 0) {
702 netdev_err(dev->net, "Failed to reset PHY: %d\n", ret);
703 return ret;
704 }
705 msleep(600);
706
707 /* set the embedded Ethernet PHY in reset state */
708 ret = sr_sw_reset(dev, SR_SWRESET_CLEAR);
709 if (ret < 0) {
710 netdev_err(dev->net, "Failed to power up PHY: %d\n", ret);
711 return ret;
712 }
713 msleep(20);
714
715 /* set the embedded Ethernet PHY in power-up state */
716 ret = sr_sw_reset(dev, SR_SWRESET_IPRL);
717 if (ret < 0) {
718 netdev_err(dev->net, "Failed to reset PHY: %d\n", ret);
719 return ret;
720 }
721
722 return 0;
723}
724
725static int sr9800_bind(struct usbnet *dev, struct usb_interface *intf)
726{
727 struct sr_data *data = (struct sr_data *)&dev->data;
728 u16 led01_mux, led23_mux;
729 int ret, embd_phy;
730 u32 phyid;
731 u16 rx_ctl;
732
733 data->eeprom_len = SR9800_EEPROM_LEN;
734
735 usbnet_get_endpoints(dev, intf);
736
737 /* LED Setting Rule :
738 * AABB:CCDD
739 * AA : MFA0(LED0)
740 * BB : MFA1(LED1)
741 * CC : MFA2(LED2), Reserved for SR9800
742 * DD : MFA3(LED3), Reserved for SR9800
743 */
744 led01_mux = (SR_LED_MUX_LINK_ACTIVE << 8) | SR_LED_MUX_LINK;
745 led23_mux = (SR_LED_MUX_LINK_ACTIVE << 8) | SR_LED_MUX_TX_ACTIVE;
746 ret = sr_write_cmd(dev, SR_CMD_LED_MUX, led01_mux, led23_mux, 0, NULL);
747 if (ret < 0) {
748 netdev_err(dev->net, "set LINK LED failed : %d\n", ret);
749 goto out;
750 }
751
752 /* Get the MAC address */
753 ret = sr_read_cmd(dev, SR_CMD_READ_NODE_ID, 0, 0, ETH_ALEN,
754 dev->net->dev_addr);
755 if (ret < 0) {
756 netdev_dbg(dev->net, "Failed to read MAC address: %d\n", ret);
757 return ret;
758 }
759 netdev_dbg(dev->net, "mac addr : %pM\n", dev->net->dev_addr);
760
761 /* Initialize MII structure */
762 dev->mii.dev = dev->net;
763 dev->mii.mdio_read = sr_mdio_read;
764 dev->mii.mdio_write = sr_mdio_write;
765 dev->mii.phy_id_mask = 0x1f;
766 dev->mii.reg_num_mask = 0x1f;
767 dev->mii.phy_id = sr_get_phy_addr(dev);
768
769 dev->net->netdev_ops = &sr9800_netdev_ops;
770 dev->net->ethtool_ops = &sr9800_ethtool_ops;
771
772 embd_phy = ((dev->mii.phy_id & 0x1f) == 0x10 ? 1 : 0);
773 /* Reset the PHY to normal operation mode */
774 ret = sr_write_cmd(dev, SR_CMD_SW_PHY_SELECT, embd_phy, 0, 0, NULL);
775 if (ret < 0) {
776 netdev_dbg(dev->net, "Select PHY #1 failed: %d\n", ret);
777 return ret;
778 }
779
780 /* Init PHY routine */
781 ret = sr9800_phy_powerup(dev);
782 if (ret < 0)
783 goto out;
784
785 rx_ctl = sr_read_rx_ctl(dev);
786 netdev_dbg(dev->net, "RX_CTL is 0x%04x after software reset\n", rx_ctl);
787 ret = sr_write_rx_ctl(dev, 0x0000);
788 if (ret < 0)
789 goto out;
790
791 rx_ctl = sr_read_rx_ctl(dev);
792 netdev_dbg(dev->net, "RX_CTL is 0x%04x setting to 0x0000\n", rx_ctl);
793
794 /* Read PHYID register *AFTER* the PHY was reset properly */
795 phyid = sr_get_phyid(dev);
796 netdev_dbg(dev->net, "PHYID=0x%08x\n", phyid);
797
798 /* medium mode setting */
799 ret = sr9800_set_default_mode(dev);
800 if (ret < 0)
801 goto out;
802
803 if (dev->udev->speed == USB_SPEED_HIGH) {
804 ret = sr_write_cmd(dev, SR_CMD_BULKIN_SIZE,
805 SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].byte_cnt,
806 SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].threshold,
807 0, NULL);
808 if (ret < 0) {
809 netdev_err(dev->net, "Reset RX_CTL failed: %d\n", ret);
810 goto out;
811 }
812 dev->rx_urb_size =
813 SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_4K].size;
814 } else {
815 ret = sr_write_cmd(dev, SR_CMD_BULKIN_SIZE,
816 SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].byte_cnt,
817 SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].threshold,
818 0, NULL);
819 if (ret < 0) {
820 netdev_err(dev->net, "Reset RX_CTL failed: %d\n", ret);
821 goto out;
822 }
823 dev->rx_urb_size =
824 SR9800_BULKIN_SIZE[SR9800_MAX_BULKIN_2K].size;
825 }
826 netdev_dbg(dev->net, "%s : setting rx_urb_size with : %ld\n", __func__,
827 dev->rx_urb_size);
828 return 0;
829
830out:
831 return ret;
832}
833
834static const struct driver_info sr9800_driver_info = {
835 .description = "CoreChip SR9800 USB 2.0 Ethernet",
836 .bind = sr9800_bind,
837 .status = sr_status,
838 .link_reset = sr9800_link_reset,
839 .reset = sr9800_reset,
840 .flags = DRIVER_FLAG,
841 .rx_fixup = sr_rx_fixup,
842 .tx_fixup = sr_tx_fixup,
843};
844
845static const struct usb_device_id products[] = {
846 {
847 USB_DEVICE(0x0fe6, 0x9800), /* SR9800 Device */
848 .driver_info = (unsigned long) &sr9800_driver_info,
849 },
850 {}, /* END */
851};
852
853MODULE_DEVICE_TABLE(usb, products);
854
855static struct usb_driver sr_driver = {
856 .name = DRIVER_NAME,
857 .id_table = products,
858 .probe = usbnet_probe,
859 .suspend = usbnet_suspend,
860 .resume = usbnet_resume,
861 .disconnect = usbnet_disconnect,
862 .supports_autosuspend = 1,
863};
864
865module_usb_driver(sr_driver);
866
867MODULE_AUTHOR("Liu Junliang <liujunliang_ljl@163.com");
868MODULE_VERSION(DRIVER_VERSION);
869MODULE_DESCRIPTION("SR9800 USB 2.0 USB2NET Dev : http://www.corechip-sz.com");
870MODULE_LICENSE("GPL");
diff --git a/drivers/net/usb/sr9800.h b/drivers/net/usb/sr9800.h
new file mode 100644
index 000000000000..18f670251275
--- /dev/null
+++ b/drivers/net/usb/sr9800.h
@@ -0,0 +1,202 @@
1/* CoreChip-sz SR9800 one chip USB 2.0 Ethernet Devices
2 *
3 * Author : Liu Junliang <liujunliang_ljl@163.com>
4 *
5 * This file is licensed under the terms of the GNU General Public License
6 * version 2. This program is licensed "as is" without any warranty of any
7 * kind, whether express or implied.
8 */
9
10#ifndef _SR9800_H
11#define _SR9800_H
12
13/* SR9800 spec. command table on Linux Platform */
14
15/* command : Software Station Management Control Reg */
16#define SR_CMD_SET_SW_MII 0x06
17/* command : PHY Read Reg */
18#define SR_CMD_READ_MII_REG 0x07
19/* command : PHY Write Reg */
20#define SR_CMD_WRITE_MII_REG 0x08
21/* command : Hardware Station Management Control Reg */
22#define SR_CMD_SET_HW_MII 0x0a
23/* command : SROM Read Reg */
24#define SR_CMD_READ_EEPROM 0x0b
25/* command : SROM Write Reg */
26#define SR_CMD_WRITE_EEPROM 0x0c
27/* command : SROM Write Enable Reg */
28#define SR_CMD_WRITE_ENABLE 0x0d
29/* command : SROM Write Disable Reg */
30#define SR_CMD_WRITE_DISABLE 0x0e
31/* command : RX Control Read Reg */
32#define SR_CMD_READ_RX_CTL 0x0f
33#define SR_RX_CTL_PRO (1 << 0)
34#define SR_RX_CTL_AMALL (1 << 1)
35#define SR_RX_CTL_SEP (1 << 2)
36#define SR_RX_CTL_AB (1 << 3)
37#define SR_RX_CTL_AM (1 << 4)
38#define SR_RX_CTL_AP (1 << 5)
39#define SR_RX_CTL_ARP (1 << 6)
40#define SR_RX_CTL_SO (1 << 7)
41#define SR_RX_CTL_RH1M (1 << 8)
42#define SR_RX_CTL_RH2M (1 << 9)
43#define SR_RX_CTL_RH3M (1 << 10)
44/* command : RX Control Write Reg */
45#define SR_CMD_WRITE_RX_CTL 0x10
46/* command : IPG0/IPG1/IPG2 Control Read Reg */
47#define SR_CMD_READ_IPG012 0x11
48/* command : IPG0/IPG1/IPG2 Control Write Reg */
49#define SR_CMD_WRITE_IPG012 0x12
50/* command : Node ID Read Reg */
51#define SR_CMD_READ_NODE_ID 0x13
52/* command : Node ID Write Reg */
53#define SR_CMD_WRITE_NODE_ID 0x14
54/* command : Multicast Filter Array Read Reg */
55#define SR_CMD_READ_MULTI_FILTER 0x15
56/* command : Multicast Filter Array Write Reg */
57#define SR_CMD_WRITE_MULTI_FILTER 0x16
58/* command : Eth/HomePNA PHY Address Reg */
59#define SR_CMD_READ_PHY_ID 0x19
60/* command : Medium Status Read Reg */
61#define SR_CMD_READ_MEDIUM_STATUS 0x1a
62#define SR_MONITOR_LINK (1 << 1)
63#define SR_MONITOR_MAGIC (1 << 2)
64#define SR_MONITOR_HSFS (1 << 4)
65/* command : Medium Status Write Reg */
66#define SR_CMD_WRITE_MEDIUM_MODE 0x1b
67#define SR_MEDIUM_GM (1 << 0)
68#define SR_MEDIUM_FD (1 << 1)
69#define SR_MEDIUM_AC (1 << 2)
70#define SR_MEDIUM_ENCK (1 << 3)
71#define SR_MEDIUM_RFC (1 << 4)
72#define SR_MEDIUM_TFC (1 << 5)
73#define SR_MEDIUM_JFE (1 << 6)
74#define SR_MEDIUM_PF (1 << 7)
75#define SR_MEDIUM_RE (1 << 8)
76#define SR_MEDIUM_PS (1 << 9)
77#define SR_MEDIUM_RSV (1 << 10)
78#define SR_MEDIUM_SBP (1 << 11)
79#define SR_MEDIUM_SM (1 << 12)
80/* command : Monitor Mode Status Read Reg */
81#define SR_CMD_READ_MONITOR_MODE 0x1c
82/* command : Monitor Mode Status Write Reg */
83#define SR_CMD_WRITE_MONITOR_MODE 0x1d
84/* command : GPIO Status Read Reg */
85#define SR_CMD_READ_GPIOS 0x1e
86#define SR_GPIO_GPO0EN (1 << 0) /* GPIO0 Output enable */
87#define SR_GPIO_GPO_0 (1 << 1) /* GPIO0 Output value */
88#define SR_GPIO_GPO1EN (1 << 2) /* GPIO1 Output enable */
89#define SR_GPIO_GPO_1 (1 << 3) /* GPIO1 Output value */
90#define SR_GPIO_GPO2EN (1 << 4) /* GPIO2 Output enable */
91#define SR_GPIO_GPO_2 (1 << 5) /* GPIO2 Output value */
92#define SR_GPIO_RESERVED (1 << 6) /* Reserved */
93#define SR_GPIO_RSE (1 << 7) /* Reload serial EEPROM */
94/* command : GPIO Status Write Reg */
95#define SR_CMD_WRITE_GPIOS 0x1f
96/* command : Eth PHY Power and Reset Control Reg */
97#define SR_CMD_SW_RESET 0x20
98#define SR_SWRESET_CLEAR 0x00
99#define SR_SWRESET_RR (1 << 0)
100#define SR_SWRESET_RT (1 << 1)
101#define SR_SWRESET_PRTE (1 << 2)
102#define SR_SWRESET_PRL (1 << 3)
103#define SR_SWRESET_BZ (1 << 4)
104#define SR_SWRESET_IPRL (1 << 5)
105#define SR_SWRESET_IPPD (1 << 6)
106/* command : Software Interface Selection Status Read Reg */
107#define SR_CMD_SW_PHY_STATUS 0x21
108/* command : Software Interface Selection Status Write Reg */
109#define SR_CMD_SW_PHY_SELECT 0x22
110/* command : BULK in Buffer Size Reg */
111#define SR_CMD_BULKIN_SIZE 0x2A
112/* command : LED_MUX Control Reg */
113#define SR_CMD_LED_MUX 0x70
114#define SR_LED_MUX_TX_ACTIVE (1 << 0)
115#define SR_LED_MUX_RX_ACTIVE (1 << 1)
116#define SR_LED_MUX_COLLISION (1 << 2)
117#define SR_LED_MUX_DUP_COL (1 << 3)
118#define SR_LED_MUX_DUP (1 << 4)
119#define SR_LED_MUX_SPEED (1 << 5)
120#define SR_LED_MUX_LINK_ACTIVE (1 << 6)
121#define SR_LED_MUX_LINK (1 << 7)
122
123/* Register Access Flags */
124#define SR_REQ_RD_REG (USB_DIR_IN | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
125#define SR_REQ_WR_REG (USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE)
126
127/* Multicast Filter Array size & Max Number */
128#define SR_MCAST_FILTER_SIZE 8
129#define SR_MAX_MCAST 64
130
131/* IPG0/1/2 Default Value */
132#define SR9800_IPG0_DEFAULT 0x15
133#define SR9800_IPG1_DEFAULT 0x0c
134#define SR9800_IPG2_DEFAULT 0x12
135
136/* Medium Status Default Mode */
137#define SR9800_MEDIUM_DEFAULT \
138 (SR_MEDIUM_FD | SR_MEDIUM_RFC | \
139 SR_MEDIUM_TFC | SR_MEDIUM_PS | \
140 SR_MEDIUM_AC | SR_MEDIUM_RE)
141
142/* RX Control Default Setting */
143#define SR_DEFAULT_RX_CTL \
144 (SR_RX_CTL_SO | SR_RX_CTL_AB | SR_RX_CTL_RH1M)
145
146/* EEPROM Magic Number & EEPROM Size */
147#define SR_EEPROM_MAGIC 0xdeadbeef
148#define SR9800_EEPROM_LEN 0xff
149
150/* SR9800 Driver Version and Driver Name */
151#define DRIVER_VERSION "11-Nov-2013"
152#define DRIVER_NAME "CoreChips"
153#define DRIVER_FLAG \
154 (FLAG_ETHER | FLAG_FRAMING_AX | FLAG_LINK_INTR | FLAG_MULTI_PACKET)
155
156/* SR9800 BULKIN Buffer Size */
157#define SR9800_MAX_BULKIN_2K 0
158#define SR9800_MAX_BULKIN_4K 1
159#define SR9800_MAX_BULKIN_6K 2
160#define SR9800_MAX_BULKIN_8K 3
161#define SR9800_MAX_BULKIN_16K 4
162#define SR9800_MAX_BULKIN_20K 5
163#define SR9800_MAX_BULKIN_24K 6
164#define SR9800_MAX_BULKIN_32K 7
165
166struct {unsigned short size, byte_cnt, threshold; } SR9800_BULKIN_SIZE[] = {
167 /* 2k */
168 {2048, 0x8000, 0x8001},
169 /* 4k */
170 {4096, 0x8100, 0x8147},
171 /* 6k */
172 {6144, 0x8200, 0x81EB},
173 /* 8k */
174 {8192, 0x8300, 0x83D7},
175 /* 16 */
176 {16384, 0x8400, 0x851E},
177 /* 20k */
178 {20480, 0x8500, 0x8666},
179 /* 24k */
180 {24576, 0x8600, 0x87AE},
181 /* 32k */
182 {32768, 0x8700, 0x8A3D},
183};
184
185/* This structure cannot exceed sizeof(unsigned long [5]) AKA 20 bytes */
186struct sr_data {
187 u8 multi_filter[SR_MCAST_FILTER_SIZE];
188 u8 mac_addr[ETH_ALEN];
189 u8 phymode;
190 u8 ledmode;
191 u8 eeprom_len;
192};
193
194struct sr9800_int_data {
195 __le16 res1;
196 u8 link;
197 __le16 res2;
198 u8 status;
199 __le16 res3;
200} __packed;
201
202#endif /* _SR9800_H */
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 026a313c2d2d..b0f705c2378f 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -469,7 +469,6 @@ static inline struct hlist_head *vxlan_fdb_head(struct vxlan_dev *vxlan,
469/* Look up Ethernet address in forwarding table */ 469/* Look up Ethernet address in forwarding table */
470static struct vxlan_fdb *__vxlan_find_mac(struct vxlan_dev *vxlan, 470static struct vxlan_fdb *__vxlan_find_mac(struct vxlan_dev *vxlan,
471 const u8 *mac) 471 const u8 *mac)
472
473{ 472{
474 struct hlist_head *head = vxlan_fdb_head(vxlan, mac); 473 struct hlist_head *head = vxlan_fdb_head(vxlan, mac);
475 struct vxlan_fdb *f; 474 struct vxlan_fdb *f;
@@ -596,10 +595,8 @@ static struct sk_buff **vxlan_gro_receive(struct sk_buff **head, struct sk_buff
596 NAPI_GRO_CB(p)->same_flow = 0; 595 NAPI_GRO_CB(p)->same_flow = 0;
597 continue; 596 continue;
598 } 597 }
599 goto found;
600 } 598 }
601 599
602found:
603 type = eh->h_proto; 600 type = eh->h_proto;
604 601
605 rcu_read_lock(); 602 rcu_read_lock();
diff --git a/drivers/net/wan/dlci.c b/drivers/net/wan/dlci.c
index 0d1c7592efa0..19f7cb2cdef3 100644
--- a/drivers/net/wan/dlci.c
+++ b/drivers/net/wan/dlci.c
@@ -71,12 +71,9 @@ static int dlci_header(struct sk_buff *skb, struct net_device *dev,
71 const void *saddr, unsigned len) 71 const void *saddr, unsigned len)
72{ 72{
73 struct frhdr hdr; 73 struct frhdr hdr;
74 struct dlci_local *dlp;
75 unsigned int hlen; 74 unsigned int hlen;
76 char *dest; 75 char *dest;
77 76
78 dlp = netdev_priv(dev);
79
80 hdr.control = FRAD_I_UI; 77 hdr.control = FRAD_I_UI;
81 switch (type) 78 switch (type)
82 { 79 {
@@ -107,11 +104,9 @@ static int dlci_header(struct sk_buff *skb, struct net_device *dev,
107 104
108static void dlci_receive(struct sk_buff *skb, struct net_device *dev) 105static void dlci_receive(struct sk_buff *skb, struct net_device *dev)
109{ 106{
110 struct dlci_local *dlp;
111 struct frhdr *hdr; 107 struct frhdr *hdr;
112 int process, header; 108 int process, header;
113 109
114 dlp = netdev_priv(dev);
115 if (!pskb_may_pull(skb, sizeof(*hdr))) { 110 if (!pskb_may_pull(skb, sizeof(*hdr))) {
116 netdev_notice(dev, "invalid data no header\n"); 111 netdev_notice(dev, "invalid data no header\n");
117 dev->stats.rx_errors++; 112 dev->stats.rx_errors++;
diff --git a/drivers/net/wireless/ath/ar5523/ar5523.c b/drivers/net/wireless/ath/ar5523/ar5523.c
index 8aa20df55e50..507d9a9ee69a 100644
--- a/drivers/net/wireless/ath/ar5523/ar5523.c
+++ b/drivers/net/wireless/ath/ar5523/ar5523.c
@@ -1764,7 +1764,7 @@ static struct usb_device_id ar5523_id_table[] = {
1764 AR5523_DEVICE_UG(0x07d1, 0x3a07), /* D-Link / WUA-2340 rev A1 */ 1764 AR5523_DEVICE_UG(0x07d1, 0x3a07), /* D-Link / WUA-2340 rev A1 */
1765 AR5523_DEVICE_UG(0x1690, 0x0712), /* Gigaset / AR5523 */ 1765 AR5523_DEVICE_UG(0x1690, 0x0712), /* Gigaset / AR5523 */
1766 AR5523_DEVICE_UG(0x1690, 0x0710), /* Gigaset / SMCWUSBTG */ 1766 AR5523_DEVICE_UG(0x1690, 0x0710), /* Gigaset / SMCWUSBTG */
1767 AR5523_DEVICE_UG(0x129b, 0x160c), /* Gigaset / USB stick 108 1767 AR5523_DEVICE_UG(0x129b, 0x160b), /* Gigaset / USB stick 108
1768 (CyberTAN Technology) */ 1768 (CyberTAN Technology) */
1769 AR5523_DEVICE_UG(0x16ab, 0x7801), /* Globalsun / AR5523_1 */ 1769 AR5523_DEVICE_UG(0x16ab, 0x7801), /* Globalsun / AR5523_1 */
1770 AR5523_DEVICE_UX(0x16ab, 0x7811), /* Globalsun / AR5523_2 */ 1770 AR5523_DEVICE_UX(0x16ab, 0x7811), /* Globalsun / AR5523_2 */
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
index 25243cbc07f0..b8daff78b9d1 100644
--- a/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
+++ b/drivers/net/wireless/ath/ath9k/ar9003_eeprom.c
@@ -5065,6 +5065,10 @@ static u16 ar9003_hw_get_max_edge_power(struct ar9300_eeprom *eep,
5065 break; 5065 break;
5066 } 5066 }
5067 } 5067 }
5068
5069 if (is2GHz && !twiceMaxEdgePower)
5070 twiceMaxEdgePower = 60;
5071
5068 return twiceMaxEdgePower; 5072 return twiceMaxEdgePower;
5069} 5073}
5070 5074
diff --git a/drivers/net/wireless/ath/ath9k/htc.h b/drivers/net/wireless/ath/ath9k/htc.h
index 58da3468d1f0..99a203174f45 100644
--- a/drivers/net/wireless/ath/ath9k/htc.h
+++ b/drivers/net/wireless/ath/ath9k/htc.h
@@ -262,6 +262,8 @@ enum tid_aggr_state {
262struct ath9k_htc_sta { 262struct ath9k_htc_sta {
263 u8 index; 263 u8 index;
264 enum tid_aggr_state tid_state[ATH9K_HTC_MAX_TID]; 264 enum tid_aggr_state tid_state[ATH9K_HTC_MAX_TID];
265 struct work_struct rc_update_work;
266 struct ath9k_htc_priv *htc_priv;
265}; 267};
266 268
267#define ATH9K_HTC_RXBUF 256 269#define ATH9K_HTC_RXBUF 256
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_init.c b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
index f4e1de20d99c..c57d6b859c04 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_init.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_init.c
@@ -34,6 +34,10 @@ static int ath9k_htc_btcoex_enable;
34module_param_named(btcoex_enable, ath9k_htc_btcoex_enable, int, 0444); 34module_param_named(btcoex_enable, ath9k_htc_btcoex_enable, int, 0444);
35MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence"); 35MODULE_PARM_DESC(btcoex_enable, "Enable wifi-BT coexistence");
36 36
37static int ath9k_ps_enable;
38module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
39MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
40
37#define CHAN2G(_freq, _idx) { \ 41#define CHAN2G(_freq, _idx) { \
38 .center_freq = (_freq), \ 42 .center_freq = (_freq), \
39 .hw_value = (_idx), \ 43 .hw_value = (_idx), \
@@ -725,12 +729,14 @@ static void ath9k_set_hw_capab(struct ath9k_htc_priv *priv,
725 IEEE80211_HW_SPECTRUM_MGMT | 729 IEEE80211_HW_SPECTRUM_MGMT |
726 IEEE80211_HW_HAS_RATE_CONTROL | 730 IEEE80211_HW_HAS_RATE_CONTROL |
727 IEEE80211_HW_RX_INCLUDES_FCS | 731 IEEE80211_HW_RX_INCLUDES_FCS |
728 IEEE80211_HW_SUPPORTS_PS |
729 IEEE80211_HW_PS_NULLFUNC_STACK | 732 IEEE80211_HW_PS_NULLFUNC_STACK |
730 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 733 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
731 IEEE80211_HW_MFP_CAPABLE | 734 IEEE80211_HW_MFP_CAPABLE |
732 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING; 735 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING;
733 736
737 if (ath9k_ps_enable)
738 hw->flags |= IEEE80211_HW_SUPPORTS_PS;
739
734 hw->wiphy->interface_modes = 740 hw->wiphy->interface_modes =
735 BIT(NL80211_IFTYPE_STATION) | 741 BIT(NL80211_IFTYPE_STATION) |
736 BIT(NL80211_IFTYPE_ADHOC) | 742 BIT(NL80211_IFTYPE_ADHOC) |
diff --git a/drivers/net/wireless/ath/ath9k/htc_drv_main.c b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
index 608d739d1378..c9254a61ca52 100644
--- a/drivers/net/wireless/ath/ath9k/htc_drv_main.c
+++ b/drivers/net/wireless/ath/ath9k/htc_drv_main.c
@@ -1270,18 +1270,50 @@ static void ath9k_htc_configure_filter(struct ieee80211_hw *hw,
1270 mutex_unlock(&priv->mutex); 1270 mutex_unlock(&priv->mutex);
1271} 1271}
1272 1272
1273static void ath9k_htc_sta_rc_update_work(struct work_struct *work)
1274{
1275 struct ath9k_htc_sta *ista =
1276 container_of(work, struct ath9k_htc_sta, rc_update_work);
1277 struct ieee80211_sta *sta =
1278 container_of((void *)ista, struct ieee80211_sta, drv_priv);
1279 struct ath9k_htc_priv *priv = ista->htc_priv;
1280 struct ath_common *common = ath9k_hw_common(priv->ah);
1281 struct ath9k_htc_target_rate trate;
1282
1283 mutex_lock(&priv->mutex);
1284 ath9k_htc_ps_wakeup(priv);
1285
1286 memset(&trate, 0, sizeof(struct ath9k_htc_target_rate));
1287 ath9k_htc_setup_rate(priv, sta, &trate);
1288 if (!ath9k_htc_send_rate_cmd(priv, &trate))
1289 ath_dbg(common, CONFIG,
1290 "Supported rates for sta: %pM updated, rate caps: 0x%X\n",
1291 sta->addr, be32_to_cpu(trate.capflags));
1292 else
1293 ath_dbg(common, CONFIG,
1294 "Unable to update supported rates for sta: %pM\n",
1295 sta->addr);
1296
1297 ath9k_htc_ps_restore(priv);
1298 mutex_unlock(&priv->mutex);
1299}
1300
1273static int ath9k_htc_sta_add(struct ieee80211_hw *hw, 1301static int ath9k_htc_sta_add(struct ieee80211_hw *hw,
1274 struct ieee80211_vif *vif, 1302 struct ieee80211_vif *vif,
1275 struct ieee80211_sta *sta) 1303 struct ieee80211_sta *sta)
1276{ 1304{
1277 struct ath9k_htc_priv *priv = hw->priv; 1305 struct ath9k_htc_priv *priv = hw->priv;
1306 struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
1278 int ret; 1307 int ret;
1279 1308
1280 mutex_lock(&priv->mutex); 1309 mutex_lock(&priv->mutex);
1281 ath9k_htc_ps_wakeup(priv); 1310 ath9k_htc_ps_wakeup(priv);
1282 ret = ath9k_htc_add_station(priv, vif, sta); 1311 ret = ath9k_htc_add_station(priv, vif, sta);
1283 if (!ret) 1312 if (!ret) {
1313 INIT_WORK(&ista->rc_update_work, ath9k_htc_sta_rc_update_work);
1314 ista->htc_priv = priv;
1284 ath9k_htc_init_rate(priv, sta); 1315 ath9k_htc_init_rate(priv, sta);
1316 }
1285 ath9k_htc_ps_restore(priv); 1317 ath9k_htc_ps_restore(priv);
1286 mutex_unlock(&priv->mutex); 1318 mutex_unlock(&priv->mutex);
1287 1319
@@ -1293,12 +1325,13 @@ static int ath9k_htc_sta_remove(struct ieee80211_hw *hw,
1293 struct ieee80211_sta *sta) 1325 struct ieee80211_sta *sta)
1294{ 1326{
1295 struct ath9k_htc_priv *priv = hw->priv; 1327 struct ath9k_htc_priv *priv = hw->priv;
1296 struct ath9k_htc_sta *ista; 1328 struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
1297 int ret; 1329 int ret;
1298 1330
1331 cancel_work_sync(&ista->rc_update_work);
1332
1299 mutex_lock(&priv->mutex); 1333 mutex_lock(&priv->mutex);
1300 ath9k_htc_ps_wakeup(priv); 1334 ath9k_htc_ps_wakeup(priv);
1301 ista = (struct ath9k_htc_sta *) sta->drv_priv;
1302 htc_sta_drain(priv->htc, ista->index); 1335 htc_sta_drain(priv->htc, ista->index);
1303 ret = ath9k_htc_remove_station(priv, vif, sta); 1336 ret = ath9k_htc_remove_station(priv, vif, sta);
1304 ath9k_htc_ps_restore(priv); 1337 ath9k_htc_ps_restore(priv);
@@ -1311,28 +1344,12 @@ static void ath9k_htc_sta_rc_update(struct ieee80211_hw *hw,
1311 struct ieee80211_vif *vif, 1344 struct ieee80211_vif *vif,
1312 struct ieee80211_sta *sta, u32 changed) 1345 struct ieee80211_sta *sta, u32 changed)
1313{ 1346{
1314 struct ath9k_htc_priv *priv = hw->priv; 1347 struct ath9k_htc_sta *ista = (struct ath9k_htc_sta *) sta->drv_priv;
1315 struct ath_common *common = ath9k_hw_common(priv->ah);
1316 struct ath9k_htc_target_rate trate;
1317
1318 mutex_lock(&priv->mutex);
1319 ath9k_htc_ps_wakeup(priv);
1320 1348
1321 if (changed & IEEE80211_RC_SUPP_RATES_CHANGED) { 1349 if (!(changed & IEEE80211_RC_SUPP_RATES_CHANGED))
1322 memset(&trate, 0, sizeof(struct ath9k_htc_target_rate)); 1350 return;
1323 ath9k_htc_setup_rate(priv, sta, &trate);
1324 if (!ath9k_htc_send_rate_cmd(priv, &trate))
1325 ath_dbg(common, CONFIG,
1326 "Supported rates for sta: %pM updated, rate caps: 0x%X\n",
1327 sta->addr, be32_to_cpu(trate.capflags));
1328 else
1329 ath_dbg(common, CONFIG,
1330 "Unable to update supported rates for sta: %pM\n",
1331 sta->addr);
1332 }
1333 1351
1334 ath9k_htc_ps_restore(priv); 1352 schedule_work(&ista->rc_update_work);
1335 mutex_unlock(&priv->mutex);
1336} 1353}
1337 1354
1338static int ath9k_htc_conf_tx(struct ieee80211_hw *hw, 1355static int ath9k_htc_conf_tx(struct ieee80211_hw *hw,
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c
index fbf43c05713f..11eab9f01fd8 100644
--- a/drivers/net/wireless/ath/ath9k/hw.c
+++ b/drivers/net/wireless/ath/ath9k/hw.c
@@ -1316,7 +1316,7 @@ static bool ath9k_hw_set_reset(struct ath_hw *ah, int type)
1316 if (AR_SREV_9300_20_OR_LATER(ah)) 1316 if (AR_SREV_9300_20_OR_LATER(ah))
1317 udelay(50); 1317 udelay(50);
1318 else if (AR_SREV_9100(ah)) 1318 else if (AR_SREV_9100(ah))
1319 udelay(10000); 1319 mdelay(10);
1320 else 1320 else
1321 udelay(100); 1321 udelay(100);
1322 1322
@@ -2051,9 +2051,8 @@ static bool ath9k_hw_set_power_awake(struct ath_hw *ah)
2051 2051
2052 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE, 2052 REG_SET_BIT(ah, AR_RTC_FORCE_WAKE,
2053 AR_RTC_FORCE_WAKE_EN); 2053 AR_RTC_FORCE_WAKE_EN);
2054
2055 if (AR_SREV_9100(ah)) 2054 if (AR_SREV_9100(ah))
2056 udelay(10000); 2055 mdelay(10);
2057 else 2056 else
2058 udelay(50); 2057 udelay(50);
2059 2058
diff --git a/drivers/net/wireless/ath/ath9k/init.c b/drivers/net/wireless/ath/ath9k/init.c
index c36de303c8f3..1fc2e5a26b52 100644
--- a/drivers/net/wireless/ath/ath9k/init.c
+++ b/drivers/net/wireless/ath/ath9k/init.c
@@ -57,6 +57,10 @@ static int ath9k_bt_ant_diversity;
57module_param_named(bt_ant_diversity, ath9k_bt_ant_diversity, int, 0444); 57module_param_named(bt_ant_diversity, ath9k_bt_ant_diversity, int, 0444);
58MODULE_PARM_DESC(bt_ant_diversity, "Enable WLAN/BT RX antenna diversity"); 58MODULE_PARM_DESC(bt_ant_diversity, "Enable WLAN/BT RX antenna diversity");
59 59
60static int ath9k_ps_enable;
61module_param_named(ps_enable, ath9k_ps_enable, int, 0444);
62MODULE_PARM_DESC(ps_enable, "Enable WLAN PowerSave");
63
60bool is_ath9k_unloaded; 64bool is_ath9k_unloaded;
61/* We use the hw_value as an index into our private channel structure */ 65/* We use the hw_value as an index into our private channel structure */
62 66
@@ -903,13 +907,15 @@ static void ath9k_set_hw_capab(struct ath_softc *sc, struct ieee80211_hw *hw)
903 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS | 907 hw->flags = IEEE80211_HW_RX_INCLUDES_FCS |
904 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING | 908 IEEE80211_HW_HOST_BROADCAST_PS_BUFFERING |
905 IEEE80211_HW_SIGNAL_DBM | 909 IEEE80211_HW_SIGNAL_DBM |
906 IEEE80211_HW_SUPPORTS_PS |
907 IEEE80211_HW_PS_NULLFUNC_STACK | 910 IEEE80211_HW_PS_NULLFUNC_STACK |
908 IEEE80211_HW_SPECTRUM_MGMT | 911 IEEE80211_HW_SPECTRUM_MGMT |
909 IEEE80211_HW_REPORTS_TX_ACK_STATUS | 912 IEEE80211_HW_REPORTS_TX_ACK_STATUS |
910 IEEE80211_HW_SUPPORTS_RC_TABLE | 913 IEEE80211_HW_SUPPORTS_RC_TABLE |
911 IEEE80211_HW_SUPPORTS_HT_CCK_RATES; 914 IEEE80211_HW_SUPPORTS_HT_CCK_RATES;
912 915
916 if (ath9k_ps_enable)
917 hw->flags |= IEEE80211_HW_SUPPORTS_PS;
918
913 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) { 919 if (sc->sc_ah->caps.hw_caps & ATH9K_HW_CAP_HT) {
914 hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION; 920 hw->flags |= IEEE80211_HW_AMPDU_AGGREGATION;
915 921
diff --git a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
index f06f4cbe1317..725e954d8475 100644
--- a/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
+++ b/drivers/net/wireless/iwlwifi/iwl-nvm-parse.c
@@ -182,6 +182,11 @@ static int iwl_init_channel_map(struct device *dev, const struct iwl_cfg *cfg,
182 182
183 for (ch_idx = 0; ch_idx < IWL_NUM_CHANNELS; ch_idx++) { 183 for (ch_idx = 0; ch_idx < IWL_NUM_CHANNELS; ch_idx++) {
184 ch_flags = __le16_to_cpup(nvm_ch_flags + ch_idx); 184 ch_flags = __le16_to_cpup(nvm_ch_flags + ch_idx);
185
186 if (ch_idx >= NUM_2GHZ_CHANNELS &&
187 !data->sku_cap_band_52GHz_enable)
188 ch_flags &= ~NVM_CHANNEL_VALID;
189
185 if (!(ch_flags & NVM_CHANNEL_VALID)) { 190 if (!(ch_flags & NVM_CHANNEL_VALID)) {
186 IWL_DEBUG_EEPROM(dev, 191 IWL_DEBUG_EEPROM(dev,
187 "Ch. %d Flags %x [%sGHz] - No traffic\n", 192 "Ch. %d Flags %x [%sGHz] - No traffic\n",
diff --git a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
index 73cbba7424f2..9426905de6b2 100644
--- a/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
+++ b/drivers/net/wireless/iwlwifi/mvm/fw-api-scan.h
@@ -504,6 +504,7 @@ struct iwl_scan_offload_profile {
504 * @match_notify: clients waiting for match found notification 504 * @match_notify: clients waiting for match found notification
505 * @pass_match: clients waiting for the results 505 * @pass_match: clients waiting for the results
506 * @active_clients: active clients bitmap - enum scan_framework_client 506 * @active_clients: active clients bitmap - enum scan_framework_client
507 * @any_beacon_notify: clients waiting for match notification without match
507 */ 508 */
508struct iwl_scan_offload_profile_cfg { 509struct iwl_scan_offload_profile_cfg {
509 struct iwl_scan_offload_profile profiles[IWL_SCAN_MAX_PROFILES]; 510 struct iwl_scan_offload_profile profiles[IWL_SCAN_MAX_PROFILES];
@@ -512,7 +513,8 @@ struct iwl_scan_offload_profile_cfg {
512 u8 match_notify; 513 u8 match_notify;
513 u8 pass_match; 514 u8 pass_match;
514 u8 active_clients; 515 u8 active_clients;
515 u8 reserved[3]; 516 u8 any_beacon_notify;
517 u8 reserved[2];
516} __packed; 518} __packed;
517 519
518/** 520/**
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index c49b5073c251..6bf9766e5982 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -246,7 +246,7 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
246 else 246 else
247 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 247 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
248 248
249 if (mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_SCHED_SCAN) { 249 if (0 && mvm->fw->ucode_capa.flags & IWL_UCODE_TLV_FLAGS_SCHED_SCAN) {
250 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; 250 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN;
251 hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; 251 hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX;
252 hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES; 252 hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES;
diff --git a/drivers/net/wireless/iwlwifi/mvm/scan.c b/drivers/net/wireless/iwlwifi/mvm/scan.c
index 0e0007960612..742afc429c94 100644
--- a/drivers/net/wireless/iwlwifi/mvm/scan.c
+++ b/drivers/net/wireless/iwlwifi/mvm/scan.c
@@ -344,7 +344,8 @@ int iwl_mvm_scan_request(struct iwl_mvm *mvm,
344 344
345 iwl_mvm_scan_fill_ssids(cmd, req, basic_ssid ? 1 : 0); 345 iwl_mvm_scan_fill_ssids(cmd, req, basic_ssid ? 1 : 0);
346 346
347 cmd->tx_cmd.tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL); 347 cmd->tx_cmd.tx_flags = cpu_to_le32(TX_CMD_FLG_SEQ_CTL |
348 TX_CMD_FLG_BT_DIS);
348 cmd->tx_cmd.sta_id = mvm->aux_sta.sta_id; 349 cmd->tx_cmd.sta_id = mvm->aux_sta.sta_id;
349 cmd->tx_cmd.life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE); 350 cmd->tx_cmd.life_time = cpu_to_le32(TX_CMD_LIFE_TIME_INFINITE);
350 cmd->tx_cmd.rate_n_flags = 351 cmd->tx_cmd.rate_n_flags =
@@ -807,6 +808,8 @@ int iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm,
807 profile_cfg->active_clients = SCAN_CLIENT_SCHED_SCAN; 808 profile_cfg->active_clients = SCAN_CLIENT_SCHED_SCAN;
808 profile_cfg->pass_match = SCAN_CLIENT_SCHED_SCAN; 809 profile_cfg->pass_match = SCAN_CLIENT_SCHED_SCAN;
809 profile_cfg->match_notify = SCAN_CLIENT_SCHED_SCAN; 810 profile_cfg->match_notify = SCAN_CLIENT_SCHED_SCAN;
811 if (!req->n_match_sets || !req->match_sets[0].ssid.ssid_len)
812 profile_cfg->any_beacon_notify = SCAN_CLIENT_SCHED_SCAN;
810 813
811 for (i = 0; i < req->n_match_sets; i++) { 814 for (i = 0; i < req->n_match_sets; i++) {
812 profile = &profile_cfg->profiles[i]; 815 profile = &profile_cfg->profiles[i];
diff --git a/drivers/net/wireless/iwlwifi/mvm/sta.c b/drivers/net/wireless/iwlwifi/mvm/sta.c
index ec1812133235..3397f59cd4e4 100644
--- a/drivers/net/wireless/iwlwifi/mvm/sta.c
+++ b/drivers/net/wireless/iwlwifi/mvm/sta.c
@@ -652,7 +652,7 @@ int iwl_mvm_send_bcast_sta(struct iwl_mvm *mvm, struct ieee80211_vif *vif,
652{ 652{
653 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif); 653 struct iwl_mvm_vif *mvmvif = iwl_mvm_vif_from_mac80211(vif);
654 static const u8 _baddr[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}; 654 static const u8 _baddr[] = {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF};
655 static const u8 *baddr = _baddr; 655 const u8 *baddr = _baddr;
656 656
657 lockdep_assert_held(&mvm->mutex); 657 lockdep_assert_held(&mvm->mutex);
658 658
diff --git a/drivers/net/wireless/iwlwifi/mvm/tx.c b/drivers/net/wireless/iwlwifi/mvm/tx.c
index 90378c217bc7..4df12fa9d336 100644
--- a/drivers/net/wireless/iwlwifi/mvm/tx.c
+++ b/drivers/net/wireless/iwlwifi/mvm/tx.c
@@ -659,8 +659,14 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
659 rcu_read_lock(); 659 rcu_read_lock();
660 660
661 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); 661 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]);
662 /*
663 * sta can't be NULL otherwise it'd mean that the sta has been freed in
664 * the firmware while we still have packets for it in the Tx queues.
665 */
666 if (WARN_ON_ONCE(!sta))
667 goto out;
662 668
663 if (!IS_ERR_OR_NULL(sta)) { 669 if (!IS_ERR(sta)) {
664 mvmsta = iwl_mvm_sta_from_mac80211(sta); 670 mvmsta = iwl_mvm_sta_from_mac80211(sta);
665 671
666 if (tid != IWL_TID_NON_QOS) { 672 if (tid != IWL_TID_NON_QOS) {
@@ -675,7 +681,6 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
675 spin_unlock_bh(&mvmsta->lock); 681 spin_unlock_bh(&mvmsta->lock);
676 } 682 }
677 } else { 683 } else {
678 sta = NULL;
679 mvmsta = NULL; 684 mvmsta = NULL;
680 } 685 }
681 686
@@ -683,42 +688,38 @@ static void iwl_mvm_rx_tx_cmd_single(struct iwl_mvm *mvm,
683 * If the txq is not an AMPDU queue, there is no chance we freed 688 * If the txq is not an AMPDU queue, there is no chance we freed
684 * several skbs. Check that out... 689 * several skbs. Check that out...
685 */ 690 */
686 if (txq_id < mvm->first_agg_queue && !WARN_ON(skb_freed > 1) && 691 if (txq_id >= mvm->first_agg_queue)
687 atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id])) { 692 goto out;
688 if (mvmsta) { 693
689 /* 694 /* We can't free more than one frame at once on a shared queue */
690 * If there are no pending frames for this STA, notify 695 WARN_ON(skb_freed > 1);
691 * mac80211 that this station can go to sleep in its 696
692 * STA table. 697 /* If we have still frames from this STA nothing to do here */
693 */ 698 if (!atomic_sub_and_test(skb_freed, &mvm->pending_frames[sta_id]))
694 if (mvmsta->vif->type == NL80211_IFTYPE_AP) 699 goto out;
695 ieee80211_sta_block_awake(mvm->hw, sta, false); 700
696 /* 701 if (mvmsta && mvmsta->vif->type == NL80211_IFTYPE_AP) {
697 * We might very well have taken mvmsta pointer while 702 /*
698 * the station was being removed. The remove flow might 703 * If there are no pending frames for this STA, notify
699 * have seen a pending_frame (because we didn't take 704 * mac80211 that this station can go to sleep in its
700 * the lock) even if now the queues are drained. So make 705 * STA table.
701 * really sure now that this the station is not being 706 * If mvmsta is not NULL, sta is valid.
702 * removed. If it is, run the drain worker to remove it. 707 */
703 */ 708 ieee80211_sta_block_awake(mvm->hw, sta, false);
704 spin_lock_bh(&mvmsta->lock); 709 }
705 sta = rcu_dereference(mvm->fw_id_to_mac_id[sta_id]); 710
706 if (!sta || PTR_ERR(sta) == -EBUSY) { 711 if (PTR_ERR(sta) == -EBUSY || PTR_ERR(sta) == -ENOENT) {
707 /* 712 /*
708 * Station disappeared in the meantime: 713 * We are draining and this was the last packet - pre_rcu_remove
709 * so we are draining. 714 * has been called already. We might be after the
710 */ 715 * synchronize_net already.
711 set_bit(sta_id, mvm->sta_drained); 716 * Don't rely on iwl_mvm_rm_sta to see the empty Tx queues.
712 schedule_work(&mvm->sta_drained_wk); 717 */
713 } 718 set_bit(sta_id, mvm->sta_drained);
714 spin_unlock_bh(&mvmsta->lock); 719 schedule_work(&mvm->sta_drained_wk);
715 } else if (!mvmsta && PTR_ERR(sta) == -EBUSY) {
716 /* Tx response without STA, so we are draining */
717 set_bit(sta_id, mvm->sta_drained);
718 schedule_work(&mvm->sta_drained_wk);
719 }
720 } 720 }
721 721
722out:
722 rcu_read_unlock(); 723 rcu_read_unlock();
723} 724}
724 725
diff --git a/drivers/net/wireless/iwlwifi/mvm/utils.c b/drivers/net/wireless/iwlwifi/mvm/utils.c
index a4a5e25623c3..86989df69356 100644
--- a/drivers/net/wireless/iwlwifi/mvm/utils.c
+++ b/drivers/net/wireless/iwlwifi/mvm/utils.c
@@ -411,6 +411,8 @@ void iwl_mvm_dump_nic_error_log(struct iwl_mvm *mvm)
411 mvm->status, table.valid); 411 mvm->status, table.valid);
412 } 412 }
413 413
414 IWL_ERR(mvm, "Loaded firmware version: %s\n", mvm->fw->fw_version);
415
414 trace_iwlwifi_dev_ucode_error(trans->dev, table.error_id, table.tsf_low, 416 trace_iwlwifi_dev_ucode_error(trans->dev, table.error_id, table.tsf_low,
415 table.data1, table.data2, table.data3, 417 table.data1, table.data2, table.data3,
416 table.blink1, table.blink2, table.ilink1, 418 table.blink1, table.blink2, table.ilink1,
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index 3040924f5f3c..f47bcbe2945a 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -359,20 +359,25 @@ static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = {
359/* 7265 Series */ 359/* 7265 Series */
360 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)}, 360 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)},
361 {IWL_PCI_DEVICE(0x095A, 0x5110, iwl7265_2ac_cfg)}, 361 {IWL_PCI_DEVICE(0x095A, 0x5110, iwl7265_2ac_cfg)},
362 {IWL_PCI_DEVICE(0x095A, 0x5112, iwl7265_2ac_cfg)},
363 {IWL_PCI_DEVICE(0x095A, 0x5100, iwl7265_2ac_cfg)},
364 {IWL_PCI_DEVICE(0x095A, 0x510A, iwl7265_2ac_cfg)},
362 {IWL_PCI_DEVICE(0x095B, 0x5310, iwl7265_2ac_cfg)}, 365 {IWL_PCI_DEVICE(0x095B, 0x5310, iwl7265_2ac_cfg)},
363 {IWL_PCI_DEVICE(0x095B, 0x5302, iwl7265_2ac_cfg)}, 366 {IWL_PCI_DEVICE(0x095B, 0x5302, iwl7265_2ac_cfg)},
364 {IWL_PCI_DEVICE(0x095B, 0x5210, iwl7265_2ac_cfg)}, 367 {IWL_PCI_DEVICE(0x095B, 0x5210, iwl7265_2ac_cfg)},
365 {IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)}, 368 {IWL_PCI_DEVICE(0x095A, 0x5012, iwl7265_2ac_cfg)},
366 {IWL_PCI_DEVICE(0x095A, 0x500A, iwl7265_2ac_cfg)},
367 {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)}, 369 {IWL_PCI_DEVICE(0x095A, 0x5410, iwl7265_2ac_cfg)},
368 {IWL_PCI_DEVICE(0x095A, 0x5400, iwl7265_2ac_cfg)}, 370 {IWL_PCI_DEVICE(0x095A, 0x5400, iwl7265_2ac_cfg)},
369 {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)}, 371 {IWL_PCI_DEVICE(0x095A, 0x1010, iwl7265_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)}, 372 {IWL_PCI_DEVICE(0x095A, 0x5000, iwl7265_2n_cfg)},
373 {IWL_PCI_DEVICE(0x095A, 0x500A, iwl7265_2n_cfg)},
371 {IWL_PCI_DEVICE(0x095B, 0x5200, iwl7265_2n_cfg)}, 374 {IWL_PCI_DEVICE(0x095B, 0x5200, iwl7265_2n_cfg)},
372 {IWL_PCI_DEVICE(0x095A, 0x5002, iwl7265_n_cfg)}, 375 {IWL_PCI_DEVICE(0x095A, 0x5002, iwl7265_n_cfg)},
373 {IWL_PCI_DEVICE(0x095B, 0x5202, iwl7265_n_cfg)}, 376 {IWL_PCI_DEVICE(0x095B, 0x5202, iwl7265_n_cfg)},
374 {IWL_PCI_DEVICE(0x095A, 0x9010, iwl7265_2ac_cfg)}, 377 {IWL_PCI_DEVICE(0x095A, 0x9010, iwl7265_2ac_cfg)},
378 {IWL_PCI_DEVICE(0x095A, 0x9012, iwl7265_2ac_cfg)},
375 {IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)}, 379 {IWL_PCI_DEVICE(0x095A, 0x9110, iwl7265_2ac_cfg)},
380 {IWL_PCI_DEVICE(0x095A, 0x9112, iwl7265_2ac_cfg)},
376 {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)}, 381 {IWL_PCI_DEVICE(0x095A, 0x9210, iwl7265_2ac_cfg)},
377 {IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)}, 382 {IWL_PCI_DEVICE(0x095A, 0x9510, iwl7265_2ac_cfg)},
378 {IWL_PCI_DEVICE(0x095A, 0x9310, iwl7265_2ac_cfg)}, 383 {IWL_PCI_DEVICE(0x095A, 0x9310, iwl7265_2ac_cfg)},
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index abc5f56f29fe..2f1cd929c6f6 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -1877,6 +1877,11 @@ static int rt2500pci_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1877 EEPROM_MAC_ADDR_0)); 1877 EEPROM_MAC_ADDR_0));
1878 1878
1879 /* 1879 /*
1880 * Disable powersaving as default.
1881 */
1882 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
1883
1884 /*
1880 * Initialize hw_mode information. 1885 * Initialize hw_mode information.
1881 */ 1886 */
1882 spec->supported_bands = SUPPORT_BAND_2GHZ; 1887 spec->supported_bands = SUPPORT_BAND_2GHZ;
diff --git a/drivers/net/wireless/rt2x00/rt2500usb.c b/drivers/net/wireless/rt2x00/rt2500usb.c
index 9f16824cd1bc..d849d590de25 100644
--- a/drivers/net/wireless/rt2x00/rt2500usb.c
+++ b/drivers/net/wireless/rt2x00/rt2500usb.c
@@ -1706,6 +1706,11 @@ static int rt2500usb_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
1706 IEEE80211_HW_SUPPORTS_PS | 1706 IEEE80211_HW_SUPPORTS_PS |
1707 IEEE80211_HW_PS_NULLFUNC_STACK; 1707 IEEE80211_HW_PS_NULLFUNC_STACK;
1708 1708
1709 /*
1710 * Disable powersaving as default.
1711 */
1712 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
1713
1709 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev); 1714 SET_IEEE80211_DEV(rt2x00dev->hw, rt2x00dev->dev);
1710 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw, 1715 SET_IEEE80211_PERM_ADDR(rt2x00dev->hw,
1711 rt2x00_eeprom_addr(rt2x00dev, 1716 rt2x00_eeprom_addr(rt2x00dev,
diff --git a/drivers/net/wireless/rt2x00/rt2800lib.c b/drivers/net/wireless/rt2x00/rt2800lib.c
index b8f5b06006c4..7f8b5d156c8c 100644
--- a/drivers/net/wireless/rt2x00/rt2800lib.c
+++ b/drivers/net/wireless/rt2x00/rt2800lib.c
@@ -7458,10 +7458,9 @@ static int rt2800_probe_hw_mode(struct rt2x00_dev *rt2x00dev)
7458 u32 reg; 7458 u32 reg;
7459 7459
7460 /* 7460 /*
7461 * Disable powersaving as default on PCI devices. 7461 * Disable powersaving as default.
7462 */ 7462 */
7463 if (rt2x00_is_pci(rt2x00dev) || rt2x00_is_soc(rt2x00dev)) 7463 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
7464 rt2x00dev->hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
7465 7464
7466 /* 7465 /*
7467 * Initialize all hw fields. 7466 * Initialize all hw fields.
diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c
index 8ec17aad0e52..3867d1470b36 100644
--- a/drivers/net/wireless/rtl818x/rtl8180/dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c
@@ -107,6 +107,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev)
107 struct rtl8180_priv *priv = dev->priv; 107 struct rtl8180_priv *priv = dev->priv;
108 unsigned int count = 32; 108 unsigned int count = 32;
109 u8 signal, agc, sq; 109 u8 signal, agc, sq;
110 dma_addr_t mapping;
110 111
111 while (count--) { 112 while (count--) {
112 struct rtl8180_rx_desc *entry = &priv->rx_ring[priv->rx_idx]; 113 struct rtl8180_rx_desc *entry = &priv->rx_ring[priv->rx_idx];
@@ -128,6 +129,17 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev)
128 if (unlikely(!new_skb)) 129 if (unlikely(!new_skb))
129 goto done; 130 goto done;
130 131
132 mapping = pci_map_single(priv->pdev,
133 skb_tail_pointer(new_skb),
134 MAX_RX_SIZE, PCI_DMA_FROMDEVICE);
135
136 if (pci_dma_mapping_error(priv->pdev, mapping)) {
137 kfree_skb(new_skb);
138 dev_err(&priv->pdev->dev, "RX DMA map error\n");
139
140 goto done;
141 }
142
131 pci_unmap_single(priv->pdev, 143 pci_unmap_single(priv->pdev,
132 *((dma_addr_t *)skb->cb), 144 *((dma_addr_t *)skb->cb),
133 MAX_RX_SIZE, PCI_DMA_FROMDEVICE); 145 MAX_RX_SIZE, PCI_DMA_FROMDEVICE);
@@ -158,9 +170,7 @@ static void rtl8180_handle_rx(struct ieee80211_hw *dev)
158 170
159 skb = new_skb; 171 skb = new_skb;
160 priv->rx_buf[priv->rx_idx] = skb; 172 priv->rx_buf[priv->rx_idx] = skb;
161 *((dma_addr_t *) skb->cb) = 173 *((dma_addr_t *) skb->cb) = mapping;
162 pci_map_single(priv->pdev, skb_tail_pointer(skb),
163 MAX_RX_SIZE, PCI_DMA_FROMDEVICE);
164 } 174 }
165 175
166 done: 176 done:
@@ -266,6 +276,13 @@ static void rtl8180_tx(struct ieee80211_hw *dev,
266 mapping = pci_map_single(priv->pdev, skb->data, 276 mapping = pci_map_single(priv->pdev, skb->data,
267 skb->len, PCI_DMA_TODEVICE); 277 skb->len, PCI_DMA_TODEVICE);
268 278
279 if (pci_dma_mapping_error(priv->pdev, mapping)) {
280 kfree_skb(skb);
281 dev_err(&priv->pdev->dev, "TX DMA mapping error\n");
282 return;
283
284 }
285
269 tx_flags = RTL818X_TX_DESC_FLAG_OWN | RTL818X_TX_DESC_FLAG_FS | 286 tx_flags = RTL818X_TX_DESC_FLAG_OWN | RTL818X_TX_DESC_FLAG_FS |
270 RTL818X_TX_DESC_FLAG_LS | 287 RTL818X_TX_DESC_FLAG_LS |
271 (ieee80211_get_tx_rate(dev, info)->hw_value << 24) | 288 (ieee80211_get_tx_rate(dev, info)->hw_value << 24) |
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index 4c76bcb9a879..ae413a2cbee7 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -143,11 +143,7 @@ struct xenvif {
143 char rx_irq_name[IFNAMSIZ+4]; /* DEVNAME-rx */ 143 char rx_irq_name[IFNAMSIZ+4]; /* DEVNAME-rx */
144 struct xen_netif_rx_back_ring rx; 144 struct xen_netif_rx_back_ring rx;
145 struct sk_buff_head rx_queue; 145 struct sk_buff_head rx_queue;
146 bool rx_queue_stopped; 146 RING_IDX rx_last_skb_slots;
147 /* Set when the RX interrupt is triggered by the frontend.
148 * The worker thread may need to wake the queue.
149 */
150 bool rx_event;
151 147
152 /* This array is allocated seperately as it is large */ 148 /* This array is allocated seperately as it is large */
153 struct gnttab_copy *grant_copy_op; 149 struct gnttab_copy *grant_copy_op;
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index b9de31ea7fc4..7669d49a67e2 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -100,7 +100,6 @@ static irqreturn_t xenvif_rx_interrupt(int irq, void *dev_id)
100{ 100{
101 struct xenvif *vif = dev_id; 101 struct xenvif *vif = dev_id;
102 102
103 vif->rx_event = true;
104 xenvif_kick_thread(vif); 103 xenvif_kick_thread(vif);
105 104
106 return IRQ_HANDLED; 105 return IRQ_HANDLED;
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index 6b62c3eb8e18..e5284bca2d90 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -476,7 +476,6 @@ static void xenvif_rx_action(struct xenvif *vif)
476 unsigned long offset; 476 unsigned long offset;
477 struct skb_cb_overlay *sco; 477 struct skb_cb_overlay *sco;
478 bool need_to_notify = false; 478 bool need_to_notify = false;
479 bool ring_full = false;
480 479
481 struct netrx_pending_operations npo = { 480 struct netrx_pending_operations npo = {
482 .copy = vif->grant_copy_op, 481 .copy = vif->grant_copy_op,
@@ -486,7 +485,7 @@ static void xenvif_rx_action(struct xenvif *vif)
486 skb_queue_head_init(&rxq); 485 skb_queue_head_init(&rxq);
487 486
488 while ((skb = skb_dequeue(&vif->rx_queue)) != NULL) { 487 while ((skb = skb_dequeue(&vif->rx_queue)) != NULL) {
489 int max_slots_needed; 488 RING_IDX max_slots_needed;
490 int i; 489 int i;
491 490
492 /* We need a cheap worse case estimate for the number of 491 /* We need a cheap worse case estimate for the number of
@@ -509,9 +508,10 @@ static void xenvif_rx_action(struct xenvif *vif)
509 if (!xenvif_rx_ring_slots_available(vif, max_slots_needed)) { 508 if (!xenvif_rx_ring_slots_available(vif, max_slots_needed)) {
510 skb_queue_head(&vif->rx_queue, skb); 509 skb_queue_head(&vif->rx_queue, skb);
511 need_to_notify = true; 510 need_to_notify = true;
512 ring_full = true; 511 vif->rx_last_skb_slots = max_slots_needed;
513 break; 512 break;
514 } 513 } else
514 vif->rx_last_skb_slots = 0;
515 515
516 sco = (struct skb_cb_overlay *)skb->cb; 516 sco = (struct skb_cb_overlay *)skb->cb;
517 sco->meta_slots_used = xenvif_gop_skb(skb, &npo); 517 sco->meta_slots_used = xenvif_gop_skb(skb, &npo);
@@ -522,8 +522,6 @@ static void xenvif_rx_action(struct xenvif *vif)
522 522
523 BUG_ON(npo.meta_prod > ARRAY_SIZE(vif->meta)); 523 BUG_ON(npo.meta_prod > ARRAY_SIZE(vif->meta));
524 524
525 vif->rx_queue_stopped = !npo.copy_prod && ring_full;
526
527 if (!npo.copy_prod) 525 if (!npo.copy_prod)
528 goto done; 526 goto done;
529 527
@@ -1473,8 +1471,8 @@ static struct xen_netif_rx_response *make_rx_response(struct xenvif *vif,
1473 1471
1474static inline int rx_work_todo(struct xenvif *vif) 1472static inline int rx_work_todo(struct xenvif *vif)
1475{ 1473{
1476 return (!skb_queue_empty(&vif->rx_queue) && !vif->rx_queue_stopped) || 1474 return !skb_queue_empty(&vif->rx_queue) &&
1477 vif->rx_event; 1475 xenvif_rx_ring_slots_available(vif, vif->rx_last_skb_slots);
1478} 1476}
1479 1477
1480static inline int tx_work_todo(struct xenvif *vif) 1478static inline int tx_work_todo(struct xenvif *vif)
@@ -1560,8 +1558,6 @@ int xenvif_kthread(void *data)
1560 if (!skb_queue_empty(&vif->rx_queue)) 1558 if (!skb_queue_empty(&vif->rx_queue))
1561 xenvif_rx_action(vif); 1559 xenvif_rx_action(vif);
1562 1560
1563 vif->rx_event = false;
1564
1565 if (skb_queue_empty(&vif->rx_queue) && 1561 if (skb_queue_empty(&vif->rx_queue) &&
1566 netif_queue_stopped(vif->dev)) 1562 netif_queue_stopped(vif->dev))
1567 xenvif_start_queue(vif); 1563 xenvif_start_queue(vif);
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index ff04d4f95baa..f9daa9e183f2 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -1832,7 +1832,6 @@ static void netback_changed(struct xenbus_device *dev,
1832 case XenbusStateReconfiguring: 1832 case XenbusStateReconfiguring:
1833 case XenbusStateReconfigured: 1833 case XenbusStateReconfigured:
1834 case XenbusStateUnknown: 1834 case XenbusStateUnknown:
1835 case XenbusStateClosed:
1836 break; 1835 break;
1837 1836
1838 case XenbusStateInitWait: 1837 case XenbusStateInitWait:
@@ -1847,6 +1846,10 @@ static void netback_changed(struct xenbus_device *dev,
1847 netdev_notify_peers(netdev); 1846 netdev_notify_peers(netdev);
1848 break; 1847 break;
1849 1848
1849 case XenbusStateClosed:
1850 if (dev->state == XenbusStateClosed)
1851 break;
1852 /* Missed the backend's CLOSING state -- fallthrough */
1850 case XenbusStateClosing: 1853 case XenbusStateClosing:
1851 xenbus_frontend_closed(dev); 1854 xenbus_frontend_closed(dev);
1852 break; 1855 break;