aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/bonding/bond_main.c2
-rw-r--r--drivers/net/caif/caif_virtio.c2
-rw-r--r--drivers/net/ethernet/8390/ne2k-pci.c6
-rw-r--r--drivers/net/ethernet/Kconfig12
-rw-r--r--drivers/net/ethernet/Makefile1
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c8
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c34
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad_debugfs.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/adapter.h4
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c142
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c54
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c12
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c8
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_netdev.c10
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/en_tx.c12
-rw-r--r--drivers/net/ethernet/micrel/ksz884x.c6
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c8
-rw-r--r--drivers/net/ethernet/realtek/8139too.c4
-rw-r--r--drivers/net/ethernet/s6gmac.c1058
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_main.c14
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c1
-rw-r--r--drivers/net/ethernet/sun/sunvnet.c1
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet.h2
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c4
-rw-r--r--drivers/net/hyperv/hyperv_net.h1
-rw-r--r--drivers/net/hyperv/netvsc.c15
-rw-r--r--drivers/net/phy/micrel.c18
-rw-r--r--drivers/net/virtio_net.c2
-rw-r--r--drivers/net/vxlan.c34
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c4
-rw-r--r--drivers/net/wireless/ipw2x00/Kconfig3
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-drv.c2
-rw-r--r--drivers/net/wireless/iwlwifi/iwl-fh.h1
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c15
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c4
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/trans.c17
37 files changed, 306 insertions, 1219 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c
index 184c434ae305..0dceba1a2ba1 100644
--- a/drivers/net/bonding/bond_main.c
+++ b/drivers/net/bonding/bond_main.c
@@ -1648,7 +1648,7 @@ static int __bond_release_one(struct net_device *bond_dev,
1648 /* slave is not a slave or master is not master of this slave */ 1648 /* slave is not a slave or master is not master of this slave */
1649 if (!(slave_dev->flags & IFF_SLAVE) || 1649 if (!(slave_dev->flags & IFF_SLAVE) ||
1650 !netdev_has_upper_dev(slave_dev, bond_dev)) { 1650 !netdev_has_upper_dev(slave_dev, bond_dev)) {
1651 netdev_err(bond_dev, "cannot release %s\n", 1651 netdev_dbg(bond_dev, "cannot release %s\n",
1652 slave_dev->name); 1652 slave_dev->name);
1653 return -EINVAL; 1653 return -EINVAL;
1654 } 1654 }
diff --git a/drivers/net/caif/caif_virtio.c b/drivers/net/caif/caif_virtio.c
index a5fefb9059c5..b306210b02b7 100644
--- a/drivers/net/caif/caif_virtio.c
+++ b/drivers/net/caif/caif_virtio.c
@@ -257,7 +257,6 @@ static int cfv_rx_poll(struct napi_struct *napi, int quota)
257 struct vringh_kiov *riov = &cfv->ctx.riov; 257 struct vringh_kiov *riov = &cfv->ctx.riov;
258 unsigned int skb_len; 258 unsigned int skb_len;
259 259
260again:
261 do { 260 do {
262 skb = NULL; 261 skb = NULL;
263 262
@@ -322,7 +321,6 @@ exit:
322 napi_schedule_prep(napi)) { 321 napi_schedule_prep(napi)) {
323 vringh_notify_disable_kern(cfv->vr_rx); 322 vringh_notify_disable_kern(cfv->vr_rx);
324 __napi_schedule(napi); 323 __napi_schedule(napi);
325 goto again;
326 } 324 }
327 break; 325 break;
328 326
diff --git a/drivers/net/ethernet/8390/ne2k-pci.c b/drivers/net/ethernet/8390/ne2k-pci.c
index 89c8d9fc97de..57e97910c728 100644
--- a/drivers/net/ethernet/8390/ne2k-pci.c
+++ b/drivers/net/ethernet/8390/ne2k-pci.c
@@ -246,13 +246,13 @@ static int ne2k_pci_init_one(struct pci_dev *pdev,
246 246
247 if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) { 247 if (!ioaddr || ((pci_resource_flags (pdev, 0) & IORESOURCE_IO) == 0)) {
248 dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n"); 248 dev_err(&pdev->dev, "no I/O resource at PCI BAR #0\n");
249 return -ENODEV; 249 goto err_out;
250 } 250 }
251 251
252 if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) { 252 if (request_region (ioaddr, NE_IO_EXTENT, DRV_NAME) == NULL) {
253 dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n", 253 dev_err(&pdev->dev, "I/O resource 0x%x @ 0x%lx busy\n",
254 NE_IO_EXTENT, ioaddr); 254 NE_IO_EXTENT, ioaddr);
255 return -EBUSY; 255 goto err_out;
256 } 256 }
257 257
258 reg0 = inb(ioaddr); 258 reg0 = inb(ioaddr);
@@ -392,6 +392,8 @@ err_out_free_netdev:
392 free_netdev (dev); 392 free_netdev (dev);
393err_out_free_res: 393err_out_free_res:
394 release_region (ioaddr, NE_IO_EXTENT); 394 release_region (ioaddr, NE_IO_EXTENT);
395err_out:
396 pci_disable_device(pdev);
395 return -ENODEV; 397 return -ENODEV;
396} 398}
397 399
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index df76050d0a9d..eadcb053807e 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -156,18 +156,6 @@ source "drivers/net/ethernet/realtek/Kconfig"
156source "drivers/net/ethernet/renesas/Kconfig" 156source "drivers/net/ethernet/renesas/Kconfig"
157source "drivers/net/ethernet/rdc/Kconfig" 157source "drivers/net/ethernet/rdc/Kconfig"
158source "drivers/net/ethernet/rocker/Kconfig" 158source "drivers/net/ethernet/rocker/Kconfig"
159
160config S6GMAC
161 tristate "S6105 GMAC ethernet support"
162 depends on XTENSA_VARIANT_S6000
163 select PHYLIB
164 ---help---
165 This driver supports the on chip ethernet device on the
166 S6105 xtensa processor.
167
168 To compile this driver as a module, choose M here. The module
169 will be called s6gmac.
170
171source "drivers/net/ethernet/samsung/Kconfig" 159source "drivers/net/ethernet/samsung/Kconfig"
172source "drivers/net/ethernet/seeq/Kconfig" 160source "drivers/net/ethernet/seeq/Kconfig"
173source "drivers/net/ethernet/silan/Kconfig" 161source "drivers/net/ethernet/silan/Kconfig"
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index bf56f8b36e90..1367afcd0a8b 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -66,7 +66,6 @@ obj-$(CONFIG_NET_VENDOR_REALTEK) += realtek/
66obj-$(CONFIG_SH_ETH) += renesas/ 66obj-$(CONFIG_SH_ETH) += renesas/
67obj-$(CONFIG_NET_VENDOR_RDC) += rdc/ 67obj-$(CONFIG_NET_VENDOR_RDC) += rdc/
68obj-$(CONFIG_NET_VENDOR_ROCKER) += rocker/ 68obj-$(CONFIG_NET_VENDOR_ROCKER) += rocker/
69obj-$(CONFIG_S6GMAC) += s6gmac.o
70obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/ 69obj-$(CONFIG_NET_VENDOR_SAMSUNG) += samsung/
71obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/ 70obj-$(CONFIG_NET_VENDOR_SEEQ) += seeq/
72obj-$(CONFIG_NET_VENDOR_SILAN) += silan/ 71obj-$(CONFIG_NET_VENDOR_SILAN) += silan/
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 9f5e38769a29..72eef9fc883e 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -12553,9 +12553,11 @@ static int bnx2x_get_phys_port_id(struct net_device *netdev,
12553 return 0; 12553 return 0;
12554} 12554}
12555 12555
12556static bool bnx2x_gso_check(struct sk_buff *skb, struct net_device *dev) 12556static netdev_features_t bnx2x_features_check(struct sk_buff *skb,
12557 struct net_device *dev,
12558 netdev_features_t features)
12557{ 12559{
12558 return vxlan_gso_check(skb); 12560 return vxlan_features_check(skb, features);
12559} 12561}
12560 12562
12561static const struct net_device_ops bnx2x_netdev_ops = { 12563static const struct net_device_ops bnx2x_netdev_ops = {
@@ -12589,7 +12591,7 @@ static const struct net_device_ops bnx2x_netdev_ops = {
12589#endif 12591#endif
12590 .ndo_get_phys_port_id = bnx2x_get_phys_port_id, 12592 .ndo_get_phys_port_id = bnx2x_get_phys_port_id,
12591 .ndo_set_vf_link_state = bnx2x_set_vf_link_state, 12593 .ndo_set_vf_link_state = bnx2x_set_vf_link_state,
12592 .ndo_gso_check = bnx2x_gso_check, 12594 .ndo_features_check = bnx2x_features_check,
12593}; 12595};
12594 12596
12595static int bnx2x_set_coherency_mask(struct bnx2x *bp) 12597static int bnx2x_set_coherency_mask(struct bnx2x *bp)
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index bb48a610b72a..553dcd8a9df2 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -17800,23 +17800,6 @@ static int tg3_init_one(struct pci_dev *pdev,
17800 goto err_out_apeunmap; 17800 goto err_out_apeunmap;
17801 } 17801 }
17802 17802
17803 /*
17804 * Reset chip in case UNDI or EFI driver did not shutdown
17805 * DMA self test will enable WDMAC and we'll see (spurious)
17806 * pending DMA on the PCI bus at that point.
17807 */
17808 if ((tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE) ||
17809 (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
17810 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
17811 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
17812 }
17813
17814 err = tg3_test_dma(tp);
17815 if (err) {
17816 dev_err(&pdev->dev, "DMA engine test failed, aborting\n");
17817 goto err_out_apeunmap;
17818 }
17819
17820 intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW; 17803 intmbx = MAILBOX_INTERRUPT_0 + TG3_64BIT_REG_LOW;
17821 rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW; 17804 rcvmbx = MAILBOX_RCVRET_CON_IDX_0 + TG3_64BIT_REG_LOW;
17822 sndmbx = MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW; 17805 sndmbx = MAILBOX_SNDHOST_PROD_IDX_0 + TG3_64BIT_REG_LOW;
@@ -17861,6 +17844,23 @@ static int tg3_init_one(struct pci_dev *pdev,
17861 sndmbx += 0xc; 17844 sndmbx += 0xc;
17862 } 17845 }
17863 17846
17847 /*
17848 * Reset chip in case UNDI or EFI driver did not shutdown
17849 * DMA self test will enable WDMAC and we'll see (spurious)
17850 * pending DMA on the PCI bus at that point.
17851 */
17852 if ((tr32(HOSTCC_MODE) & HOSTCC_MODE_ENABLE) ||
17853 (tr32(WDMAC_MODE) & WDMAC_MODE_ENABLE)) {
17854 tw32(MEMARB_MODE, MEMARB_MODE_ENABLE);
17855 tg3_halt(tp, RESET_KIND_SHUTDOWN, 1);
17856 }
17857
17858 err = tg3_test_dma(tp);
17859 if (err) {
17860 dev_err(&pdev->dev, "DMA engine test failed, aborting\n");
17861 goto err_out_apeunmap;
17862 }
17863
17864 tg3_init_coal(tp); 17864 tg3_init_coal(tp);
17865 17865
17866 pci_set_drvdata(pdev, dev); 17866 pci_set_drvdata(pdev, dev);
diff --git a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
index 7d6aa8c87df8..619083a860a4 100644
--- a/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
+++ b/drivers/net/ethernet/brocade/bna/bnad_debugfs.c
@@ -172,7 +172,7 @@ bnad_get_debug_drvinfo(struct bnad *bnad, void *buffer, u32 len)
172 172
173 /* Retrieve flash partition info */ 173 /* Retrieve flash partition info */
174 fcomp.comp_status = 0; 174 fcomp.comp_status = 0;
175 init_completion(&fcomp.comp); 175 reinit_completion(&fcomp.comp);
176 spin_lock_irqsave(&bnad->bna_lock, flags); 176 spin_lock_irqsave(&bnad->bna_lock, flags);
177 ret = bfa_nw_flash_get_attr(&bnad->bna.flash, &drvinfo->flash_attr, 177 ret = bfa_nw_flash_get_attr(&bnad->bna.flash, &drvinfo->flash_attr,
178 bnad_cb_completion, &fcomp); 178 bnad_cb_completion, &fcomp);
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
index d00a751f0588..6049f70e110c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/adapter.h
@@ -96,6 +96,9 @@ struct port_info {
96 s16 xact_addr_filt; /* index of our MAC address filter */ 96 s16 xact_addr_filt; /* index of our MAC address filter */
97 u16 rss_size; /* size of VI's RSS table slice */ 97 u16 rss_size; /* size of VI's RSS table slice */
98 u8 pidx; /* index into adapter port[] */ 98 u8 pidx; /* index into adapter port[] */
99 s8 mdio_addr;
100 u8 port_type; /* firmware port type */
101 u8 mod_type; /* firmware module type */
99 u8 port_id; /* physical port ID */ 102 u8 port_id; /* physical port ID */
100 u8 nqsets; /* # of "Queue Sets" */ 103 u8 nqsets; /* # of "Queue Sets" */
101 u8 first_qset; /* index of first "Queue Set" */ 104 u8 first_qset; /* index of first "Queue Set" */
@@ -522,6 +525,7 @@ static inline struct adapter *netdev2adap(const struct net_device *dev)
522 * is "contracted" to provide for the common code. 525 * is "contracted" to provide for the common code.
523 */ 526 */
524void t4vf_os_link_changed(struct adapter *, int, int); 527void t4vf_os_link_changed(struct adapter *, int, int);
528void t4vf_os_portmod_changed(struct adapter *, int);
525 529
526/* 530/*
527 * SGE function prototype declarations. 531 * SGE function prototype declarations.
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index aa74ec34a467..2215d432a059 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -44,6 +44,7 @@
44#include <linux/etherdevice.h> 44#include <linux/etherdevice.h>
45#include <linux/debugfs.h> 45#include <linux/debugfs.h>
46#include <linux/ethtool.h> 46#include <linux/ethtool.h>
47#include <linux/mdio.h>
47 48
48#include "t4vf_common.h" 49#include "t4vf_common.h"
49#include "t4vf_defs.h" 50#include "t4vf_defs.h"
@@ -210,6 +211,38 @@ void t4vf_os_link_changed(struct adapter *adapter, int pidx, int link_ok)
210} 211}
211 212
212/* 213/*
214 * THe port module type has changed on the indicated "port" (Virtual
215 * Interface).
216 */
217void t4vf_os_portmod_changed(struct adapter *adapter, int pidx)
218{
219 static const char * const mod_str[] = {
220 NULL, "LR", "SR", "ER", "passive DA", "active DA", "LRM"
221 };
222 const struct net_device *dev = adapter->port[pidx];
223 const struct port_info *pi = netdev_priv(dev);
224
225 if (pi->mod_type == FW_PORT_MOD_TYPE_NONE)
226 dev_info(adapter->pdev_dev, "%s: port module unplugged\n",
227 dev->name);
228 else if (pi->mod_type < ARRAY_SIZE(mod_str))
229 dev_info(adapter->pdev_dev, "%s: %s port module inserted\n",
230 dev->name, mod_str[pi->mod_type]);
231 else if (pi->mod_type == FW_PORT_MOD_TYPE_NOTSUPPORTED)
232 dev_info(adapter->pdev_dev, "%s: unsupported optical port "
233 "module inserted\n", dev->name);
234 else if (pi->mod_type == FW_PORT_MOD_TYPE_UNKNOWN)
235 dev_info(adapter->pdev_dev, "%s: unknown port module inserted,"
236 "forcing TWINAX\n", dev->name);
237 else if (pi->mod_type == FW_PORT_MOD_TYPE_ERROR)
238 dev_info(adapter->pdev_dev, "%s: transceiver module error\n",
239 dev->name);
240 else
241 dev_info(adapter->pdev_dev, "%s: unknown module type %d "
242 "inserted\n", dev->name, pi->mod_type);
243}
244
245/*
213 * Net device operations. 246 * Net device operations.
214 * ====================== 247 * ======================
215 */ 248 */
@@ -1193,24 +1226,103 @@ static void cxgb4vf_poll_controller(struct net_device *dev)
1193 * state of the port to which we're linked. 1226 * state of the port to which we're linked.
1194 */ 1227 */
1195 1228
1196/* 1229static unsigned int t4vf_from_fw_linkcaps(enum fw_port_type type,
1197 * Return current port link settings. 1230 unsigned int caps)
1198 */ 1231{
1199static int cxgb4vf_get_settings(struct net_device *dev, 1232 unsigned int v = 0;
1200 struct ethtool_cmd *cmd) 1233
1201{ 1234 if (type == FW_PORT_TYPE_BT_SGMII || type == FW_PORT_TYPE_BT_XFI ||
1202 const struct port_info *pi = netdev_priv(dev); 1235 type == FW_PORT_TYPE_BT_XAUI) {
1236 v |= SUPPORTED_TP;
1237 if (caps & FW_PORT_CAP_SPEED_100M)
1238 v |= SUPPORTED_100baseT_Full;
1239 if (caps & FW_PORT_CAP_SPEED_1G)
1240 v |= SUPPORTED_1000baseT_Full;
1241 if (caps & FW_PORT_CAP_SPEED_10G)
1242 v |= SUPPORTED_10000baseT_Full;
1243 } else if (type == FW_PORT_TYPE_KX4 || type == FW_PORT_TYPE_KX) {
1244 v |= SUPPORTED_Backplane;
1245 if (caps & FW_PORT_CAP_SPEED_1G)
1246 v |= SUPPORTED_1000baseKX_Full;
1247 if (caps & FW_PORT_CAP_SPEED_10G)
1248 v |= SUPPORTED_10000baseKX4_Full;
1249 } else if (type == FW_PORT_TYPE_KR)
1250 v |= SUPPORTED_Backplane | SUPPORTED_10000baseKR_Full;
1251 else if (type == FW_PORT_TYPE_BP_AP)
1252 v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC |
1253 SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full;
1254 else if (type == FW_PORT_TYPE_BP4_AP)
1255 v |= SUPPORTED_Backplane | SUPPORTED_10000baseR_FEC |
1256 SUPPORTED_10000baseKR_Full | SUPPORTED_1000baseKX_Full |
1257 SUPPORTED_10000baseKX4_Full;
1258 else if (type == FW_PORT_TYPE_FIBER_XFI ||
1259 type == FW_PORT_TYPE_FIBER_XAUI ||
1260 type == FW_PORT_TYPE_SFP ||
1261 type == FW_PORT_TYPE_QSFP_10G ||
1262 type == FW_PORT_TYPE_QSA) {
1263 v |= SUPPORTED_FIBRE;
1264 if (caps & FW_PORT_CAP_SPEED_1G)
1265 v |= SUPPORTED_1000baseT_Full;
1266 if (caps & FW_PORT_CAP_SPEED_10G)
1267 v |= SUPPORTED_10000baseT_Full;
1268 } else if (type == FW_PORT_TYPE_BP40_BA ||
1269 type == FW_PORT_TYPE_QSFP) {
1270 v |= SUPPORTED_40000baseSR4_Full;
1271 v |= SUPPORTED_FIBRE;
1272 }
1273
1274 if (caps & FW_PORT_CAP_ANEG)
1275 v |= SUPPORTED_Autoneg;
1276 return v;
1277}
1278
1279static int cxgb4vf_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
1280{
1281 const struct port_info *p = netdev_priv(dev);
1282
1283 if (p->port_type == FW_PORT_TYPE_BT_SGMII ||
1284 p->port_type == FW_PORT_TYPE_BT_XFI ||
1285 p->port_type == FW_PORT_TYPE_BT_XAUI)
1286 cmd->port = PORT_TP;
1287 else if (p->port_type == FW_PORT_TYPE_FIBER_XFI ||
1288 p->port_type == FW_PORT_TYPE_FIBER_XAUI)
1289 cmd->port = PORT_FIBRE;
1290 else if (p->port_type == FW_PORT_TYPE_SFP ||
1291 p->port_type == FW_PORT_TYPE_QSFP_10G ||
1292 p->port_type == FW_PORT_TYPE_QSA ||
1293 p->port_type == FW_PORT_TYPE_QSFP) {
1294 if (p->mod_type == FW_PORT_MOD_TYPE_LR ||
1295 p->mod_type == FW_PORT_MOD_TYPE_SR ||
1296 p->mod_type == FW_PORT_MOD_TYPE_ER ||
1297 p->mod_type == FW_PORT_MOD_TYPE_LRM)
1298 cmd->port = PORT_FIBRE;
1299 else if (p->mod_type == FW_PORT_MOD_TYPE_TWINAX_PASSIVE ||
1300 p->mod_type == FW_PORT_MOD_TYPE_TWINAX_ACTIVE)
1301 cmd->port = PORT_DA;
1302 else
1303 cmd->port = PORT_OTHER;
1304 } else
1305 cmd->port = PORT_OTHER;
1203 1306
1204 cmd->supported = pi->link_cfg.supported; 1307 if (p->mdio_addr >= 0) {
1205 cmd->advertising = pi->link_cfg.advertising; 1308 cmd->phy_address = p->mdio_addr;
1309 cmd->transceiver = XCVR_EXTERNAL;
1310 cmd->mdio_support = p->port_type == FW_PORT_TYPE_BT_SGMII ?
1311 MDIO_SUPPORTS_C22 : MDIO_SUPPORTS_C45;
1312 } else {
1313 cmd->phy_address = 0; /* not really, but no better option */
1314 cmd->transceiver = XCVR_INTERNAL;
1315 cmd->mdio_support = 0;
1316 }
1317
1318 cmd->supported = t4vf_from_fw_linkcaps(p->port_type,
1319 p->link_cfg.supported);
1320 cmd->advertising = t4vf_from_fw_linkcaps(p->port_type,
1321 p->link_cfg.advertising);
1206 ethtool_cmd_speed_set(cmd, 1322 ethtool_cmd_speed_set(cmd,
1207 netif_carrier_ok(dev) ? pi->link_cfg.speed : -1); 1323 netif_carrier_ok(dev) ? p->link_cfg.speed : 0);
1208 cmd->duplex = DUPLEX_FULL; 1324 cmd->duplex = DUPLEX_FULL;
1209 1325 cmd->autoneg = p->link_cfg.autoneg;
1210 cmd->port = (cmd->supported & SUPPORTED_TP) ? PORT_TP : PORT_FIBRE;
1211 cmd->phy_address = pi->port_id;
1212 cmd->transceiver = XCVR_EXTERNAL;
1213 cmd->autoneg = pi->link_cfg.autoneg;
1214 cmd->maxtxpkt = 0; 1326 cmd->maxtxpkt = 0;
1215 cmd->maxrxpkt = 0; 1327 cmd->maxrxpkt = 0;
1216 return 0; 1328 return 0;
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
index 8d3237f5e364..b9debb4f29a3 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h
@@ -230,7 +230,7 @@ struct adapter_params {
230 230
231static inline bool is_10g_port(const struct link_config *lc) 231static inline bool is_10g_port(const struct link_config *lc)
232{ 232{
233 return (lc->supported & SUPPORTED_10000baseT_Full) != 0; 233 return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0;
234} 234}
235 235
236static inline bool is_x_10g_port(const struct link_config *lc) 236static inline bool is_x_10g_port(const struct link_config *lc)
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
index 02e8833b7797..21dc9a20308c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c
@@ -245,6 +245,10 @@ static int hash_mac_addr(const u8 *addr)
245 return a & 0x3f; 245 return a & 0x3f;
246} 246}
247 247
248#define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\
249 FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_SPEED_40G | \
250 FW_PORT_CAP_SPEED_100G | FW_PORT_CAP_ANEG)
251
248/** 252/**
249 * init_link_config - initialize a link's SW state 253 * init_link_config - initialize a link's SW state
250 * @lc: structure holding the link state 254 * @lc: structure holding the link state
@@ -259,8 +263,8 @@ static void init_link_config(struct link_config *lc, unsigned int caps)
259 lc->requested_speed = 0; 263 lc->requested_speed = 0;
260 lc->speed = 0; 264 lc->speed = 0;
261 lc->requested_fc = lc->fc = PAUSE_RX | PAUSE_TX; 265 lc->requested_fc = lc->fc = PAUSE_RX | PAUSE_TX;
262 if (lc->supported & SUPPORTED_Autoneg) { 266 if (lc->supported & FW_PORT_CAP_ANEG) {
263 lc->advertising = lc->supported; 267 lc->advertising = lc->supported & ADVERT_MASK;
264 lc->autoneg = AUTONEG_ENABLE; 268 lc->autoneg = AUTONEG_ENABLE;
265 lc->requested_fc |= PAUSE_AUTONEG; 269 lc->requested_fc |= PAUSE_AUTONEG;
266 } else { 270 } else {
@@ -280,7 +284,6 @@ int t4vf_port_init(struct adapter *adapter, int pidx)
280 struct fw_vi_cmd vi_cmd, vi_rpl; 284 struct fw_vi_cmd vi_cmd, vi_rpl;
281 struct fw_port_cmd port_cmd, port_rpl; 285 struct fw_port_cmd port_cmd, port_rpl;
282 int v; 286 int v;
283 u32 word;
284 287
285 /* 288 /*
286 * Execute a VI Read command to get our Virtual Interface information 289 * Execute a VI Read command to get our Virtual Interface information
@@ -319,19 +322,11 @@ int t4vf_port_init(struct adapter *adapter, int pidx)
319 if (v) 322 if (v)
320 return v; 323 return v;
321 324
322 v = 0; 325 v = be32_to_cpu(port_rpl.u.info.lstatus_to_modtype);
323 word = be16_to_cpu(port_rpl.u.info.pcap); 326 pi->port_type = FW_PORT_CMD_PTYPE_G(v);
324 if (word & FW_PORT_CAP_SPEED_100M) 327 pi->mod_type = FW_PORT_MOD_TYPE_NA;
325 v |= SUPPORTED_100baseT_Full; 328
326 if (word & FW_PORT_CAP_SPEED_1G) 329 init_link_config(&pi->link_cfg, be16_to_cpu(port_rpl.u.info.pcap));
327 v |= SUPPORTED_1000baseT_Full;
328 if (word & FW_PORT_CAP_SPEED_10G)
329 v |= SUPPORTED_10000baseT_Full;
330 if (word & FW_PORT_CAP_SPEED_40G)
331 v |= SUPPORTED_40000baseSR4_Full;
332 if (word & FW_PORT_CAP_ANEG)
333 v |= SUPPORTED_Autoneg;
334 init_link_config(&pi->link_cfg, v);
335 330
336 return 0; 331 return 0;
337} 332}
@@ -1491,7 +1486,7 @@ int t4vf_handle_fw_rpl(struct adapter *adapter, const __be64 *rpl)
1491 */ 1486 */
1492 const struct fw_port_cmd *port_cmd = 1487 const struct fw_port_cmd *port_cmd =
1493 (const struct fw_port_cmd *)rpl; 1488 (const struct fw_port_cmd *)rpl;
1494 u32 word; 1489 u32 stat, mod;
1495 int action, port_id, link_ok, speed, fc, pidx; 1490 int action, port_id, link_ok, speed, fc, pidx;
1496 1491
1497 /* 1492 /*
@@ -1509,21 +1504,21 @@ int t4vf_handle_fw_rpl(struct adapter *adapter, const __be64 *rpl)
1509 port_id = FW_PORT_CMD_PORTID_G( 1504 port_id = FW_PORT_CMD_PORTID_G(
1510 be32_to_cpu(port_cmd->op_to_portid)); 1505 be32_to_cpu(port_cmd->op_to_portid));
1511 1506
1512 word = be32_to_cpu(port_cmd->u.info.lstatus_to_modtype); 1507 stat = be32_to_cpu(port_cmd->u.info.lstatus_to_modtype);
1513 link_ok = (word & FW_PORT_CMD_LSTATUS_F) != 0; 1508 link_ok = (stat & FW_PORT_CMD_LSTATUS_F) != 0;
1514 speed = 0; 1509 speed = 0;
1515 fc = 0; 1510 fc = 0;
1516 if (word & FW_PORT_CMD_RXPAUSE_F) 1511 if (stat & FW_PORT_CMD_RXPAUSE_F)
1517 fc |= PAUSE_RX; 1512 fc |= PAUSE_RX;
1518 if (word & FW_PORT_CMD_TXPAUSE_F) 1513 if (stat & FW_PORT_CMD_TXPAUSE_F)
1519 fc |= PAUSE_TX; 1514 fc |= PAUSE_TX;
1520 if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_100M)) 1515 if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_100M))
1521 speed = 100; 1516 speed = 100;
1522 else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_1G)) 1517 else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_1G))
1523 speed = 1000; 1518 speed = 1000;
1524 else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_10G)) 1519 else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_10G))
1525 speed = 10000; 1520 speed = 10000;
1526 else if (word & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_40G)) 1521 else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_40G))
1527 speed = 40000; 1522 speed = 40000;
1528 1523
1529 /* 1524 /*
@@ -1540,12 +1535,21 @@ int t4vf_handle_fw_rpl(struct adapter *adapter, const __be64 *rpl)
1540 continue; 1535 continue;
1541 1536
1542 lc = &pi->link_cfg; 1537 lc = &pi->link_cfg;
1538
1539 mod = FW_PORT_CMD_MODTYPE_G(stat);
1540 if (mod != pi->mod_type) {
1541 pi->mod_type = mod;
1542 t4vf_os_portmod_changed(adapter, pidx);
1543 }
1544
1543 if (link_ok != lc->link_ok || speed != lc->speed || 1545 if (link_ok != lc->link_ok || speed != lc->speed ||
1544 fc != lc->fc) { 1546 fc != lc->fc) {
1545 /* something changed */ 1547 /* something changed */
1546 lc->link_ok = link_ok; 1548 lc->link_ok = link_ok;
1547 lc->speed = speed; 1549 lc->speed = speed;
1548 lc->fc = fc; 1550 lc->fc = fc;
1551 lc->supported =
1552 be16_to_cpu(port_cmd->u.info.pcap);
1549 t4vf_os_link_changed(adapter, pidx, link_ok); 1553 t4vf_os_link_changed(adapter, pidx, link_ok);
1550 } 1554 }
1551 } 1555 }
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 868d0f605d60..705f334ebb85 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -1060,10 +1060,14 @@ static void enic_rq_indicate_buf(struct vnic_rq *rq,
1060 PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3); 1060 PKT_HASH_TYPE_L4 : PKT_HASH_TYPE_L3);
1061 } 1061 }
1062 1062
1063 if ((netdev->features & NETIF_F_RXCSUM) && !csum_not_calc) { 1063 /* Hardware does not provide whole packet checksum. It only
1064 skb->csum = htons(checksum); 1064 * provides pseudo checksum. Since hw validates the packet
1065 skb->ip_summed = CHECKSUM_COMPLETE; 1065 * checksum but not provide us the checksum value. use
1066 } 1066 * CHECSUM_UNNECESSARY.
1067 */
1068 if ((netdev->features & NETIF_F_RXCSUM) && tcp_udp_csum_ok &&
1069 ipv4_csum_ok)
1070 skb->ip_summed = CHECKSUM_UNNECESSARY;
1067 1071
1068 if (vlan_stripped) 1072 if (vlan_stripped)
1069 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci); 1073 __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan_tci);
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index 196073110e32..41a0a5498da7 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4459,9 +4459,11 @@ done:
4459 adapter->vxlan_port_count--; 4459 adapter->vxlan_port_count--;
4460} 4460}
4461 4461
4462static bool be_gso_check(struct sk_buff *skb, struct net_device *dev) 4462static netdev_features_t be_features_check(struct sk_buff *skb,
4463 struct net_device *dev,
4464 netdev_features_t features)
4463{ 4465{
4464 return vxlan_gso_check(skb); 4466 return vxlan_features_check(skb, features);
4465} 4467}
4466#endif 4468#endif
4467 4469
@@ -4492,7 +4494,7 @@ static const struct net_device_ops be_netdev_ops = {
4492#ifdef CONFIG_BE2NET_VXLAN 4494#ifdef CONFIG_BE2NET_VXLAN
4493 .ndo_add_vxlan_port = be_add_vxlan_port, 4495 .ndo_add_vxlan_port = be_add_vxlan_port,
4494 .ndo_del_vxlan_port = be_del_vxlan_port, 4496 .ndo_del_vxlan_port = be_del_vxlan_port,
4495 .ndo_gso_check = be_gso_check, 4497 .ndo_features_check = be_features_check,
4496#endif 4498#endif
4497}; 4499};
4498 4500
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 190cbd931f6b..d0d6dc1b8e46 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -2365,9 +2365,11 @@ static void mlx4_en_del_vxlan_port(struct net_device *dev,
2365 queue_work(priv->mdev->workqueue, &priv->vxlan_del_task); 2365 queue_work(priv->mdev->workqueue, &priv->vxlan_del_task);
2366} 2366}
2367 2367
2368static bool mlx4_en_gso_check(struct sk_buff *skb, struct net_device *dev) 2368static netdev_features_t mlx4_en_features_check(struct sk_buff *skb,
2369 struct net_device *dev,
2370 netdev_features_t features)
2369{ 2371{
2370 return vxlan_gso_check(skb); 2372 return vxlan_features_check(skb, features);
2371} 2373}
2372#endif 2374#endif
2373 2375
@@ -2400,7 +2402,7 @@ static const struct net_device_ops mlx4_netdev_ops = {
2400#ifdef CONFIG_MLX4_EN_VXLAN 2402#ifdef CONFIG_MLX4_EN_VXLAN
2401 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port, 2403 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
2402 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, 2404 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
2403 .ndo_gso_check = mlx4_en_gso_check, 2405 .ndo_features_check = mlx4_en_features_check,
2404#endif 2406#endif
2405}; 2407};
2406 2408
@@ -2434,7 +2436,7 @@ static const struct net_device_ops mlx4_netdev_ops_master = {
2434#ifdef CONFIG_MLX4_EN_VXLAN 2436#ifdef CONFIG_MLX4_EN_VXLAN
2435 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port, 2437 .ndo_add_vxlan_port = mlx4_en_add_vxlan_port,
2436 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port, 2438 .ndo_del_vxlan_port = mlx4_en_del_vxlan_port,
2437 .ndo_gso_check = mlx4_en_gso_check, 2439 .ndo_features_check = mlx4_en_features_check,
2438#endif 2440#endif
2439}; 2441};
2440 2442
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
index a308d41e4de0..e3357bf523df 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c
@@ -962,7 +962,17 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev)
962 tx_desc->ctrl.owner_opcode = op_own; 962 tx_desc->ctrl.owner_opcode = op_own;
963 if (send_doorbell) { 963 if (send_doorbell) {
964 wmb(); 964 wmb();
965 iowrite32(ring->doorbell_qpn, 965 /* Since there is no iowrite*_native() that writes the
966 * value as is, without byteswapping - using the one
967 * the doesn't do byteswapping in the relevant arch
968 * endianness.
969 */
970#if defined(__LITTLE_ENDIAN)
971 iowrite32(
972#else
973 iowrite32be(
974#endif
975 ring->doorbell_qpn,
966 ring->bf.uar->map + MLX4_SEND_DOORBELL); 976 ring->bf.uar->map + MLX4_SEND_DOORBELL);
967 } else { 977 } else {
968 ring->xmit_more++; 978 ring->xmit_more++;
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index f1ebed6c63b1..2fa6ae026e4f 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -2303,12 +2303,6 @@ static inline int port_chk_force_flow_ctrl(struct ksz_hw *hw, int p)
2303 2303
2304/* Spanning Tree */ 2304/* Spanning Tree */
2305 2305
2306static inline void port_cfg_dis_learn(struct ksz_hw *hw, int p, int set)
2307{
2308 port_cfg(hw, p,
2309 KS8842_PORT_CTRL_2_OFFSET, PORT_LEARN_DISABLE, set);
2310}
2311
2312static inline void port_cfg_rx(struct ksz_hw *hw, int p, int set) 2306static inline void port_cfg_rx(struct ksz_hw *hw, int p, int set)
2313{ 2307{
2314 port_cfg(hw, p, 2308 port_cfg(hw, p,
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 1aa25b13ace1..9929b97cfb36 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -505,9 +505,11 @@ static void qlcnic_del_vxlan_port(struct net_device *netdev,
505 adapter->flags |= QLCNIC_DEL_VXLAN_PORT; 505 adapter->flags |= QLCNIC_DEL_VXLAN_PORT;
506} 506}
507 507
508static bool qlcnic_gso_check(struct sk_buff *skb, struct net_device *dev) 508static netdev_features_t qlcnic_features_check(struct sk_buff *skb,
509 struct net_device *dev,
510 netdev_features_t features)
509{ 511{
510 return vxlan_gso_check(skb); 512 return vxlan_features_check(skb, features);
511} 513}
512#endif 514#endif
513 515
@@ -532,7 +534,7 @@ static const struct net_device_ops qlcnic_netdev_ops = {
532#ifdef CONFIG_QLCNIC_VXLAN 534#ifdef CONFIG_QLCNIC_VXLAN
533 .ndo_add_vxlan_port = qlcnic_add_vxlan_port, 535 .ndo_add_vxlan_port = qlcnic_add_vxlan_port,
534 .ndo_del_vxlan_port = qlcnic_del_vxlan_port, 536 .ndo_del_vxlan_port = qlcnic_del_vxlan_port,
535 .ndo_gso_check = qlcnic_gso_check, 537 .ndo_features_check = qlcnic_features_check,
536#endif 538#endif
537#ifdef CONFIG_NET_POLL_CONTROLLER 539#ifdef CONFIG_NET_POLL_CONTROLLER
538 .ndo_poll_controller = qlcnic_poll_controller, 540 .ndo_poll_controller = qlcnic_poll_controller,
diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c
index 6d0b9dfac313..78bb4ceb1cdd 100644
--- a/drivers/net/ethernet/realtek/8139too.c
+++ b/drivers/net/ethernet/realtek/8139too.c
@@ -787,10 +787,10 @@ static struct net_device *rtl8139_init_board(struct pci_dev *pdev)
787 if (rc) 787 if (rc)
788 goto err_out; 788 goto err_out;
789 789
790 disable_dev_on_err = 1;
790 rc = pci_request_regions (pdev, DRV_NAME); 791 rc = pci_request_regions (pdev, DRV_NAME);
791 if (rc) 792 if (rc)
792 goto err_out; 793 goto err_out;
793 disable_dev_on_err = 1;
794 794
795 pci_set_master (pdev); 795 pci_set_master (pdev);
796 796
@@ -1110,6 +1110,7 @@ static int rtl8139_init_one(struct pci_dev *pdev,
1110 return 0; 1110 return 0;
1111 1111
1112err_out: 1112err_out:
1113 netif_napi_del(&tp->napi);
1113 __rtl8139_cleanup_dev (dev); 1114 __rtl8139_cleanup_dev (dev);
1114 pci_disable_device (pdev); 1115 pci_disable_device (pdev);
1115 return i; 1116 return i;
@@ -1124,6 +1125,7 @@ static void rtl8139_remove_one(struct pci_dev *pdev)
1124 assert (dev != NULL); 1125 assert (dev != NULL);
1125 1126
1126 cancel_delayed_work_sync(&tp->thread); 1127 cancel_delayed_work_sync(&tp->thread);
1128 netif_napi_del(&tp->napi);
1127 1129
1128 unregister_netdev (dev); 1130 unregister_netdev (dev);
1129 1131
diff --git a/drivers/net/ethernet/s6gmac.c b/drivers/net/ethernet/s6gmac.c
deleted file mode 100644
index f537cbea20e5..000000000000
--- a/drivers/net/ethernet/s6gmac.c
+++ /dev/null
@@ -1,1058 +0,0 @@
1/*
2 * Ethernet driver for S6105 on chip network device
3 * (c)2008 emlix GmbH http://www.emlix.com
4 * Authors: Oskar Schirmer <oskar@scara.com>
5 * Daniel Gloeckner <dg@emlix.com>
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version
10 * 2 of the License, or (at your option) any later version.
11 */
12#include <linux/kernel.h>
13#include <linux/module.h>
14#include <linux/interrupt.h>
15#include <linux/types.h>
16#include <linux/delay.h>
17#include <linux/spinlock.h>
18#include <linux/netdevice.h>
19#include <linux/etherdevice.h>
20#include <linux/if.h>
21#include <linux/stddef.h>
22#include <linux/mii.h>
23#include <linux/phy.h>
24#include <linux/platform_device.h>
25#include <variant/hardware.h>
26#include <variant/dmac.h>
27
28#define DRV_NAME "s6gmac"
29#define DRV_PRMT DRV_NAME ": "
30
31
32/* register declarations */
33
34#define S6_GMAC_MACCONF1 0x000
35#define S6_GMAC_MACCONF1_TXENA 0
36#define S6_GMAC_MACCONF1_SYNCTX 1
37#define S6_GMAC_MACCONF1_RXENA 2
38#define S6_GMAC_MACCONF1_SYNCRX 3
39#define S6_GMAC_MACCONF1_TXFLOWCTRL 4
40#define S6_GMAC_MACCONF1_RXFLOWCTRL 5
41#define S6_GMAC_MACCONF1_LOOPBACK 8
42#define S6_GMAC_MACCONF1_RESTXFUNC 16
43#define S6_GMAC_MACCONF1_RESRXFUNC 17
44#define S6_GMAC_MACCONF1_RESTXMACCTRL 18
45#define S6_GMAC_MACCONF1_RESRXMACCTRL 19
46#define S6_GMAC_MACCONF1_SIMULRES 30
47#define S6_GMAC_MACCONF1_SOFTRES 31
48#define S6_GMAC_MACCONF2 0x004
49#define S6_GMAC_MACCONF2_FULL 0
50#define S6_GMAC_MACCONF2_CRCENA 1
51#define S6_GMAC_MACCONF2_PADCRCENA 2
52#define S6_GMAC_MACCONF2_LENGTHFCHK 4
53#define S6_GMAC_MACCONF2_HUGEFRAMENA 5
54#define S6_GMAC_MACCONF2_IFMODE 8
55#define S6_GMAC_MACCONF2_IFMODE_NIBBLE 1
56#define S6_GMAC_MACCONF2_IFMODE_BYTE 2
57#define S6_GMAC_MACCONF2_IFMODE_MASK 3
58#define S6_GMAC_MACCONF2_PREAMBLELEN 12
59#define S6_GMAC_MACCONF2_PREAMBLELEN_MASK 0x0F
60#define S6_GMAC_MACIPGIFG 0x008
61#define S6_GMAC_MACIPGIFG_B2BINTERPGAP 0
62#define S6_GMAC_MACIPGIFG_B2BINTERPGAP_MASK 0x7F
63#define S6_GMAC_MACIPGIFG_MINIFGENFORCE 8
64#define S6_GMAC_MACIPGIFG_B2BINTERPGAP2 16
65#define S6_GMAC_MACIPGIFG_B2BINTERPGAP1 24
66#define S6_GMAC_MACHALFDUPLEX 0x00C
67#define S6_GMAC_MACHALFDUPLEX_COLLISWIN 0
68#define S6_GMAC_MACHALFDUPLEX_COLLISWIN_MASK 0x3F
69#define S6_GMAC_MACHALFDUPLEX_RETXMAX 12
70#define S6_GMAC_MACHALFDUPLEX_RETXMAX_MASK 0x0F
71#define S6_GMAC_MACHALFDUPLEX_EXCESSDEF 16
72#define S6_GMAC_MACHALFDUPLEX_NOBACKOFF 17
73#define S6_GMAC_MACHALFDUPLEX_BPNOBCKOF 18
74#define S6_GMAC_MACHALFDUPLEX_ALTBEBENA 19
75#define S6_GMAC_MACHALFDUPLEX_ALTBEBTRN 20
76#define S6_GMAC_MACHALFDUPLEX_ALTBEBTR_MASK 0x0F
77#define S6_GMAC_MACMAXFRAMELEN 0x010
78#define S6_GMAC_MACMIICONF 0x020
79#define S6_GMAC_MACMIICONF_CSEL 0
80#define S6_GMAC_MACMIICONF_CSEL_DIV10 0
81#define S6_GMAC_MACMIICONF_CSEL_DIV12 1
82#define S6_GMAC_MACMIICONF_CSEL_DIV14 2
83#define S6_GMAC_MACMIICONF_CSEL_DIV18 3
84#define S6_GMAC_MACMIICONF_CSEL_DIV24 4
85#define S6_GMAC_MACMIICONF_CSEL_DIV34 5
86#define S6_GMAC_MACMIICONF_CSEL_DIV68 6
87#define S6_GMAC_MACMIICONF_CSEL_DIV168 7
88#define S6_GMAC_MACMIICONF_CSEL_MASK 7
89#define S6_GMAC_MACMIICONF_PREAMBLESUPR 4
90#define S6_GMAC_MACMIICONF_SCANAUTOINCR 5
91#define S6_GMAC_MACMIICMD 0x024
92#define S6_GMAC_MACMIICMD_READ 0
93#define S6_GMAC_MACMIICMD_SCAN 1
94#define S6_GMAC_MACMIIADDR 0x028
95#define S6_GMAC_MACMIIADDR_REG 0
96#define S6_GMAC_MACMIIADDR_REG_MASK 0x1F
97#define S6_GMAC_MACMIIADDR_PHY 8
98#define S6_GMAC_MACMIIADDR_PHY_MASK 0x1F
99#define S6_GMAC_MACMIICTRL 0x02C
100#define S6_GMAC_MACMIISTAT 0x030
101#define S6_GMAC_MACMIIINDI 0x034
102#define S6_GMAC_MACMIIINDI_BUSY 0
103#define S6_GMAC_MACMIIINDI_SCAN 1
104#define S6_GMAC_MACMIIINDI_INVAL 2
105#define S6_GMAC_MACINTERFSTAT 0x03C
106#define S6_GMAC_MACINTERFSTAT_LINKFAIL 3
107#define S6_GMAC_MACINTERFSTAT_EXCESSDEF 9
108#define S6_GMAC_MACSTATADDR1 0x040
109#define S6_GMAC_MACSTATADDR2 0x044
110
111#define S6_GMAC_FIFOCONF0 0x048
112#define S6_GMAC_FIFOCONF0_HSTRSTWT 0
113#define S6_GMAC_FIFOCONF0_HSTRSTSR 1
114#define S6_GMAC_FIFOCONF0_HSTRSTFR 2
115#define S6_GMAC_FIFOCONF0_HSTRSTST 3
116#define S6_GMAC_FIFOCONF0_HSTRSTFT 4
117#define S6_GMAC_FIFOCONF0_WTMENREQ 8
118#define S6_GMAC_FIFOCONF0_SRFENREQ 9
119#define S6_GMAC_FIFOCONF0_FRFENREQ 10
120#define S6_GMAC_FIFOCONF0_STFENREQ 11
121#define S6_GMAC_FIFOCONF0_FTFENREQ 12
122#define S6_GMAC_FIFOCONF0_WTMENRPLY 16
123#define S6_GMAC_FIFOCONF0_SRFENRPLY 17
124#define S6_GMAC_FIFOCONF0_FRFENRPLY 18
125#define S6_GMAC_FIFOCONF0_STFENRPLY 19
126#define S6_GMAC_FIFOCONF0_FTFENRPLY 20
127#define S6_GMAC_FIFOCONF1 0x04C
128#define S6_GMAC_FIFOCONF2 0x050
129#define S6_GMAC_FIFOCONF2_CFGLWM 0
130#define S6_GMAC_FIFOCONF2_CFGHWM 16
131#define S6_GMAC_FIFOCONF3 0x054
132#define S6_GMAC_FIFOCONF3_CFGFTTH 0
133#define S6_GMAC_FIFOCONF3_CFGHWMFT 16
134#define S6_GMAC_FIFOCONF4 0x058
135#define S6_GMAC_FIFOCONF_RSV_PREVDROP 0
136#define S6_GMAC_FIFOCONF_RSV_RUNT 1
137#define S6_GMAC_FIFOCONF_RSV_FALSECAR 2
138#define S6_GMAC_FIFOCONF_RSV_CODEERR 3
139#define S6_GMAC_FIFOCONF_RSV_CRCERR 4
140#define S6_GMAC_FIFOCONF_RSV_LENGTHERR 5
141#define S6_GMAC_FIFOCONF_RSV_LENRANGE 6
142#define S6_GMAC_FIFOCONF_RSV_OK 7
143#define S6_GMAC_FIFOCONF_RSV_MULTICAST 8
144#define S6_GMAC_FIFOCONF_RSV_BROADCAST 9
145#define S6_GMAC_FIFOCONF_RSV_DRIBBLE 10
146#define S6_GMAC_FIFOCONF_RSV_CTRLFRAME 11
147#define S6_GMAC_FIFOCONF_RSV_PAUSECTRL 12
148#define S6_GMAC_FIFOCONF_RSV_UNOPCODE 13
149#define S6_GMAC_FIFOCONF_RSV_VLANTAG 14
150#define S6_GMAC_FIFOCONF_RSV_LONGEVENT 15
151#define S6_GMAC_FIFOCONF_RSV_TRUNCATED 16
152#define S6_GMAC_FIFOCONF_RSV_MASK 0x3FFFF
153#define S6_GMAC_FIFOCONF5 0x05C
154#define S6_GMAC_FIFOCONF5_DROPLT64 18
155#define S6_GMAC_FIFOCONF5_CFGBYTM 19
156#define S6_GMAC_FIFOCONF5_RXDROPSIZE 20
157#define S6_GMAC_FIFOCONF5_RXDROPSIZE_MASK 0xF
158
159#define S6_GMAC_STAT_REGS 0x080
160#define S6_GMAC_STAT_SIZE_MIN 12
161#define S6_GMAC_STATTR64 0x080
162#define S6_GMAC_STATTR64_SIZE 18
163#define S6_GMAC_STATTR127 0x084
164#define S6_GMAC_STATTR127_SIZE 18
165#define S6_GMAC_STATTR255 0x088
166#define S6_GMAC_STATTR255_SIZE 18
167#define S6_GMAC_STATTR511 0x08C
168#define S6_GMAC_STATTR511_SIZE 18
169#define S6_GMAC_STATTR1K 0x090
170#define S6_GMAC_STATTR1K_SIZE 18
171#define S6_GMAC_STATTRMAX 0x094
172#define S6_GMAC_STATTRMAX_SIZE 18
173#define S6_GMAC_STATTRMGV 0x098
174#define S6_GMAC_STATTRMGV_SIZE 18
175#define S6_GMAC_STATRBYT 0x09C
176#define S6_GMAC_STATRBYT_SIZE 24
177#define S6_GMAC_STATRPKT 0x0A0
178#define S6_GMAC_STATRPKT_SIZE 18
179#define S6_GMAC_STATRFCS 0x0A4
180#define S6_GMAC_STATRFCS_SIZE 12
181#define S6_GMAC_STATRMCA 0x0A8
182#define S6_GMAC_STATRMCA_SIZE 18
183#define S6_GMAC_STATRBCA 0x0AC
184#define S6_GMAC_STATRBCA_SIZE 22
185#define S6_GMAC_STATRXCF 0x0B0
186#define S6_GMAC_STATRXCF_SIZE 18
187#define S6_GMAC_STATRXPF 0x0B4
188#define S6_GMAC_STATRXPF_SIZE 12
189#define S6_GMAC_STATRXUO 0x0B8
190#define S6_GMAC_STATRXUO_SIZE 12
191#define S6_GMAC_STATRALN 0x0BC
192#define S6_GMAC_STATRALN_SIZE 12
193#define S6_GMAC_STATRFLR 0x0C0
194#define S6_GMAC_STATRFLR_SIZE 16
195#define S6_GMAC_STATRCDE 0x0C4
196#define S6_GMAC_STATRCDE_SIZE 12
197#define S6_GMAC_STATRCSE 0x0C8
198#define S6_GMAC_STATRCSE_SIZE 12
199#define S6_GMAC_STATRUND 0x0CC
200#define S6_GMAC_STATRUND_SIZE 12
201#define S6_GMAC_STATROVR 0x0D0
202#define S6_GMAC_STATROVR_SIZE 12
203#define S6_GMAC_STATRFRG 0x0D4
204#define S6_GMAC_STATRFRG_SIZE 12
205#define S6_GMAC_STATRJBR 0x0D8
206#define S6_GMAC_STATRJBR_SIZE 12
207#define S6_GMAC_STATRDRP 0x0DC
208#define S6_GMAC_STATRDRP_SIZE 12
209#define S6_GMAC_STATTBYT 0x0E0
210#define S6_GMAC_STATTBYT_SIZE 24
211#define S6_GMAC_STATTPKT 0x0E4
212#define S6_GMAC_STATTPKT_SIZE 18
213#define S6_GMAC_STATTMCA 0x0E8
214#define S6_GMAC_STATTMCA_SIZE 18
215#define S6_GMAC_STATTBCA 0x0EC
216#define S6_GMAC_STATTBCA_SIZE 18
217#define S6_GMAC_STATTXPF 0x0F0
218#define S6_GMAC_STATTXPF_SIZE 12
219#define S6_GMAC_STATTDFR 0x0F4
220#define S6_GMAC_STATTDFR_SIZE 12
221#define S6_GMAC_STATTEDF 0x0F8
222#define S6_GMAC_STATTEDF_SIZE 12
223#define S6_GMAC_STATTSCL 0x0FC
224#define S6_GMAC_STATTSCL_SIZE 12
225#define S6_GMAC_STATTMCL 0x100
226#define S6_GMAC_STATTMCL_SIZE 12
227#define S6_GMAC_STATTLCL 0x104
228#define S6_GMAC_STATTLCL_SIZE 12
229#define S6_GMAC_STATTXCL 0x108
230#define S6_GMAC_STATTXCL_SIZE 12
231#define S6_GMAC_STATTNCL 0x10C
232#define S6_GMAC_STATTNCL_SIZE 13
233#define S6_GMAC_STATTPFH 0x110
234#define S6_GMAC_STATTPFH_SIZE 12
235#define S6_GMAC_STATTDRP 0x114
236#define S6_GMAC_STATTDRP_SIZE 12
237#define S6_GMAC_STATTJBR 0x118
238#define S6_GMAC_STATTJBR_SIZE 12
239#define S6_GMAC_STATTFCS 0x11C
240#define S6_GMAC_STATTFCS_SIZE 12
241#define S6_GMAC_STATTXCF 0x120
242#define S6_GMAC_STATTXCF_SIZE 12
243#define S6_GMAC_STATTOVR 0x124
244#define S6_GMAC_STATTOVR_SIZE 12
245#define S6_GMAC_STATTUND 0x128
246#define S6_GMAC_STATTUND_SIZE 12
247#define S6_GMAC_STATTFRG 0x12C
248#define S6_GMAC_STATTFRG_SIZE 12
249#define S6_GMAC_STATCARRY(n) (0x130 + 4*(n))
250#define S6_GMAC_STATCARRYMSK(n) (0x138 + 4*(n))
251#define S6_GMAC_STATCARRY1_RDRP 0
252#define S6_GMAC_STATCARRY1_RJBR 1
253#define S6_GMAC_STATCARRY1_RFRG 2
254#define S6_GMAC_STATCARRY1_ROVR 3
255#define S6_GMAC_STATCARRY1_RUND 4
256#define S6_GMAC_STATCARRY1_RCSE 5
257#define S6_GMAC_STATCARRY1_RCDE 6
258#define S6_GMAC_STATCARRY1_RFLR 7
259#define S6_GMAC_STATCARRY1_RALN 8
260#define S6_GMAC_STATCARRY1_RXUO 9
261#define S6_GMAC_STATCARRY1_RXPF 10
262#define S6_GMAC_STATCARRY1_RXCF 11
263#define S6_GMAC_STATCARRY1_RBCA 12
264#define S6_GMAC_STATCARRY1_RMCA 13
265#define S6_GMAC_STATCARRY1_RFCS 14
266#define S6_GMAC_STATCARRY1_RPKT 15
267#define S6_GMAC_STATCARRY1_RBYT 16
268#define S6_GMAC_STATCARRY1_TRMGV 25
269#define S6_GMAC_STATCARRY1_TRMAX 26
270#define S6_GMAC_STATCARRY1_TR1K 27
271#define S6_GMAC_STATCARRY1_TR511 28
272#define S6_GMAC_STATCARRY1_TR255 29
273#define S6_GMAC_STATCARRY1_TR127 30
274#define S6_GMAC_STATCARRY1_TR64 31
275#define S6_GMAC_STATCARRY2_TDRP 0
276#define S6_GMAC_STATCARRY2_TPFH 1
277#define S6_GMAC_STATCARRY2_TNCL 2
278#define S6_GMAC_STATCARRY2_TXCL 3
279#define S6_GMAC_STATCARRY2_TLCL 4
280#define S6_GMAC_STATCARRY2_TMCL 5
281#define S6_GMAC_STATCARRY2_TSCL 6
282#define S6_GMAC_STATCARRY2_TEDF 7
283#define S6_GMAC_STATCARRY2_TDFR 8
284#define S6_GMAC_STATCARRY2_TXPF 9
285#define S6_GMAC_STATCARRY2_TBCA 10
286#define S6_GMAC_STATCARRY2_TMCA 11
287#define S6_GMAC_STATCARRY2_TPKT 12
288#define S6_GMAC_STATCARRY2_TBYT 13
289#define S6_GMAC_STATCARRY2_TFRG 14
290#define S6_GMAC_STATCARRY2_TUND 15
291#define S6_GMAC_STATCARRY2_TOVR 16
292#define S6_GMAC_STATCARRY2_TXCF 17
293#define S6_GMAC_STATCARRY2_TFCS 18
294#define S6_GMAC_STATCARRY2_TJBR 19
295
296#define S6_GMAC_HOST_PBLKCTRL 0x140
297#define S6_GMAC_HOST_PBLKCTRL_TXENA 0
298#define S6_GMAC_HOST_PBLKCTRL_RXENA 1
299#define S6_GMAC_HOST_PBLKCTRL_TXSRES 2
300#define S6_GMAC_HOST_PBLKCTRL_RXSRES 3
301#define S6_GMAC_HOST_PBLKCTRL_TXBSIZ 8
302#define S6_GMAC_HOST_PBLKCTRL_RXBSIZ 12
303#define S6_GMAC_HOST_PBLKCTRL_SIZ_16 4
304#define S6_GMAC_HOST_PBLKCTRL_SIZ_32 5
305#define S6_GMAC_HOST_PBLKCTRL_SIZ_64 6
306#define S6_GMAC_HOST_PBLKCTRL_SIZ_128 7
307#define S6_GMAC_HOST_PBLKCTRL_SIZ_MASK 0xF
308#define S6_GMAC_HOST_PBLKCTRL_STATENA 16
309#define S6_GMAC_HOST_PBLKCTRL_STATAUTOZ 17
310#define S6_GMAC_HOST_PBLKCTRL_STATCLEAR 18
311#define S6_GMAC_HOST_PBLKCTRL_RGMII 19
312#define S6_GMAC_HOST_INTMASK 0x144
313#define S6_GMAC_HOST_INTSTAT 0x148
314#define S6_GMAC_HOST_INT_TXBURSTOVER 3
315#define S6_GMAC_HOST_INT_TXPREWOVER 4
316#define S6_GMAC_HOST_INT_RXBURSTUNDER 5
317#define S6_GMAC_HOST_INT_RXPOSTRFULL 6
318#define S6_GMAC_HOST_INT_RXPOSTRUNDER 7
319#define S6_GMAC_HOST_RXFIFOHWM 0x14C
320#define S6_GMAC_HOST_CTRLFRAMXP 0x150
321#define S6_GMAC_HOST_DSTADDRLO(n) (0x160 + 8*(n))
322#define S6_GMAC_HOST_DSTADDRHI(n) (0x164 + 8*(n))
323#define S6_GMAC_HOST_DSTMASKLO(n) (0x180 + 8*(n))
324#define S6_GMAC_HOST_DSTMASKHI(n) (0x184 + 8*(n))
325
326#define S6_GMAC_BURST_PREWR 0x1B0
327#define S6_GMAC_BURST_PREWR_LEN 0
328#define S6_GMAC_BURST_PREWR_LEN_MASK ((1 << 20) - 1)
329#define S6_GMAC_BURST_PREWR_CFE 20
330#define S6_GMAC_BURST_PREWR_PPE 21
331#define S6_GMAC_BURST_PREWR_FCS 22
332#define S6_GMAC_BURST_PREWR_PAD 23
333#define S6_GMAC_BURST_POSTRD 0x1D0
334#define S6_GMAC_BURST_POSTRD_LEN 0
335#define S6_GMAC_BURST_POSTRD_LEN_MASK ((1 << 20) - 1)
336#define S6_GMAC_BURST_POSTRD_DROP 20
337
338
339/* data handling */
340
341#define S6_NUM_TX_SKB 8 /* must be larger than TX fifo size */
342#define S6_NUM_RX_SKB 16
343#define S6_MAX_FRLEN 1536
344
345struct s6gmac {
346 u32 reg;
347 u32 tx_dma;
348 u32 rx_dma;
349 u32 io;
350 u8 tx_chan;
351 u8 rx_chan;
352 spinlock_t lock;
353 u8 tx_skb_i, tx_skb_o;
354 u8 rx_skb_i, rx_skb_o;
355 struct sk_buff *tx_skb[S6_NUM_TX_SKB];
356 struct sk_buff *rx_skb[S6_NUM_RX_SKB];
357 unsigned long carry[sizeof(struct net_device_stats) / sizeof(long)];
358 unsigned long stats[sizeof(struct net_device_stats) / sizeof(long)];
359 struct phy_device *phydev;
360 struct {
361 struct mii_bus *bus;
362 int irq[PHY_MAX_ADDR];
363 } mii;
364 struct {
365 unsigned int mbit;
366 u8 giga;
367 u8 isup;
368 u8 full;
369 } link;
370};
371
372static void s6gmac_rx_fillfifo(struct net_device *dev)
373{
374 struct s6gmac *pd = netdev_priv(dev);
375 struct sk_buff *skb;
376 while ((((u8)(pd->rx_skb_i - pd->rx_skb_o)) < S6_NUM_RX_SKB) &&
377 (!s6dmac_fifo_full(pd->rx_dma, pd->rx_chan)) &&
378 (skb = netdev_alloc_skb(dev, S6_MAX_FRLEN + 2))) {
379 pd->rx_skb[(pd->rx_skb_i++) % S6_NUM_RX_SKB] = skb;
380 s6dmac_put_fifo_cache(pd->rx_dma, pd->rx_chan,
381 pd->io, (u32)skb->data, S6_MAX_FRLEN);
382 }
383}
384
385static void s6gmac_rx_interrupt(struct net_device *dev)
386{
387 struct s6gmac *pd = netdev_priv(dev);
388 u32 pfx;
389 struct sk_buff *skb;
390 while (((u8)(pd->rx_skb_i - pd->rx_skb_o)) >
391 s6dmac_pending_count(pd->rx_dma, pd->rx_chan)) {
392 skb = pd->rx_skb[(pd->rx_skb_o++) % S6_NUM_RX_SKB];
393 pfx = readl(pd->reg + S6_GMAC_BURST_POSTRD);
394 if (pfx & (1 << S6_GMAC_BURST_POSTRD_DROP)) {
395 dev_kfree_skb_irq(skb);
396 } else {
397 skb_put(skb, (pfx >> S6_GMAC_BURST_POSTRD_LEN)
398 & S6_GMAC_BURST_POSTRD_LEN_MASK);
399 skb->protocol = eth_type_trans(skb, dev);
400 skb->ip_summed = CHECKSUM_UNNECESSARY;
401 netif_rx(skb);
402 }
403 }
404}
405
406static void s6gmac_tx_interrupt(struct net_device *dev)
407{
408 struct s6gmac *pd = netdev_priv(dev);
409 while (((u8)(pd->tx_skb_i - pd->tx_skb_o)) >
410 s6dmac_pending_count(pd->tx_dma, pd->tx_chan)) {
411 dev_kfree_skb_irq(pd->tx_skb[(pd->tx_skb_o++) % S6_NUM_TX_SKB]);
412 }
413 if (!s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
414 netif_wake_queue(dev);
415}
416
417struct s6gmac_statinf {
418 unsigned reg_size : 4; /* 0: unused */
419 unsigned reg_off : 6;
420 unsigned net_index : 6;
421};
422
423#define S6_STATS_B (8 * sizeof(u32))
424#define S6_STATS_C(b, r, f) [b] = { \
425 BUILD_BUG_ON_ZERO(r##_SIZE < S6_GMAC_STAT_SIZE_MIN) + \
426 BUILD_BUG_ON_ZERO((r##_SIZE - (S6_GMAC_STAT_SIZE_MIN - 1)) \
427 >= (1<<4)) + \
428 r##_SIZE - (S6_GMAC_STAT_SIZE_MIN - 1), \
429 BUILD_BUG_ON_ZERO(((unsigned)((r - S6_GMAC_STAT_REGS) / sizeof(u32))) \
430 >= ((1<<6)-1)) + \
431 (r - S6_GMAC_STAT_REGS) / sizeof(u32), \
432 BUILD_BUG_ON_ZERO((offsetof(struct net_device_stats, f)) \
433 % sizeof(unsigned long)) + \
434 BUILD_BUG_ON_ZERO((((unsigned)(offsetof(struct net_device_stats, f)) \
435 / sizeof(unsigned long)) >= (1<<6))) + \
436 BUILD_BUG_ON_ZERO((sizeof(((struct net_device_stats *)0)->f) \
437 != sizeof(unsigned long))) + \
438 (offsetof(struct net_device_stats, f)) / sizeof(unsigned long)},
439
440static const struct s6gmac_statinf statinf[2][S6_STATS_B] = { {
441 S6_STATS_C(S6_GMAC_STATCARRY1_RBYT, S6_GMAC_STATRBYT, rx_bytes)
442 S6_STATS_C(S6_GMAC_STATCARRY1_RPKT, S6_GMAC_STATRPKT, rx_packets)
443 S6_STATS_C(S6_GMAC_STATCARRY1_RFCS, S6_GMAC_STATRFCS, rx_crc_errors)
444 S6_STATS_C(S6_GMAC_STATCARRY1_RMCA, S6_GMAC_STATRMCA, multicast)
445 S6_STATS_C(S6_GMAC_STATCARRY1_RALN, S6_GMAC_STATRALN, rx_frame_errors)
446 S6_STATS_C(S6_GMAC_STATCARRY1_RFLR, S6_GMAC_STATRFLR, rx_length_errors)
447 S6_STATS_C(S6_GMAC_STATCARRY1_RCDE, S6_GMAC_STATRCDE, rx_missed_errors)
448 S6_STATS_C(S6_GMAC_STATCARRY1_RUND, S6_GMAC_STATRUND, rx_length_errors)
449 S6_STATS_C(S6_GMAC_STATCARRY1_ROVR, S6_GMAC_STATROVR, rx_length_errors)
450 S6_STATS_C(S6_GMAC_STATCARRY1_RFRG, S6_GMAC_STATRFRG, rx_crc_errors)
451 S6_STATS_C(S6_GMAC_STATCARRY1_RJBR, S6_GMAC_STATRJBR, rx_crc_errors)
452 S6_STATS_C(S6_GMAC_STATCARRY1_RDRP, S6_GMAC_STATRDRP, rx_dropped)
453}, {
454 S6_STATS_C(S6_GMAC_STATCARRY2_TBYT, S6_GMAC_STATTBYT, tx_bytes)
455 S6_STATS_C(S6_GMAC_STATCARRY2_TPKT, S6_GMAC_STATTPKT, tx_packets)
456 S6_STATS_C(S6_GMAC_STATCARRY2_TEDF, S6_GMAC_STATTEDF, tx_aborted_errors)
457 S6_STATS_C(S6_GMAC_STATCARRY2_TXCL, S6_GMAC_STATTXCL, tx_aborted_errors)
458 S6_STATS_C(S6_GMAC_STATCARRY2_TNCL, S6_GMAC_STATTNCL, collisions)
459 S6_STATS_C(S6_GMAC_STATCARRY2_TDRP, S6_GMAC_STATTDRP, tx_dropped)
460 S6_STATS_C(S6_GMAC_STATCARRY2_TJBR, S6_GMAC_STATTJBR, tx_errors)
461 S6_STATS_C(S6_GMAC_STATCARRY2_TFCS, S6_GMAC_STATTFCS, tx_errors)
462 S6_STATS_C(S6_GMAC_STATCARRY2_TOVR, S6_GMAC_STATTOVR, tx_errors)
463 S6_STATS_C(S6_GMAC_STATCARRY2_TUND, S6_GMAC_STATTUND, tx_errors)
464 S6_STATS_C(S6_GMAC_STATCARRY2_TFRG, S6_GMAC_STATTFRG, tx_errors)
465} };
466
467static void s6gmac_stats_collect(struct s6gmac *pd,
468 const struct s6gmac_statinf *inf)
469{
470 int b;
471 for (b = 0; b < S6_STATS_B; b++) {
472 if (inf[b].reg_size) {
473 pd->stats[inf[b].net_index] +=
474 readl(pd->reg + S6_GMAC_STAT_REGS
475 + sizeof(u32) * inf[b].reg_off);
476 }
477 }
478}
479
480static void s6gmac_stats_carry(struct s6gmac *pd,
481 const struct s6gmac_statinf *inf, u32 mask)
482{
483 int b;
484 while (mask) {
485 b = fls(mask) - 1;
486 mask &= ~(1 << b);
487 pd->carry[inf[b].net_index] += (1 << inf[b].reg_size);
488 }
489}
490
491static inline u32 s6gmac_stats_pending(struct s6gmac *pd, int carry)
492{
493 int r = readl(pd->reg + S6_GMAC_STATCARRY(carry)) &
494 ~readl(pd->reg + S6_GMAC_STATCARRYMSK(carry));
495 return r;
496}
497
498static inline void s6gmac_stats_interrupt(struct s6gmac *pd, int carry)
499{
500 u32 mask;
501 mask = s6gmac_stats_pending(pd, carry);
502 if (mask) {
503 writel(mask, pd->reg + S6_GMAC_STATCARRY(carry));
504 s6gmac_stats_carry(pd, &statinf[carry][0], mask);
505 }
506}
507
508static irqreturn_t s6gmac_interrupt(int irq, void *dev_id)
509{
510 struct net_device *dev = (struct net_device *)dev_id;
511 struct s6gmac *pd = netdev_priv(dev);
512 if (!dev)
513 return IRQ_NONE;
514 spin_lock(&pd->lock);
515 if (s6dmac_termcnt_irq(pd->rx_dma, pd->rx_chan))
516 s6gmac_rx_interrupt(dev);
517 s6gmac_rx_fillfifo(dev);
518 if (s6dmac_termcnt_irq(pd->tx_dma, pd->tx_chan))
519 s6gmac_tx_interrupt(dev);
520 s6gmac_stats_interrupt(pd, 0);
521 s6gmac_stats_interrupt(pd, 1);
522 spin_unlock(&pd->lock);
523 return IRQ_HANDLED;
524}
525
526static inline void s6gmac_set_dstaddr(struct s6gmac *pd, int n,
527 u32 addrlo, u32 addrhi, u32 masklo, u32 maskhi)
528{
529 writel(addrlo, pd->reg + S6_GMAC_HOST_DSTADDRLO(n));
530 writel(addrhi, pd->reg + S6_GMAC_HOST_DSTADDRHI(n));
531 writel(masklo, pd->reg + S6_GMAC_HOST_DSTMASKLO(n));
532 writel(maskhi, pd->reg + S6_GMAC_HOST_DSTMASKHI(n));
533}
534
535static inline void s6gmac_stop_device(struct net_device *dev)
536{
537 struct s6gmac *pd = netdev_priv(dev);
538 writel(0, pd->reg + S6_GMAC_MACCONF1);
539}
540
541static inline void s6gmac_init_device(struct net_device *dev)
542{
543 struct s6gmac *pd = netdev_priv(dev);
544 int is_rgmii = !!(pd->phydev->supported
545 & (SUPPORTED_1000baseT_Full | SUPPORTED_1000baseT_Half));
546#if 0
547 writel(1 << S6_GMAC_MACCONF1_SYNCTX |
548 1 << S6_GMAC_MACCONF1_SYNCRX |
549 1 << S6_GMAC_MACCONF1_TXFLOWCTRL |
550 1 << S6_GMAC_MACCONF1_RXFLOWCTRL |
551 1 << S6_GMAC_MACCONF1_RESTXFUNC |
552 1 << S6_GMAC_MACCONF1_RESRXFUNC |
553 1 << S6_GMAC_MACCONF1_RESTXMACCTRL |
554 1 << S6_GMAC_MACCONF1_RESRXMACCTRL,
555 pd->reg + S6_GMAC_MACCONF1);
556#endif
557 writel(1 << S6_GMAC_MACCONF1_SOFTRES, pd->reg + S6_GMAC_MACCONF1);
558 udelay(1000);
559 writel(1 << S6_GMAC_MACCONF1_TXENA | 1 << S6_GMAC_MACCONF1_RXENA,
560 pd->reg + S6_GMAC_MACCONF1);
561 writel(1 << S6_GMAC_HOST_PBLKCTRL_TXSRES |
562 1 << S6_GMAC_HOST_PBLKCTRL_RXSRES,
563 pd->reg + S6_GMAC_HOST_PBLKCTRL);
564 writel(S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_TXBSIZ |
565 S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_RXBSIZ |
566 1 << S6_GMAC_HOST_PBLKCTRL_STATENA |
567 1 << S6_GMAC_HOST_PBLKCTRL_STATCLEAR |
568 is_rgmii << S6_GMAC_HOST_PBLKCTRL_RGMII,
569 pd->reg + S6_GMAC_HOST_PBLKCTRL);
570 writel(1 << S6_GMAC_MACCONF1_TXENA |
571 1 << S6_GMAC_MACCONF1_RXENA |
572 (dev->flags & IFF_LOOPBACK ? 1 : 0)
573 << S6_GMAC_MACCONF1_LOOPBACK,
574 pd->reg + S6_GMAC_MACCONF1);
575 writel(dev->mtu && (dev->mtu < (S6_MAX_FRLEN - ETH_HLEN-ETH_FCS_LEN)) ?
576 dev->mtu+ETH_HLEN+ETH_FCS_LEN : S6_MAX_FRLEN,
577 pd->reg + S6_GMAC_MACMAXFRAMELEN);
578 writel((pd->link.full ? 1 : 0) << S6_GMAC_MACCONF2_FULL |
579 1 << S6_GMAC_MACCONF2_PADCRCENA |
580 1 << S6_GMAC_MACCONF2_LENGTHFCHK |
581 (pd->link.giga ?
582 S6_GMAC_MACCONF2_IFMODE_BYTE :
583 S6_GMAC_MACCONF2_IFMODE_NIBBLE)
584 << S6_GMAC_MACCONF2_IFMODE |
585 7 << S6_GMAC_MACCONF2_PREAMBLELEN,
586 pd->reg + S6_GMAC_MACCONF2);
587 writel(0, pd->reg + S6_GMAC_MACSTATADDR1);
588 writel(0, pd->reg + S6_GMAC_MACSTATADDR2);
589 writel(1 << S6_GMAC_FIFOCONF0_WTMENREQ |
590 1 << S6_GMAC_FIFOCONF0_SRFENREQ |
591 1 << S6_GMAC_FIFOCONF0_FRFENREQ |
592 1 << S6_GMAC_FIFOCONF0_STFENREQ |
593 1 << S6_GMAC_FIFOCONF0_FTFENREQ,
594 pd->reg + S6_GMAC_FIFOCONF0);
595 writel(128 << S6_GMAC_FIFOCONF3_CFGFTTH |
596 128 << S6_GMAC_FIFOCONF3_CFGHWMFT,
597 pd->reg + S6_GMAC_FIFOCONF3);
598 writel((S6_GMAC_FIFOCONF_RSV_MASK & ~(
599 1 << S6_GMAC_FIFOCONF_RSV_RUNT |
600 1 << S6_GMAC_FIFOCONF_RSV_CRCERR |
601 1 << S6_GMAC_FIFOCONF_RSV_OK |
602 1 << S6_GMAC_FIFOCONF_RSV_DRIBBLE |
603 1 << S6_GMAC_FIFOCONF_RSV_CTRLFRAME |
604 1 << S6_GMAC_FIFOCONF_RSV_PAUSECTRL |
605 1 << S6_GMAC_FIFOCONF_RSV_UNOPCODE |
606 1 << S6_GMAC_FIFOCONF_RSV_TRUNCATED)) |
607 1 << S6_GMAC_FIFOCONF5_DROPLT64 |
608 pd->link.giga << S6_GMAC_FIFOCONF5_CFGBYTM |
609 1 << S6_GMAC_FIFOCONF5_RXDROPSIZE,
610 pd->reg + S6_GMAC_FIFOCONF5);
611 writel(1 << S6_GMAC_FIFOCONF_RSV_RUNT |
612 1 << S6_GMAC_FIFOCONF_RSV_CRCERR |
613 1 << S6_GMAC_FIFOCONF_RSV_DRIBBLE |
614 1 << S6_GMAC_FIFOCONF_RSV_CTRLFRAME |
615 1 << S6_GMAC_FIFOCONF_RSV_PAUSECTRL |
616 1 << S6_GMAC_FIFOCONF_RSV_UNOPCODE |
617 1 << S6_GMAC_FIFOCONF_RSV_TRUNCATED,
618 pd->reg + S6_GMAC_FIFOCONF4);
619 s6gmac_set_dstaddr(pd, 0,
620 0xFFFFFFFF, 0x0000FFFF, 0xFFFFFFFF, 0x0000FFFF);
621 s6gmac_set_dstaddr(pd, 1,
622 dev->dev_addr[5] |
623 dev->dev_addr[4] << 8 |
624 dev->dev_addr[3] << 16 |
625 dev->dev_addr[2] << 24,
626 dev->dev_addr[1] |
627 dev->dev_addr[0] << 8,
628 0xFFFFFFFF, 0x0000FFFF);
629 s6gmac_set_dstaddr(pd, 2,
630 0x00000000, 0x00000100, 0x00000000, 0x00000100);
631 s6gmac_set_dstaddr(pd, 3,
632 0x00000000, 0x00000000, 0x00000000, 0x00000000);
633 writel(1 << S6_GMAC_HOST_PBLKCTRL_TXENA |
634 1 << S6_GMAC_HOST_PBLKCTRL_RXENA |
635 S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_TXBSIZ |
636 S6_GMAC_HOST_PBLKCTRL_SIZ_128 << S6_GMAC_HOST_PBLKCTRL_RXBSIZ |
637 1 << S6_GMAC_HOST_PBLKCTRL_STATENA |
638 1 << S6_GMAC_HOST_PBLKCTRL_STATCLEAR |
639 is_rgmii << S6_GMAC_HOST_PBLKCTRL_RGMII,
640 pd->reg + S6_GMAC_HOST_PBLKCTRL);
641}
642
643static void s6mii_enable(struct s6gmac *pd)
644{
645 writel(readl(pd->reg + S6_GMAC_MACCONF1) &
646 ~(1 << S6_GMAC_MACCONF1_SOFTRES),
647 pd->reg + S6_GMAC_MACCONF1);
648 writel((readl(pd->reg + S6_GMAC_MACMIICONF)
649 & ~(S6_GMAC_MACMIICONF_CSEL_MASK << S6_GMAC_MACMIICONF_CSEL))
650 | (S6_GMAC_MACMIICONF_CSEL_DIV168 << S6_GMAC_MACMIICONF_CSEL),
651 pd->reg + S6_GMAC_MACMIICONF);
652}
653
654static int s6mii_busy(struct s6gmac *pd, int tmo)
655{
656 while (readl(pd->reg + S6_GMAC_MACMIIINDI)) {
657 if (--tmo == 0)
658 return -ETIME;
659 udelay(64);
660 }
661 return 0;
662}
663
664static int s6mii_read(struct mii_bus *bus, int phy_addr, int regnum)
665{
666 struct s6gmac *pd = bus->priv;
667 s6mii_enable(pd);
668 if (s6mii_busy(pd, 256))
669 return -ETIME;
670 writel(phy_addr << S6_GMAC_MACMIIADDR_PHY |
671 regnum << S6_GMAC_MACMIIADDR_REG,
672 pd->reg + S6_GMAC_MACMIIADDR);
673 writel(1 << S6_GMAC_MACMIICMD_READ, pd->reg + S6_GMAC_MACMIICMD);
674 writel(0, pd->reg + S6_GMAC_MACMIICMD);
675 if (s6mii_busy(pd, 256))
676 return -ETIME;
677 return (u16)readl(pd->reg + S6_GMAC_MACMIISTAT);
678}
679
680static int s6mii_write(struct mii_bus *bus, int phy_addr, int regnum, u16 value)
681{
682 struct s6gmac *pd = bus->priv;
683 s6mii_enable(pd);
684 if (s6mii_busy(pd, 256))
685 return -ETIME;
686 writel(phy_addr << S6_GMAC_MACMIIADDR_PHY |
687 regnum << S6_GMAC_MACMIIADDR_REG,
688 pd->reg + S6_GMAC_MACMIIADDR);
689 writel(value, pd->reg + S6_GMAC_MACMIICTRL);
690 if (s6mii_busy(pd, 256))
691 return -ETIME;
692 return 0;
693}
694
695static int s6mii_reset(struct mii_bus *bus)
696{
697 struct s6gmac *pd = bus->priv;
698 s6mii_enable(pd);
699 if (s6mii_busy(pd, PHY_INIT_TIMEOUT))
700 return -ETIME;
701 return 0;
702}
703
704static void s6gmac_set_rgmii_txclock(struct s6gmac *pd)
705{
706 u32 pllsel = readl(S6_REG_GREG1 + S6_GREG1_PLLSEL);
707 pllsel &= ~(S6_GREG1_PLLSEL_GMAC_MASK << S6_GREG1_PLLSEL_GMAC);
708 switch (pd->link.mbit) {
709 case 10:
710 pllsel |= S6_GREG1_PLLSEL_GMAC_2500KHZ << S6_GREG1_PLLSEL_GMAC;
711 break;
712 case 100:
713 pllsel |= S6_GREG1_PLLSEL_GMAC_25MHZ << S6_GREG1_PLLSEL_GMAC;
714 break;
715 case 1000:
716 pllsel |= S6_GREG1_PLLSEL_GMAC_125MHZ << S6_GREG1_PLLSEL_GMAC;
717 break;
718 default:
719 return;
720 }
721 writel(pllsel, S6_REG_GREG1 + S6_GREG1_PLLSEL);
722}
723
724static inline void s6gmac_linkisup(struct net_device *dev, int isup)
725{
726 struct s6gmac *pd = netdev_priv(dev);
727 struct phy_device *phydev = pd->phydev;
728
729 pd->link.full = phydev->duplex;
730 pd->link.giga = (phydev->speed == 1000);
731 if (pd->link.mbit != phydev->speed) {
732 pd->link.mbit = phydev->speed;
733 s6gmac_set_rgmii_txclock(pd);
734 }
735 pd->link.isup = isup;
736 if (isup)
737 netif_carrier_on(dev);
738 phy_print_status(phydev);
739}
740
741static void s6gmac_adjust_link(struct net_device *dev)
742{
743 struct s6gmac *pd = netdev_priv(dev);
744 struct phy_device *phydev = pd->phydev;
745 if (pd->link.isup &&
746 (!phydev->link ||
747 (pd->link.mbit != phydev->speed) ||
748 (pd->link.full != phydev->duplex))) {
749 pd->link.isup = 0;
750 netif_tx_disable(dev);
751 if (!phydev->link) {
752 netif_carrier_off(dev);
753 phy_print_status(phydev);
754 }
755 }
756 if (!pd->link.isup && phydev->link) {
757 if (pd->link.full != phydev->duplex) {
758 u32 maccfg = readl(pd->reg + S6_GMAC_MACCONF2);
759 if (phydev->duplex)
760 maccfg |= 1 << S6_GMAC_MACCONF2_FULL;
761 else
762 maccfg &= ~(1 << S6_GMAC_MACCONF2_FULL);
763 writel(maccfg, pd->reg + S6_GMAC_MACCONF2);
764 }
765
766 if (pd->link.giga != (phydev->speed == 1000)) {
767 u32 fifocfg = readl(pd->reg + S6_GMAC_FIFOCONF5);
768 u32 maccfg = readl(pd->reg + S6_GMAC_MACCONF2);
769 maccfg &= ~(S6_GMAC_MACCONF2_IFMODE_MASK
770 << S6_GMAC_MACCONF2_IFMODE);
771 if (phydev->speed == 1000) {
772 fifocfg |= 1 << S6_GMAC_FIFOCONF5_CFGBYTM;
773 maccfg |= S6_GMAC_MACCONF2_IFMODE_BYTE
774 << S6_GMAC_MACCONF2_IFMODE;
775 } else {
776 fifocfg &= ~(1 << S6_GMAC_FIFOCONF5_CFGBYTM);
777 maccfg |= S6_GMAC_MACCONF2_IFMODE_NIBBLE
778 << S6_GMAC_MACCONF2_IFMODE;
779 }
780 writel(fifocfg, pd->reg + S6_GMAC_FIFOCONF5);
781 writel(maccfg, pd->reg + S6_GMAC_MACCONF2);
782 }
783
784 if (!s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
785 netif_wake_queue(dev);
786 s6gmac_linkisup(dev, 1);
787 }
788}
789
790static inline int s6gmac_phy_start(struct net_device *dev)
791{
792 struct s6gmac *pd = netdev_priv(dev);
793 int i = 0;
794 struct phy_device *p = NULL;
795 while ((i < PHY_MAX_ADDR) && (!(p = pd->mii.bus->phy_map[i])))
796 i++;
797 p = phy_connect(dev, dev_name(&p->dev), &s6gmac_adjust_link,
798 PHY_INTERFACE_MODE_RGMII);
799 if (IS_ERR(p)) {
800 printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
801 return PTR_ERR(p);
802 }
803 p->supported &= PHY_GBIT_FEATURES;
804 p->advertising = p->supported;
805 pd->phydev = p;
806 return 0;
807}
808
809static inline void s6gmac_init_stats(struct net_device *dev)
810{
811 struct s6gmac *pd = netdev_priv(dev);
812 u32 mask;
813 mask = 1 << S6_GMAC_STATCARRY1_RDRP |
814 1 << S6_GMAC_STATCARRY1_RJBR |
815 1 << S6_GMAC_STATCARRY1_RFRG |
816 1 << S6_GMAC_STATCARRY1_ROVR |
817 1 << S6_GMAC_STATCARRY1_RUND |
818 1 << S6_GMAC_STATCARRY1_RCDE |
819 1 << S6_GMAC_STATCARRY1_RFLR |
820 1 << S6_GMAC_STATCARRY1_RALN |
821 1 << S6_GMAC_STATCARRY1_RMCA |
822 1 << S6_GMAC_STATCARRY1_RFCS |
823 1 << S6_GMAC_STATCARRY1_RPKT |
824 1 << S6_GMAC_STATCARRY1_RBYT;
825 writel(mask, pd->reg + S6_GMAC_STATCARRY(0));
826 writel(~mask, pd->reg + S6_GMAC_STATCARRYMSK(0));
827 mask = 1 << S6_GMAC_STATCARRY2_TDRP |
828 1 << S6_GMAC_STATCARRY2_TNCL |
829 1 << S6_GMAC_STATCARRY2_TXCL |
830 1 << S6_GMAC_STATCARRY2_TEDF |
831 1 << S6_GMAC_STATCARRY2_TPKT |
832 1 << S6_GMAC_STATCARRY2_TBYT |
833 1 << S6_GMAC_STATCARRY2_TFRG |
834 1 << S6_GMAC_STATCARRY2_TUND |
835 1 << S6_GMAC_STATCARRY2_TOVR |
836 1 << S6_GMAC_STATCARRY2_TFCS |
837 1 << S6_GMAC_STATCARRY2_TJBR;
838 writel(mask, pd->reg + S6_GMAC_STATCARRY(1));
839 writel(~mask, pd->reg + S6_GMAC_STATCARRYMSK(1));
840}
841
842static inline void s6gmac_init_dmac(struct net_device *dev)
843{
844 struct s6gmac *pd = netdev_priv(dev);
845 s6dmac_disable_chan(pd->tx_dma, pd->tx_chan);
846 s6dmac_disable_chan(pd->rx_dma, pd->rx_chan);
847 s6dmac_disable_error_irqs(pd->tx_dma, 1 << S6_HIFDMA_GMACTX);
848 s6dmac_disable_error_irqs(pd->rx_dma, 1 << S6_HIFDMA_GMACRX);
849}
850
851static int s6gmac_tx(struct sk_buff *skb, struct net_device *dev)
852{
853 struct s6gmac *pd = netdev_priv(dev);
854 unsigned long flags;
855
856 spin_lock_irqsave(&pd->lock, flags);
857 writel(skb->len << S6_GMAC_BURST_PREWR_LEN |
858 0 << S6_GMAC_BURST_PREWR_CFE |
859 1 << S6_GMAC_BURST_PREWR_PPE |
860 1 << S6_GMAC_BURST_PREWR_FCS |
861 ((skb->len < ETH_ZLEN) ? 1 : 0) << S6_GMAC_BURST_PREWR_PAD,
862 pd->reg + S6_GMAC_BURST_PREWR);
863 s6dmac_put_fifo_cache(pd->tx_dma, pd->tx_chan,
864 (u32)skb->data, pd->io, skb->len);
865 if (s6dmac_fifo_full(pd->tx_dma, pd->tx_chan))
866 netif_stop_queue(dev);
867 if (((u8)(pd->tx_skb_i - pd->tx_skb_o)) >= S6_NUM_TX_SKB) {
868 printk(KERN_ERR "GMAC BUG: skb tx ring overflow [%x, %x]\n",
869 pd->tx_skb_o, pd->tx_skb_i);
870 BUG();
871 }
872 pd->tx_skb[(pd->tx_skb_i++) % S6_NUM_TX_SKB] = skb;
873 spin_unlock_irqrestore(&pd->lock, flags);
874 return 0;
875}
876
877static void s6gmac_tx_timeout(struct net_device *dev)
878{
879 struct s6gmac *pd = netdev_priv(dev);
880 unsigned long flags;
881 spin_lock_irqsave(&pd->lock, flags);
882 s6gmac_tx_interrupt(dev);
883 spin_unlock_irqrestore(&pd->lock, flags);
884}
885
886static int s6gmac_open(struct net_device *dev)
887{
888 struct s6gmac *pd = netdev_priv(dev);
889 unsigned long flags;
890 phy_read_status(pd->phydev);
891 spin_lock_irqsave(&pd->lock, flags);
892 pd->link.mbit = 0;
893 s6gmac_linkisup(dev, pd->phydev->link);
894 s6gmac_init_device(dev);
895 s6gmac_init_stats(dev);
896 s6gmac_init_dmac(dev);
897 s6gmac_rx_fillfifo(dev);
898 s6dmac_enable_chan(pd->rx_dma, pd->rx_chan,
899 2, 1, 0, 1, 0, 0, 0, 7, -1, 2, 0, 1);
900 s6dmac_enable_chan(pd->tx_dma, pd->tx_chan,
901 2, 0, 1, 0, 0, 0, 0, 7, -1, 2, 0, 1);
902 writel(0 << S6_GMAC_HOST_INT_TXBURSTOVER |
903 0 << S6_GMAC_HOST_INT_TXPREWOVER |
904 0 << S6_GMAC_HOST_INT_RXBURSTUNDER |
905 0 << S6_GMAC_HOST_INT_RXPOSTRFULL |
906 0 << S6_GMAC_HOST_INT_RXPOSTRUNDER,
907 pd->reg + S6_GMAC_HOST_INTMASK);
908 spin_unlock_irqrestore(&pd->lock, flags);
909 phy_start(pd->phydev);
910 netif_start_queue(dev);
911 return 0;
912}
913
914static int s6gmac_stop(struct net_device *dev)
915{
916 struct s6gmac *pd = netdev_priv(dev);
917 unsigned long flags;
918 netif_stop_queue(dev);
919 phy_stop(pd->phydev);
920 spin_lock_irqsave(&pd->lock, flags);
921 s6gmac_init_dmac(dev);
922 s6gmac_stop_device(dev);
923 while (pd->tx_skb_i != pd->tx_skb_o)
924 dev_kfree_skb(pd->tx_skb[(pd->tx_skb_o++) % S6_NUM_TX_SKB]);
925 while (pd->rx_skb_i != pd->rx_skb_o)
926 dev_kfree_skb(pd->rx_skb[(pd->rx_skb_o++) % S6_NUM_RX_SKB]);
927 spin_unlock_irqrestore(&pd->lock, flags);
928 return 0;
929}
930
931static struct net_device_stats *s6gmac_stats(struct net_device *dev)
932{
933 struct s6gmac *pd = netdev_priv(dev);
934 struct net_device_stats *st = (struct net_device_stats *)&pd->stats;
935 int i;
936 do {
937 unsigned long flags;
938 spin_lock_irqsave(&pd->lock, flags);
939 for (i = 0; i < ARRAY_SIZE(pd->stats); i++)
940 pd->stats[i] =
941 pd->carry[i] << (S6_GMAC_STAT_SIZE_MIN - 1);
942 s6gmac_stats_collect(pd, &statinf[0][0]);
943 s6gmac_stats_collect(pd, &statinf[1][0]);
944 i = s6gmac_stats_pending(pd, 0) |
945 s6gmac_stats_pending(pd, 1);
946 spin_unlock_irqrestore(&pd->lock, flags);
947 } while (i);
948 st->rx_errors = st->rx_crc_errors +
949 st->rx_frame_errors +
950 st->rx_length_errors +
951 st->rx_missed_errors;
952 st->tx_errors += st->tx_aborted_errors;
953 return st;
954}
955
956static int s6gmac_probe(struct platform_device *pdev)
957{
958 struct net_device *dev;
959 struct s6gmac *pd;
960 int res;
961 unsigned long i;
962 struct mii_bus *mb;
963
964 dev = alloc_etherdev(sizeof(*pd));
965 if (!dev)
966 return -ENOMEM;
967
968 dev->open = s6gmac_open;
969 dev->stop = s6gmac_stop;
970 dev->hard_start_xmit = s6gmac_tx;
971 dev->tx_timeout = s6gmac_tx_timeout;
972 dev->watchdog_timeo = HZ;
973 dev->get_stats = s6gmac_stats;
974 dev->irq = platform_get_irq(pdev, 0);
975 pd = netdev_priv(dev);
976 memset(pd, 0, sizeof(*pd));
977 spin_lock_init(&pd->lock);
978 pd->reg = platform_get_resource(pdev, IORESOURCE_MEM, 0)->start;
979 i = platform_get_resource(pdev, IORESOURCE_DMA, 0)->start;
980 pd->tx_dma = DMA_MASK_DMAC(i);
981 pd->tx_chan = DMA_INDEX_CHNL(i);
982 i = platform_get_resource(pdev, IORESOURCE_DMA, 1)->start;
983 pd->rx_dma = DMA_MASK_DMAC(i);
984 pd->rx_chan = DMA_INDEX_CHNL(i);
985 pd->io = platform_get_resource(pdev, IORESOURCE_IO, 0)->start;
986 res = request_irq(dev->irq, s6gmac_interrupt, 0, dev->name, dev);
987 if (res) {
988 printk(KERN_ERR DRV_PRMT "irq request failed: %d\n", dev->irq);
989 goto errirq;
990 }
991 res = register_netdev(dev);
992 if (res) {
993 printk(KERN_ERR DRV_PRMT "error registering device %s\n",
994 dev->name);
995 goto errdev;
996 }
997 mb = mdiobus_alloc();
998 if (!mb) {
999 printk(KERN_ERR DRV_PRMT "error allocating mii bus\n");
1000 res = -ENOMEM;
1001 goto errmii;
1002 }
1003 mb->name = "s6gmac_mii";
1004 mb->read = s6mii_read;
1005 mb->write = s6mii_write;
1006 mb->reset = s6mii_reset;
1007 mb->priv = pd;
1008 snprintf(mb->id, MII_BUS_ID_SIZE, "%s-%x", pdev->name, pdev->id);
1009 mb->phy_mask = ~(1 << 0);
1010 mb->irq = &pd->mii.irq[0];
1011 for (i = 0; i < PHY_MAX_ADDR; i++) {
1012 int n = platform_get_irq(pdev, i + 1);
1013 if (n < 0)
1014 n = PHY_POLL;
1015 pd->mii.irq[i] = n;
1016 }
1017 mdiobus_register(mb);
1018 pd->mii.bus = mb;
1019 res = s6gmac_phy_start(dev);
1020 if (res)
1021 return res;
1022 platform_set_drvdata(pdev, dev);
1023 return 0;
1024errmii:
1025 unregister_netdev(dev);
1026errdev:
1027 free_irq(dev->irq, dev);
1028errirq:
1029 free_netdev(dev);
1030 return res;
1031}
1032
1033static int s6gmac_remove(struct platform_device *pdev)
1034{
1035 struct net_device *dev = platform_get_drvdata(pdev);
1036 if (dev) {
1037 struct s6gmac *pd = netdev_priv(dev);
1038 mdiobus_unregister(pd->mii.bus);
1039 unregister_netdev(dev);
1040 free_irq(dev->irq, dev);
1041 free_netdev(dev);
1042 }
1043 return 0;
1044}
1045
1046static struct platform_driver s6gmac_driver = {
1047 .probe = s6gmac_probe,
1048 .remove = s6gmac_remove,
1049 .driver = {
1050 .name = "s6gmac",
1051 },
1052};
1053
1054module_platform_driver(s6gmac_driver);
1055
1056MODULE_LICENSE("GPL");
1057MODULE_DESCRIPTION("S6105 on chip Ethernet driver");
1058MODULE_AUTHOR("Oskar Schirmer <oskar@scara.com>");
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index 118a427d1942..8c6b7c1651e5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -1671,7 +1671,7 @@ static void stmmac_init_tx_coalesce(struct stmmac_priv *priv)
1671 * 0 on success and an appropriate (-)ve integer as defined in errno.h 1671 * 0 on success and an appropriate (-)ve integer as defined in errno.h
1672 * file on failure. 1672 * file on failure.
1673 */ 1673 */
1674static int stmmac_hw_setup(struct net_device *dev) 1674static int stmmac_hw_setup(struct net_device *dev, bool init_ptp)
1675{ 1675{
1676 struct stmmac_priv *priv = netdev_priv(dev); 1676 struct stmmac_priv *priv = netdev_priv(dev);
1677 int ret; 1677 int ret;
@@ -1708,9 +1708,11 @@ static int stmmac_hw_setup(struct net_device *dev)
1708 1708
1709 stmmac_mmc_setup(priv); 1709 stmmac_mmc_setup(priv);
1710 1710
1711 ret = stmmac_init_ptp(priv); 1711 if (init_ptp) {
1712 if (ret && ret != -EOPNOTSUPP) 1712 ret = stmmac_init_ptp(priv);
1713 pr_warn("%s: failed PTP initialisation\n", __func__); 1713 if (ret && ret != -EOPNOTSUPP)
1714 pr_warn("%s: failed PTP initialisation\n", __func__);
1715 }
1714 1716
1715#ifdef CONFIG_DEBUG_FS 1717#ifdef CONFIG_DEBUG_FS
1716 ret = stmmac_init_fs(dev); 1718 ret = stmmac_init_fs(dev);
@@ -1787,7 +1789,7 @@ static int stmmac_open(struct net_device *dev)
1787 goto init_error; 1789 goto init_error;
1788 } 1790 }
1789 1791
1790 ret = stmmac_hw_setup(dev); 1792 ret = stmmac_hw_setup(dev, true);
1791 if (ret < 0) { 1793 if (ret < 0) {
1792 pr_err("%s: Hw setup failed\n", __func__); 1794 pr_err("%s: Hw setup failed\n", __func__);
1793 goto init_error; 1795 goto init_error;
@@ -3036,7 +3038,7 @@ int stmmac_resume(struct net_device *ndev)
3036 netif_device_attach(ndev); 3038 netif_device_attach(ndev);
3037 3039
3038 init_dma_desc_rings(ndev, GFP_ATOMIC); 3040 init_dma_desc_rings(ndev, GFP_ATOMIC);
3039 stmmac_hw_setup(ndev); 3041 stmmac_hw_setup(ndev, false);
3040 stmmac_init_tx_coalesce(priv); 3042 stmmac_init_tx_coalesce(priv);
3041 3043
3042 napi_enable(&priv->napi); 3044 napi_enable(&priv->napi);
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 4032b170fe24..3039de2465ba 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -430,7 +430,6 @@ static struct platform_driver stmmac_pltfr_driver = {
430 .remove = stmmac_pltfr_remove, 430 .remove = stmmac_pltfr_remove,
431 .driver = { 431 .driver = {
432 .name = STMMAC_RESOURCE_NAME, 432 .name = STMMAC_RESOURCE_NAME,
433 .owner = THIS_MODULE,
434 .pm = &stmmac_pltfr_pm_ops, 433 .pm = &stmmac_pltfr_pm_ops,
435 .of_match_table = of_match_ptr(stmmac_dt_ids), 434 .of_match_table = of_match_ptr(stmmac_dt_ids),
436 }, 435 },
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index 45c408ef67d0..d2835bf7b4fb 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -1201,6 +1201,7 @@ static int vnet_handle_offloads(struct vnet_port *port, struct sk_buff *skb)
1201 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO); 1201 segs = skb_gso_segment(skb, dev->features & ~NETIF_F_TSO);
1202 if (IS_ERR(segs)) { 1202 if (IS_ERR(segs)) {
1203 dev->stats.tx_dropped++; 1203 dev->stats.tx_dropped++;
1204 dev_kfree_skb_any(skb);
1204 return NETDEV_TX_OK; 1205 return NETDEV_TX_OK;
1205 } 1206 }
1206 1207
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet.h b/drivers/net/ethernet/xilinx/xilinx_axienet.h
index 44b8d2bad8c3..4c9b4fa1d3c1 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet.h
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet.h
@@ -388,7 +388,6 @@ struct axidma_bd {
388 * @dma_err_tasklet: Tasklet structure to process Axi DMA errors 388 * @dma_err_tasklet: Tasklet structure to process Axi DMA errors
389 * @tx_irq: Axidma TX IRQ number 389 * @tx_irq: Axidma TX IRQ number
390 * @rx_irq: Axidma RX IRQ number 390 * @rx_irq: Axidma RX IRQ number
391 * @temac_type: axienet type to identify between soft and hard temac
392 * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X 391 * @phy_type: Phy type to identify between MII/GMII/RGMII/SGMII/1000 Base-X
393 * @options: AxiEthernet option word 392 * @options: AxiEthernet option word
394 * @last_link: Phy link state in which the PHY was negotiated earlier 393 * @last_link: Phy link state in which the PHY was negotiated earlier
@@ -431,7 +430,6 @@ struct axienet_local {
431 430
432 int tx_irq; 431 int tx_irq;
433 int rx_irq; 432 int rx_irq;
434 u32 temac_type;
435 u32 phy_type; 433 u32 phy_type;
436 434
437 u32 options; /* Current options word */ 435 u32 options; /* Current options word */
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 4ea2d4e6f1d1..c18a0c637c44 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1555,10 +1555,6 @@ static int axienet_of_probe(struct platform_device *op)
1555 if ((be32_to_cpup(p)) >= 0x4000) 1555 if ((be32_to_cpup(p)) >= 0x4000)
1556 lp->jumbo_support = 1; 1556 lp->jumbo_support = 1;
1557 } 1557 }
1558 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,temac-type",
1559 NULL);
1560 if (p)
1561 lp->temac_type = be32_to_cpup(p);
1562 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL); 1558 p = (__be32 *) of_get_property(op->dev.of_node, "xlnx,phy-type", NULL);
1563 if (p) 1559 if (p)
1564 lp->phy_type = be32_to_cpup(p); 1560 lp->phy_type = be32_to_cpup(p);
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 2f48f790c9b4..384ca4f4de4a 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -590,6 +590,7 @@ struct nvsp_message {
590 590
591 591
592#define NETVSC_RECEIVE_BUFFER_ID 0xcafe 592#define NETVSC_RECEIVE_BUFFER_ID 0xcafe
593#define NETVSC_SEND_BUFFER_ID 0
593 594
594#define NETVSC_PACKET_SIZE 4096 595#define NETVSC_PACKET_SIZE 4096
595 596
diff --git a/drivers/net/hyperv/netvsc.c b/drivers/net/hyperv/netvsc.c
index dd867e6cabd6..9f49c0129a78 100644
--- a/drivers/net/hyperv/netvsc.c
+++ b/drivers/net/hyperv/netvsc.c
@@ -161,8 +161,8 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
161 161
162 /* Deal with the send buffer we may have setup. 162 /* Deal with the send buffer we may have setup.
163 * If we got a send section size, it means we received a 163 * If we got a send section size, it means we received a
164 * SendsendBufferComplete msg (ie sent 164 * NVSP_MSG1_TYPE_SEND_SEND_BUF_COMPLETE msg (ie sent
165 * NvspMessage1TypeSendReceiveBuffer msg) therefore, we need 165 * NVSP_MSG1_TYPE_SEND_SEND_BUF msg) therefore, we need
166 * to send a revoke msg here 166 * to send a revoke msg here
167 */ 167 */
168 if (net_device->send_section_size) { 168 if (net_device->send_section_size) {
@@ -172,7 +172,8 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
172 172
173 revoke_packet->hdr.msg_type = 173 revoke_packet->hdr.msg_type =
174 NVSP_MSG1_TYPE_REVOKE_SEND_BUF; 174 NVSP_MSG1_TYPE_REVOKE_SEND_BUF;
175 revoke_packet->msg.v1_msg.revoke_recv_buf.id = 0; 175 revoke_packet->msg.v1_msg.revoke_send_buf.id =
176 NETVSC_SEND_BUFFER_ID;
176 177
177 ret = vmbus_sendpacket(net_device->dev->channel, 178 ret = vmbus_sendpacket(net_device->dev->channel,
178 revoke_packet, 179 revoke_packet,
@@ -204,7 +205,7 @@ static int netvsc_destroy_buf(struct netvsc_device *net_device)
204 net_device->send_buf_gpadl_handle = 0; 205 net_device->send_buf_gpadl_handle = 0;
205 } 206 }
206 if (net_device->send_buf) { 207 if (net_device->send_buf) {
207 /* Free up the receive buffer */ 208 /* Free up the send buffer */
208 vfree(net_device->send_buf); 209 vfree(net_device->send_buf);
209 net_device->send_buf = NULL; 210 net_device->send_buf = NULL;
210 } 211 }
@@ -339,9 +340,9 @@ static int netvsc_init_buf(struct hv_device *device)
339 init_packet = &net_device->channel_init_pkt; 340 init_packet = &net_device->channel_init_pkt;
340 memset(init_packet, 0, sizeof(struct nvsp_message)); 341 memset(init_packet, 0, sizeof(struct nvsp_message));
341 init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_SEND_BUF; 342 init_packet->hdr.msg_type = NVSP_MSG1_TYPE_SEND_SEND_BUF;
342 init_packet->msg.v1_msg.send_recv_buf.gpadl_handle = 343 init_packet->msg.v1_msg.send_send_buf.gpadl_handle =
343 net_device->send_buf_gpadl_handle; 344 net_device->send_buf_gpadl_handle;
344 init_packet->msg.v1_msg.send_recv_buf.id = 0; 345 init_packet->msg.v1_msg.send_send_buf.id = NETVSC_SEND_BUFFER_ID;
345 346
346 /* Send the gpadl notification request */ 347 /* Send the gpadl notification request */
347 ret = vmbus_sendpacket(device->channel, init_packet, 348 ret = vmbus_sendpacket(device->channel, init_packet,
@@ -364,7 +365,7 @@ static int netvsc_init_buf(struct hv_device *device)
364 netdev_err(ndev, "Unable to complete send buffer " 365 netdev_err(ndev, "Unable to complete send buffer "
365 "initialization with NetVsp - status %d\n", 366 "initialization with NetVsp - status %d\n",
366 init_packet->msg.v1_msg. 367 init_packet->msg.v1_msg.
367 send_recv_buf_complete.status); 368 send_send_buf_complete.status);
368 ret = -EINVAL; 369 ret = -EINVAL;
369 goto cleanup; 370 goto cleanup;
370 } 371 }
diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c
index c530de1e63f5..3ad8ca76196d 100644
--- a/drivers/net/phy/micrel.c
+++ b/drivers/net/phy/micrel.c
@@ -88,6 +88,7 @@ struct kszphy_priv {
88 88
89static const struct kszphy_type ksz8021_type = { 89static const struct kszphy_type ksz8021_type = {
90 .led_mode_reg = MII_KSZPHY_CTRL_2, 90 .led_mode_reg = MII_KSZPHY_CTRL_2,
91 .has_broadcast_disable = true,
91 .has_rmii_ref_clk_sel = true, 92 .has_rmii_ref_clk_sel = true,
92}; 93};
93 94
@@ -258,19 +259,6 @@ static int kszphy_config_init(struct phy_device *phydev)
258 return 0; 259 return 0;
259} 260}
260 261
261static int ksz8021_config_init(struct phy_device *phydev)
262{
263 int rc;
264
265 rc = kszphy_config_init(phydev);
266 if (rc)
267 return rc;
268
269 rc = kszphy_broadcast_disable(phydev);
270
271 return rc < 0 ? rc : 0;
272}
273
274static int ksz9021_load_values_from_of(struct phy_device *phydev, 262static int ksz9021_load_values_from_of(struct phy_device *phydev,
275 struct device_node *of_node, u16 reg, 263 struct device_node *of_node, u16 reg,
276 char *field1, char *field2, 264 char *field1, char *field2,
@@ -584,7 +572,7 @@ static struct phy_driver ksphy_driver[] = {
584 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 572 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
585 .driver_data = &ksz8021_type, 573 .driver_data = &ksz8021_type,
586 .probe = kszphy_probe, 574 .probe = kszphy_probe,
587 .config_init = ksz8021_config_init, 575 .config_init = kszphy_config_init,
588 .config_aneg = genphy_config_aneg, 576 .config_aneg = genphy_config_aneg,
589 .read_status = genphy_read_status, 577 .read_status = genphy_read_status,
590 .ack_interrupt = kszphy_ack_interrupt, 578 .ack_interrupt = kszphy_ack_interrupt,
@@ -601,7 +589,7 @@ static struct phy_driver ksphy_driver[] = {
601 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT, 589 .flags = PHY_HAS_MAGICANEG | PHY_HAS_INTERRUPT,
602 .driver_data = &ksz8021_type, 590 .driver_data = &ksz8021_type,
603 .probe = kszphy_probe, 591 .probe = kszphy_probe,
604 .config_init = ksz8021_config_init, 592 .config_init = kszphy_config_init,
605 .config_aneg = genphy_config_aneg, 593 .config_aneg = genphy_config_aneg,
606 .read_status = genphy_read_status, 594 .read_status = genphy_read_status,
607 .ack_interrupt = kszphy_ack_interrupt, 595 .ack_interrupt = kszphy_ack_interrupt,
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index b8bd7191572d..5ca97713bfb3 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -760,7 +760,6 @@ static int virtnet_poll(struct napi_struct *napi, int budget)
760 container_of(napi, struct receive_queue, napi); 760 container_of(napi, struct receive_queue, napi);
761 unsigned int r, received = 0; 761 unsigned int r, received = 0;
762 762
763again:
764 received += virtnet_receive(rq, budget - received); 763 received += virtnet_receive(rq, budget - received);
765 764
766 /* Out of packets? */ 765 /* Out of packets? */
@@ -771,7 +770,6 @@ again:
771 napi_schedule_prep(napi)) { 770 napi_schedule_prep(napi)) {
772 virtqueue_disable_cb(rq->vq); 771 virtqueue_disable_cb(rq->vq);
773 __napi_schedule(napi); 772 __napi_schedule(napi);
774 goto again;
775 } 773 }
776 } 774 }
777 775
diff --git a/drivers/net/vxlan.c b/drivers/net/vxlan.c
index 49d9f2291998..7fbd89fbe107 100644
--- a/drivers/net/vxlan.c
+++ b/drivers/net/vxlan.c
@@ -1579,8 +1579,10 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
1579 bool udp_sum = !udp_get_no_check6_tx(vs->sock->sk); 1579 bool udp_sum = !udp_get_no_check6_tx(vs->sock->sk);
1580 1580
1581 skb = udp_tunnel_handle_offloads(skb, udp_sum); 1581 skb = udp_tunnel_handle_offloads(skb, udp_sum);
1582 if (IS_ERR(skb)) 1582 if (IS_ERR(skb)) {
1583 return -EINVAL; 1583 err = -EINVAL;
1584 goto err;
1585 }
1584 1586
1585 skb_scrub_packet(skb, xnet); 1587 skb_scrub_packet(skb, xnet);
1586 1588
@@ -1590,12 +1592,16 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
1590 1592
1591 /* Need space for new headers (invalidates iph ptr) */ 1593 /* Need space for new headers (invalidates iph ptr) */
1592 err = skb_cow_head(skb, min_headroom); 1594 err = skb_cow_head(skb, min_headroom);
1593 if (unlikely(err)) 1595 if (unlikely(err)) {
1594 return err; 1596 kfree_skb(skb);
1597 goto err;
1598 }
1595 1599
1596 skb = vlan_hwaccel_push_inside(skb); 1600 skb = vlan_hwaccel_push_inside(skb);
1597 if (WARN_ON(!skb)) 1601 if (WARN_ON(!skb)) {
1598 return -ENOMEM; 1602 err = -ENOMEM;
1603 goto err;
1604 }
1599 1605
1600 vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh)); 1606 vxh = (struct vxlanhdr *) __skb_push(skb, sizeof(*vxh));
1601 vxh->vx_flags = htonl(VXLAN_FLAGS); 1607 vxh->vx_flags = htonl(VXLAN_FLAGS);
@@ -1606,6 +1612,9 @@ static int vxlan6_xmit_skb(struct vxlan_sock *vs,
1606 udp_tunnel6_xmit_skb(vs->sock, dst, skb, dev, saddr, daddr, prio, 1612 udp_tunnel6_xmit_skb(vs->sock, dst, skb, dev, saddr, daddr, prio,
1607 ttl, src_port, dst_port); 1613 ttl, src_port, dst_port);
1608 return 0; 1614 return 0;
1615err:
1616 dst_release(dst);
1617 return err;
1609} 1618}
1610#endif 1619#endif
1611 1620
@@ -1621,7 +1630,7 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
1621 1630
1622 skb = udp_tunnel_handle_offloads(skb, udp_sum); 1631 skb = udp_tunnel_handle_offloads(skb, udp_sum);
1623 if (IS_ERR(skb)) 1632 if (IS_ERR(skb))
1624 return -EINVAL; 1633 return PTR_ERR(skb);
1625 1634
1626 min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len 1635 min_headroom = LL_RESERVED_SPACE(rt->dst.dev) + rt->dst.header_len
1627 + VXLAN_HLEN + sizeof(struct iphdr) 1636 + VXLAN_HLEN + sizeof(struct iphdr)
@@ -1629,8 +1638,10 @@ int vxlan_xmit_skb(struct vxlan_sock *vs,
1629 1638
1630 /* Need space for new headers (invalidates iph ptr) */ 1639 /* Need space for new headers (invalidates iph ptr) */
1631 err = skb_cow_head(skb, min_headroom); 1640 err = skb_cow_head(skb, min_headroom);
1632 if (unlikely(err)) 1641 if (unlikely(err)) {
1642 kfree_skb(skb);
1633 return err; 1643 return err;
1644 }
1634 1645
1635 skb = vlan_hwaccel_push_inside(skb); 1646 skb = vlan_hwaccel_push_inside(skb);
1636 if (WARN_ON(!skb)) 1647 if (WARN_ON(!skb))
@@ -1776,9 +1787,12 @@ static void vxlan_xmit_one(struct sk_buff *skb, struct net_device *dev,
1776 tos, ttl, df, src_port, dst_port, 1787 tos, ttl, df, src_port, dst_port,
1777 htonl(vni << 8), 1788 htonl(vni << 8),
1778 !net_eq(vxlan->net, dev_net(vxlan->dev))); 1789 !net_eq(vxlan->net, dev_net(vxlan->dev)));
1779 1790 if (err < 0) {
1780 if (err < 0) 1791 /* skb is already freed. */
1792 skb = NULL;
1781 goto rt_tx_error; 1793 goto rt_tx_error;
1794 }
1795
1782 iptunnel_xmit_stats(err, &dev->stats, dev->tstats); 1796 iptunnel_xmit_stats(err, &dev->stats, dev->tstats);
1783#if IS_ENABLED(CONFIG_IPV6) 1797#if IS_ENABLED(CONFIG_IPV6)
1784 } else { 1798 } else {
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
index 3c06e9365949..9880dae2a569 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/bcmsdh.c
@@ -1070,7 +1070,7 @@ static int brcmf_ops_sdio_probe(struct sdio_func *func,
1070 */ 1070 */
1071 if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) && 1071 if ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_KEEP_POWER) &&
1072 ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) || 1072 ((sdio_get_host_pm_caps(sdiodev->func[1]) & MMC_PM_WAKE_SDIO_IRQ) ||
1073 (sdiodev->pdata->oob_irq_supported))) 1073 (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)))
1074 bus_if->wowl_supported = true; 1074 bus_if->wowl_supported = true;
1075#endif 1075#endif
1076 1076
@@ -1167,7 +1167,7 @@ static int brcmf_ops_sdio_resume(struct device *dev)
1167 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio; 1167 struct brcmf_sdio_dev *sdiodev = bus_if->bus_priv.sdio;
1168 1168
1169 brcmf_dbg(SDIO, "Enter\n"); 1169 brcmf_dbg(SDIO, "Enter\n");
1170 if (sdiodev->pdata->oob_irq_supported) 1170 if (sdiodev->pdata && sdiodev->pdata->oob_irq_supported)
1171 disable_irq_wake(sdiodev->pdata->oob_irq_nr); 1171 disable_irq_wake(sdiodev->pdata->oob_irq_nr);
1172 brcmf_sdio_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS); 1172 brcmf_sdio_wd_timer(sdiodev->bus, BRCMF_WD_POLL_MS);
1173 atomic_set(&sdiodev->suspend, false); 1173 atomic_set(&sdiodev->suspend, false);
diff --git a/drivers/net/wireless/ipw2x00/Kconfig b/drivers/net/wireless/ipw2x00/Kconfig
index 91c0cb3c368e..21de4fe6cf2d 100644
--- a/drivers/net/wireless/ipw2x00/Kconfig
+++ b/drivers/net/wireless/ipw2x00/Kconfig
@@ -65,7 +65,8 @@ config IPW2100_DEBUG
65 65
66config IPW2200 66config IPW2200
67 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection" 67 tristate "Intel PRO/Wireless 2200BG and 2915ABG Network Connection"
68 depends on PCI && CFG80211 && CFG80211_WEXT 68 depends on PCI && CFG80211
69 select CFG80211_WEXT
69 select WIRELESS_EXT 70 select WIRELESS_EXT
70 select WEXT_SPY 71 select WEXT_SPY
71 select WEXT_PRIV 72 select WEXT_PRIV
diff --git a/drivers/net/wireless/iwlwifi/iwl-drv.c b/drivers/net/wireless/iwlwifi/iwl-drv.c
index 38de1513e4de..850b85a47806 100644
--- a/drivers/net/wireless/iwlwifi/iwl-drv.c
+++ b/drivers/net/wireless/iwlwifi/iwl-drv.c
@@ -1323,10 +1323,10 @@ static void iwl_req_fw_callback(const struct firmware *ucode_raw, void *context)
1323 1323
1324 try_again: 1324 try_again:
1325 /* try next, if any */ 1325 /* try next, if any */
1326 kfree(pieces);
1327 release_firmware(ucode_raw); 1326 release_firmware(ucode_raw);
1328 if (iwl_request_firmware(drv, false)) 1327 if (iwl_request_firmware(drv, false))
1329 goto out_unbind; 1328 goto out_unbind;
1329 kfree(pieces);
1330 return; 1330 return;
1331 1331
1332 out_free_fw: 1332 out_free_fw:
diff --git a/drivers/net/wireless/iwlwifi/iwl-fh.h b/drivers/net/wireless/iwlwifi/iwl-fh.h
index 9564ae173d06..1f7f15eb86da 100644
--- a/drivers/net/wireless/iwlwifi/iwl-fh.h
+++ b/drivers/net/wireless/iwlwifi/iwl-fh.h
@@ -310,6 +310,7 @@ static inline unsigned int FH_MEM_CBBC_QUEUE(unsigned int chnl)
310#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000) 310#define FH_RSSR_CHNL0_RX_STATUS_CHNL_IDLE (0x01000000)
311 311
312#define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28 312#define FH_MEM_TFDIB_REG1_ADDR_BITSHIFT 28
313#define FH_MEM_TB_MAX_LENGTH (0x00020000)
313 314
314/* TFDB Area - TFDs buffer table */ 315/* TFDB Area - TFDs buffer table */
315#define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF) 316#define FH_MEM_TFDIB_DRAM_ADDR_LSB_MSK (0xFFFFFFFF)
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 31a5b3f4266c..e880f9d4717b 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -1004,8 +1004,13 @@ void __iwl_mvm_mac_stop(struct iwl_mvm *mvm)
1004{ 1004{
1005 lockdep_assert_held(&mvm->mutex); 1005 lockdep_assert_held(&mvm->mutex);
1006 1006
1007 /* disallow low power states when the FW is down */ 1007 /*
1008 iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN); 1008 * Disallow low power states when the FW is down by taking
1009 * the UCODE_DOWN ref. in case of ongoing hw restart the
1010 * ref is already taken, so don't take it again.
1011 */
1012 if (!test_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status))
1013 iwl_mvm_ref(mvm, IWL_MVM_REF_UCODE_DOWN);
1009 1014
1010 /* async_handlers_wk is now blocked */ 1015 /* async_handlers_wk is now blocked */
1011 1016
@@ -1023,6 +1028,12 @@ void __iwl_mvm_mac_stop(struct iwl_mvm *mvm)
1023 /* the fw is stopped, the aux sta is dead: clean up driver state */ 1028 /* the fw is stopped, the aux sta is dead: clean up driver state */
1024 iwl_mvm_del_aux_sta(mvm); 1029 iwl_mvm_del_aux_sta(mvm);
1025 1030
1031 /*
1032 * Clear IN_HW_RESTART flag when stopping the hw (as restart_complete()
1033 * won't be called in this case).
1034 */
1035 clear_bit(IWL_MVM_STATUS_IN_HW_RESTART, &mvm->status);
1036
1026 mvm->ucode_loaded = false; 1037 mvm->ucode_loaded = false;
1027} 1038}
1028 1039
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index 3ee8e3848876..2f0c4b170344 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -367,7 +367,11 @@ static const struct pci_device_id iwl_hw_card_ids[] = {
367 367
368/* 3165 Series */ 368/* 3165 Series */
369 {IWL_PCI_DEVICE(0x3165, 0x4010, iwl3165_2ac_cfg)}, 369 {IWL_PCI_DEVICE(0x3165, 0x4010, iwl3165_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x3165, 0x4012, iwl3165_2ac_cfg)},
371 {IWL_PCI_DEVICE(0x3165, 0x4110, iwl3165_2ac_cfg)},
370 {IWL_PCI_DEVICE(0x3165, 0x4210, iwl3165_2ac_cfg)}, 372 {IWL_PCI_DEVICE(0x3165, 0x4210, iwl3165_2ac_cfg)},
373 {IWL_PCI_DEVICE(0x3165, 0x4410, iwl3165_2ac_cfg)},
374 {IWL_PCI_DEVICE(0x3165, 0x4510, iwl3165_2ac_cfg)},
371 375
372/* 7265 Series */ 376/* 7265 Series */
373 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)}, 377 {IWL_PCI_DEVICE(0x095A, 0x5010, iwl7265_2ac_cfg)},
diff --git a/drivers/net/wireless/iwlwifi/pcie/trans.c b/drivers/net/wireless/iwlwifi/pcie/trans.c
index 5d79a1f44b8e..523fe0c88dcb 100644
--- a/drivers/net/wireless/iwlwifi/pcie/trans.c
+++ b/drivers/net/wireless/iwlwifi/pcie/trans.c
@@ -614,7 +614,7 @@ static int iwl_pcie_load_section(struct iwl_trans *trans, u8 section_num,
614{ 614{
615 u8 *v_addr; 615 u8 *v_addr;
616 dma_addr_t p_addr; 616 dma_addr_t p_addr;
617 u32 offset, chunk_sz = section->len; 617 u32 offset, chunk_sz = min_t(u32, FH_MEM_TB_MAX_LENGTH, section->len);
618 int ret = 0; 618 int ret = 0;
619 619
620 IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n", 620 IWL_DEBUG_FW(trans, "[%d] uCode section being loaded...\n",
@@ -1012,16 +1012,21 @@ static void iwl_trans_pcie_stop_device(struct iwl_trans *trans)
1012 /* Stop the device, and put it in low power state */ 1012 /* Stop the device, and put it in low power state */
1013 iwl_pcie_apm_stop(trans); 1013 iwl_pcie_apm_stop(trans);
1014 1014
1015 /* Upon stop, the APM issues an interrupt if HW RF kill is set. 1015 /* stop and reset the on-board processor */
1016 * Clean again the interrupt here 1016 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
1017 udelay(20);
1018
1019 /*
1020 * Upon stop, the APM issues an interrupt if HW RF kill is set.
1021 * This is a bug in certain verions of the hardware.
1022 * Certain devices also keep sending HW RF kill interrupt all
1023 * the time, unless the interrupt is ACKed even if the interrupt
1024 * should be masked. Re-ACK all the interrupts here.
1017 */ 1025 */
1018 spin_lock(&trans_pcie->irq_lock); 1026 spin_lock(&trans_pcie->irq_lock);
1019 iwl_disable_interrupts(trans); 1027 iwl_disable_interrupts(trans);
1020 spin_unlock(&trans_pcie->irq_lock); 1028 spin_unlock(&trans_pcie->irq_lock);
1021 1029
1022 /* stop and reset the on-board processor */
1023 iwl_write32(trans, CSR_RESET, CSR_RESET_REG_FLAG_SW_RESET);
1024 udelay(20);
1025 1030
1026 /* clear all status bits */ 1031 /* clear all status bits */
1027 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status); 1032 clear_bit(STATUS_SYNC_HCMD_ACTIVE, &trans->status);