aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/arcnet/com20020-pci.c2
-rw-r--r--drivers/net/arcnet/com20020_cs.c16
-rw-r--r--drivers/net/can/c_can/c_can_pci.c3
-rw-r--r--drivers/net/can/pch_can.c2
-rw-r--r--drivers/net/can/sja1000/ems_pci.c2
-rw-r--r--drivers/net/can/sja1000/kvaser_pci.c2
-rw-r--r--drivers/net/can/sja1000/peak_pci.c2
-rw-r--r--drivers/net/can/sja1000/plx_pci.c2
-rw-r--r--drivers/net/ethernet/3com/3c59x.c2
-rw-r--r--drivers/net/ethernet/3com/typhoon.c2
-rw-r--r--drivers/net/ethernet/8390/Kconfig3
-rw-r--r--drivers/net/ethernet/8390/axnet_cs.c26
-rw-r--r--drivers/net/ethernet/8390/ne.c2
-rw-r--r--drivers/net/ethernet/8390/ne2k-pci.c2
-rw-r--r--drivers/net/ethernet/8390/pcnet_cs.c68
-rw-r--r--drivers/net/ethernet/Kconfig1
-rw-r--r--drivers/net/ethernet/Makefile1
-rw-r--r--drivers/net/ethernet/adaptec/starfire.c2
-rw-r--r--drivers/net/ethernet/alteon/acenic.c2
-rw-r--r--drivers/net/ethernet/amd/au1000_eth.c149
-rw-r--r--drivers/net/ethernet/amd/pcnet32.c47
-rw-r--r--drivers/net/ethernet/amd/xgbe/xgbe-drv.c1
-rw-r--r--drivers/net/ethernet/apm/Kconfig1
-rw-r--r--drivers/net/ethernet/apm/Makefile5
-rw-r--r--drivers/net/ethernet/apm/xgene/Kconfig9
-rw-r--r--drivers/net/ethernet/apm/xgene/Makefile6
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c125
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.c728
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_hw.h337
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_main.c954
-rw-r--r--drivers/net/ethernet/apm/xgene/xgene_enet_main.h135
-rw-r--r--drivers/net/ethernet/atheros/alx/main.c2
-rw-r--r--drivers/net/ethernet/atheros/atl1c/atl1c_main.c2
-rw-r--r--drivers/net/ethernet/atheros/atl1e/atl1e_main.c9
-rw-r--r--drivers/net/ethernet/atheros/atlx/atl1.c2
-rw-r--r--drivers/net/ethernet/atheros/atlx/atl2.c2
-rw-r--r--drivers/net/ethernet/broadcom/b44.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2.c2
-rw-r--r--drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c2
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmgenet.c37
-rw-r--r--drivers/net/ethernet/broadcom/genet/bcmmii.c14
-rw-r--r--drivers/net/ethernet/broadcom/tg3.c9
-rw-r--r--drivers/net/ethernet/brocade/bna/bnad.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb/subr.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c2
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4.h11
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c260
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h10
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c11
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h12
-rw-r--r--drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c2
-rw-r--r--drivers/net/ethernet/cisco/enic/enic_main.c2
-rw-r--r--drivers/net/ethernet/cisco/enic/vnic_dev.c8
-rw-r--r--drivers/net/ethernet/davicom/dm9000.c92
-rw-r--r--drivers/net/ethernet/dec/tulip/de2104x.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/de4x5.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/dmfe.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/tulip_core.c4
-rw-r--r--drivers/net/ethernet/dec/tulip/uli526x.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/winbond-840.c2
-rw-r--r--drivers/net/ethernet/dec/tulip/xircom_cb.c2
-rw-r--r--drivers/net/ethernet/dlink/dl2k.h2
-rw-r--r--drivers/net/ethernet/dlink/sundance.c2
-rw-r--r--drivers/net/ethernet/emulex/benet/be.h1
-rw-r--r--drivers/net/ethernet/emulex/benet/be_main.c3
-rw-r--r--drivers/net/ethernet/emulex/benet/be_roce.c18
-rw-r--r--drivers/net/ethernet/emulex/benet/be_roce.h3
-rw-r--r--drivers/net/ethernet/fealnx.c2
-rw-r--r--drivers/net/ethernet/freescale/fec.h1
-rw-r--r--drivers/net/ethernet/freescale/fec_main.c76
-rw-r--r--drivers/net/ethernet/freescale/fec_mpc52xx.c3
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c2
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/mac-fec.c1
-rw-r--r--drivers/net/ethernet/freescale/fs_enet/mac-scc.c1
-rw-r--r--drivers/net/ethernet/freescale/gianfar.c16
-rw-r--r--drivers/net/ethernet/freescale/ucc_geth.c24
-rw-r--r--drivers/net/ethernet/fujitsu/fmvj18x_cs.c34
-rw-r--r--drivers/net/ethernet/hp/hp100.c2
-rw-r--r--drivers/net/ethernet/ibm/ehea/Makefile2
-rw-r--r--drivers/net/ethernet/icplus/ipg.c2
-rw-r--r--drivers/net/ethernet/intel/e100.c2
-rw-r--r--drivers/net/ethernet/intel/e1000/e1000_main.c2
-rw-r--r--drivers/net/ethernet/intel/e1000e/manage.c4
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_ethtool.c2
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_fcoe.c1
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_main.c20
-rw-r--r--drivers/net/ethernet/intel/i40e/i40e_nvm.c6
-rw-r--r--drivers/net/ethernet/intel/i40evf/i40evf_main.c2
-rw-r--r--drivers/net/ethernet/intel/igbvf/netdev.c2
-rw-r--r--drivers/net/ethernet/intel/ixgb/ixgb_main.c2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c2
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_main.c2
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c2
-rw-r--r--drivers/net/ethernet/jme.c2
-rw-r--r--drivers/net/ethernet/marvell/mvneta.c9
-rw-r--r--drivers/net/ethernet/marvell/skge.c2
-rw-r--r--drivers/net/ethernet/marvell/sky2.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/cmd.c9
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/fw.c91
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/main.c7
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mlx4.h3
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/mr.c160
-rw-r--r--drivers/net/ethernet/mellanox/mlx4/resource_tracker.c26
-rw-r--r--drivers/net/ethernet/micrel/ksz884x.c9
-rw-r--r--drivers/net/ethernet/myricom/myri10ge/myri10ge.c91
-rw-r--r--drivers/net/ethernet/natsemi/natsemi.c2
-rw-r--r--drivers/net/ethernet/natsemi/ns83820.c2
-rw-r--r--drivers/net/ethernet/neterion/s2io.c2
-rw-r--r--drivers/net/ethernet/neterion/vxge/vxge-main.c2
-rw-r--r--drivers/net/ethernet/nvidia/forcedeth.c2
-rw-r--r--drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c2
-rw-r--r--drivers/net/ethernet/packetengines/hamachi.c2
-rw-r--r--drivers/net/ethernet/packetengines/yellowfin.c2
-rw-r--r--drivers/net/ethernet/pasemi/pasemi_mac.c2
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c4
-rw-r--r--drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c2
-rw-r--r--drivers/net/ethernet/qlogic/qla3xxx.c2
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/Makefile2
-rw-r--r--drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c2
-rw-r--r--drivers/net/ethernet/qlogic/qlge/qlge_main.c13
-rw-r--r--drivers/net/ethernet/rdc/r6040.c2
-rw-r--r--drivers/net/ethernet/realtek/8139too.c2
-rw-r--r--drivers/net/ethernet/realtek/r8169.c2
-rw-r--r--drivers/net/ethernet/sfc/efx.c2
-rw-r--r--drivers/net/ethernet/sgi/ioc3-eth.c2
-rw-r--r--drivers/net/ethernet/silan/sc92031.c2
-rw-r--r--drivers/net/ethernet/sis/sis190.c2
-rw-r--r--drivers/net/ethernet/sis/sis900.c3
-rw-r--r--drivers/net/ethernet/smsc/epic100.c2
-rw-r--r--drivers/net/ethernet/smsc/smsc911x.h2
-rw-r--r--drivers/net/ethernet/smsc/smsc9420.c2
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c2
-rw-r--r--drivers/net/ethernet/sun/cassini.c2
-rw-r--r--drivers/net/ethernet/sun/niu.c2
-rw-r--r--drivers/net/ethernet/sun/sungem.c2
-rw-r--r--drivers/net/ethernet/sun/sunhme.c2
-rw-r--r--drivers/net/ethernet/sun/sunvnet.c38
-rw-r--r--drivers/net/ethernet/sun/sunvnet.h4
-rw-r--r--drivers/net/ethernet/tehuti/tehuti.c2
-rw-r--r--drivers/net/ethernet/ti/cpmac.c1
-rw-r--r--drivers/net/ethernet/ti/tlan.c2
-rw-r--r--drivers/net/ethernet/toshiba/spider_net.c2
-rw-r--r--drivers/net/ethernet/toshiba/tc35815.c2
-rw-r--r--drivers/net/ethernet/via/via-rhine.c2
-rw-r--r--drivers/net/ethernet/via/via-velocity.c2
-rw-r--r--drivers/net/ethernet/xilinx/ll_temac_main.c4
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_axienet_main.c4
-rw-r--r--drivers/net/ethernet/xilinx/xilinx_emaclite.c1
-rw-r--r--drivers/net/ethernet/xircom/xirc2ps_cs.c40
-rw-r--r--drivers/net/fddi/defxx.c2
-rw-r--r--drivers/net/fddi/skfp/skfddi.c2
-rw-r--r--drivers/net/hippi/rrunner.c2
-rw-r--r--drivers/net/hyperv/hyperv_net.h2
-rw-r--r--drivers/net/irda/au1k_ir.c48
-rw-r--r--drivers/net/irda/donauboe.c17
-rw-r--r--drivers/net/irda/via-ircc.c2
-rw-r--r--drivers/net/irda/vlsi_ir.c6
-rw-r--r--drivers/net/macvlan.c12
-rw-r--r--drivers/net/usb/Kconfig4
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c4
-rw-r--r--drivers/net/wan/dscc4.c2
-rw-r--r--drivers/net/wan/farsync.c2
-rw-r--r--drivers/net/wan/hdlc_fr.c63
-rw-r--r--drivers/net/wan/lmc/lmc_main.c2
-rw-r--r--drivers/net/wan/pc300too.c2
-rw-r--r--drivers/net/wan/pci200syn.c2
-rw-r--r--drivers/net/wan/wanxl.c65
-rw-r--r--drivers/net/wireless/Kconfig1
-rw-r--r--drivers/net/wireless/adm8211.c2
-rw-r--r--drivers/net/wireless/airo.c2
-rw-r--r--drivers/net/wireless/airo_cs.c25
-rw-r--r--drivers/net/wireless/ath/ath10k/pci.c2
-rw-r--r--drivers/net/wireless/ath/ath5k/led.c2
-rw-r--r--drivers/net/wireless/ath/ath5k/pci.c2
-rw-r--r--drivers/net/wireless/ath/ath9k/pci.c2
-rw-r--r--drivers/net/wireless/ath/carl9170/carl9170.h1
-rw-r--r--drivers/net/wireless/ath/carl9170/usb.c31
-rw-r--r--drivers/net/wireless/atmel.c8
-rw-r--r--drivers/net/wireless/atmel_pci.c2
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c4
-rw-r--r--drivers/net/wireless/brcm80211/brcmfmac/pcie.c3
-rw-r--r--drivers/net/wireless/hostap/hostap_pci.c2
-rw-r--r--drivers/net/wireless/hostap/hostap_plx.c2
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2100.c18
-rw-r--r--drivers/net/wireless/ipw2x00/ipw2200.c3
-rw-r--r--drivers/net/wireless/iwlegacy/3945.c2
-rw-r--r--drivers/net/wireless/iwlegacy/4965-mac.c2
-rw-r--r--drivers/net/wireless/iwlwifi/mvm/mac80211.c3
-rw-r--r--drivers/net/wireless/iwlwifi/pcie/drv.c2
-rw-r--r--drivers/net/wireless/mwifiex/pcie.c2
-rw-r--r--drivers/net/wireless/mwl8k.c8
-rw-r--r--drivers/net/wireless/orinoco/orinoco_nortel.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_pci.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_plx.c2
-rw-r--r--drivers/net/wireless/orinoco/orinoco_tmd.c2
-rw-r--r--drivers/net/wireless/p54/p54pci.c2
-rw-r--r--drivers/net/wireless/prism54/islpci_hotplug.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2400pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2500pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt2800pci.c2
-rw-r--r--drivers/net/wireless/rt2x00/rt61pci.c2
-rw-r--r--drivers/net/wireless/rtl818x/rtl8180/dev.c13
-rw-r--r--drivers/net/wireless/rtlwifi/pci.c17
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8188ee/sw.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8192ce/sw.c2
-rw-r--r--drivers/net/wireless/rtlwifi/rtl8723be/sw.c2
-rw-r--r--drivers/net/xen-netback/common.h5
-rw-r--r--drivers/net/xen-netback/interface.c62
-rw-r--r--drivers/net/xen-netback/netback.c36
-rw-r--r--drivers/net/xen-netback/xenbus.c17
-rw-r--r--drivers/net/xen-netfront.c7
211 files changed, 3793 insertions, 752 deletions
diff --git a/drivers/net/arcnet/com20020-pci.c b/drivers/net/arcnet/com20020-pci.c
index cbc44f53755a..7bb292e59559 100644
--- a/drivers/net/arcnet/com20020-pci.c
+++ b/drivers/net/arcnet/com20020-pci.c
@@ -144,7 +144,7 @@ static void com20020pci_remove(struct pci_dev *pdev)
144 free_netdev(dev); 144 free_netdev(dev);
145} 145}
146 146
147static DEFINE_PCI_DEVICE_TABLE(com20020pci_id_table) = { 147static const struct pci_device_id com20020pci_id_table[] = {
148 { 0x1571, 0xa001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 148 { 0x1571, 0xa001, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
149 { 0x1571, 0xa002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 149 { 0x1571, 0xa002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
150 { 0x1571, 0xa003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 150 { 0x1571, 0xa003, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
diff --git a/drivers/net/arcnet/com20020_cs.c b/drivers/net/arcnet/com20020_cs.c
index 326a612a2730..1a790a20210d 100644
--- a/drivers/net/arcnet/com20020_cs.c
+++ b/drivers/net/arcnet/com20020_cs.c
@@ -112,20 +112,20 @@ static void com20020_detach(struct pcmcia_device *p_dev);
112 112
113/*====================================================================*/ 113/*====================================================================*/
114 114
115typedef struct com20020_dev_t { 115struct com20020_dev {
116 struct net_device *dev; 116 struct net_device *dev;
117} com20020_dev_t; 117};
118 118
119static int com20020_probe(struct pcmcia_device *p_dev) 119static int com20020_probe(struct pcmcia_device *p_dev)
120{ 120{
121 com20020_dev_t *info; 121 struct com20020_dev *info;
122 struct net_device *dev; 122 struct net_device *dev;
123 struct arcnet_local *lp; 123 struct arcnet_local *lp;
124 124
125 dev_dbg(&p_dev->dev, "com20020_attach()\n"); 125 dev_dbg(&p_dev->dev, "com20020_attach()\n");
126 126
127 /* Create new network device */ 127 /* Create new network device */
128 info = kzalloc(sizeof(struct com20020_dev_t), GFP_KERNEL); 128 info = kzalloc(sizeof(*info), GFP_KERNEL);
129 if (!info) 129 if (!info)
130 goto fail_alloc_info; 130 goto fail_alloc_info;
131 131
@@ -160,7 +160,7 @@ fail_alloc_info:
160 160
161static void com20020_detach(struct pcmcia_device *link) 161static void com20020_detach(struct pcmcia_device *link)
162{ 162{
163 struct com20020_dev_t *info = link->priv; 163 struct com20020_dev *info = link->priv;
164 struct net_device *dev = info->dev; 164 struct net_device *dev = info->dev;
165 165
166 dev_dbg(&link->dev, "detach...\n"); 166 dev_dbg(&link->dev, "detach...\n");
@@ -199,7 +199,7 @@ static void com20020_detach(struct pcmcia_device *link)
199static int com20020_config(struct pcmcia_device *link) 199static int com20020_config(struct pcmcia_device *link)
200{ 200{
201 struct arcnet_local *lp; 201 struct arcnet_local *lp;
202 com20020_dev_t *info; 202 struct com20020_dev *info;
203 struct net_device *dev; 203 struct net_device *dev;
204 int i, ret; 204 int i, ret;
205 int ioaddr; 205 int ioaddr;
@@ -291,7 +291,7 @@ static void com20020_release(struct pcmcia_device *link)
291 291
292static int com20020_suspend(struct pcmcia_device *link) 292static int com20020_suspend(struct pcmcia_device *link)
293{ 293{
294 com20020_dev_t *info = link->priv; 294 struct com20020_dev *info = link->priv;
295 struct net_device *dev = info->dev; 295 struct net_device *dev = info->dev;
296 296
297 if (link->open) 297 if (link->open)
@@ -302,7 +302,7 @@ static int com20020_suspend(struct pcmcia_device *link)
302 302
303static int com20020_resume(struct pcmcia_device *link) 303static int com20020_resume(struct pcmcia_device *link)
304{ 304{
305 com20020_dev_t *info = link->priv; 305 struct com20020_dev *info = link->priv;
306 struct net_device *dev = info->dev; 306 struct net_device *dev = info->dev;
307 307
308 if (link->open) { 308 if (link->open) {
diff --git a/drivers/net/can/c_can/c_can_pci.c b/drivers/net/can/c_can/c_can_pci.c
index 5d11e0e4225b..7be393c96b1a 100644
--- a/drivers/net/can/c_can/c_can_pci.c
+++ b/drivers/net/can/c_can/c_can_pci.c
@@ -270,7 +270,8 @@ static struct c_can_pci_data c_can_pch = {
270 PCI_DEVICE(_vend, _dev), \ 270 PCI_DEVICE(_vend, _dev), \
271 .driver_data = (unsigned long)&_driverdata, \ 271 .driver_data = (unsigned long)&_driverdata, \
272} 272}
273static DEFINE_PCI_DEVICE_TABLE(c_can_pci_tbl) = { 273
274static const struct pci_device_id c_can_pci_tbl[] = {
274 C_CAN_ID(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_CAN, 275 C_CAN_ID(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_CAN,
275 c_can_sta2x11), 276 c_can_sta2x11),
276 C_CAN_ID(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PCH_CAN, 277 C_CAN_ID(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_PCH_CAN,
diff --git a/drivers/net/can/pch_can.c b/drivers/net/can/pch_can.c
index 6472562efedc..a67eb01f3028 100644
--- a/drivers/net/can/pch_can.c
+++ b/drivers/net/can/pch_can.c
@@ -194,7 +194,7 @@ static const struct can_bittiming_const pch_can_bittiming_const = {
194 .brp_inc = 1, 194 .brp_inc = 1,
195}; 195};
196 196
197static DEFINE_PCI_DEVICE_TABLE(pch_pci_tbl) = { 197static const struct pci_device_id pch_pci_tbl[] = {
198 {PCI_VENDOR_ID_INTEL, 0x8818, PCI_ANY_ID, PCI_ANY_ID,}, 198 {PCI_VENDOR_ID_INTEL, 0x8818, PCI_ANY_ID, PCI_ANY_ID,},
199 {0,} 199 {0,}
200}; 200};
diff --git a/drivers/net/can/sja1000/ems_pci.c b/drivers/net/can/sja1000/ems_pci.c
index fd13dbf07d9c..7481c324a476 100644
--- a/drivers/net/can/sja1000/ems_pci.c
+++ b/drivers/net/can/sja1000/ems_pci.c
@@ -101,7 +101,7 @@ struct ems_pci_card {
101 101
102#define EMS_PCI_BASE_SIZE 4096 /* size of controller area */ 102#define EMS_PCI_BASE_SIZE 4096 /* size of controller area */
103 103
104static DEFINE_PCI_DEVICE_TABLE(ems_pci_tbl) = { 104static const struct pci_device_id ems_pci_tbl[] = {
105 /* CPC-PCI v1 */ 105 /* CPC-PCI v1 */
106 {PCI_VENDOR_ID_SIEMENS, 0x2104, PCI_ANY_ID, PCI_ANY_ID,}, 106 {PCI_VENDOR_ID_SIEMENS, 0x2104, PCI_ANY_ID, PCI_ANY_ID,},
107 /* CPC-PCI v2 */ 107 /* CPC-PCI v2 */
diff --git a/drivers/net/can/sja1000/kvaser_pci.c b/drivers/net/can/sja1000/kvaser_pci.c
index 23b8e1324e25..8ff3424d5147 100644
--- a/drivers/net/can/sja1000/kvaser_pci.c
+++ b/drivers/net/can/sja1000/kvaser_pci.c
@@ -107,7 +107,7 @@ struct kvaser_pci {
107#define KVASER_PCI_VENDOR_ID2 0x1a07 /* the PCI device and vendor IDs */ 107#define KVASER_PCI_VENDOR_ID2 0x1a07 /* the PCI device and vendor IDs */
108#define KVASER_PCI_DEVICE_ID2 0x0008 108#define KVASER_PCI_DEVICE_ID2 0x0008
109 109
110static DEFINE_PCI_DEVICE_TABLE(kvaser_pci_tbl) = { 110static const struct pci_device_id kvaser_pci_tbl[] = {
111 {KVASER_PCI_VENDOR_ID1, KVASER_PCI_DEVICE_ID1, PCI_ANY_ID, PCI_ANY_ID,}, 111 {KVASER_PCI_VENDOR_ID1, KVASER_PCI_DEVICE_ID1, PCI_ANY_ID, PCI_ANY_ID,},
112 {KVASER_PCI_VENDOR_ID2, KVASER_PCI_DEVICE_ID2, PCI_ANY_ID, PCI_ANY_ID,}, 112 {KVASER_PCI_VENDOR_ID2, KVASER_PCI_DEVICE_ID2, PCI_ANY_ID, PCI_ANY_ID,},
113 { 0,} 113 { 0,}
diff --git a/drivers/net/can/sja1000/peak_pci.c b/drivers/net/can/sja1000/peak_pci.c
index 564933ae218c..7a85590fefb9 100644
--- a/drivers/net/can/sja1000/peak_pci.c
+++ b/drivers/net/can/sja1000/peak_pci.c
@@ -77,7 +77,7 @@ static const u16 peak_pci_icr_masks[PEAK_PCI_CHAN_MAX] = {
77 0x02, 0x01, 0x40, 0x80 77 0x02, 0x01, 0x40, 0x80
78}; 78};
79 79
80static DEFINE_PCI_DEVICE_TABLE(peak_pci_tbl) = { 80static const struct pci_device_id peak_pci_tbl[] = {
81 {PEAK_PCI_VENDOR_ID, PEAK_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 81 {PEAK_PCI_VENDOR_ID, PEAK_PCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
82 {PEAK_PCI_VENDOR_ID, PEAK_PCIE_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 82 {PEAK_PCI_VENDOR_ID, PEAK_PCIE_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
83 {PEAK_PCI_VENDOR_ID, PEAK_MPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,}, 83 {PEAK_PCI_VENDOR_ID, PEAK_MPCI_DEVICE_ID, PCI_ANY_ID, PCI_ANY_ID,},
diff --git a/drivers/net/can/sja1000/plx_pci.c b/drivers/net/can/sja1000/plx_pci.c
index ec39b7cb2287..8836a7485c81 100644
--- a/drivers/net/can/sja1000/plx_pci.c
+++ b/drivers/net/can/sja1000/plx_pci.c
@@ -247,7 +247,7 @@ static struct plx_pci_card_info plx_pci_card_info_elcus = {
247 /* based on PLX9030 */ 247 /* based on PLX9030 */
248}; 248};
249 249
250static DEFINE_PCI_DEVICE_TABLE(plx_pci_tbl) = { 250static const struct pci_device_id plx_pci_tbl[] = {
251 { 251 {
252 /* Adlink PCI-7841/cPCI-7841 */ 252 /* Adlink PCI-7841/cPCI-7841 */
253 ADLINK_PCI_VENDOR_ID, ADLINK_PCI_DEVICE_ID, 253 ADLINK_PCI_VENDOR_ID, ADLINK_PCI_DEVICE_ID,
diff --git a/drivers/net/ethernet/3com/3c59x.c b/drivers/net/ethernet/3com/3c59x.c
index 61477b8e8d24..059c7414e303 100644
--- a/drivers/net/ethernet/3com/3c59x.c
+++ b/drivers/net/ethernet/3com/3c59x.c
@@ -375,7 +375,7 @@ static struct vortex_chip_info {
375}; 375};
376 376
377 377
378static DEFINE_PCI_DEVICE_TABLE(vortex_pci_tbl) = { 378static const struct pci_device_id vortex_pci_tbl[] = {
379 { 0x10B7, 0x5900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C590 }, 379 { 0x10B7, 0x5900, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C590 },
380 { 0x10B7, 0x5920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C592 }, 380 { 0x10B7, 0x5920, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C592 },
381 { 0x10B7, 0x5970, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C597 }, 381 { 0x10B7, 0x5970, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_3C597 },
diff --git a/drivers/net/ethernet/3com/typhoon.c b/drivers/net/ethernet/3com/typhoon.c
index e13b04624ded..48775b88bac7 100644
--- a/drivers/net/ethernet/3com/typhoon.c
+++ b/drivers/net/ethernet/3com/typhoon.c
@@ -203,7 +203,7 @@ static struct typhoon_card_info typhoon_card_info[] = {
203 * bit 8 indicates if this is a (0) copper or (1) fiber card 203 * bit 8 indicates if this is a (0) copper or (1) fiber card
204 * bits 12-16 indicate card type: (0) client and (1) server 204 * bits 12-16 indicate card type: (0) client and (1) server
205 */ 205 */
206static DEFINE_PCI_DEVICE_TABLE(typhoon_pci_tbl) = { 206static const struct pci_device_id typhoon_pci_tbl[] = {
207 { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3CR990, 207 { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3CR990,
208 PCI_ANY_ID, PCI_ANY_ID, 0, 0,TYPHOON_TX }, 208 PCI_ANY_ID, PCI_ANY_ID, 0, 0,TYPHOON_TX },
209 { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3CR990_TX_95, 209 { PCI_VENDOR_ID_3COM, PCI_DEVICE_ID_3COM_3CR990_TX_95,
diff --git a/drivers/net/ethernet/8390/Kconfig b/drivers/net/ethernet/8390/Kconfig
index 0988811f4e40..2d89bd00de61 100644
--- a/drivers/net/ethernet/8390/Kconfig
+++ b/drivers/net/ethernet/8390/Kconfig
@@ -91,7 +91,8 @@ config MCF8390
91 91
92config NE2000 92config NE2000
93 tristate "NE2000/NE1000 support" 93 tristate "NE2000/NE1000 support"
94 depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX) 94 depends on (ISA || (Q40 && m) || M32R || MACH_TX49XX || \
95 ATARI_ETHERNEC)
95 select CRC32 96 select CRC32
96 ---help--- 97 ---help---
97 If you have a network (Ethernet) card of this type, say Y and read 98 If you have a network (Ethernet) card of this type, say Y and read
diff --git a/drivers/net/ethernet/8390/axnet_cs.c b/drivers/net/ethernet/8390/axnet_cs.c
index 73c57a4a7b9e..7769c05543f1 100644
--- a/drivers/net/ethernet/8390/axnet_cs.c
+++ b/drivers/net/ethernet/8390/axnet_cs.c
@@ -108,7 +108,7 @@ static u32 axnet_msg_enable;
108 108
109/*====================================================================*/ 109/*====================================================================*/
110 110
111typedef struct axnet_dev_t { 111struct axnet_dev {
112 struct pcmcia_device *p_dev; 112 struct pcmcia_device *p_dev;
113 caddr_t base; 113 caddr_t base;
114 struct timer_list watchdog; 114 struct timer_list watchdog;
@@ -118,9 +118,9 @@ typedef struct axnet_dev_t {
118 int phy_id; 118 int phy_id;
119 int flags; 119 int flags;
120 int active_low; 120 int active_low;
121} axnet_dev_t; 121};
122 122
123static inline axnet_dev_t *PRIV(struct net_device *dev) 123static inline struct axnet_dev *PRIV(struct net_device *dev)
124{ 124{
125 void *p = (char *)netdev_priv(dev) + sizeof(struct ei_device); 125 void *p = (char *)netdev_priv(dev) + sizeof(struct ei_device);
126 return p; 126 return p;
@@ -141,13 +141,13 @@ static const struct net_device_ops axnet_netdev_ops = {
141 141
142static int axnet_probe(struct pcmcia_device *link) 142static int axnet_probe(struct pcmcia_device *link)
143{ 143{
144 axnet_dev_t *info; 144 struct axnet_dev *info;
145 struct net_device *dev; 145 struct net_device *dev;
146 struct ei_device *ei_local; 146 struct ei_device *ei_local;
147 147
148 dev_dbg(&link->dev, "axnet_attach()\n"); 148 dev_dbg(&link->dev, "axnet_attach()\n");
149 149
150 dev = alloc_etherdev(sizeof(struct ei_device) + sizeof(axnet_dev_t)); 150 dev = alloc_etherdev(sizeof(struct ei_device) + sizeof(struct axnet_dev));
151 if (!dev) 151 if (!dev)
152 return -ENOMEM; 152 return -ENOMEM;
153 153
@@ -274,7 +274,7 @@ static int axnet_configcheck(struct pcmcia_device *p_dev, void *priv_data)
274static int axnet_config(struct pcmcia_device *link) 274static int axnet_config(struct pcmcia_device *link)
275{ 275{
276 struct net_device *dev = link->priv; 276 struct net_device *dev = link->priv;
277 axnet_dev_t *info = PRIV(dev); 277 struct axnet_dev *info = PRIV(dev);
278 int i, j, j2, ret; 278 int i, j, j2, ret;
279 279
280 dev_dbg(&link->dev, "axnet_config(0x%p)\n", link); 280 dev_dbg(&link->dev, "axnet_config(0x%p)\n", link);
@@ -389,7 +389,7 @@ static int axnet_suspend(struct pcmcia_device *link)
389static int axnet_resume(struct pcmcia_device *link) 389static int axnet_resume(struct pcmcia_device *link)
390{ 390{
391 struct net_device *dev = link->priv; 391 struct net_device *dev = link->priv;
392 axnet_dev_t *info = PRIV(dev); 392 struct axnet_dev *info = PRIV(dev);
393 393
394 if (link->open) { 394 if (link->open) {
395 if (info->active_low == 1) 395 if (info->active_low == 1)
@@ -467,7 +467,7 @@ static void mdio_write(unsigned int addr, int phy_id, int loc, int value)
467static int axnet_open(struct net_device *dev) 467static int axnet_open(struct net_device *dev)
468{ 468{
469 int ret; 469 int ret;
470 axnet_dev_t *info = PRIV(dev); 470 struct axnet_dev *info = PRIV(dev);
471 struct pcmcia_device *link = info->p_dev; 471 struct pcmcia_device *link = info->p_dev;
472 unsigned int nic_base = dev->base_addr; 472 unsigned int nic_base = dev->base_addr;
473 473
@@ -497,7 +497,7 @@ static int axnet_open(struct net_device *dev)
497 497
498static int axnet_close(struct net_device *dev) 498static int axnet_close(struct net_device *dev)
499{ 499{
500 axnet_dev_t *info = PRIV(dev); 500 struct axnet_dev *info = PRIV(dev);
501 struct pcmcia_device *link = info->p_dev; 501 struct pcmcia_device *link = info->p_dev;
502 502
503 dev_dbg(&link->dev, "axnet_close('%s')\n", dev->name); 503 dev_dbg(&link->dev, "axnet_close('%s')\n", dev->name);
@@ -554,7 +554,7 @@ static irqreturn_t ei_irq_wrapper(int irq, void *dev_id)
554static void ei_watchdog(u_long arg) 554static void ei_watchdog(u_long arg)
555{ 555{
556 struct net_device *dev = (struct net_device *)(arg); 556 struct net_device *dev = (struct net_device *)(arg);
557 axnet_dev_t *info = PRIV(dev); 557 struct axnet_dev *info = PRIV(dev);
558 unsigned int nic_base = dev->base_addr; 558 unsigned int nic_base = dev->base_addr;
559 unsigned int mii_addr = nic_base + AXNET_MII_EEP; 559 unsigned int mii_addr = nic_base + AXNET_MII_EEP;
560 u_short link; 560 u_short link;
@@ -610,7 +610,7 @@ reschedule:
610 610
611static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 611static int axnet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
612{ 612{
613 axnet_dev_t *info = PRIV(dev); 613 struct axnet_dev *info = PRIV(dev);
614 struct mii_ioctl_data *data = if_mii(rq); 614 struct mii_ioctl_data *data = if_mii(rq);
615 unsigned int mii_addr = dev->base_addr + AXNET_MII_EEP; 615 unsigned int mii_addr = dev->base_addr + AXNET_MII_EEP;
616 switch (cmd) { 616 switch (cmd) {
@@ -1452,7 +1452,7 @@ static void ei_receive(struct net_device *dev)
1452 1452
1453static void ei_rx_overrun(struct net_device *dev) 1453static void ei_rx_overrun(struct net_device *dev)
1454{ 1454{
1455 axnet_dev_t *info = PRIV(dev); 1455 struct axnet_dev *info = PRIV(dev);
1456 long e8390_base = dev->base_addr; 1456 long e8390_base = dev->base_addr;
1457 unsigned char was_txing, must_resend = 0; 1457 unsigned char was_txing, must_resend = 0;
1458 struct ei_device *ei_local = netdev_priv(dev); 1458 struct ei_device *ei_local = netdev_priv(dev);
@@ -1624,7 +1624,7 @@ static void set_multicast_list(struct net_device *dev)
1624 1624
1625static void AX88190_init(struct net_device *dev, int startp) 1625static void AX88190_init(struct net_device *dev, int startp)
1626{ 1626{
1627 axnet_dev_t *info = PRIV(dev); 1627 struct axnet_dev *info = PRIV(dev);
1628 long e8390_base = dev->base_addr; 1628 long e8390_base = dev->base_addr;
1629 struct ei_device *ei_local = netdev_priv(dev); 1629 struct ei_device *ei_local = netdev_priv(dev);
1630 int i; 1630 int i;
diff --git a/drivers/net/ethernet/8390/ne.c b/drivers/net/ethernet/8390/ne.c
index 58eaa8f34942..de566fb6e0f7 100644
--- a/drivers/net/ethernet/8390/ne.c
+++ b/drivers/net/ethernet/8390/ne.c
@@ -169,6 +169,8 @@ bad_clone_list[] __initdata = {
169#elif defined(CONFIG_PLAT_OAKS32R) || \ 169#elif defined(CONFIG_PLAT_OAKS32R) || \
170 defined(CONFIG_MACH_TX49XX) 170 defined(CONFIG_MACH_TX49XX)
171# define DCR_VAL 0x48 /* 8-bit mode */ 171# define DCR_VAL 0x48 /* 8-bit mode */
172#elif defined(CONFIG_ATARI) /* 8-bit mode on Atari, normal on Q40 */
173# define DCR_VAL (MACH_IS_ATARI ? 0x48 : 0x49)
172#else 174#else
173# define DCR_VAL 0x49 175# define DCR_VAL 0x49
174#endif 176#endif
diff --git a/drivers/net/ethernet/8390/ne2k-pci.c b/drivers/net/ethernet/8390/ne2k-pci.c
index f395c967262e..89c8d9fc97de 100644
--- a/drivers/net/ethernet/8390/ne2k-pci.c
+++ b/drivers/net/ethernet/8390/ne2k-pci.c
@@ -135,7 +135,7 @@ static struct {
135}; 135};
136 136
137 137
138static DEFINE_PCI_DEVICE_TABLE(ne2k_pci_tbl) = { 138static const struct pci_device_id ne2k_pci_tbl[] = {
139 { 0x10ec, 0x8029, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RealTek_RTL_8029 }, 139 { 0x10ec, 0x8029, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_RealTek_RTL_8029 },
140 { 0x1050, 0x0940, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Winbond_89C940 }, 140 { 0x1050, 0x0940, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Winbond_89C940 },
141 { 0x11f6, 0x1401, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Compex_RL2000 }, 141 { 0x11f6, 0x1401, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CH_Compex_RL2000 },
diff --git a/drivers/net/ethernet/8390/pcnet_cs.c b/drivers/net/ethernet/8390/pcnet_cs.c
index ca3c2b921cf6..9fb7b9d4fd6c 100644
--- a/drivers/net/ethernet/8390/pcnet_cs.c
+++ b/drivers/net/ethernet/8390/pcnet_cs.c
@@ -111,11 +111,11 @@ static void pcnet_detach(struct pcmcia_device *p_dev);
111 111
112/*====================================================================*/ 112/*====================================================================*/
113 113
114typedef struct hw_info_t { 114struct hw_info {
115 u_int offset; 115 u_int offset;
116 u_char a0, a1, a2; 116 u_char a0, a1, a2;
117 u_int flags; 117 u_int flags;
118} hw_info_t; 118};
119 119
120#define DELAY_OUTPUT 0x01 120#define DELAY_OUTPUT 0x01
121#define HAS_MISC_REG 0x02 121#define HAS_MISC_REG 0x02
@@ -132,7 +132,7 @@ typedef struct hw_info_t {
132#define MII_PHYID_REG1 0x02 132#define MII_PHYID_REG1 0x02
133#define MII_PHYID_REG2 0x03 133#define MII_PHYID_REG2 0x03
134 134
135static hw_info_t hw_info[] = { 135static struct hw_info hw_info[] = {
136 { /* Accton EN2212 */ 0x0ff0, 0x00, 0x00, 0xe8, DELAY_OUTPUT }, 136 { /* Accton EN2212 */ 0x0ff0, 0x00, 0x00, 0xe8, DELAY_OUTPUT },
137 { /* Allied Telesis LA-PCM */ 0x0ff0, 0x00, 0x00, 0xf4, 0 }, 137 { /* Allied Telesis LA-PCM */ 0x0ff0, 0x00, 0x00, 0xf4, 0 },
138 { /* APEX MultiCard */ 0x03f4, 0x00, 0x20, 0xe5, 0 }, 138 { /* APEX MultiCard */ 0x03f4, 0x00, 0x20, 0xe5, 0 },
@@ -196,11 +196,11 @@ static hw_info_t hw_info[] = {
196 196
197#define NR_INFO ARRAY_SIZE(hw_info) 197#define NR_INFO ARRAY_SIZE(hw_info)
198 198
199static hw_info_t default_info = { 0, 0, 0, 0, 0 }; 199static struct hw_info default_info = { 0, 0, 0, 0, 0 };
200static hw_info_t dl10019_info = { 0, 0, 0, 0, IS_DL10019|HAS_MII }; 200static struct hw_info dl10019_info = { 0, 0, 0, 0, IS_DL10019|HAS_MII };
201static hw_info_t dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII }; 201static struct hw_info dl10022_info = { 0, 0, 0, 0, IS_DL10022|HAS_MII };
202 202
203typedef struct pcnet_dev_t { 203struct pcnet_dev {
204 struct pcmcia_device *p_dev; 204 struct pcmcia_device *p_dev;
205 u_int flags; 205 u_int flags;
206 void __iomem *base; 206 void __iomem *base;
@@ -210,12 +210,12 @@ typedef struct pcnet_dev_t {
210 u_char eth_phy, pna_phy; 210 u_char eth_phy, pna_phy;
211 u_short link_status; 211 u_short link_status;
212 u_long mii_reset; 212 u_long mii_reset;
213} pcnet_dev_t; 213};
214 214
215static inline pcnet_dev_t *PRIV(struct net_device *dev) 215static inline struct pcnet_dev *PRIV(struct net_device *dev)
216{ 216{
217 char *p = netdev_priv(dev); 217 char *p = netdev_priv(dev);
218 return (pcnet_dev_t *)(p + sizeof(struct ei_device)); 218 return (struct pcnet_dev *)(p + sizeof(struct ei_device));
219} 219}
220 220
221static const struct net_device_ops pcnet_netdev_ops = { 221static const struct net_device_ops pcnet_netdev_ops = {
@@ -237,13 +237,13 @@ static const struct net_device_ops pcnet_netdev_ops = {
237 237
238static int pcnet_probe(struct pcmcia_device *link) 238static int pcnet_probe(struct pcmcia_device *link)
239{ 239{
240 pcnet_dev_t *info; 240 struct pcnet_dev *info;
241 struct net_device *dev; 241 struct net_device *dev;
242 242
243 dev_dbg(&link->dev, "pcnet_attach()\n"); 243 dev_dbg(&link->dev, "pcnet_attach()\n");
244 244
245 /* Create new ethernet device */ 245 /* Create new ethernet device */
246 dev = __alloc_ei_netdev(sizeof(pcnet_dev_t)); 246 dev = __alloc_ei_netdev(sizeof(struct pcnet_dev));
247 if (!dev) return -ENOMEM; 247 if (!dev) return -ENOMEM;
248 info = PRIV(dev); 248 info = PRIV(dev);
249 info->p_dev = link; 249 info->p_dev = link;
@@ -276,7 +276,7 @@ static void pcnet_detach(struct pcmcia_device *link)
276 276
277======================================================================*/ 277======================================================================*/
278 278
279static hw_info_t *get_hwinfo(struct pcmcia_device *link) 279static struct hw_info *get_hwinfo(struct pcmcia_device *link)
280{ 280{
281 struct net_device *dev = link->priv; 281 struct net_device *dev = link->priv;
282 u_char __iomem *base, *virt; 282 u_char __iomem *base, *virt;
@@ -317,7 +317,7 @@ static hw_info_t *get_hwinfo(struct pcmcia_device *link)
317 317
318======================================================================*/ 318======================================================================*/
319 319
320static hw_info_t *get_prom(struct pcmcia_device *link) 320static struct hw_info *get_prom(struct pcmcia_device *link)
321{ 321{
322 struct net_device *dev = link->priv; 322 struct net_device *dev = link->priv;
323 unsigned int ioaddr = dev->base_addr; 323 unsigned int ioaddr = dev->base_addr;
@@ -371,7 +371,7 @@ static hw_info_t *get_prom(struct pcmcia_device *link)
371 371
372======================================================================*/ 372======================================================================*/
373 373
374static hw_info_t *get_dl10019(struct pcmcia_device *link) 374static struct hw_info *get_dl10019(struct pcmcia_device *link)
375{ 375{
376 struct net_device *dev = link->priv; 376 struct net_device *dev = link->priv;
377 int i; 377 int i;
@@ -393,7 +393,7 @@ static hw_info_t *get_dl10019(struct pcmcia_device *link)
393 393
394======================================================================*/ 394======================================================================*/
395 395
396static hw_info_t *get_ax88190(struct pcmcia_device *link) 396static struct hw_info *get_ax88190(struct pcmcia_device *link)
397{ 397{
398 struct net_device *dev = link->priv; 398 struct net_device *dev = link->priv;
399 unsigned int ioaddr = dev->base_addr; 399 unsigned int ioaddr = dev->base_addr;
@@ -424,7 +424,7 @@ static hw_info_t *get_ax88190(struct pcmcia_device *link)
424 424
425======================================================================*/ 425======================================================================*/
426 426
427static hw_info_t *get_hwired(struct pcmcia_device *link) 427static struct hw_info *get_hwired(struct pcmcia_device *link)
428{ 428{
429 struct net_device *dev = link->priv; 429 struct net_device *dev = link->priv;
430 int i; 430 int i;
@@ -489,12 +489,12 @@ static int pcnet_confcheck(struct pcmcia_device *p_dev, void *priv_data)
489 return try_io_port(p_dev); 489 return try_io_port(p_dev);
490} 490}
491 491
492static hw_info_t *pcnet_try_config(struct pcmcia_device *link, 492static struct hw_info *pcnet_try_config(struct pcmcia_device *link,
493 int *has_shmem, int try) 493 int *has_shmem, int try)
494{ 494{
495 struct net_device *dev = link->priv; 495 struct net_device *dev = link->priv;
496 hw_info_t *local_hw_info; 496 struct hw_info *local_hw_info;
497 pcnet_dev_t *info = PRIV(dev); 497 struct pcnet_dev *info = PRIV(dev);
498 int priv = try; 498 int priv = try;
499 int ret; 499 int ret;
500 500
@@ -553,10 +553,10 @@ static hw_info_t *pcnet_try_config(struct pcmcia_device *link,
553static int pcnet_config(struct pcmcia_device *link) 553static int pcnet_config(struct pcmcia_device *link)
554{ 554{
555 struct net_device *dev = link->priv; 555 struct net_device *dev = link->priv;
556 pcnet_dev_t *info = PRIV(dev); 556 struct pcnet_dev *info = PRIV(dev);
557 int start_pg, stop_pg, cm_offset; 557 int start_pg, stop_pg, cm_offset;
558 int has_shmem = 0; 558 int has_shmem = 0;
559 hw_info_t *local_hw_info; 559 struct hw_info *local_hw_info;
560 struct ei_device *ei_local; 560 struct ei_device *ei_local;
561 561
562 dev_dbg(&link->dev, "pcnet_config\n"); 562 dev_dbg(&link->dev, "pcnet_config\n");
@@ -639,7 +639,7 @@ failed:
639 639
640static void pcnet_release(struct pcmcia_device *link) 640static void pcnet_release(struct pcmcia_device *link)
641{ 641{
642 pcnet_dev_t *info = PRIV(link->priv); 642 struct pcnet_dev *info = PRIV(link->priv);
643 643
644 dev_dbg(&link->dev, "pcnet_release\n"); 644 dev_dbg(&link->dev, "pcnet_release\n");
645 645
@@ -836,7 +836,7 @@ static void write_asic(unsigned int ioaddr, int location, short asic_data)
836static void set_misc_reg(struct net_device *dev) 836static void set_misc_reg(struct net_device *dev)
837{ 837{
838 unsigned int nic_base = dev->base_addr; 838 unsigned int nic_base = dev->base_addr;
839 pcnet_dev_t *info = PRIV(dev); 839 struct pcnet_dev *info = PRIV(dev);
840 u_char tmp; 840 u_char tmp;
841 841
842 if (info->flags & HAS_MISC_REG) { 842 if (info->flags & HAS_MISC_REG) {
@@ -873,7 +873,7 @@ static void set_misc_reg(struct net_device *dev)
873 873
874static void mii_phy_probe(struct net_device *dev) 874static void mii_phy_probe(struct net_device *dev)
875{ 875{
876 pcnet_dev_t *info = PRIV(dev); 876 struct pcnet_dev *info = PRIV(dev);
877 unsigned int mii_addr = dev->base_addr + DLINK_GPIO; 877 unsigned int mii_addr = dev->base_addr + DLINK_GPIO;
878 int i; 878 int i;
879 u_int tmp, phyid; 879 u_int tmp, phyid;
@@ -898,7 +898,7 @@ static void mii_phy_probe(struct net_device *dev)
898static int pcnet_open(struct net_device *dev) 898static int pcnet_open(struct net_device *dev)
899{ 899{
900 int ret; 900 int ret;
901 pcnet_dev_t *info = PRIV(dev); 901 struct pcnet_dev *info = PRIV(dev);
902 struct pcmcia_device *link = info->p_dev; 902 struct pcmcia_device *link = info->p_dev;
903 unsigned int nic_base = dev->base_addr; 903 unsigned int nic_base = dev->base_addr;
904 904
@@ -931,7 +931,7 @@ static int pcnet_open(struct net_device *dev)
931 931
932static int pcnet_close(struct net_device *dev) 932static int pcnet_close(struct net_device *dev)
933{ 933{
934 pcnet_dev_t *info = PRIV(dev); 934 struct pcnet_dev *info = PRIV(dev);
935 struct pcmcia_device *link = info->p_dev; 935 struct pcmcia_device *link = info->p_dev;
936 936
937 dev_dbg(&link->dev, "pcnet_close('%s')\n", dev->name); 937 dev_dbg(&link->dev, "pcnet_close('%s')\n", dev->name);
@@ -982,7 +982,7 @@ static void pcnet_reset_8390(struct net_device *dev)
982 982
983static int set_config(struct net_device *dev, struct ifmap *map) 983static int set_config(struct net_device *dev, struct ifmap *map)
984{ 984{
985 pcnet_dev_t *info = PRIV(dev); 985 struct pcnet_dev *info = PRIV(dev);
986 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) { 986 if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) {
987 if (!(info->flags & HAS_MISC_REG)) 987 if (!(info->flags & HAS_MISC_REG))
988 return -EOPNOTSUPP; 988 return -EOPNOTSUPP;
@@ -1000,7 +1000,7 @@ static int set_config(struct net_device *dev, struct ifmap *map)
1000static irqreturn_t ei_irq_wrapper(int irq, void *dev_id) 1000static irqreturn_t ei_irq_wrapper(int irq, void *dev_id)
1001{ 1001{
1002 struct net_device *dev = dev_id; 1002 struct net_device *dev = dev_id;
1003 pcnet_dev_t *info; 1003 struct pcnet_dev *info;
1004 irqreturn_t ret = ei_interrupt(irq, dev_id); 1004 irqreturn_t ret = ei_interrupt(irq, dev_id);
1005 1005
1006 if (ret == IRQ_HANDLED) { 1006 if (ret == IRQ_HANDLED) {
@@ -1013,7 +1013,7 @@ static irqreturn_t ei_irq_wrapper(int irq, void *dev_id)
1013static void ei_watchdog(u_long arg) 1013static void ei_watchdog(u_long arg)
1014{ 1014{
1015 struct net_device *dev = (struct net_device *)arg; 1015 struct net_device *dev = (struct net_device *)arg;
1016 pcnet_dev_t *info = PRIV(dev); 1016 struct pcnet_dev *info = PRIV(dev);
1017 unsigned int nic_base = dev->base_addr; 1017 unsigned int nic_base = dev->base_addr;
1018 unsigned int mii_addr = nic_base + DLINK_GPIO; 1018 unsigned int mii_addr = nic_base + DLINK_GPIO;
1019 u_short link; 1019 u_short link;
@@ -1101,7 +1101,7 @@ reschedule:
1101 1101
1102static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1102static int ei_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1103{ 1103{
1104 pcnet_dev_t *info = PRIV(dev); 1104 struct pcnet_dev *info = PRIV(dev);
1105 struct mii_ioctl_data *data = if_mii(rq); 1105 struct mii_ioctl_data *data = if_mii(rq);
1106 unsigned int mii_addr = dev->base_addr + DLINK_GPIO; 1106 unsigned int mii_addr = dev->base_addr + DLINK_GPIO;
1107 1107
@@ -1214,7 +1214,7 @@ static void dma_block_output(struct net_device *dev, int count,
1214 const u_char *buf, const int start_page) 1214 const u_char *buf, const int start_page)
1215{ 1215{
1216 unsigned int nic_base = dev->base_addr; 1216 unsigned int nic_base = dev->base_addr;
1217 pcnet_dev_t *info = PRIV(dev); 1217 struct pcnet_dev *info = PRIV(dev);
1218#ifdef PCMCIA_DEBUG 1218#ifdef PCMCIA_DEBUG
1219 int retries = 0; 1219 int retries = 0;
1220 struct ei_device *ei_local = netdev_priv(dev); 1220 struct ei_device *ei_local = netdev_priv(dev);
@@ -1403,7 +1403,7 @@ static int setup_shmem_window(struct pcmcia_device *link, int start_pg,
1403 int stop_pg, int cm_offset) 1403 int stop_pg, int cm_offset)
1404{ 1404{
1405 struct net_device *dev = link->priv; 1405 struct net_device *dev = link->priv;
1406 pcnet_dev_t *info = PRIV(dev); 1406 struct pcnet_dev *info = PRIV(dev);
1407 int i, window_size, offset, ret; 1407 int i, window_size, offset, ret;
1408 1408
1409 window_size = (stop_pg - start_pg) << 8; 1409 window_size = (stop_pg - start_pg) << 8;
diff --git a/drivers/net/ethernet/Kconfig b/drivers/net/ethernet/Kconfig
index edb718661850..dc7406c81c45 100644
--- a/drivers/net/ethernet/Kconfig
+++ b/drivers/net/ethernet/Kconfig
@@ -24,6 +24,7 @@ source "drivers/net/ethernet/allwinner/Kconfig"
24source "drivers/net/ethernet/alteon/Kconfig" 24source "drivers/net/ethernet/alteon/Kconfig"
25source "drivers/net/ethernet/altera/Kconfig" 25source "drivers/net/ethernet/altera/Kconfig"
26source "drivers/net/ethernet/amd/Kconfig" 26source "drivers/net/ethernet/amd/Kconfig"
27source "drivers/net/ethernet/apm/Kconfig"
27source "drivers/net/ethernet/apple/Kconfig" 28source "drivers/net/ethernet/apple/Kconfig"
28source "drivers/net/ethernet/arc/Kconfig" 29source "drivers/net/ethernet/arc/Kconfig"
29source "drivers/net/ethernet/atheros/Kconfig" 30source "drivers/net/ethernet/atheros/Kconfig"
diff --git a/drivers/net/ethernet/Makefile b/drivers/net/ethernet/Makefile
index 58de3339ab3c..224a01877149 100644
--- a/drivers/net/ethernet/Makefile
+++ b/drivers/net/ethernet/Makefile
@@ -10,6 +10,7 @@ obj-$(CONFIG_NET_VENDOR_ALLWINNER) += allwinner/
10obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/ 10obj-$(CONFIG_NET_VENDOR_ALTEON) += alteon/
11obj-$(CONFIG_ALTERA_TSE) += altera/ 11obj-$(CONFIG_ALTERA_TSE) += altera/
12obj-$(CONFIG_NET_VENDOR_AMD) += amd/ 12obj-$(CONFIG_NET_VENDOR_AMD) += amd/
13obj-$(CONFIG_NET_XGENE) += apm/
13obj-$(CONFIG_NET_VENDOR_APPLE) += apple/ 14obj-$(CONFIG_NET_VENDOR_APPLE) += apple/
14obj-$(CONFIG_NET_VENDOR_ARC) += arc/ 15obj-$(CONFIG_NET_VENDOR_ARC) += arc/
15obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/ 16obj-$(CONFIG_NET_VENDOR_ATHEROS) += atheros/
diff --git a/drivers/net/ethernet/adaptec/starfire.c b/drivers/net/ethernet/adaptec/starfire.c
index 40dbbf740331..ac7288240d55 100644
--- a/drivers/net/ethernet/adaptec/starfire.c
+++ b/drivers/net/ethernet/adaptec/starfire.c
@@ -285,7 +285,7 @@ enum chipset {
285 CH_6915 = 0, 285 CH_6915 = 0,
286}; 286};
287 287
288static DEFINE_PCI_DEVICE_TABLE(starfire_pci_tbl) = { 288static const struct pci_device_id starfire_pci_tbl[] = {
289 { PCI_VDEVICE(ADAPTEC, 0x6915), CH_6915 }, 289 { PCI_VDEVICE(ADAPTEC, 0x6915), CH_6915 },
290 { 0, } 290 { 0, }
291}; 291};
diff --git a/drivers/net/ethernet/alteon/acenic.c b/drivers/net/ethernet/alteon/acenic.c
index 9a6991be9749..b68074803de3 100644
--- a/drivers/net/ethernet/alteon/acenic.c
+++ b/drivers/net/ethernet/alteon/acenic.c
@@ -131,7 +131,7 @@
131#define PCI_DEVICE_ID_SGI_ACENIC 0x0009 131#define PCI_DEVICE_ID_SGI_ACENIC 0x0009
132#endif 132#endif
133 133
134static DEFINE_PCI_DEVICE_TABLE(acenic_pci_tbl) = { 134static const struct pci_device_id acenic_pci_tbl[] = {
135 { PCI_VENDOR_ID_ALTEON, PCI_DEVICE_ID_ALTEON_ACENIC_FIBRE, 135 { PCI_VENDOR_ID_ALTEON, PCI_DEVICE_ID_ALTEON_ACENIC_FIBRE,
136 PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, }, 136 PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_NETWORK_ETHERNET << 8, 0xffff00, },
137 { PCI_VENDOR_ID_ALTEON, PCI_DEVICE_ID_ALTEON_ACENIC_COPPER, 137 { PCI_VENDOR_ID_ALTEON, PCI_DEVICE_ID_ALTEON_ACENIC_COPPER,
diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c
index a78e4c136959..31c48a7ac2b6 100644
--- a/drivers/net/ethernet/amd/au1000_eth.c
+++ b/drivers/net/ethernet/amd/au1000_eth.c
@@ -89,6 +89,124 @@ MODULE_DESCRIPTION(DRV_DESC);
89MODULE_LICENSE("GPL"); 89MODULE_LICENSE("GPL");
90MODULE_VERSION(DRV_VERSION); 90MODULE_VERSION(DRV_VERSION);
91 91
92/* AU1000 MAC registers and bits */
93#define MAC_CONTROL 0x0
94# define MAC_RX_ENABLE (1 << 2)
95# define MAC_TX_ENABLE (1 << 3)
96# define MAC_DEF_CHECK (1 << 5)
97# define MAC_SET_BL(X) (((X) & 0x3) << 6)
98# define MAC_AUTO_PAD (1 << 8)
99# define MAC_DISABLE_RETRY (1 << 10)
100# define MAC_DISABLE_BCAST (1 << 11)
101# define MAC_LATE_COL (1 << 12)
102# define MAC_HASH_MODE (1 << 13)
103# define MAC_HASH_ONLY (1 << 15)
104# define MAC_PASS_ALL (1 << 16)
105# define MAC_INVERSE_FILTER (1 << 17)
106# define MAC_PROMISCUOUS (1 << 18)
107# define MAC_PASS_ALL_MULTI (1 << 19)
108# define MAC_FULL_DUPLEX (1 << 20)
109# define MAC_NORMAL_MODE 0
110# define MAC_INT_LOOPBACK (1 << 21)
111# define MAC_EXT_LOOPBACK (1 << 22)
112# define MAC_DISABLE_RX_OWN (1 << 23)
113# define MAC_BIG_ENDIAN (1 << 30)
114# define MAC_RX_ALL (1 << 31)
115#define MAC_ADDRESS_HIGH 0x4
116#define MAC_ADDRESS_LOW 0x8
117#define MAC_MCAST_HIGH 0xC
118#define MAC_MCAST_LOW 0x10
119#define MAC_MII_CNTRL 0x14
120# define MAC_MII_BUSY (1 << 0)
121# define MAC_MII_READ 0
122# define MAC_MII_WRITE (1 << 1)
123# define MAC_SET_MII_SELECT_REG(X) (((X) & 0x1f) << 6)
124# define MAC_SET_MII_SELECT_PHY(X) (((X) & 0x1f) << 11)
125#define MAC_MII_DATA 0x18
126#define MAC_FLOW_CNTRL 0x1C
127# define MAC_FLOW_CNTRL_BUSY (1 << 0)
128# define MAC_FLOW_CNTRL_ENABLE (1 << 1)
129# define MAC_PASS_CONTROL (1 << 2)
130# define MAC_SET_PAUSE(X) (((X) & 0xffff) << 16)
131#define MAC_VLAN1_TAG 0x20
132#define MAC_VLAN2_TAG 0x24
133
134/* Ethernet Controller Enable */
135# define MAC_EN_CLOCK_ENABLE (1 << 0)
136# define MAC_EN_RESET0 (1 << 1)
137# define MAC_EN_TOSS (0 << 2)
138# define MAC_EN_CACHEABLE (1 << 3)
139# define MAC_EN_RESET1 (1 << 4)
140# define MAC_EN_RESET2 (1 << 5)
141# define MAC_DMA_RESET (1 << 6)
142
143/* Ethernet Controller DMA Channels */
144/* offsets from MAC_TX_RING_ADDR address */
145#define MAC_TX_BUFF0_STATUS 0x0
146# define TX_FRAME_ABORTED (1 << 0)
147# define TX_JAB_TIMEOUT (1 << 1)
148# define TX_NO_CARRIER (1 << 2)
149# define TX_LOSS_CARRIER (1 << 3)
150# define TX_EXC_DEF (1 << 4)
151# define TX_LATE_COLL_ABORT (1 << 5)
152# define TX_EXC_COLL (1 << 6)
153# define TX_UNDERRUN (1 << 7)
154# define TX_DEFERRED (1 << 8)
155# define TX_LATE_COLL (1 << 9)
156# define TX_COLL_CNT_MASK (0xF << 10)
157# define TX_PKT_RETRY (1 << 31)
158#define MAC_TX_BUFF0_ADDR 0x4
159# define TX_DMA_ENABLE (1 << 0)
160# define TX_T_DONE (1 << 1)
161# define TX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3)
162#define MAC_TX_BUFF0_LEN 0x8
163#define MAC_TX_BUFF1_STATUS 0x10
164#define MAC_TX_BUFF1_ADDR 0x14
165#define MAC_TX_BUFF1_LEN 0x18
166#define MAC_TX_BUFF2_STATUS 0x20
167#define MAC_TX_BUFF2_ADDR 0x24
168#define MAC_TX_BUFF2_LEN 0x28
169#define MAC_TX_BUFF3_STATUS 0x30
170#define MAC_TX_BUFF3_ADDR 0x34
171#define MAC_TX_BUFF3_LEN 0x38
172
173/* offsets from MAC_RX_RING_ADDR */
174#define MAC_RX_BUFF0_STATUS 0x0
175# define RX_FRAME_LEN_MASK 0x3fff
176# define RX_WDOG_TIMER (1 << 14)
177# define RX_RUNT (1 << 15)
178# define RX_OVERLEN (1 << 16)
179# define RX_COLL (1 << 17)
180# define RX_ETHER (1 << 18)
181# define RX_MII_ERROR (1 << 19)
182# define RX_DRIBBLING (1 << 20)
183# define RX_CRC_ERROR (1 << 21)
184# define RX_VLAN1 (1 << 22)
185# define RX_VLAN2 (1 << 23)
186# define RX_LEN_ERROR (1 << 24)
187# define RX_CNTRL_FRAME (1 << 25)
188# define RX_U_CNTRL_FRAME (1 << 26)
189# define RX_MCAST_FRAME (1 << 27)
190# define RX_BCAST_FRAME (1 << 28)
191# define RX_FILTER_FAIL (1 << 29)
192# define RX_PACKET_FILTER (1 << 30)
193# define RX_MISSED_FRAME (1 << 31)
194
195# define RX_ERROR (RX_WDOG_TIMER | RX_RUNT | RX_OVERLEN | \
196 RX_COLL | RX_MII_ERROR | RX_CRC_ERROR | \
197 RX_LEN_ERROR | RX_U_CNTRL_FRAME | RX_MISSED_FRAME)
198#define MAC_RX_BUFF0_ADDR 0x4
199# define RX_DMA_ENABLE (1 << 0)
200# define RX_T_DONE (1 << 1)
201# define RX_GET_DMA_BUFFER(X) (((X) >> 2) & 0x3)
202# define RX_SET_BUFF_ADDR(X) ((X) & 0xffffffc0)
203#define MAC_RX_BUFF1_STATUS 0x10
204#define MAC_RX_BUFF1_ADDR 0x14
205#define MAC_RX_BUFF2_STATUS 0x20
206#define MAC_RX_BUFF2_ADDR 0x24
207#define MAC_RX_BUFF3_STATUS 0x30
208#define MAC_RX_BUFF3_ADDR 0x34
209
92/* 210/*
93 * Theory of operation 211 * Theory of operation
94 * 212 *
@@ -152,10 +270,12 @@ static void au1000_enable_mac(struct net_device *dev, int force_reset)
152 270
153 if (force_reset || (!aup->mac_enabled)) { 271 if (force_reset || (!aup->mac_enabled)) {
154 writel(MAC_EN_CLOCK_ENABLE, aup->enable); 272 writel(MAC_EN_CLOCK_ENABLE, aup->enable);
155 au_sync_delay(2); 273 wmb(); /* drain writebuffer */
274 mdelay(2);
156 writel((MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2 275 writel((MAC_EN_RESET0 | MAC_EN_RESET1 | MAC_EN_RESET2
157 | MAC_EN_CLOCK_ENABLE), aup->enable); 276 | MAC_EN_CLOCK_ENABLE), aup->enable);
158 au_sync_delay(2); 277 wmb(); /* drain writebuffer */
278 mdelay(2);
159 279
160 aup->mac_enabled = 1; 280 aup->mac_enabled = 1;
161 } 281 }
@@ -273,7 +393,8 @@ static void au1000_hard_stop(struct net_device *dev)
273 reg = readl(&aup->mac->control); 393 reg = readl(&aup->mac->control);
274 reg &= ~(MAC_RX_ENABLE | MAC_TX_ENABLE); 394 reg &= ~(MAC_RX_ENABLE | MAC_TX_ENABLE);
275 writel(reg, &aup->mac->control); 395 writel(reg, &aup->mac->control);
276 au_sync_delay(10); 396 wmb(); /* drain writebuffer */
397 mdelay(10);
277} 398}
278 399
279static void au1000_enable_rx_tx(struct net_device *dev) 400static void au1000_enable_rx_tx(struct net_device *dev)
@@ -286,7 +407,8 @@ static void au1000_enable_rx_tx(struct net_device *dev)
286 reg = readl(&aup->mac->control); 407 reg = readl(&aup->mac->control);
287 reg |= (MAC_RX_ENABLE | MAC_TX_ENABLE); 408 reg |= (MAC_RX_ENABLE | MAC_TX_ENABLE);
288 writel(reg, &aup->mac->control); 409 writel(reg, &aup->mac->control);
289 au_sync_delay(10); 410 wmb(); /* drain writebuffer */
411 mdelay(10);
290} 412}
291 413
292static void 414static void
@@ -336,7 +458,8 @@ au1000_adjust_link(struct net_device *dev)
336 reg |= MAC_DISABLE_RX_OWN; 458 reg |= MAC_DISABLE_RX_OWN;
337 } 459 }
338 writel(reg, &aup->mac->control); 460 writel(reg, &aup->mac->control);
339 au_sync_delay(1); 461 wmb(); /* drain writebuffer */
462 mdelay(1);
340 463
341 au1000_enable_rx_tx(dev); 464 au1000_enable_rx_tx(dev);
342 aup->old_duplex = phydev->duplex; 465 aup->old_duplex = phydev->duplex;
@@ -500,9 +623,11 @@ static void au1000_reset_mac_unlocked(struct net_device *dev)
500 au1000_hard_stop(dev); 623 au1000_hard_stop(dev);
501 624
502 writel(MAC_EN_CLOCK_ENABLE, aup->enable); 625 writel(MAC_EN_CLOCK_ENABLE, aup->enable);
503 au_sync_delay(2); 626 wmb(); /* drain writebuffer */
627 mdelay(2);
504 writel(0, aup->enable); 628 writel(0, aup->enable);
505 au_sync_delay(2); 629 wmb(); /* drain writebuffer */
630 mdelay(2);
506 631
507 aup->tx_full = 0; 632 aup->tx_full = 0;
508 for (i = 0; i < NUM_RX_DMA; i++) { 633 for (i = 0; i < NUM_RX_DMA; i++) {
@@ -652,7 +777,7 @@ static int au1000_init(struct net_device *dev)
652 for (i = 0; i < NUM_RX_DMA; i++) 777 for (i = 0; i < NUM_RX_DMA; i++)
653 aup->rx_dma_ring[i]->buff_stat |= RX_DMA_ENABLE; 778 aup->rx_dma_ring[i]->buff_stat |= RX_DMA_ENABLE;
654 779
655 au_sync(); 780 wmb(); /* drain writebuffer */
656 781
657 control = MAC_RX_ENABLE | MAC_TX_ENABLE; 782 control = MAC_RX_ENABLE | MAC_TX_ENABLE;
658#ifndef CONFIG_CPU_LITTLE_ENDIAN 783#ifndef CONFIG_CPU_LITTLE_ENDIAN
@@ -669,7 +794,7 @@ static int au1000_init(struct net_device *dev)
669 794
670 writel(control, &aup->mac->control); 795 writel(control, &aup->mac->control);
671 writel(0x8100, &aup->mac->vlan1_tag); /* activate vlan support */ 796 writel(0x8100, &aup->mac->vlan1_tag); /* activate vlan support */
672 au_sync(); 797 wmb(); /* drain writebuffer */
673 798
674 spin_unlock_irqrestore(&aup->lock, flags); 799 spin_unlock_irqrestore(&aup->lock, flags);
675 return 0; 800 return 0;
@@ -760,7 +885,7 @@ static int au1000_rx(struct net_device *dev)
760 } 885 }
761 prxd->buff_stat = (u32)(pDB->dma_addr | RX_DMA_ENABLE); 886 prxd->buff_stat = (u32)(pDB->dma_addr | RX_DMA_ENABLE);
762 aup->rx_head = (aup->rx_head + 1) & (NUM_RX_DMA - 1); 887 aup->rx_head = (aup->rx_head + 1) & (NUM_RX_DMA - 1);
763 au_sync(); 888 wmb(); /* drain writebuffer */
764 889
765 /* next descriptor */ 890 /* next descriptor */
766 prxd = aup->rx_dma_ring[aup->rx_head]; 891 prxd = aup->rx_dma_ring[aup->rx_head];
@@ -808,7 +933,7 @@ static void au1000_tx_ack(struct net_device *dev)
808 au1000_update_tx_stats(dev, ptxd->status); 933 au1000_update_tx_stats(dev, ptxd->status);
809 ptxd->buff_stat &= ~TX_T_DONE; 934 ptxd->buff_stat &= ~TX_T_DONE;
810 ptxd->len = 0; 935 ptxd->len = 0;
811 au_sync(); 936 wmb(); /* drain writebuffer */
812 937
813 aup->tx_tail = (aup->tx_tail + 1) & (NUM_TX_DMA - 1); 938 aup->tx_tail = (aup->tx_tail + 1) & (NUM_TX_DMA - 1);
814 ptxd = aup->tx_dma_ring[aup->tx_tail]; 939 ptxd = aup->tx_dma_ring[aup->tx_tail];
@@ -939,7 +1064,7 @@ static netdev_tx_t au1000_tx(struct sk_buff *skb, struct net_device *dev)
939 ps->tx_bytes += ptxd->len; 1064 ps->tx_bytes += ptxd->len;
940 1065
941 ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE; 1066 ptxd->buff_stat = pDB->dma_addr | TX_DMA_ENABLE;
942 au_sync(); 1067 wmb(); /* drain writebuffer */
943 dev_kfree_skb(skb); 1068 dev_kfree_skb(skb);
944 aup->tx_head = (aup->tx_head + 1) & (NUM_TX_DMA - 1); 1069 aup->tx_head = (aup->tx_head + 1) & (NUM_TX_DMA - 1);
945 return NETDEV_TX_OK; 1070 return NETDEV_TX_OK;
diff --git a/drivers/net/ethernet/amd/pcnet32.c b/drivers/net/ethernet/amd/pcnet32.c
index e7cc9174e364..e2e3aaf501a2 100644
--- a/drivers/net/ethernet/amd/pcnet32.c
+++ b/drivers/net/ethernet/amd/pcnet32.c
@@ -61,7 +61,7 @@ static const char *const version =
61/* 61/*
62 * PCI device identifiers for "new style" Linux PCI Device Drivers 62 * PCI device identifiers for "new style" Linux PCI Device Drivers
63 */ 63 */
64static DEFINE_PCI_DEVICE_TABLE(pcnet32_pci_tbl) = { 64static const struct pci_device_id pcnet32_pci_tbl[] = {
65 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE_HOME), }, 65 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE_HOME), },
66 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE), }, 66 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_LANCE), },
67 67
@@ -481,37 +481,32 @@ static void pcnet32_realloc_tx_ring(struct net_device *dev,
481 dma_addr_t *new_dma_addr_list; 481 dma_addr_t *new_dma_addr_list;
482 struct pcnet32_tx_head *new_tx_ring; 482 struct pcnet32_tx_head *new_tx_ring;
483 struct sk_buff **new_skb_list; 483 struct sk_buff **new_skb_list;
484 unsigned int entries = BIT(size);
484 485
485 pcnet32_purge_tx_ring(dev); 486 pcnet32_purge_tx_ring(dev);
486 487
487 new_tx_ring = pci_alloc_consistent(lp->pci_dev, 488 new_tx_ring =
488 sizeof(struct pcnet32_tx_head) * 489 pci_zalloc_consistent(lp->pci_dev,
489 (1 << size), 490 sizeof(struct pcnet32_tx_head) * entries,
490 &new_ring_dma_addr); 491 &new_ring_dma_addr);
491 if (new_tx_ring == NULL) { 492 if (new_tx_ring == NULL)
492 netif_err(lp, drv, dev, "Consistent memory allocation failed\n");
493 return; 493 return;
494 }
495 memset(new_tx_ring, 0, sizeof(struct pcnet32_tx_head) * (1 << size));
496 494
497 new_dma_addr_list = kcalloc(1 << size, sizeof(dma_addr_t), 495 new_dma_addr_list = kcalloc(entries, sizeof(dma_addr_t), GFP_ATOMIC);
498 GFP_ATOMIC);
499 if (!new_dma_addr_list) 496 if (!new_dma_addr_list)
500 goto free_new_tx_ring; 497 goto free_new_tx_ring;
501 498
502 new_skb_list = kcalloc(1 << size, sizeof(struct sk_buff *), 499 new_skb_list = kcalloc(entries, sizeof(struct sk_buff *), GFP_ATOMIC);
503 GFP_ATOMIC);
504 if (!new_skb_list) 500 if (!new_skb_list)
505 goto free_new_lists; 501 goto free_new_lists;
506 502
507 kfree(lp->tx_skbuff); 503 kfree(lp->tx_skbuff);
508 kfree(lp->tx_dma_addr); 504 kfree(lp->tx_dma_addr);
509 pci_free_consistent(lp->pci_dev, 505 pci_free_consistent(lp->pci_dev,
510 sizeof(struct pcnet32_tx_head) * 506 sizeof(struct pcnet32_tx_head) * lp->tx_ring_size,
511 lp->tx_ring_size, lp->tx_ring, 507 lp->tx_ring, lp->tx_ring_dma_addr);
512 lp->tx_ring_dma_addr);
513 508
514 lp->tx_ring_size = (1 << size); 509 lp->tx_ring_size = entries;
515 lp->tx_mod_mask = lp->tx_ring_size - 1; 510 lp->tx_mod_mask = lp->tx_ring_size - 1;
516 lp->tx_len_bits = (size << 12); 511 lp->tx_len_bits = (size << 12);
517 lp->tx_ring = new_tx_ring; 512 lp->tx_ring = new_tx_ring;
@@ -524,8 +519,7 @@ free_new_lists:
524 kfree(new_dma_addr_list); 519 kfree(new_dma_addr_list);
525free_new_tx_ring: 520free_new_tx_ring:
526 pci_free_consistent(lp->pci_dev, 521 pci_free_consistent(lp->pci_dev,
527 sizeof(struct pcnet32_tx_head) * 522 sizeof(struct pcnet32_tx_head) * entries,
528 (1 << size),
529 new_tx_ring, 523 new_tx_ring,
530 new_ring_dma_addr); 524 new_ring_dma_addr);
531} 525}
@@ -549,17 +543,14 @@ static void pcnet32_realloc_rx_ring(struct net_device *dev,
549 struct pcnet32_rx_head *new_rx_ring; 543 struct pcnet32_rx_head *new_rx_ring;
550 struct sk_buff **new_skb_list; 544 struct sk_buff **new_skb_list;
551 int new, overlap; 545 int new, overlap;
552 unsigned int entries = 1 << size; 546 unsigned int entries = BIT(size);
553 547
554 new_rx_ring = pci_alloc_consistent(lp->pci_dev, 548 new_rx_ring =
555 sizeof(struct pcnet32_rx_head) * 549 pci_zalloc_consistent(lp->pci_dev,
556 entries, 550 sizeof(struct pcnet32_rx_head) * entries,
557 &new_ring_dma_addr); 551 &new_ring_dma_addr);
558 if (new_rx_ring == NULL) { 552 if (new_rx_ring == NULL)
559 netif_err(lp, drv, dev, "Consistent memory allocation failed\n");
560 return; 553 return;
561 }
562 memset(new_rx_ring, 0, sizeof(struct pcnet32_rx_head) * entries);
563 554
564 new_dma_addr_list = kcalloc(entries, sizeof(dma_addr_t), GFP_ATOMIC); 555 new_dma_addr_list = kcalloc(entries, sizeof(dma_addr_t), GFP_ATOMIC);
565 if (!new_dma_addr_list) 556 if (!new_dma_addr_list)
diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
index 1f5487f4888c..dc84f7193c2d 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-drv.c
@@ -117,7 +117,6 @@
117#include <linux/spinlock.h> 117#include <linux/spinlock.h>
118#include <linux/tcp.h> 118#include <linux/tcp.h>
119#include <linux/if_vlan.h> 119#include <linux/if_vlan.h>
120#include <linux/phy.h>
121#include <net/busy_poll.h> 120#include <net/busy_poll.h>
122#include <linux/clk.h> 121#include <linux/clk.h>
123#include <linux/if_ether.h> 122#include <linux/if_ether.h>
diff --git a/drivers/net/ethernet/apm/Kconfig b/drivers/net/ethernet/apm/Kconfig
new file mode 100644
index 000000000000..ec63d706d464
--- /dev/null
+++ b/drivers/net/ethernet/apm/Kconfig
@@ -0,0 +1 @@
source "drivers/net/ethernet/apm/xgene/Kconfig"
diff --git a/drivers/net/ethernet/apm/Makefile b/drivers/net/ethernet/apm/Makefile
new file mode 100644
index 000000000000..65ce32ad1b2c
--- /dev/null
+++ b/drivers/net/ethernet/apm/Makefile
@@ -0,0 +1,5 @@
1#
2# Makefile for APM X-GENE Ethernet driver.
3#
4
5obj-$(CONFIG_NET_XGENE) += xgene/
diff --git a/drivers/net/ethernet/apm/xgene/Kconfig b/drivers/net/ethernet/apm/xgene/Kconfig
new file mode 100644
index 000000000000..616dff6d3f5f
--- /dev/null
+++ b/drivers/net/ethernet/apm/xgene/Kconfig
@@ -0,0 +1,9 @@
1config NET_XGENE
2 tristate "APM X-Gene SoC Ethernet Driver"
3 select PHYLIB
4 help
5 This is the Ethernet driver for the on-chip ethernet interface on the
6 APM X-Gene SoC.
7
8 To compile this driver as a module, choose M here. This module will
9 be called xgene_enet.
diff --git a/drivers/net/ethernet/apm/xgene/Makefile b/drivers/net/ethernet/apm/xgene/Makefile
new file mode 100644
index 000000000000..c643e8a0a0dc
--- /dev/null
+++ b/drivers/net/ethernet/apm/xgene/Makefile
@@ -0,0 +1,6 @@
1#
2# Makefile for APM X-Gene Ethernet Driver.
3#
4
5xgene-enet-objs := xgene_enet_hw.o xgene_enet_main.o xgene_enet_ethtool.o
6obj-$(CONFIG_NET_XGENE) += xgene-enet.o
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c b/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c
new file mode 100644
index 000000000000..63f2aa54a594
--- /dev/null
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_ethtool.c
@@ -0,0 +1,125 @@
1/* Applied Micro X-Gene SoC Ethernet Driver
2 *
3 * Copyright (c) 2014, Applied Micro Circuits Corporation
4 * Authors: Iyappan Subramanian <isubramanian@apm.com>
5 *
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation; either version 2 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#include <linux/ethtool.h>
21#include "xgene_enet_main.h"
22
23struct xgene_gstrings_stats {
24 char name[ETH_GSTRING_LEN];
25 int offset;
26};
27
28#define XGENE_STAT(m) { #m, offsetof(struct xgene_enet_pdata, stats.m) }
29
30static const struct xgene_gstrings_stats gstrings_stats[] = {
31 XGENE_STAT(rx_packets),
32 XGENE_STAT(tx_packets),
33 XGENE_STAT(rx_bytes),
34 XGENE_STAT(tx_bytes),
35 XGENE_STAT(rx_errors),
36 XGENE_STAT(tx_errors),
37 XGENE_STAT(rx_length_errors),
38 XGENE_STAT(rx_crc_errors),
39 XGENE_STAT(rx_frame_errors),
40 XGENE_STAT(rx_fifo_errors)
41};
42
43#define XGENE_STATS_LEN ARRAY_SIZE(gstrings_stats)
44
45static void xgene_get_drvinfo(struct net_device *ndev,
46 struct ethtool_drvinfo *info)
47{
48 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
49 struct platform_device *pdev = pdata->pdev;
50
51 strcpy(info->driver, "xgene_enet");
52 strcpy(info->version, XGENE_DRV_VERSION);
53 snprintf(info->fw_version, ETHTOOL_FWVERS_LEN, "N/A");
54 sprintf(info->bus_info, "%s", pdev->name);
55}
56
57static int xgene_get_settings(struct net_device *ndev, struct ethtool_cmd *cmd)
58{
59 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
60 struct phy_device *phydev = pdata->phy_dev;
61
62 if (phydev == NULL)
63 return -ENODEV;
64
65 return phy_ethtool_gset(phydev, cmd);
66}
67
68static int xgene_set_settings(struct net_device *ndev, struct ethtool_cmd *cmd)
69{
70 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
71 struct phy_device *phydev = pdata->phy_dev;
72
73 if (phydev == NULL)
74 return -ENODEV;
75
76 return phy_ethtool_sset(phydev, cmd);
77}
78
79static void xgene_get_strings(struct net_device *ndev, u32 stringset, u8 *data)
80{
81 int i;
82 u8 *p = data;
83
84 if (stringset != ETH_SS_STATS)
85 return;
86
87 for (i = 0; i < XGENE_STATS_LEN; i++) {
88 memcpy(p, gstrings_stats[i].name, ETH_GSTRING_LEN);
89 p += ETH_GSTRING_LEN;
90 }
91}
92
93static int xgene_get_sset_count(struct net_device *ndev, int sset)
94{
95 if (sset != ETH_SS_STATS)
96 return -EINVAL;
97
98 return XGENE_STATS_LEN;
99}
100
101static void xgene_get_ethtool_stats(struct net_device *ndev,
102 struct ethtool_stats *dummy,
103 u64 *data)
104{
105 void *pdata = netdev_priv(ndev);
106 int i;
107
108 for (i = 0; i < XGENE_STATS_LEN; i++)
109 *data++ = *(u64 *)(pdata + gstrings_stats[i].offset);
110}
111
112static const struct ethtool_ops xgene_ethtool_ops = {
113 .get_drvinfo = xgene_get_drvinfo,
114 .get_settings = xgene_get_settings,
115 .set_settings = xgene_set_settings,
116 .get_link = ethtool_op_get_link,
117 .get_strings = xgene_get_strings,
118 .get_sset_count = xgene_get_sset_count,
119 .get_ethtool_stats = xgene_get_ethtool_stats
120};
121
122void xgene_enet_set_ethtool_ops(struct net_device *ndev)
123{
124 ndev->ethtool_ops = &xgene_ethtool_ops;
125}
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
new file mode 100644
index 000000000000..812d8d65159b
--- /dev/null
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.c
@@ -0,0 +1,728 @@
1/* Applied Micro X-Gene SoC Ethernet Driver
2 *
3 * Copyright (c) 2014, Applied Micro Circuits Corporation
4 * Authors: Iyappan Subramanian <isubramanian@apm.com>
5 * Ravi Patel <rapatel@apm.com>
6 * Keyur Chudgar <kchudgar@apm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "xgene_enet_main.h"
23#include "xgene_enet_hw.h"
24
25static void xgene_enet_ring_init(struct xgene_enet_desc_ring *ring)
26{
27 u32 *ring_cfg = ring->state;
28 u64 addr = ring->dma;
29 enum xgene_enet_ring_cfgsize cfgsize = ring->cfgsize;
30
31 ring_cfg[4] |= (1 << SELTHRSH_POS) &
32 CREATE_MASK(SELTHRSH_POS, SELTHRSH_LEN);
33 ring_cfg[3] |= ACCEPTLERR;
34 ring_cfg[2] |= QCOHERENT;
35
36 addr >>= 8;
37 ring_cfg[2] |= (addr << RINGADDRL_POS) &
38 CREATE_MASK_ULL(RINGADDRL_POS, RINGADDRL_LEN);
39 addr >>= RINGADDRL_LEN;
40 ring_cfg[3] |= addr & CREATE_MASK_ULL(RINGADDRH_POS, RINGADDRH_LEN);
41 ring_cfg[3] |= ((u32)cfgsize << RINGSIZE_POS) &
42 CREATE_MASK(RINGSIZE_POS, RINGSIZE_LEN);
43}
44
45static void xgene_enet_ring_set_type(struct xgene_enet_desc_ring *ring)
46{
47 u32 *ring_cfg = ring->state;
48 bool is_bufpool;
49 u32 val;
50
51 is_bufpool = xgene_enet_is_bufpool(ring->id);
52 val = (is_bufpool) ? RING_BUFPOOL : RING_REGULAR;
53 ring_cfg[4] |= (val << RINGTYPE_POS) &
54 CREATE_MASK(RINGTYPE_POS, RINGTYPE_LEN);
55
56 if (is_bufpool) {
57 ring_cfg[3] |= (BUFPOOL_MODE << RINGMODE_POS) &
58 CREATE_MASK(RINGMODE_POS, RINGMODE_LEN);
59 }
60}
61
62static void xgene_enet_ring_set_recombbuf(struct xgene_enet_desc_ring *ring)
63{
64 u32 *ring_cfg = ring->state;
65
66 ring_cfg[3] |= RECOMBBUF;
67 ring_cfg[3] |= (0xf << RECOMTIMEOUTL_POS) &
68 CREATE_MASK(RECOMTIMEOUTL_POS, RECOMTIMEOUTL_LEN);
69 ring_cfg[4] |= 0x7 & CREATE_MASK(RECOMTIMEOUTH_POS, RECOMTIMEOUTH_LEN);
70}
71
72static void xgene_enet_ring_wr32(struct xgene_enet_desc_ring *ring,
73 u32 offset, u32 data)
74{
75 struct xgene_enet_pdata *pdata = netdev_priv(ring->ndev);
76
77 iowrite32(data, pdata->ring_csr_addr + offset);
78}
79
80static void xgene_enet_ring_rd32(struct xgene_enet_desc_ring *ring,
81 u32 offset, u32 *data)
82{
83 struct xgene_enet_pdata *pdata = netdev_priv(ring->ndev);
84
85 *data = ioread32(pdata->ring_csr_addr + offset);
86}
87
88static void xgene_enet_write_ring_state(struct xgene_enet_desc_ring *ring)
89{
90 int i;
91
92 xgene_enet_ring_wr32(ring, CSR_RING_CONFIG, ring->num);
93 for (i = 0; i < NUM_RING_CONFIG; i++) {
94 xgene_enet_ring_wr32(ring, CSR_RING_WR_BASE + (i * 4),
95 ring->state[i]);
96 }
97}
98
99static void xgene_enet_clr_ring_state(struct xgene_enet_desc_ring *ring)
100{
101 memset(ring->state, 0, sizeof(u32) * NUM_RING_CONFIG);
102 xgene_enet_write_ring_state(ring);
103}
104
105static void xgene_enet_set_ring_state(struct xgene_enet_desc_ring *ring)
106{
107 xgene_enet_ring_set_type(ring);
108
109 if (xgene_enet_ring_owner(ring->id) == RING_OWNER_ETH0)
110 xgene_enet_ring_set_recombbuf(ring);
111
112 xgene_enet_ring_init(ring);
113 xgene_enet_write_ring_state(ring);
114}
115
116static void xgene_enet_set_ring_id(struct xgene_enet_desc_ring *ring)
117{
118 u32 ring_id_val, ring_id_buf;
119 bool is_bufpool;
120
121 is_bufpool = xgene_enet_is_bufpool(ring->id);
122
123 ring_id_val = ring->id & GENMASK(9, 0);
124 ring_id_val |= OVERWRITE;
125
126 ring_id_buf = (ring->num << 9) & GENMASK(18, 9);
127 ring_id_buf |= PREFETCH_BUF_EN;
128 if (is_bufpool)
129 ring_id_buf |= IS_BUFFER_POOL;
130
131 xgene_enet_ring_wr32(ring, CSR_RING_ID, ring_id_val);
132 xgene_enet_ring_wr32(ring, CSR_RING_ID_BUF, ring_id_buf);
133}
134
135static void xgene_enet_clr_desc_ring_id(struct xgene_enet_desc_ring *ring)
136{
137 u32 ring_id;
138
139 ring_id = ring->id | OVERWRITE;
140 xgene_enet_ring_wr32(ring, CSR_RING_ID, ring_id);
141 xgene_enet_ring_wr32(ring, CSR_RING_ID_BUF, 0);
142}
143
144struct xgene_enet_desc_ring *xgene_enet_setup_ring(
145 struct xgene_enet_desc_ring *ring)
146{
147 u32 size = ring->size;
148 u32 i, data;
149 bool is_bufpool;
150
151 xgene_enet_clr_ring_state(ring);
152 xgene_enet_set_ring_state(ring);
153 xgene_enet_set_ring_id(ring);
154
155 ring->slots = xgene_enet_get_numslots(ring->id, size);
156
157 is_bufpool = xgene_enet_is_bufpool(ring->id);
158 if (is_bufpool || xgene_enet_ring_owner(ring->id) != RING_OWNER_CPU)
159 return ring;
160
161 for (i = 0; i < ring->slots; i++)
162 xgene_enet_mark_desc_slot_empty(&ring->raw_desc[i]);
163
164 xgene_enet_ring_rd32(ring, CSR_RING_NE_INT_MODE, &data);
165 data |= BIT(31 - xgene_enet_ring_bufnum(ring->id));
166 xgene_enet_ring_wr32(ring, CSR_RING_NE_INT_MODE, data);
167
168 return ring;
169}
170
171void xgene_enet_clear_ring(struct xgene_enet_desc_ring *ring)
172{
173 u32 data;
174 bool is_bufpool;
175
176 is_bufpool = xgene_enet_is_bufpool(ring->id);
177 if (is_bufpool || xgene_enet_ring_owner(ring->id) != RING_OWNER_CPU)
178 goto out;
179
180 xgene_enet_ring_rd32(ring, CSR_RING_NE_INT_MODE, &data);
181 data &= ~BIT(31 - xgene_enet_ring_bufnum(ring->id));
182 xgene_enet_ring_wr32(ring, CSR_RING_NE_INT_MODE, data);
183
184out:
185 xgene_enet_clr_desc_ring_id(ring);
186 xgene_enet_clr_ring_state(ring);
187}
188
189void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
190 struct xgene_enet_pdata *pdata,
191 enum xgene_enet_err_code status)
192{
193 struct rtnl_link_stats64 *stats = &pdata->stats;
194
195 switch (status) {
196 case INGRESS_CRC:
197 stats->rx_crc_errors++;
198 break;
199 case INGRESS_CHECKSUM:
200 case INGRESS_CHECKSUM_COMPUTE:
201 stats->rx_errors++;
202 break;
203 case INGRESS_TRUNC_FRAME:
204 stats->rx_frame_errors++;
205 break;
206 case INGRESS_PKT_LEN:
207 stats->rx_length_errors++;
208 break;
209 case INGRESS_PKT_UNDER:
210 stats->rx_frame_errors++;
211 break;
212 case INGRESS_FIFO_OVERRUN:
213 stats->rx_fifo_errors++;
214 break;
215 default:
216 break;
217 }
218}
219
220static void xgene_enet_wr_csr(struct xgene_enet_pdata *pdata,
221 u32 offset, u32 val)
222{
223 void __iomem *addr = pdata->eth_csr_addr + offset;
224
225 iowrite32(val, addr);
226}
227
228static void xgene_enet_wr_ring_if(struct xgene_enet_pdata *pdata,
229 u32 offset, u32 val)
230{
231 void __iomem *addr = pdata->eth_ring_if_addr + offset;
232
233 iowrite32(val, addr);
234}
235
236static void xgene_enet_wr_diag_csr(struct xgene_enet_pdata *pdata,
237 u32 offset, u32 val)
238{
239 void __iomem *addr = pdata->eth_diag_csr_addr + offset;
240
241 iowrite32(val, addr);
242}
243
244static void xgene_enet_wr_mcx_csr(struct xgene_enet_pdata *pdata,
245 u32 offset, u32 val)
246{
247 void __iomem *addr = pdata->mcx_mac_csr_addr + offset;
248
249 iowrite32(val, addr);
250}
251
252static bool xgene_enet_wr_indirect(void __iomem *addr, void __iomem *wr,
253 void __iomem *cmd, void __iomem *cmd_done,
254 u32 wr_addr, u32 wr_data)
255{
256 u32 done;
257 u8 wait = 10;
258
259 iowrite32(wr_addr, addr);
260 iowrite32(wr_data, wr);
261 iowrite32(XGENE_ENET_WR_CMD, cmd);
262
263 /* wait for write command to complete */
264 while (!(done = ioread32(cmd_done)) && wait--)
265 udelay(1);
266
267 if (!done)
268 return false;
269
270 iowrite32(0, cmd);
271
272 return true;
273}
274
275static void xgene_enet_wr_mcx_mac(struct xgene_enet_pdata *pdata,
276 u32 wr_addr, u32 wr_data)
277{
278 void __iomem *addr, *wr, *cmd, *cmd_done;
279
280 addr = pdata->mcx_mac_addr + MAC_ADDR_REG_OFFSET;
281 wr = pdata->mcx_mac_addr + MAC_WRITE_REG_OFFSET;
282 cmd = pdata->mcx_mac_addr + MAC_COMMAND_REG_OFFSET;
283 cmd_done = pdata->mcx_mac_addr + MAC_COMMAND_DONE_REG_OFFSET;
284
285 if (!xgene_enet_wr_indirect(addr, wr, cmd, cmd_done, wr_addr, wr_data))
286 netdev_err(pdata->ndev, "MCX mac write failed, addr: %04x\n",
287 wr_addr);
288}
289
290static void xgene_enet_rd_csr(struct xgene_enet_pdata *pdata,
291 u32 offset, u32 *val)
292{
293 void __iomem *addr = pdata->eth_csr_addr + offset;
294
295 *val = ioread32(addr);
296}
297
298static void xgene_enet_rd_diag_csr(struct xgene_enet_pdata *pdata,
299 u32 offset, u32 *val)
300{
301 void __iomem *addr = pdata->eth_diag_csr_addr + offset;
302
303 *val = ioread32(addr);
304}
305
306static void xgene_enet_rd_mcx_csr(struct xgene_enet_pdata *pdata,
307 u32 offset, u32 *val)
308{
309 void __iomem *addr = pdata->mcx_mac_csr_addr + offset;
310
311 *val = ioread32(addr);
312}
313
314static bool xgene_enet_rd_indirect(void __iomem *addr, void __iomem *rd,
315 void __iomem *cmd, void __iomem *cmd_done,
316 u32 rd_addr, u32 *rd_data)
317{
318 u32 done;
319 u8 wait = 10;
320
321 iowrite32(rd_addr, addr);
322 iowrite32(XGENE_ENET_RD_CMD, cmd);
323
324 /* wait for read command to complete */
325 while (!(done = ioread32(cmd_done)) && wait--)
326 udelay(1);
327
328 if (!done)
329 return false;
330
331 *rd_data = ioread32(rd);
332 iowrite32(0, cmd);
333
334 return true;
335}
336
337static void xgene_enet_rd_mcx_mac(struct xgene_enet_pdata *pdata,
338 u32 rd_addr, u32 *rd_data)
339{
340 void __iomem *addr, *rd, *cmd, *cmd_done;
341
342 addr = pdata->mcx_mac_addr + MAC_ADDR_REG_OFFSET;
343 rd = pdata->mcx_mac_addr + MAC_READ_REG_OFFSET;
344 cmd = pdata->mcx_mac_addr + MAC_COMMAND_REG_OFFSET;
345 cmd_done = pdata->mcx_mac_addr + MAC_COMMAND_DONE_REG_OFFSET;
346
347 if (!xgene_enet_rd_indirect(addr, rd, cmd, cmd_done, rd_addr, rd_data))
348 netdev_err(pdata->ndev, "MCX mac read failed, addr: %04x\n",
349 rd_addr);
350}
351
352static int xgene_mii_phy_write(struct xgene_enet_pdata *pdata, int phy_id,
353 u32 reg, u16 data)
354{
355 u32 addr = 0, wr_data = 0;
356 u32 done;
357 u8 wait = 10;
358
359 PHY_ADDR_SET(&addr, phy_id);
360 REG_ADDR_SET(&addr, reg);
361 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_ADDRESS_ADDR, addr);
362
363 PHY_CONTROL_SET(&wr_data, data);
364 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONTROL_ADDR, wr_data);
365 do {
366 usleep_range(5, 10);
367 xgene_enet_rd_mcx_mac(pdata, MII_MGMT_INDICATORS_ADDR, &done);
368 } while ((done & BUSY_MASK) && wait--);
369
370 if (done & BUSY_MASK) {
371 netdev_err(pdata->ndev, "MII_MGMT write failed\n");
372 return -EBUSY;
373 }
374
375 return 0;
376}
377
378static int xgene_mii_phy_read(struct xgene_enet_pdata *pdata,
379 u8 phy_id, u32 reg)
380{
381 u32 addr = 0;
382 u32 data, done;
383 u8 wait = 10;
384
385 PHY_ADDR_SET(&addr, phy_id);
386 REG_ADDR_SET(&addr, reg);
387 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_ADDRESS_ADDR, addr);
388 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_COMMAND_ADDR, READ_CYCLE_MASK);
389 do {
390 usleep_range(5, 10);
391 xgene_enet_rd_mcx_mac(pdata, MII_MGMT_INDICATORS_ADDR, &done);
392 } while ((done & BUSY_MASK) && wait--);
393
394 if (done & BUSY_MASK) {
395 netdev_err(pdata->ndev, "MII_MGMT read failed\n");
396 return -EBUSY;
397 }
398
399 xgene_enet_rd_mcx_mac(pdata, MII_MGMT_STATUS_ADDR, &data);
400 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_COMMAND_ADDR, 0);
401
402 return data;
403}
404
405void xgene_gmac_set_mac_addr(struct xgene_enet_pdata *pdata)
406{
407 u32 addr0, addr1;
408 u8 *dev_addr = pdata->ndev->dev_addr;
409
410 addr0 = (dev_addr[3] << 24) | (dev_addr[2] << 16) |
411 (dev_addr[1] << 8) | dev_addr[0];
412 addr1 = (dev_addr[5] << 24) | (dev_addr[4] << 16);
413 addr1 |= pdata->phy_addr & 0xFFFF;
414
415 xgene_enet_wr_mcx_mac(pdata, STATION_ADDR0_ADDR, addr0);
416 xgene_enet_wr_mcx_mac(pdata, STATION_ADDR1_ADDR, addr1);
417}
418
419static int xgene_enet_ecc_init(struct xgene_enet_pdata *pdata)
420{
421 struct net_device *ndev = pdata->ndev;
422 u32 data;
423 u8 wait = 10;
424
425 xgene_enet_wr_diag_csr(pdata, ENET_CFG_MEM_RAM_SHUTDOWN_ADDR, 0x0);
426 do {
427 usleep_range(100, 110);
428 xgene_enet_rd_diag_csr(pdata, ENET_BLOCK_MEM_RDY_ADDR, &data);
429 } while ((data != 0xffffffff) && wait--);
430
431 if (data != 0xffffffff) {
432 netdev_err(ndev, "Failed to release memory from shutdown\n");
433 return -ENODEV;
434 }
435
436 return 0;
437}
438
439void xgene_gmac_reset(struct xgene_enet_pdata *pdata)
440{
441 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, SOFT_RESET1);
442 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, 0);
443}
444
445void xgene_gmac_init(struct xgene_enet_pdata *pdata, int speed)
446{
447 u32 value, mc2;
448 u32 intf_ctl, rgmii;
449 u32 icm0, icm2;
450
451 xgene_gmac_reset(pdata);
452
453 xgene_enet_rd_mcx_csr(pdata, ICM_CONFIG0_REG_0_ADDR, &icm0);
454 xgene_enet_rd_mcx_csr(pdata, ICM_CONFIG2_REG_0_ADDR, &icm2);
455 xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_2_ADDR, &mc2);
456 xgene_enet_rd_mcx_mac(pdata, INTERFACE_CONTROL_ADDR, &intf_ctl);
457 xgene_enet_rd_csr(pdata, RGMII_REG_0_ADDR, &rgmii);
458
459 switch (speed) {
460 case SPEED_10:
461 ENET_INTERFACE_MODE2_SET(&mc2, 1);
462 CFG_MACMODE_SET(&icm0, 0);
463 CFG_WAITASYNCRD_SET(&icm2, 500);
464 rgmii &= ~CFG_SPEED_1250;
465 break;
466 case SPEED_100:
467 ENET_INTERFACE_MODE2_SET(&mc2, 1);
468 intf_ctl |= ENET_LHD_MODE;
469 CFG_MACMODE_SET(&icm0, 1);
470 CFG_WAITASYNCRD_SET(&icm2, 80);
471 rgmii &= ~CFG_SPEED_1250;
472 break;
473 default:
474 ENET_INTERFACE_MODE2_SET(&mc2, 2);
475 intf_ctl |= ENET_GHD_MODE;
476 CFG_TXCLK_MUXSEL0_SET(&rgmii, 4);
477 xgene_enet_rd_csr(pdata, DEBUG_REG_ADDR, &value);
478 value |= CFG_BYPASS_UNISEC_TX | CFG_BYPASS_UNISEC_RX;
479 xgene_enet_wr_csr(pdata, DEBUG_REG_ADDR, value);
480 break;
481 }
482
483 mc2 |= FULL_DUPLEX2;
484 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_2_ADDR, mc2);
485 xgene_enet_wr_mcx_mac(pdata, INTERFACE_CONTROL_ADDR, intf_ctl);
486
487 xgene_gmac_set_mac_addr(pdata);
488
489 /* Adjust MDC clock frequency */
490 xgene_enet_rd_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, &value);
491 MGMT_CLOCK_SEL_SET(&value, 7);
492 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, value);
493
494 /* Enable drop if bufpool not available */
495 xgene_enet_rd_csr(pdata, RSIF_CONFIG_REG_ADDR, &value);
496 value |= CFG_RSIF_FPBUFF_TIMEOUT_EN;
497 xgene_enet_wr_csr(pdata, RSIF_CONFIG_REG_ADDR, value);
498
499 /* Rtype should be copied from FP */
500 xgene_enet_wr_csr(pdata, RSIF_RAM_DBG_REG0_ADDR, 0);
501 xgene_enet_wr_csr(pdata, RGMII_REG_0_ADDR, rgmii);
502
503 /* Rx-Tx traffic resume */
504 xgene_enet_wr_csr(pdata, CFG_LINK_AGGR_RESUME_0_ADDR, TX_PORT0);
505
506 xgene_enet_wr_mcx_csr(pdata, ICM_CONFIG0_REG_0_ADDR, icm0);
507 xgene_enet_wr_mcx_csr(pdata, ICM_CONFIG2_REG_0_ADDR, icm2);
508
509 xgene_enet_rd_mcx_csr(pdata, RX_DV_GATE_REG_0_ADDR, &value);
510 value &= ~TX_DV_GATE_EN0;
511 value &= ~RX_DV_GATE_EN0;
512 value |= RESUME_RX0;
513 xgene_enet_wr_mcx_csr(pdata, RX_DV_GATE_REG_0_ADDR, value);
514
515 xgene_enet_wr_csr(pdata, CFG_BYPASS_ADDR, RESUME_TX);
516}
517
518static void xgene_enet_config_ring_if_assoc(struct xgene_enet_pdata *pdata)
519{
520 u32 val = 0xffffffff;
521
522 xgene_enet_wr_ring_if(pdata, ENET_CFGSSQMIWQASSOC_ADDR, val);
523 xgene_enet_wr_ring_if(pdata, ENET_CFGSSQMIFPQASSOC_ADDR, val);
524 xgene_enet_wr_ring_if(pdata, ENET_CFGSSQMIQMLITEWQASSOC_ADDR, val);
525 xgene_enet_wr_ring_if(pdata, ENET_CFGSSQMIQMLITEFPQASSOC_ADDR, val);
526}
527
528void xgene_enet_cle_bypass(struct xgene_enet_pdata *pdata,
529 u32 dst_ring_num, u16 bufpool_id)
530{
531 u32 cb;
532 u32 fpsel;
533
534 fpsel = xgene_enet_ring_bufnum(bufpool_id) - 0x20;
535
536 xgene_enet_rd_csr(pdata, CLE_BYPASS_REG0_0_ADDR, &cb);
537 cb |= CFG_CLE_BYPASS_EN0;
538 CFG_CLE_IP_PROTOCOL0_SET(&cb, 3);
539 xgene_enet_wr_csr(pdata, CLE_BYPASS_REG0_0_ADDR, cb);
540
541 xgene_enet_rd_csr(pdata, CLE_BYPASS_REG1_0_ADDR, &cb);
542 CFG_CLE_DSTQID0_SET(&cb, dst_ring_num);
543 CFG_CLE_FPSEL0_SET(&cb, fpsel);
544 xgene_enet_wr_csr(pdata, CLE_BYPASS_REG1_0_ADDR, cb);
545}
546
547void xgene_gmac_rx_enable(struct xgene_enet_pdata *pdata)
548{
549 u32 data;
550
551 xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_1_ADDR, &data);
552 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data | RX_EN);
553}
554
555void xgene_gmac_tx_enable(struct xgene_enet_pdata *pdata)
556{
557 u32 data;
558
559 xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_1_ADDR, &data);
560 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data | TX_EN);
561}
562
563void xgene_gmac_rx_disable(struct xgene_enet_pdata *pdata)
564{
565 u32 data;
566
567 xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_1_ADDR, &data);
568 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~RX_EN);
569}
570
571void xgene_gmac_tx_disable(struct xgene_enet_pdata *pdata)
572{
573 u32 data;
574
575 xgene_enet_rd_mcx_mac(pdata, MAC_CONFIG_1_ADDR, &data);
576 xgene_enet_wr_mcx_mac(pdata, MAC_CONFIG_1_ADDR, data & ~TX_EN);
577}
578
579void xgene_enet_reset(struct xgene_enet_pdata *pdata)
580{
581 u32 val;
582
583 clk_prepare_enable(pdata->clk);
584 clk_disable_unprepare(pdata->clk);
585 clk_prepare_enable(pdata->clk);
586 xgene_enet_ecc_init(pdata);
587 xgene_enet_config_ring_if_assoc(pdata);
588
589 /* Enable auto-incr for scanning */
590 xgene_enet_rd_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, &val);
591 val |= SCAN_AUTO_INCR;
592 MGMT_CLOCK_SEL_SET(&val, 1);
593 xgene_enet_wr_mcx_mac(pdata, MII_MGMT_CONFIG_ADDR, val);
594}
595
596void xgene_gport_shutdown(struct xgene_enet_pdata *pdata)
597{
598 clk_disable_unprepare(pdata->clk);
599}
600
601static int xgene_enet_mdio_read(struct mii_bus *bus, int mii_id, int regnum)
602{
603 struct xgene_enet_pdata *pdata = bus->priv;
604 u32 val;
605
606 val = xgene_mii_phy_read(pdata, mii_id, regnum);
607 netdev_dbg(pdata->ndev, "mdio_rd: bus=%d reg=%d val=%x\n",
608 mii_id, regnum, val);
609
610 return val;
611}
612
613static int xgene_enet_mdio_write(struct mii_bus *bus, int mii_id, int regnum,
614 u16 val)
615{
616 struct xgene_enet_pdata *pdata = bus->priv;
617
618 netdev_dbg(pdata->ndev, "mdio_wr: bus=%d reg=%d val=%x\n",
619 mii_id, regnum, val);
620 return xgene_mii_phy_write(pdata, mii_id, regnum, val);
621}
622
623static void xgene_enet_adjust_link(struct net_device *ndev)
624{
625 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
626 struct phy_device *phydev = pdata->phy_dev;
627
628 if (phydev->link) {
629 if (pdata->phy_speed != phydev->speed) {
630 xgene_gmac_init(pdata, phydev->speed);
631 xgene_gmac_rx_enable(pdata);
632 xgene_gmac_tx_enable(pdata);
633 pdata->phy_speed = phydev->speed;
634 phy_print_status(phydev);
635 }
636 } else {
637 xgene_gmac_rx_disable(pdata);
638 xgene_gmac_tx_disable(pdata);
639 pdata->phy_speed = SPEED_UNKNOWN;
640 phy_print_status(phydev);
641 }
642}
643
644static int xgene_enet_phy_connect(struct net_device *ndev)
645{
646 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
647 struct device_node *phy_np;
648 struct phy_device *phy_dev;
649 struct device *dev = &pdata->pdev->dev;
650
651 phy_np = of_parse_phandle(dev->of_node, "phy-handle", 0);
652 if (!phy_np) {
653 netdev_dbg(ndev, "No phy-handle found\n");
654 return -ENODEV;
655 }
656
657 phy_dev = of_phy_connect(ndev, phy_np, &xgene_enet_adjust_link,
658 0, pdata->phy_mode);
659 if (!phy_dev) {
660 netdev_err(ndev, "Could not connect to PHY\n");
661 return -ENODEV;
662 }
663
664 pdata->phy_speed = SPEED_UNKNOWN;
665 phy_dev->supported &= ~SUPPORTED_10baseT_Half &
666 ~SUPPORTED_100baseT_Half &
667 ~SUPPORTED_1000baseT_Half;
668 phy_dev->advertising = phy_dev->supported;
669 pdata->phy_dev = phy_dev;
670
671 return 0;
672}
673
674int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata)
675{
676 struct net_device *ndev = pdata->ndev;
677 struct device *dev = &pdata->pdev->dev;
678 struct device_node *child_np;
679 struct device_node *mdio_np = NULL;
680 struct mii_bus *mdio_bus;
681 int ret;
682
683 for_each_child_of_node(dev->of_node, child_np) {
684 if (of_device_is_compatible(child_np, "apm,xgene-mdio")) {
685 mdio_np = child_np;
686 break;
687 }
688 }
689
690 if (!mdio_np) {
691 netdev_dbg(ndev, "No mdio node in the dts\n");
692 return -ENXIO;
693 }
694
695 mdio_bus = mdiobus_alloc();
696 if (!mdio_bus)
697 return -ENOMEM;
698
699 mdio_bus->name = "APM X-Gene MDIO bus";
700 mdio_bus->read = xgene_enet_mdio_read;
701 mdio_bus->write = xgene_enet_mdio_write;
702 snprintf(mdio_bus->id, MII_BUS_ID_SIZE, "%s-%s", "xgene-mii",
703 ndev->name);
704
705 mdio_bus->priv = pdata;
706 mdio_bus->parent = &ndev->dev;
707
708 ret = of_mdiobus_register(mdio_bus, mdio_np);
709 if (ret) {
710 netdev_err(ndev, "Failed to register MDIO bus\n");
711 mdiobus_free(mdio_bus);
712 return ret;
713 }
714 pdata->mdio_bus = mdio_bus;
715
716 ret = xgene_enet_phy_connect(ndev);
717 if (ret)
718 xgene_enet_mdio_remove(pdata);
719
720 return ret;
721}
722
723void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata)
724{
725 mdiobus_unregister(pdata->mdio_bus);
726 mdiobus_free(pdata->mdio_bus);
727 pdata->mdio_bus = NULL;
728}
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
new file mode 100644
index 000000000000..371e7a5b2507
--- /dev/null
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_hw.h
@@ -0,0 +1,337 @@
1/* Applied Micro X-Gene SoC Ethernet Driver
2 *
3 * Copyright (c) 2014, Applied Micro Circuits Corporation
4 * Authors: Iyappan Subramanian <isubramanian@apm.com>
5 * Ravi Patel <rapatel@apm.com>
6 * Keyur Chudgar <kchudgar@apm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef __XGENE_ENET_HW_H__
23#define __XGENE_ENET_HW_H__
24
25#include "xgene_enet_main.h"
26
27struct xgene_enet_pdata;
28struct xgene_enet_stats;
29
30/* clears and then set bits */
31static inline void xgene_set_bits(u32 *dst, u32 val, u32 start, u32 len)
32{
33 u32 end = start + len - 1;
34 u32 mask = GENMASK(end, start);
35
36 *dst &= ~mask;
37 *dst |= (val << start) & mask;
38}
39
40static inline u32 xgene_get_bits(u32 val, u32 start, u32 end)
41{
42 return (val & GENMASK(end, start)) >> start;
43}
44
45#define CSR_RING_ID 0x0008
46#define OVERWRITE BIT(31)
47#define IS_BUFFER_POOL BIT(20)
48#define PREFETCH_BUF_EN BIT(21)
49#define CSR_RING_ID_BUF 0x000c
50#define CSR_RING_NE_INT_MODE 0x017c
51#define CSR_RING_CONFIG 0x006c
52#define CSR_RING_WR_BASE 0x0070
53#define NUM_RING_CONFIG 5
54#define BUFPOOL_MODE 3
55#define RM3 3
56#define INC_DEC_CMD_ADDR 0x002c
57#define UDP_HDR_SIZE 2
58#define BUF_LEN_CODE_2K 0x5000
59
60#define CREATE_MASK(pos, len) GENMASK((pos)+(len)-1, (pos))
61#define CREATE_MASK_ULL(pos, len) GENMASK_ULL((pos)+(len)-1, (pos))
62
63/* Empty slot soft signature */
64#define EMPTY_SLOT_INDEX 1
65#define EMPTY_SLOT ~0ULL
66
67#define WORK_DESC_SIZE 32
68#define BUFPOOL_DESC_SIZE 16
69
70#define RING_OWNER_MASK GENMASK(9, 6)
71#define RING_BUFNUM_MASK GENMASK(5, 0)
72
73#define SELTHRSH_POS 3
74#define SELTHRSH_LEN 3
75#define RINGADDRL_POS 5
76#define RINGADDRL_LEN 27
77#define RINGADDRH_POS 0
78#define RINGADDRH_LEN 6
79#define RINGSIZE_POS 23
80#define RINGSIZE_LEN 3
81#define RINGTYPE_POS 19
82#define RINGTYPE_LEN 2
83#define RINGMODE_POS 20
84#define RINGMODE_LEN 3
85#define RECOMTIMEOUTL_POS 28
86#define RECOMTIMEOUTL_LEN 3
87#define RECOMTIMEOUTH_POS 0
88#define RECOMTIMEOUTH_LEN 2
89#define NUMMSGSINQ_POS 1
90#define NUMMSGSINQ_LEN 16
91#define ACCEPTLERR BIT(19)
92#define QCOHERENT BIT(4)
93#define RECOMBBUF BIT(27)
94
95#define BLOCK_ETH_CSR_OFFSET 0x2000
96#define BLOCK_ETH_RING_IF_OFFSET 0x9000
97#define BLOCK_ETH_CLKRST_CSR_OFFSET 0xC000
98#define BLOCK_ETH_DIAG_CSR_OFFSET 0xD000
99
100#define BLOCK_ETH_MAC_OFFSET 0x0000
101#define BLOCK_ETH_STATS_OFFSET 0x0014
102#define BLOCK_ETH_MAC_CSR_OFFSET 0x2800
103
104#define MAC_ADDR_REG_OFFSET 0x00
105#define MAC_COMMAND_REG_OFFSET 0x04
106#define MAC_WRITE_REG_OFFSET 0x08
107#define MAC_READ_REG_OFFSET 0x0c
108#define MAC_COMMAND_DONE_REG_OFFSET 0x10
109
110#define STAT_ADDR_REG_OFFSET 0x00
111#define STAT_COMMAND_REG_OFFSET 0x04
112#define STAT_WRITE_REG_OFFSET 0x08
113#define STAT_READ_REG_OFFSET 0x0c
114#define STAT_COMMAND_DONE_REG_OFFSET 0x10
115
116#define MII_MGMT_CONFIG_ADDR 0x20
117#define MII_MGMT_COMMAND_ADDR 0x24
118#define MII_MGMT_ADDRESS_ADDR 0x28
119#define MII_MGMT_CONTROL_ADDR 0x2c
120#define MII_MGMT_STATUS_ADDR 0x30
121#define MII_MGMT_INDICATORS_ADDR 0x34
122
123#define BUSY_MASK BIT(0)
124#define READ_CYCLE_MASK BIT(0)
125#define PHY_CONTROL_SET(dst, val) xgene_set_bits(dst, val, 0, 16)
126
127#define ENET_SPARE_CFG_REG_ADDR 0x0750
128#define RSIF_CONFIG_REG_ADDR 0x0010
129#define RSIF_RAM_DBG_REG0_ADDR 0x0048
130#define RGMII_REG_0_ADDR 0x07e0
131#define CFG_LINK_AGGR_RESUME_0_ADDR 0x07c8
132#define DEBUG_REG_ADDR 0x0700
133#define CFG_BYPASS_ADDR 0x0294
134#define CLE_BYPASS_REG0_0_ADDR 0x0490
135#define CLE_BYPASS_REG1_0_ADDR 0x0494
136#define CFG_RSIF_FPBUFF_TIMEOUT_EN BIT(31)
137#define RESUME_TX BIT(0)
138#define CFG_SPEED_1250 BIT(24)
139#define TX_PORT0 BIT(0)
140#define CFG_BYPASS_UNISEC_TX BIT(2)
141#define CFG_BYPASS_UNISEC_RX BIT(1)
142#define CFG_CLE_BYPASS_EN0 BIT(31)
143#define CFG_TXCLK_MUXSEL0_SET(dst, val) xgene_set_bits(dst, val, 29, 3)
144
145#define CFG_CLE_IP_PROTOCOL0_SET(dst, val) xgene_set_bits(dst, val, 16, 2)
146#define CFG_CLE_DSTQID0_SET(dst, val) xgene_set_bits(dst, val, 0, 12)
147#define CFG_CLE_FPSEL0_SET(dst, val) xgene_set_bits(dst, val, 16, 4)
148#define CFG_MACMODE_SET(dst, val) xgene_set_bits(dst, val, 18, 2)
149#define CFG_WAITASYNCRD_SET(dst, val) xgene_set_bits(dst, val, 0, 16)
150#define ICM_CONFIG0_REG_0_ADDR 0x0400
151#define ICM_CONFIG2_REG_0_ADDR 0x0410
152#define RX_DV_GATE_REG_0_ADDR 0x05fc
153#define TX_DV_GATE_EN0 BIT(2)
154#define RX_DV_GATE_EN0 BIT(1)
155#define RESUME_RX0 BIT(0)
156#define ENET_CFGSSQMIWQASSOC_ADDR 0xe0
157#define ENET_CFGSSQMIFPQASSOC_ADDR 0xdc
158#define ENET_CFGSSQMIQMLITEFPQASSOC_ADDR 0xf0
159#define ENET_CFGSSQMIQMLITEWQASSOC_ADDR 0xf4
160#define ENET_CFG_MEM_RAM_SHUTDOWN_ADDR 0x70
161#define ENET_BLOCK_MEM_RDY_ADDR 0x74
162#define MAC_CONFIG_1_ADDR 0x00
163#define MAC_CONFIG_2_ADDR 0x04
164#define MAX_FRAME_LEN_ADDR 0x10
165#define INTERFACE_CONTROL_ADDR 0x38
166#define STATION_ADDR0_ADDR 0x40
167#define STATION_ADDR1_ADDR 0x44
168#define PHY_ADDR_SET(dst, val) xgene_set_bits(dst, val, 8, 5)
169#define REG_ADDR_SET(dst, val) xgene_set_bits(dst, val, 0, 5)
170#define ENET_INTERFACE_MODE2_SET(dst, val) xgene_set_bits(dst, val, 8, 2)
171#define MGMT_CLOCK_SEL_SET(dst, val) xgene_set_bits(dst, val, 0, 3)
172#define SOFT_RESET1 BIT(31)
173#define TX_EN BIT(0)
174#define RX_EN BIT(2)
175#define ENET_LHD_MODE BIT(25)
176#define ENET_GHD_MODE BIT(26)
177#define FULL_DUPLEX2 BIT(0)
178#define SCAN_AUTO_INCR BIT(5)
179#define TBYT_ADDR 0x38
180#define TPKT_ADDR 0x39
181#define TDRP_ADDR 0x45
182#define TFCS_ADDR 0x47
183#define TUND_ADDR 0x4a
184
185#define TSO_IPPROTO_TCP 1
186#define FULL_DUPLEX 2
187
188#define USERINFO_POS 0
189#define USERINFO_LEN 32
190#define FPQNUM_POS 32
191#define FPQNUM_LEN 12
192#define LERR_POS 60
193#define LERR_LEN 3
194#define STASH_POS 52
195#define STASH_LEN 2
196#define BUFDATALEN_POS 48
197#define BUFDATALEN_LEN 12
198#define DATAADDR_POS 0
199#define DATAADDR_LEN 42
200#define COHERENT_POS 63
201#define HENQNUM_POS 48
202#define HENQNUM_LEN 12
203#define TYPESEL_POS 44
204#define TYPESEL_LEN 4
205#define ETHHDR_POS 12
206#define ETHHDR_LEN 8
207#define IC_POS 35 /* Insert CRC */
208#define TCPHDR_POS 0
209#define TCPHDR_LEN 6
210#define IPHDR_POS 6
211#define IPHDR_LEN 6
212#define EC_POS 22 /* Enable checksum */
213#define EC_LEN 1
214#define IS_POS 24 /* IP protocol select */
215#define IS_LEN 1
216#define TYPE_ETH_WORK_MESSAGE_POS 44
217
218struct xgene_enet_raw_desc {
219 __le64 m0;
220 __le64 m1;
221 __le64 m2;
222 __le64 m3;
223};
224
225struct xgene_enet_raw_desc16 {
226 __le64 m0;
227 __le64 m1;
228};
229
230static inline void xgene_enet_mark_desc_slot_empty(void *desc_slot_ptr)
231{
232 __le64 *desc_slot = desc_slot_ptr;
233
234 desc_slot[EMPTY_SLOT_INDEX] = cpu_to_le64(EMPTY_SLOT);
235}
236
237static inline bool xgene_enet_is_desc_slot_empty(void *desc_slot_ptr)
238{
239 __le64 *desc_slot = desc_slot_ptr;
240
241 return (desc_slot[EMPTY_SLOT_INDEX] == cpu_to_le64(EMPTY_SLOT));
242}
243
244enum xgene_enet_ring_cfgsize {
245 RING_CFGSIZE_512B,
246 RING_CFGSIZE_2KB,
247 RING_CFGSIZE_16KB,
248 RING_CFGSIZE_64KB,
249 RING_CFGSIZE_512KB,
250 RING_CFGSIZE_INVALID
251};
252
253enum xgene_enet_ring_type {
254 RING_DISABLED,
255 RING_REGULAR,
256 RING_BUFPOOL
257};
258
259enum xgene_ring_owner {
260 RING_OWNER_ETH0,
261 RING_OWNER_CPU = 15,
262 RING_OWNER_INVALID
263};
264
265enum xgene_enet_ring_bufnum {
266 RING_BUFNUM_REGULAR = 0x0,
267 RING_BUFNUM_BUFPOOL = 0x20,
268 RING_BUFNUM_INVALID
269};
270
271enum xgene_enet_cmd {
272 XGENE_ENET_WR_CMD = BIT(31),
273 XGENE_ENET_RD_CMD = BIT(30)
274};
275
276enum xgene_enet_err_code {
277 HBF_READ_DATA = 3,
278 HBF_LL_READ = 4,
279 BAD_WORK_MSG = 6,
280 BUFPOOL_TIMEOUT = 15,
281 INGRESS_CRC = 16,
282 INGRESS_CHECKSUM = 17,
283 INGRESS_TRUNC_FRAME = 18,
284 INGRESS_PKT_LEN = 19,
285 INGRESS_PKT_UNDER = 20,
286 INGRESS_FIFO_OVERRUN = 21,
287 INGRESS_CHECKSUM_COMPUTE = 26,
288 ERR_CODE_INVALID
289};
290
291static inline enum xgene_ring_owner xgene_enet_ring_owner(u16 id)
292{
293 return (id & RING_OWNER_MASK) >> 6;
294}
295
296static inline u8 xgene_enet_ring_bufnum(u16 id)
297{
298 return id & RING_BUFNUM_MASK;
299}
300
301static inline bool xgene_enet_is_bufpool(u16 id)
302{
303 return ((id & RING_BUFNUM_MASK) >= 0x20) ? true : false;
304}
305
306static inline u16 xgene_enet_get_numslots(u16 id, u32 size)
307{
308 bool is_bufpool = xgene_enet_is_bufpool(id);
309
310 return (is_bufpool) ? size / BUFPOOL_DESC_SIZE :
311 size / WORK_DESC_SIZE;
312}
313
314struct xgene_enet_desc_ring *xgene_enet_setup_ring(
315 struct xgene_enet_desc_ring *ring);
316void xgene_enet_clear_ring(struct xgene_enet_desc_ring *ring);
317void xgene_enet_parse_error(struct xgene_enet_desc_ring *ring,
318 struct xgene_enet_pdata *pdata,
319 enum xgene_enet_err_code status);
320
321void xgene_enet_reset(struct xgene_enet_pdata *priv);
322void xgene_gmac_reset(struct xgene_enet_pdata *priv);
323void xgene_gmac_init(struct xgene_enet_pdata *priv, int speed);
324void xgene_gmac_tx_enable(struct xgene_enet_pdata *priv);
325void xgene_gmac_rx_enable(struct xgene_enet_pdata *priv);
326void xgene_gmac_tx_disable(struct xgene_enet_pdata *priv);
327void xgene_gmac_rx_disable(struct xgene_enet_pdata *priv);
328void xgene_gmac_set_mac_addr(struct xgene_enet_pdata *pdata);
329void xgene_enet_cle_bypass(struct xgene_enet_pdata *pdata,
330 u32 dst_ring_num, u16 bufpool_id);
331void xgene_gport_shutdown(struct xgene_enet_pdata *priv);
332void xgene_gmac_get_tx_stats(struct xgene_enet_pdata *pdata);
333
334int xgene_enet_mdio_config(struct xgene_enet_pdata *pdata);
335void xgene_enet_mdio_remove(struct xgene_enet_pdata *pdata);
336
337#endif /* __XGENE_ENET_HW_H__ */
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.c b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
new file mode 100644
index 000000000000..e1a8f4e19983
--- /dev/null
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.c
@@ -0,0 +1,954 @@
1/* Applied Micro X-Gene SoC Ethernet Driver
2 *
3 * Copyright (c) 2014, Applied Micro Circuits Corporation
4 * Authors: Iyappan Subramanian <isubramanian@apm.com>
5 * Ravi Patel <rapatel@apm.com>
6 * Keyur Chudgar <kchudgar@apm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#include "xgene_enet_main.h"
23#include "xgene_enet_hw.h"
24
25static void xgene_enet_init_bufpool(struct xgene_enet_desc_ring *buf_pool)
26{
27 struct xgene_enet_raw_desc16 *raw_desc;
28 int i;
29
30 for (i = 0; i < buf_pool->slots; i++) {
31 raw_desc = &buf_pool->raw_desc16[i];
32
33 /* Hardware expects descriptor in little endian format */
34 raw_desc->m0 = cpu_to_le64(i |
35 SET_VAL(FPQNUM, buf_pool->dst_ring_num) |
36 SET_VAL(STASH, 3));
37 }
38}
39
40static int xgene_enet_refill_bufpool(struct xgene_enet_desc_ring *buf_pool,
41 u32 nbuf)
42{
43 struct sk_buff *skb;
44 struct xgene_enet_raw_desc16 *raw_desc;
45 struct net_device *ndev;
46 struct device *dev;
47 dma_addr_t dma_addr;
48 u32 tail = buf_pool->tail;
49 u32 slots = buf_pool->slots - 1;
50 u16 bufdatalen, len;
51 int i;
52
53 ndev = buf_pool->ndev;
54 dev = ndev_to_dev(buf_pool->ndev);
55 bufdatalen = BUF_LEN_CODE_2K | (SKB_BUFFER_SIZE & GENMASK(11, 0));
56 len = XGENE_ENET_MAX_MTU;
57
58 for (i = 0; i < nbuf; i++) {
59 raw_desc = &buf_pool->raw_desc16[tail];
60
61 skb = netdev_alloc_skb_ip_align(ndev, len);
62 if (unlikely(!skb))
63 return -ENOMEM;
64 buf_pool->rx_skb[tail] = skb;
65
66 dma_addr = dma_map_single(dev, skb->data, len, DMA_FROM_DEVICE);
67 if (dma_mapping_error(dev, dma_addr)) {
68 netdev_err(ndev, "DMA mapping error\n");
69 dev_kfree_skb_any(skb);
70 return -EINVAL;
71 }
72
73 raw_desc->m1 = cpu_to_le64(SET_VAL(DATAADDR, dma_addr) |
74 SET_VAL(BUFDATALEN, bufdatalen) |
75 SET_BIT(COHERENT));
76 tail = (tail + 1) & slots;
77 }
78
79 iowrite32(nbuf, buf_pool->cmd);
80 buf_pool->tail = tail;
81
82 return 0;
83}
84
85static u16 xgene_enet_dst_ring_num(struct xgene_enet_desc_ring *ring)
86{
87 struct xgene_enet_pdata *pdata = netdev_priv(ring->ndev);
88
89 return ((u16)pdata->rm << 10) | ring->num;
90}
91
92static u8 xgene_enet_hdr_len(const void *data)
93{
94 const struct ethhdr *eth = data;
95
96 return (eth->h_proto == htons(ETH_P_8021Q)) ? VLAN_ETH_HLEN : ETH_HLEN;
97}
98
99static u32 xgene_enet_ring_len(struct xgene_enet_desc_ring *ring)
100{
101 u32 __iomem *cmd_base = ring->cmd_base;
102 u32 ring_state, num_msgs;
103
104 ring_state = ioread32(&cmd_base[1]);
105 num_msgs = ring_state & CREATE_MASK(NUMMSGSINQ_POS, NUMMSGSINQ_LEN);
106
107 return num_msgs >> NUMMSGSINQ_POS;
108}
109
110static void xgene_enet_delete_bufpool(struct xgene_enet_desc_ring *buf_pool)
111{
112 struct xgene_enet_raw_desc16 *raw_desc;
113 u32 slots = buf_pool->slots - 1;
114 u32 tail = buf_pool->tail;
115 u32 userinfo;
116 int i, len;
117
118 len = xgene_enet_ring_len(buf_pool);
119 for (i = 0; i < len; i++) {
120 tail = (tail - 1) & slots;
121 raw_desc = &buf_pool->raw_desc16[tail];
122
123 /* Hardware stores descriptor in little endian format */
124 userinfo = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0));
125 dev_kfree_skb_any(buf_pool->rx_skb[userinfo]);
126 }
127
128 iowrite32(-len, buf_pool->cmd);
129 buf_pool->tail = tail;
130}
131
132static irqreturn_t xgene_enet_rx_irq(const int irq, void *data)
133{
134 struct xgene_enet_desc_ring *rx_ring = data;
135
136 if (napi_schedule_prep(&rx_ring->napi)) {
137 disable_irq_nosync(irq);
138 __napi_schedule(&rx_ring->napi);
139 }
140
141 return IRQ_HANDLED;
142}
143
144static int xgene_enet_tx_completion(struct xgene_enet_desc_ring *cp_ring,
145 struct xgene_enet_raw_desc *raw_desc)
146{
147 struct sk_buff *skb;
148 struct device *dev;
149 u16 skb_index;
150 u8 status;
151 int ret = 0;
152
153 skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0));
154 skb = cp_ring->cp_skb[skb_index];
155
156 dev = ndev_to_dev(cp_ring->ndev);
157 dma_unmap_single(dev, GET_VAL(DATAADDR, le64_to_cpu(raw_desc->m1)),
158 GET_VAL(BUFDATALEN, le64_to_cpu(raw_desc->m1)),
159 DMA_TO_DEVICE);
160
161 /* Checking for error */
162 status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0));
163 if (unlikely(status > 2)) {
164 xgene_enet_parse_error(cp_ring, netdev_priv(cp_ring->ndev),
165 status);
166 ret = -EIO;
167 }
168
169 if (likely(skb)) {
170 dev_kfree_skb_any(skb);
171 } else {
172 netdev_err(cp_ring->ndev, "completion skb is NULL\n");
173 ret = -EIO;
174 }
175
176 return ret;
177}
178
179static u64 xgene_enet_work_msg(struct sk_buff *skb)
180{
181 struct iphdr *iph;
182 u8 l3hlen, l4hlen = 0;
183 u8 csum_enable = 0;
184 u8 proto = 0;
185 u8 ethhdr;
186 u64 hopinfo;
187
188 if (unlikely(skb->protocol != htons(ETH_P_IP)) &&
189 unlikely(skb->protocol != htons(ETH_P_8021Q)))
190 goto out;
191
192 if (unlikely(!(skb->dev->features & NETIF_F_IP_CSUM)))
193 goto out;
194
195 iph = ip_hdr(skb);
196 if (unlikely(ip_is_fragment(iph)))
197 goto out;
198
199 if (likely(iph->protocol == IPPROTO_TCP)) {
200 l4hlen = tcp_hdrlen(skb) >> 2;
201 csum_enable = 1;
202 proto = TSO_IPPROTO_TCP;
203 } else if (iph->protocol == IPPROTO_UDP) {
204 l4hlen = UDP_HDR_SIZE;
205 csum_enable = 1;
206 }
207out:
208 l3hlen = ip_hdrlen(skb) >> 2;
209 ethhdr = xgene_enet_hdr_len(skb->data);
210 hopinfo = SET_VAL(TCPHDR, l4hlen) |
211 SET_VAL(IPHDR, l3hlen) |
212 SET_VAL(ETHHDR, ethhdr) |
213 SET_VAL(EC, csum_enable) |
214 SET_VAL(IS, proto) |
215 SET_BIT(IC) |
216 SET_BIT(TYPE_ETH_WORK_MESSAGE);
217
218 return hopinfo;
219}
220
221static int xgene_enet_setup_tx_desc(struct xgene_enet_desc_ring *tx_ring,
222 struct sk_buff *skb)
223{
224 struct device *dev = ndev_to_dev(tx_ring->ndev);
225 struct xgene_enet_raw_desc *raw_desc;
226 dma_addr_t dma_addr;
227 u16 tail = tx_ring->tail;
228 u64 hopinfo;
229
230 raw_desc = &tx_ring->raw_desc[tail];
231 memset(raw_desc, 0, sizeof(struct xgene_enet_raw_desc));
232
233 dma_addr = dma_map_single(dev, skb->data, skb->len, DMA_TO_DEVICE);
234 if (dma_mapping_error(dev, dma_addr)) {
235 netdev_err(tx_ring->ndev, "DMA mapping error\n");
236 return -EINVAL;
237 }
238
239 /* Hardware expects descriptor in little endian format */
240 raw_desc->m0 = cpu_to_le64(tail);
241 raw_desc->m1 = cpu_to_le64(SET_VAL(DATAADDR, dma_addr) |
242 SET_VAL(BUFDATALEN, skb->len) |
243 SET_BIT(COHERENT));
244 hopinfo = xgene_enet_work_msg(skb);
245 raw_desc->m3 = cpu_to_le64(SET_VAL(HENQNUM, tx_ring->dst_ring_num) |
246 hopinfo);
247 tx_ring->cp_ring->cp_skb[tail] = skb;
248
249 return 0;
250}
251
252static netdev_tx_t xgene_enet_start_xmit(struct sk_buff *skb,
253 struct net_device *ndev)
254{
255 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
256 struct xgene_enet_desc_ring *tx_ring = pdata->tx_ring;
257 struct xgene_enet_desc_ring *cp_ring = tx_ring->cp_ring;
258 u32 tx_level, cq_level;
259
260 tx_level = xgene_enet_ring_len(tx_ring);
261 cq_level = xgene_enet_ring_len(cp_ring);
262 if (unlikely(tx_level > pdata->tx_qcnt_hi ||
263 cq_level > pdata->cp_qcnt_hi)) {
264 netif_stop_queue(ndev);
265 return NETDEV_TX_BUSY;
266 }
267
268 if (xgene_enet_setup_tx_desc(tx_ring, skb)) {
269 dev_kfree_skb_any(skb);
270 return NETDEV_TX_OK;
271 }
272
273 iowrite32(1, tx_ring->cmd);
274 skb_tx_timestamp(skb);
275 tx_ring->tail = (tx_ring->tail + 1) & (tx_ring->slots - 1);
276
277 pdata->stats.tx_packets++;
278 pdata->stats.tx_bytes += skb->len;
279
280 return NETDEV_TX_OK;
281}
282
283static void xgene_enet_skip_csum(struct sk_buff *skb)
284{
285 struct iphdr *iph = ip_hdr(skb);
286
287 if (!ip_is_fragment(iph) ||
288 (iph->protocol != IPPROTO_TCP && iph->protocol != IPPROTO_UDP)) {
289 skb->ip_summed = CHECKSUM_UNNECESSARY;
290 }
291}
292
293static int xgene_enet_rx_frame(struct xgene_enet_desc_ring *rx_ring,
294 struct xgene_enet_raw_desc *raw_desc)
295{
296 struct net_device *ndev;
297 struct xgene_enet_pdata *pdata;
298 struct device *dev;
299 struct xgene_enet_desc_ring *buf_pool;
300 u32 datalen, skb_index;
301 struct sk_buff *skb;
302 u8 status;
303 int ret = 0;
304
305 ndev = rx_ring->ndev;
306 pdata = netdev_priv(ndev);
307 dev = ndev_to_dev(rx_ring->ndev);
308 buf_pool = rx_ring->buf_pool;
309
310 dma_unmap_single(dev, GET_VAL(DATAADDR, le64_to_cpu(raw_desc->m1)),
311 XGENE_ENET_MAX_MTU, DMA_FROM_DEVICE);
312 skb_index = GET_VAL(USERINFO, le64_to_cpu(raw_desc->m0));
313 skb = buf_pool->rx_skb[skb_index];
314
315 /* checking for error */
316 status = GET_VAL(LERR, le64_to_cpu(raw_desc->m0));
317 if (unlikely(status > 2)) {
318 dev_kfree_skb_any(skb);
319 xgene_enet_parse_error(rx_ring, netdev_priv(rx_ring->ndev),
320 status);
321 pdata->stats.rx_dropped++;
322 ret = -EIO;
323 goto out;
324 }
325
326 /* strip off CRC as HW isn't doing this */
327 datalen = GET_VAL(BUFDATALEN, le64_to_cpu(raw_desc->m1));
328 datalen -= 4;
329 prefetch(skb->data - NET_IP_ALIGN);
330 skb_put(skb, datalen);
331
332 skb_checksum_none_assert(skb);
333 skb->protocol = eth_type_trans(skb, ndev);
334 if (likely((ndev->features & NETIF_F_IP_CSUM) &&
335 skb->protocol == htons(ETH_P_IP))) {
336 xgene_enet_skip_csum(skb);
337 }
338
339 pdata->stats.rx_packets++;
340 pdata->stats.rx_bytes += datalen;
341 napi_gro_receive(&rx_ring->napi, skb);
342out:
343 if (--rx_ring->nbufpool == 0) {
344 ret = xgene_enet_refill_bufpool(buf_pool, NUM_BUFPOOL);
345 rx_ring->nbufpool = NUM_BUFPOOL;
346 }
347
348 return ret;
349}
350
351static bool is_rx_desc(struct xgene_enet_raw_desc *raw_desc)
352{
353 return GET_VAL(FPQNUM, le64_to_cpu(raw_desc->m0)) ? true : false;
354}
355
356static int xgene_enet_process_ring(struct xgene_enet_desc_ring *ring,
357 int budget)
358{
359 struct xgene_enet_pdata *pdata = netdev_priv(ring->ndev);
360 struct xgene_enet_raw_desc *raw_desc;
361 u16 head = ring->head;
362 u16 slots = ring->slots - 1;
363 int ret, count = 0;
364
365 do {
366 raw_desc = &ring->raw_desc[head];
367 if (unlikely(xgene_enet_is_desc_slot_empty(raw_desc)))
368 break;
369
370 if (is_rx_desc(raw_desc))
371 ret = xgene_enet_rx_frame(ring, raw_desc);
372 else
373 ret = xgene_enet_tx_completion(ring, raw_desc);
374 xgene_enet_mark_desc_slot_empty(raw_desc);
375
376 head = (head + 1) & slots;
377 count++;
378
379 if (ret)
380 break;
381 } while (--budget);
382
383 if (likely(count)) {
384 iowrite32(-count, ring->cmd);
385 ring->head = head;
386
387 if (netif_queue_stopped(ring->ndev)) {
388 if (xgene_enet_ring_len(ring) < pdata->cp_qcnt_low)
389 netif_wake_queue(ring->ndev);
390 }
391 }
392
393 return budget;
394}
395
396static int xgene_enet_napi(struct napi_struct *napi, const int budget)
397{
398 struct xgene_enet_desc_ring *ring;
399 int processed;
400
401 ring = container_of(napi, struct xgene_enet_desc_ring, napi);
402 processed = xgene_enet_process_ring(ring, budget);
403
404 if (processed != budget) {
405 napi_complete(napi);
406 enable_irq(ring->irq);
407 }
408
409 return processed;
410}
411
412static void xgene_enet_timeout(struct net_device *ndev)
413{
414 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
415
416 xgene_gmac_reset(pdata);
417}
418
419static int xgene_enet_register_irq(struct net_device *ndev)
420{
421 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
422 struct device *dev = ndev_to_dev(ndev);
423 int ret;
424
425 ret = devm_request_irq(dev, pdata->rx_ring->irq, xgene_enet_rx_irq,
426 IRQF_SHARED, ndev->name, pdata->rx_ring);
427 if (ret) {
428 netdev_err(ndev, "rx%d interrupt request failed\n",
429 pdata->rx_ring->irq);
430 }
431
432 return ret;
433}
434
435static void xgene_enet_free_irq(struct net_device *ndev)
436{
437 struct xgene_enet_pdata *pdata;
438 struct device *dev;
439
440 pdata = netdev_priv(ndev);
441 dev = ndev_to_dev(ndev);
442 devm_free_irq(dev, pdata->rx_ring->irq, pdata->rx_ring);
443}
444
445static int xgene_enet_open(struct net_device *ndev)
446{
447 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
448 int ret;
449
450 xgene_gmac_tx_enable(pdata);
451 xgene_gmac_rx_enable(pdata);
452
453 ret = xgene_enet_register_irq(ndev);
454 if (ret)
455 return ret;
456 napi_enable(&pdata->rx_ring->napi);
457
458 if (pdata->phy_dev)
459 phy_start(pdata->phy_dev);
460
461 netif_start_queue(ndev);
462
463 return ret;
464}
465
466static int xgene_enet_close(struct net_device *ndev)
467{
468 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
469
470 netif_stop_queue(ndev);
471
472 if (pdata->phy_dev)
473 phy_stop(pdata->phy_dev);
474
475 napi_disable(&pdata->rx_ring->napi);
476 xgene_enet_free_irq(ndev);
477 xgene_enet_process_ring(pdata->rx_ring, -1);
478
479 xgene_gmac_tx_disable(pdata);
480 xgene_gmac_rx_disable(pdata);
481
482 return 0;
483}
484
485static void xgene_enet_delete_ring(struct xgene_enet_desc_ring *ring)
486{
487 struct xgene_enet_pdata *pdata;
488 struct device *dev;
489
490 pdata = netdev_priv(ring->ndev);
491 dev = ndev_to_dev(ring->ndev);
492
493 xgene_enet_clear_ring(ring);
494 dma_free_coherent(dev, ring->size, ring->desc_addr, ring->dma);
495}
496
497static void xgene_enet_delete_desc_rings(struct xgene_enet_pdata *pdata)
498{
499 struct xgene_enet_desc_ring *buf_pool;
500
501 if (pdata->tx_ring) {
502 xgene_enet_delete_ring(pdata->tx_ring);
503 pdata->tx_ring = NULL;
504 }
505
506 if (pdata->rx_ring) {
507 buf_pool = pdata->rx_ring->buf_pool;
508 xgene_enet_delete_bufpool(buf_pool);
509 xgene_enet_delete_ring(buf_pool);
510 xgene_enet_delete_ring(pdata->rx_ring);
511 pdata->rx_ring = NULL;
512 }
513}
514
515static int xgene_enet_get_ring_size(struct device *dev,
516 enum xgene_enet_ring_cfgsize cfgsize)
517{
518 int size = -EINVAL;
519
520 switch (cfgsize) {
521 case RING_CFGSIZE_512B:
522 size = 0x200;
523 break;
524 case RING_CFGSIZE_2KB:
525 size = 0x800;
526 break;
527 case RING_CFGSIZE_16KB:
528 size = 0x4000;
529 break;
530 case RING_CFGSIZE_64KB:
531 size = 0x10000;
532 break;
533 case RING_CFGSIZE_512KB:
534 size = 0x80000;
535 break;
536 default:
537 dev_err(dev, "Unsupported cfg ring size %d\n", cfgsize);
538 break;
539 }
540
541 return size;
542}
543
544static void xgene_enet_free_desc_ring(struct xgene_enet_desc_ring *ring)
545{
546 struct device *dev;
547
548 if (!ring)
549 return;
550
551 dev = ndev_to_dev(ring->ndev);
552
553 if (ring->desc_addr) {
554 xgene_enet_clear_ring(ring);
555 dma_free_coherent(dev, ring->size, ring->desc_addr, ring->dma);
556 }
557 devm_kfree(dev, ring);
558}
559
560static void xgene_enet_free_desc_rings(struct xgene_enet_pdata *pdata)
561{
562 struct device *dev = &pdata->pdev->dev;
563 struct xgene_enet_desc_ring *ring;
564
565 ring = pdata->tx_ring;
566 if (ring && ring->cp_ring && ring->cp_ring->cp_skb)
567 devm_kfree(dev, ring->cp_ring->cp_skb);
568 xgene_enet_free_desc_ring(ring);
569
570 ring = pdata->rx_ring;
571 if (ring && ring->buf_pool && ring->buf_pool->rx_skb)
572 devm_kfree(dev, ring->buf_pool->rx_skb);
573 xgene_enet_free_desc_ring(ring->buf_pool);
574 xgene_enet_free_desc_ring(ring);
575}
576
577static struct xgene_enet_desc_ring *xgene_enet_create_desc_ring(
578 struct net_device *ndev, u32 ring_num,
579 enum xgene_enet_ring_cfgsize cfgsize, u32 ring_id)
580{
581 struct xgene_enet_desc_ring *ring;
582 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
583 struct device *dev = ndev_to_dev(ndev);
584 int size;
585
586 size = xgene_enet_get_ring_size(dev, cfgsize);
587 if (size < 0)
588 return NULL;
589
590 ring = devm_kzalloc(dev, sizeof(struct xgene_enet_desc_ring),
591 GFP_KERNEL);
592 if (!ring)
593 return NULL;
594
595 ring->ndev = ndev;
596 ring->num = ring_num;
597 ring->cfgsize = cfgsize;
598 ring->id = ring_id;
599
600 ring->desc_addr = dma_zalloc_coherent(dev, size, &ring->dma,
601 GFP_KERNEL);
602 if (!ring->desc_addr) {
603 devm_kfree(dev, ring);
604 return NULL;
605 }
606 ring->size = size;
607
608 ring->cmd_base = pdata->ring_cmd_addr + (ring->num << 6);
609 ring->cmd = ring->cmd_base + INC_DEC_CMD_ADDR;
610 pdata->rm = RM3;
611 ring = xgene_enet_setup_ring(ring);
612 netdev_dbg(ndev, "ring info: num=%d size=%d id=%d slots=%d\n",
613 ring->num, ring->size, ring->id, ring->slots);
614
615 return ring;
616}
617
618static u16 xgene_enet_get_ring_id(enum xgene_ring_owner owner, u8 bufnum)
619{
620 return (owner << 6) | (bufnum & GENMASK(5, 0));
621}
622
623static int xgene_enet_create_desc_rings(struct net_device *ndev)
624{
625 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
626 struct device *dev = ndev_to_dev(ndev);
627 struct xgene_enet_desc_ring *rx_ring, *tx_ring, *cp_ring;
628 struct xgene_enet_desc_ring *buf_pool = NULL;
629 u8 cpu_bufnum = 0, eth_bufnum = 0;
630 u8 bp_bufnum = 0x20;
631 u16 ring_id, ring_num = 0;
632 int ret;
633
634 /* allocate rx descriptor ring */
635 ring_id = xgene_enet_get_ring_id(RING_OWNER_CPU, cpu_bufnum++);
636 rx_ring = xgene_enet_create_desc_ring(ndev, ring_num++,
637 RING_CFGSIZE_16KB, ring_id);
638 if (!rx_ring) {
639 ret = -ENOMEM;
640 goto err;
641 }
642
643 /* allocate buffer pool for receiving packets */
644 ring_id = xgene_enet_get_ring_id(RING_OWNER_ETH0, bp_bufnum++);
645 buf_pool = xgene_enet_create_desc_ring(ndev, ring_num++,
646 RING_CFGSIZE_2KB, ring_id);
647 if (!buf_pool) {
648 ret = -ENOMEM;
649 goto err;
650 }
651
652 rx_ring->nbufpool = NUM_BUFPOOL;
653 rx_ring->buf_pool = buf_pool;
654 rx_ring->irq = pdata->rx_irq;
655 buf_pool->rx_skb = devm_kcalloc(dev, buf_pool->slots,
656 sizeof(struct sk_buff *), GFP_KERNEL);
657 if (!buf_pool->rx_skb) {
658 ret = -ENOMEM;
659 goto err;
660 }
661
662 buf_pool->dst_ring_num = xgene_enet_dst_ring_num(buf_pool);
663 rx_ring->buf_pool = buf_pool;
664 pdata->rx_ring = rx_ring;
665
666 /* allocate tx descriptor ring */
667 ring_id = xgene_enet_get_ring_id(RING_OWNER_ETH0, eth_bufnum++);
668 tx_ring = xgene_enet_create_desc_ring(ndev, ring_num++,
669 RING_CFGSIZE_16KB, ring_id);
670 if (!tx_ring) {
671 ret = -ENOMEM;
672 goto err;
673 }
674 pdata->tx_ring = tx_ring;
675
676 cp_ring = pdata->rx_ring;
677 cp_ring->cp_skb = devm_kcalloc(dev, tx_ring->slots,
678 sizeof(struct sk_buff *), GFP_KERNEL);
679 if (!cp_ring->cp_skb) {
680 ret = -ENOMEM;
681 goto err;
682 }
683 pdata->tx_ring->cp_ring = cp_ring;
684 pdata->tx_ring->dst_ring_num = xgene_enet_dst_ring_num(cp_ring);
685
686 pdata->tx_qcnt_hi = pdata->tx_ring->slots / 2;
687 pdata->cp_qcnt_hi = pdata->rx_ring->slots / 2;
688 pdata->cp_qcnt_low = pdata->cp_qcnt_hi / 2;
689
690 return 0;
691
692err:
693 xgene_enet_free_desc_rings(pdata);
694 return ret;
695}
696
697static struct rtnl_link_stats64 *xgene_enet_get_stats64(
698 struct net_device *ndev,
699 struct rtnl_link_stats64 *storage)
700{
701 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
702 struct rtnl_link_stats64 *stats = &pdata->stats;
703
704 stats->rx_errors += stats->rx_length_errors +
705 stats->rx_crc_errors +
706 stats->rx_frame_errors +
707 stats->rx_fifo_errors;
708 memcpy(storage, &pdata->stats, sizeof(struct rtnl_link_stats64));
709
710 return storage;
711}
712
713static int xgene_enet_set_mac_address(struct net_device *ndev, void *addr)
714{
715 struct xgene_enet_pdata *pdata = netdev_priv(ndev);
716 int ret;
717
718 ret = eth_mac_addr(ndev, addr);
719 if (ret)
720 return ret;
721 xgene_gmac_set_mac_addr(pdata);
722
723 return ret;
724}
725
726static const struct net_device_ops xgene_ndev_ops = {
727 .ndo_open = xgene_enet_open,
728 .ndo_stop = xgene_enet_close,
729 .ndo_start_xmit = xgene_enet_start_xmit,
730 .ndo_tx_timeout = xgene_enet_timeout,
731 .ndo_get_stats64 = xgene_enet_get_stats64,
732 .ndo_change_mtu = eth_change_mtu,
733 .ndo_set_mac_address = xgene_enet_set_mac_address,
734};
735
736static int xgene_enet_get_resources(struct xgene_enet_pdata *pdata)
737{
738 struct platform_device *pdev;
739 struct net_device *ndev;
740 struct device *dev;
741 struct resource *res;
742 void __iomem *base_addr;
743 const char *mac;
744 int ret;
745
746 pdev = pdata->pdev;
747 dev = &pdev->dev;
748 ndev = pdata->ndev;
749
750 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "enet_csr");
751 if (!res) {
752 dev_err(dev, "Resource enet_csr not defined\n");
753 return -ENODEV;
754 }
755 pdata->base_addr = devm_ioremap_resource(dev, res);
756 if (IS_ERR(pdata->base_addr)) {
757 dev_err(dev, "Unable to retrieve ENET Port CSR region\n");
758 return PTR_ERR(pdata->base_addr);
759 }
760
761 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ring_csr");
762 if (!res) {
763 dev_err(dev, "Resource ring_csr not defined\n");
764 return -ENODEV;
765 }
766 pdata->ring_csr_addr = devm_ioremap_resource(dev, res);
767 if (IS_ERR(pdata->ring_csr_addr)) {
768 dev_err(dev, "Unable to retrieve ENET Ring CSR region\n");
769 return PTR_ERR(pdata->ring_csr_addr);
770 }
771
772 res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ring_cmd");
773 if (!res) {
774 dev_err(dev, "Resource ring_cmd not defined\n");
775 return -ENODEV;
776 }
777 pdata->ring_cmd_addr = devm_ioremap_resource(dev, res);
778 if (IS_ERR(pdata->ring_cmd_addr)) {
779 dev_err(dev, "Unable to retrieve ENET Ring command region\n");
780 return PTR_ERR(pdata->ring_cmd_addr);
781 }
782
783 ret = platform_get_irq(pdev, 0);
784 if (ret <= 0) {
785 dev_err(dev, "Unable to get ENET Rx IRQ\n");
786 ret = ret ? : -ENXIO;
787 return ret;
788 }
789 pdata->rx_irq = ret;
790
791 mac = of_get_mac_address(dev->of_node);
792 if (mac)
793 memcpy(ndev->dev_addr, mac, ndev->addr_len);
794 else
795 eth_hw_addr_random(ndev);
796 memcpy(ndev->perm_addr, ndev->dev_addr, ndev->addr_len);
797
798 pdata->phy_mode = of_get_phy_mode(pdev->dev.of_node);
799 if (pdata->phy_mode < 0) {
800 dev_err(dev, "Incorrect phy-connection-type in DTS\n");
801 return -EINVAL;
802 }
803
804 pdata->clk = devm_clk_get(&pdev->dev, NULL);
805 ret = IS_ERR(pdata->clk);
806 if (IS_ERR(pdata->clk)) {
807 dev_err(&pdev->dev, "can't get clock\n");
808 ret = PTR_ERR(pdata->clk);
809 return ret;
810 }
811
812 base_addr = pdata->base_addr;
813 pdata->eth_csr_addr = base_addr + BLOCK_ETH_CSR_OFFSET;
814 pdata->eth_ring_if_addr = base_addr + BLOCK_ETH_RING_IF_OFFSET;
815 pdata->eth_diag_csr_addr = base_addr + BLOCK_ETH_DIAG_CSR_OFFSET;
816 pdata->mcx_mac_addr = base_addr + BLOCK_ETH_MAC_OFFSET;
817 pdata->mcx_stats_addr = base_addr + BLOCK_ETH_STATS_OFFSET;
818 pdata->mcx_mac_csr_addr = base_addr + BLOCK_ETH_MAC_CSR_OFFSET;
819 pdata->rx_buff_cnt = NUM_PKT_BUF;
820
821 return ret;
822}
823
824static int xgene_enet_init_hw(struct xgene_enet_pdata *pdata)
825{
826 struct net_device *ndev = pdata->ndev;
827 struct xgene_enet_desc_ring *buf_pool;
828 u16 dst_ring_num;
829 int ret;
830
831 xgene_gmac_tx_disable(pdata);
832 xgene_gmac_rx_disable(pdata);
833
834 ret = xgene_enet_create_desc_rings(ndev);
835 if (ret) {
836 netdev_err(ndev, "Error in ring configuration\n");
837 return ret;
838 }
839
840 /* setup buffer pool */
841 buf_pool = pdata->rx_ring->buf_pool;
842 xgene_enet_init_bufpool(buf_pool);
843 ret = xgene_enet_refill_bufpool(buf_pool, pdata->rx_buff_cnt);
844 if (ret) {
845 xgene_enet_delete_desc_rings(pdata);
846 return ret;
847 }
848
849 dst_ring_num = xgene_enet_dst_ring_num(pdata->rx_ring);
850 xgene_enet_cle_bypass(pdata, dst_ring_num, buf_pool->id);
851
852 return ret;
853}
854
855static int xgene_enet_probe(struct platform_device *pdev)
856{
857 struct net_device *ndev;
858 struct xgene_enet_pdata *pdata;
859 struct device *dev = &pdev->dev;
860 struct napi_struct *napi;
861 int ret;
862
863 ndev = alloc_etherdev(sizeof(struct xgene_enet_pdata));
864 if (!ndev)
865 return -ENOMEM;
866
867 pdata = netdev_priv(ndev);
868
869 pdata->pdev = pdev;
870 pdata->ndev = ndev;
871 SET_NETDEV_DEV(ndev, dev);
872 platform_set_drvdata(pdev, pdata);
873 ndev->netdev_ops = &xgene_ndev_ops;
874 xgene_enet_set_ethtool_ops(ndev);
875 ndev->features |= NETIF_F_IP_CSUM |
876 NETIF_F_GSO |
877 NETIF_F_GRO;
878
879 ret = xgene_enet_get_resources(pdata);
880 if (ret)
881 goto err;
882
883 xgene_enet_reset(pdata);
884 xgene_gmac_init(pdata, SPEED_1000);
885
886 ret = register_netdev(ndev);
887 if (ret) {
888 netdev_err(ndev, "Failed to register netdev\n");
889 goto err;
890 }
891
892 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
893 if (ret) {
894 netdev_err(ndev, "No usable DMA configuration\n");
895 goto err;
896 }
897
898 ret = xgene_enet_init_hw(pdata);
899 if (ret)
900 goto err;
901
902 napi = &pdata->rx_ring->napi;
903 netif_napi_add(ndev, napi, xgene_enet_napi, NAPI_POLL_WEIGHT);
904 ret = xgene_enet_mdio_config(pdata);
905
906 return ret;
907err:
908 free_netdev(ndev);
909 return ret;
910}
911
912static int xgene_enet_remove(struct platform_device *pdev)
913{
914 struct xgene_enet_pdata *pdata;
915 struct net_device *ndev;
916
917 pdata = platform_get_drvdata(pdev);
918 ndev = pdata->ndev;
919
920 xgene_gmac_rx_disable(pdata);
921 xgene_gmac_tx_disable(pdata);
922
923 netif_napi_del(&pdata->rx_ring->napi);
924 xgene_enet_mdio_remove(pdata);
925 xgene_enet_delete_desc_rings(pdata);
926 unregister_netdev(ndev);
927 xgene_gport_shutdown(pdata);
928 free_netdev(ndev);
929
930 return 0;
931}
932
933static struct of_device_id xgene_enet_match[] = {
934 {.compatible = "apm,xgene-enet",},
935 {},
936};
937
938MODULE_DEVICE_TABLE(of, xgene_enet_match);
939
940static struct platform_driver xgene_enet_driver = {
941 .driver = {
942 .name = "xgene-enet",
943 .of_match_table = xgene_enet_match,
944 },
945 .probe = xgene_enet_probe,
946 .remove = xgene_enet_remove,
947};
948
949module_platform_driver(xgene_enet_driver);
950
951MODULE_DESCRIPTION("APM X-Gene SoC Ethernet driver");
952MODULE_VERSION(XGENE_DRV_VERSION);
953MODULE_AUTHOR("Keyur Chudgar <kchudgar@apm.com>");
954MODULE_LICENSE("GPL");
diff --git a/drivers/net/ethernet/apm/xgene/xgene_enet_main.h b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
new file mode 100644
index 000000000000..0815866986b0
--- /dev/null
+++ b/drivers/net/ethernet/apm/xgene/xgene_enet_main.h
@@ -0,0 +1,135 @@
1/* Applied Micro X-Gene SoC Ethernet Driver
2 *
3 * Copyright (c) 2014, Applied Micro Circuits Corporation
4 * Authors: Iyappan Subramanian <isubramanian@apm.com>
5 * Ravi Patel <rapatel@apm.com>
6 * Keyur Chudgar <kchudgar@apm.com>
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License as published by the
10 * Free Software Foundation; either version 2 of the License, or (at your
11 * option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 */
21
22#ifndef __XGENE_ENET_MAIN_H__
23#define __XGENE_ENET_MAIN_H__
24
25#include <linux/clk.h>
26#include <linux/of_platform.h>
27#include <linux/of_net.h>
28#include <linux/of_mdio.h>
29#include <linux/module.h>
30#include <net/ip.h>
31#include <linux/prefetch.h>
32#include <linux/if_vlan.h>
33#include <linux/phy.h>
34#include "xgene_enet_hw.h"
35
36#define XGENE_DRV_VERSION "v1.0"
37#define XGENE_ENET_MAX_MTU 1536
38#define SKB_BUFFER_SIZE (XGENE_ENET_MAX_MTU - NET_IP_ALIGN)
39#define NUM_PKT_BUF 64
40#define NUM_BUFPOOL 32
41
42/* software context of a descriptor ring */
43struct xgene_enet_desc_ring {
44 struct net_device *ndev;
45 u16 id;
46 u16 num;
47 u16 head;
48 u16 tail;
49 u16 slots;
50 u16 irq;
51 u32 size;
52 u32 state[NUM_RING_CONFIG];
53 void __iomem *cmd_base;
54 void __iomem *cmd;
55 dma_addr_t dma;
56 u16 dst_ring_num;
57 u8 nbufpool;
58 struct sk_buff *(*rx_skb);
59 struct sk_buff *(*cp_skb);
60 enum xgene_enet_ring_cfgsize cfgsize;
61 struct xgene_enet_desc_ring *cp_ring;
62 struct xgene_enet_desc_ring *buf_pool;
63 struct napi_struct napi;
64 union {
65 void *desc_addr;
66 struct xgene_enet_raw_desc *raw_desc;
67 struct xgene_enet_raw_desc16 *raw_desc16;
68 };
69};
70
71/* ethernet private data */
72struct xgene_enet_pdata {
73 struct net_device *ndev;
74 struct mii_bus *mdio_bus;
75 struct phy_device *phy_dev;
76 int phy_speed;
77 struct clk *clk;
78 struct platform_device *pdev;
79 struct xgene_enet_desc_ring *tx_ring;
80 struct xgene_enet_desc_ring *rx_ring;
81 char *dev_name;
82 u32 rx_buff_cnt;
83 u32 tx_qcnt_hi;
84 u32 cp_qcnt_hi;
85 u32 cp_qcnt_low;
86 u32 rx_irq;
87 void __iomem *eth_csr_addr;
88 void __iomem *eth_ring_if_addr;
89 void __iomem *eth_diag_csr_addr;
90 void __iomem *mcx_mac_addr;
91 void __iomem *mcx_stats_addr;
92 void __iomem *mcx_mac_csr_addr;
93 void __iomem *base_addr;
94 void __iomem *ring_csr_addr;
95 void __iomem *ring_cmd_addr;
96 u32 phy_addr;
97 int phy_mode;
98 u32 speed;
99 u16 rm;
100 struct rtnl_link_stats64 stats;
101};
102
103/* Set the specified value into a bit-field defined by its starting position
104 * and length within a single u64.
105 */
106static inline u64 xgene_enet_set_field_value(int pos, int len, u64 val)
107{
108 return (val & ((1ULL << len) - 1)) << pos;
109}
110
111#define SET_VAL(field, val) \
112 xgene_enet_set_field_value(field ## _POS, field ## _LEN, val)
113
114#define SET_BIT(field) \
115 xgene_enet_set_field_value(field ## _POS, 1, 1)
116
117/* Get the value from a bit-field defined by its starting position
118 * and length within the specified u64.
119 */
120static inline u64 xgene_enet_get_field_value(int pos, int len, u64 src)
121{
122 return (src >> pos) & ((1ULL << len) - 1);
123}
124
125#define GET_VAL(field, src) \
126 xgene_enet_get_field_value(field ## _POS, field ## _LEN, src)
127
128static inline struct device *ndev_to_dev(struct net_device *ndev)
129{
130 return ndev->dev.parent;
131}
132
133void xgene_enet_set_ethtool_ops(struct net_device *netdev);
134
135#endif /* __XGENE_ENET_MAIN_H__ */
diff --git a/drivers/net/ethernet/atheros/alx/main.c b/drivers/net/ethernet/atheros/alx/main.c
index 49faa97a30c3..e398eda07298 100644
--- a/drivers/net/ethernet/atheros/alx/main.c
+++ b/drivers/net/ethernet/atheros/alx/main.c
@@ -1527,7 +1527,7 @@ static const struct pci_error_handlers alx_err_handlers = {
1527 .resume = alx_pci_error_resume, 1527 .resume = alx_pci_error_resume,
1528}; 1528};
1529 1529
1530static DEFINE_PCI_DEVICE_TABLE(alx_pci_tbl) = { 1530static const struct pci_device_id alx_pci_tbl[] = {
1531 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8161), 1531 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_AR8161),
1532 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG }, 1532 .driver_data = ALX_DEV_QUIRK_MSI_INTX_DISABLE_BUG },
1533 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2200), 1533 { PCI_VDEVICE(ATTANSIC, ALX_DEV_ID_E2200),
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index e11bf18fbbd1..72fb86b9aa24 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -34,7 +34,7 @@ char atl1c_driver_version[] = ATL1C_DRV_VERSION;
34 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, 34 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
35 * Class, Class Mask, private data (not used) } 35 * Class, Class Mask, private data (not used) }
36 */ 36 */
37static DEFINE_PCI_DEVICE_TABLE(atl1c_pci_tbl) = { 37static const struct pci_device_id atl1c_pci_tbl[] = {
38 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L1C)}, 38 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L1C)},
39 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L2C)}, 39 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L2C)},
40 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATHEROS_L2C_B)}, 40 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATHEROS_L2C_B)},
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index 4345332533ad..2326579f9454 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -35,7 +35,7 @@ char atl1e_driver_version[] = DRV_VERSION;
35 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, 35 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
36 * Class, Class Mask, private data (not used) } 36 * Class, Class Mask, private data (not used) }
37 */ 37 */
38static DEFINE_PCI_DEVICE_TABLE(atl1e_pci_tbl) = { 38static const struct pci_device_id atl1e_pci_tbl[] = {
39 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L1E)}, 39 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L1E)},
40 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, 0x1066)}, 40 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, 0x1066)},
41 /* required last entry */ 41 /* required last entry */
@@ -831,17 +831,14 @@ static int atl1e_setup_ring_resources(struct atl1e_adapter *adapter)
831 /* real ring DMA buffer */ 831 /* real ring DMA buffer */
832 832
833 size = adapter->ring_size; 833 size = adapter->ring_size;
834 adapter->ring_vir_addr = pci_alloc_consistent(pdev, 834 adapter->ring_vir_addr = pci_zalloc_consistent(pdev, adapter->ring_size,
835 adapter->ring_size, &adapter->ring_dma); 835 &adapter->ring_dma);
836
837 if (adapter->ring_vir_addr == NULL) { 836 if (adapter->ring_vir_addr == NULL) {
838 netdev_err(adapter->netdev, 837 netdev_err(adapter->netdev,
839 "pci_alloc_consistent failed, size = D%d\n", size); 838 "pci_alloc_consistent failed, size = D%d\n", size);
840 return -ENOMEM; 839 return -ENOMEM;
841 } 840 }
842 841
843 memset(adapter->ring_vir_addr, 0, adapter->ring_size);
844
845 rx_page_desc = rx_ring->rx_page_desc; 842 rx_page_desc = rx_ring->rx_page_desc;
846 843
847 /* Init TPD Ring */ 844 /* Init TPD Ring */
diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
index 1546d550ac97..2c8f398aeda9 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -235,7 +235,7 @@ static void atl1_check_options(struct atl1_adapter *adapter)
235/* 235/*
236 * atl1_pci_tbl - PCI Device ID Table 236 * atl1_pci_tbl - PCI Device ID Table
237 */ 237 */
238static DEFINE_PCI_DEVICE_TABLE(atl1_pci_tbl) = { 238static const struct pci_device_id atl1_pci_tbl[] = {
239 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L1)}, 239 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L1)},
240 /* required last entry */ 240 /* required last entry */
241 {0,} 241 {0,}
diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c
index c194bc687c30..84a09e8ddd9c 100644
--- a/drivers/net/ethernet/atheros/atlx/atl2.c
+++ b/drivers/net/ethernet/atheros/atlx/atl2.c
@@ -65,7 +65,7 @@ MODULE_VERSION(ATL2_DRV_VERSION);
65/* 65/*
66 * atl2_pci_tbl - PCI Device ID Table 66 * atl2_pci_tbl - PCI Device ID Table
67 */ 67 */
68static DEFINE_PCI_DEVICE_TABLE(atl2_pci_tbl) = { 68static const struct pci_device_id atl2_pci_tbl[] = {
69 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L2)}, 69 {PCI_DEVICE(PCI_VENDOR_ID_ATTANSIC, PCI_DEVICE_ID_ATTANSIC_L2)},
70 /* required last entry */ 70 /* required last entry */
71 {0,} 71 {0,}
diff --git a/drivers/net/ethernet/broadcom/b44.c b/drivers/net/ethernet/broadcom/b44.c
index ca5a20a48b14..4a7028d65912 100644
--- a/drivers/net/ethernet/broadcom/b44.c
+++ b/drivers/net/ethernet/broadcom/b44.c
@@ -105,7 +105,7 @@ MODULE_PARM_DESC(b44_debug, "B44 bitmapped debugging message enable value");
105 105
106 106
107#ifdef CONFIG_B44_PCI 107#ifdef CONFIG_B44_PCI
108static DEFINE_PCI_DEVICE_TABLE(b44_pci_tbl) = { 108static const struct pci_device_id b44_pci_tbl[] = {
109 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401) }, 109 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401) },
110 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B0) }, 110 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B0) },
111 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B1) }, 111 { PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_BCM4401B1) },
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c
index e64c963fe775..2fee73b878c2 100644
--- a/drivers/net/ethernet/broadcom/bnx2.c
+++ b/drivers/net/ethernet/broadcom/bnx2.c
@@ -120,7 +120,7 @@ static struct {
120 { "Broadcom NetXtreme II BCM5716 1000Base-SX" }, 120 { "Broadcom NetXtreme II BCM5716 1000Base-SX" },
121 }; 121 };
122 122
123static DEFINE_PCI_DEVICE_TABLE(bnx2_pci_tbl) = { 123static const struct pci_device_id bnx2_pci_tbl[] = {
124 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706, 124 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706,
125 PCI_VENDOR_ID_HP, 0x3101, 0, 0, NC370T }, 125 PCI_VENDOR_ID_HP, 0x3101, 0, 0, NC370T },
126 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706, 126 { PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_NX2_5706,
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
index 3871ec49cc4d..c13364b6cc19 100644
--- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
+++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c
@@ -249,7 +249,7 @@ static struct {
249#define PCI_DEVICE_ID_NX2_57811_VF CHIP_NUM_57811_VF 249#define PCI_DEVICE_ID_NX2_57811_VF CHIP_NUM_57811_VF
250#endif 250#endif
251 251
252static DEFINE_PCI_DEVICE_TABLE(bnx2x_pci_tbl) = { 252static const struct pci_device_id bnx2x_pci_tbl[] = {
253 { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57710), BCM57710 }, 253 { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57710), BCM57710 },
254 { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57711), BCM57711 }, 254 { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57711), BCM57711 },
255 { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57711E), BCM57711E }, 255 { PCI_VDEVICE(BROADCOM, PCI_DEVICE_ID_NX2_57711E), BCM57711E },
diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index ce455aed5a2f..3f9d4de8173c 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -739,7 +739,6 @@ static void bcmgenet_power_down(struct bcmgenet_priv *priv,
739 739
740 case GENET_POWER_PASSIVE: 740 case GENET_POWER_PASSIVE:
741 /* Power down LED */ 741 /* Power down LED */
742 bcmgenet_mii_reset(priv->dev);
743 if (priv->hw_params->flags & GENET_HAS_EXT) { 742 if (priv->hw_params->flags & GENET_HAS_EXT) {
744 reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT); 743 reg = bcmgenet_ext_readl(priv, EXT_EXT_PWR_MGMT);
745 reg |= (EXT_PWR_DOWN_PHY | 744 reg |= (EXT_PWR_DOWN_PHY |
@@ -779,7 +778,9 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv,
779 } 778 }
780 779
781 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); 780 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
782 bcmgenet_mii_reset(priv->dev); 781
782 if (mode == GENET_POWER_PASSIVE)
783 bcmgenet_mii_reset(priv->dev);
783} 784}
784 785
785/* ioctl handle special commands that are not present in ethtool. */ 786/* ioctl handle special commands that are not present in ethtool. */
@@ -1961,7 +1962,8 @@ static void bcmgenet_set_hw_addr(struct bcmgenet_priv *priv,
1961static int bcmgenet_wol_resume(struct bcmgenet_priv *priv) 1962static int bcmgenet_wol_resume(struct bcmgenet_priv *priv)
1962{ 1963{
1963 /* From WOL-enabled suspend, switch to regular clock */ 1964 /* From WOL-enabled suspend, switch to regular clock */
1964 clk_disable_unprepare(priv->clk_wol); 1965 if (priv->wolopts)
1966 clk_disable_unprepare(priv->clk_wol);
1965 1967
1966 phy_init_hw(priv->phydev); 1968 phy_init_hw(priv->phydev);
1967 /* Speed settings must be restored */ 1969 /* Speed settings must be restored */
@@ -2164,6 +2166,10 @@ static void bcmgenet_netif_stop(struct net_device *dev)
2164 * disabled no new work will be scheduled. 2166 * disabled no new work will be scheduled.
2165 */ 2167 */
2166 cancel_work_sync(&priv->bcmgenet_irq_work); 2168 cancel_work_sync(&priv->bcmgenet_irq_work);
2169
2170 priv->old_pause = -1;
2171 priv->old_link = -1;
2172 priv->old_duplex = -1;
2167} 2173}
2168 2174
2169static int bcmgenet_close(struct net_device *dev) 2175static int bcmgenet_close(struct net_device *dev)
@@ -2533,6 +2539,13 @@ static int bcmgenet_probe(struct platform_device *pdev)
2533 priv->pdev = pdev; 2539 priv->pdev = pdev;
2534 priv->version = (enum bcmgenet_version)of_id->data; 2540 priv->version = (enum bcmgenet_version)of_id->data;
2535 2541
2542 priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
2543 if (IS_ERR(priv->clk))
2544 dev_warn(&priv->pdev->dev, "failed to get enet clock\n");
2545
2546 if (!IS_ERR(priv->clk))
2547 clk_prepare_enable(priv->clk);
2548
2536 bcmgenet_set_hw_params(priv); 2549 bcmgenet_set_hw_params(priv);
2537 2550
2538 /* Mii wait queue */ 2551 /* Mii wait queue */
@@ -2541,17 +2554,10 @@ static int bcmgenet_probe(struct platform_device *pdev)
2541 priv->rx_buf_len = RX_BUF_LENGTH; 2554 priv->rx_buf_len = RX_BUF_LENGTH;
2542 INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task); 2555 INIT_WORK(&priv->bcmgenet_irq_work, bcmgenet_irq_task);
2543 2556
2544 priv->clk = devm_clk_get(&priv->pdev->dev, "enet");
2545 if (IS_ERR(priv->clk))
2546 dev_warn(&priv->pdev->dev, "failed to get enet clock\n");
2547
2548 priv->clk_wol = devm_clk_get(&priv->pdev->dev, "enet-wol"); 2557 priv->clk_wol = devm_clk_get(&priv->pdev->dev, "enet-wol");
2549 if (IS_ERR(priv->clk_wol)) 2558 if (IS_ERR(priv->clk_wol))
2550 dev_warn(&priv->pdev->dev, "failed to get enet-wol clock\n"); 2559 dev_warn(&priv->pdev->dev, "failed to get enet-wol clock\n");
2551 2560
2552 if (!IS_ERR(priv->clk))
2553 clk_prepare_enable(priv->clk);
2554
2555 err = reset_umac(priv); 2561 err = reset_umac(priv);
2556 if (err) 2562 if (err)
2557 goto err_clk_disable; 2563 goto err_clk_disable;
@@ -2611,6 +2617,8 @@ static int bcmgenet_suspend(struct device *d)
2611 2617
2612 bcmgenet_netif_stop(dev); 2618 bcmgenet_netif_stop(dev);
2613 2619
2620 phy_suspend(priv->phydev);
2621
2614 netif_device_detach(dev); 2622 netif_device_detach(dev);
2615 2623
2616 /* Disable MAC receive */ 2624 /* Disable MAC receive */
@@ -2661,9 +2669,7 @@ static int bcmgenet_resume(struct device *d)
2661 if (ret) 2669 if (ret)
2662 goto out_clk_disable; 2670 goto out_clk_disable;
2663 2671
2664 if (priv->wolopts) 2672 ret = bcmgenet_wol_resume(priv);
2665 ret = bcmgenet_wol_resume(priv);
2666
2667 if (ret) 2673 if (ret)
2668 goto out_clk_disable; 2674 goto out_clk_disable;
2669 2675
@@ -2678,6 +2684,9 @@ static int bcmgenet_resume(struct device *d)
2678 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT); 2684 bcmgenet_ext_writel(priv, reg, EXT_EXT_PWR_MGMT);
2679 } 2685 }
2680 2686
2687 if (priv->wolopts)
2688 bcmgenet_power_up(priv, GENET_POWER_WOL_MAGIC);
2689
2681 /* Disable RX/TX DMA and flush TX queues */ 2690 /* Disable RX/TX DMA and flush TX queues */
2682 dma_ctrl = bcmgenet_dma_disable(priv); 2691 dma_ctrl = bcmgenet_dma_disable(priv);
2683 2692
@@ -2693,6 +2702,8 @@ static int bcmgenet_resume(struct device *d)
2693 2702
2694 netif_device_attach(dev); 2703 netif_device_attach(dev);
2695 2704
2705 phy_resume(priv->phydev);
2706
2696 bcmgenet_netif_start(dev); 2707 bcmgenet_netif_start(dev);
2697 2708
2698 return 0; 2709 return 0;
diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c
index 18961613d385..c88f7ae99636 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmmii.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c
@@ -129,7 +129,10 @@ static void bcmgenet_mii_setup(struct net_device *dev)
129 cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE; 129 cmd_bits |= CMD_RX_PAUSE_IGNORE | CMD_TX_PAUSE_IGNORE;
130 } 130 }
131 131
132 if (status_changed) { 132 if (!status_changed)
133 return;
134
135 if (phydev->link) {
133 reg = bcmgenet_umac_readl(priv, UMAC_CMD); 136 reg = bcmgenet_umac_readl(priv, UMAC_CMD);
134 reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) | 137 reg &= ~((CMD_SPEED_MASK << CMD_SPEED_SHIFT) |
135 CMD_HD_EN | 138 CMD_HD_EN |
@@ -137,8 +140,9 @@ static void bcmgenet_mii_setup(struct net_device *dev)
137 reg |= cmd_bits; 140 reg |= cmd_bits;
138 bcmgenet_umac_writel(priv, reg, UMAC_CMD); 141 bcmgenet_umac_writel(priv, reg, UMAC_CMD);
139 142
140 phy_print_status(phydev);
141 } 143 }
144
145 phy_print_status(phydev);
142} 146}
143 147
144void bcmgenet_mii_reset(struct net_device *dev) 148void bcmgenet_mii_reset(struct net_device *dev)
@@ -303,12 +307,12 @@ static int bcmgenet_mii_probe(struct net_device *dev)
303 /* In the case of a fixed PHY, the DT node associated 307 /* In the case of a fixed PHY, the DT node associated
304 * to the PHY is the Ethernet MAC DT node. 308 * to the PHY is the Ethernet MAC DT node.
305 */ 309 */
306 if (of_phy_is_fixed_link(dn)) { 310 if (!priv->phy_dn && of_phy_is_fixed_link(dn)) {
307 ret = of_phy_register_fixed_link(dn); 311 ret = of_phy_register_fixed_link(dn);
308 if (ret) 312 if (ret)
309 return ret; 313 return ret;
310 314
311 priv->phy_dn = dn; 315 priv->phy_dn = of_node_get(dn);
312 } 316 }
313 317
314 phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, 0, 318 phydev = of_phy_connect(dev, priv->phy_dn, bcmgenet_mii_setup, 0,
@@ -444,6 +448,7 @@ int bcmgenet_mii_init(struct net_device *dev)
444 return 0; 448 return 0;
445 449
446out: 450out:
451 of_node_put(priv->phy_dn);
447 mdiobus_unregister(priv->mii_bus); 452 mdiobus_unregister(priv->mii_bus);
448out_free: 453out_free:
449 kfree(priv->mii_bus->irq); 454 kfree(priv->mii_bus->irq);
@@ -455,6 +460,7 @@ void bcmgenet_mii_exit(struct net_device *dev)
455{ 460{
456 struct bcmgenet_priv *priv = netdev_priv(dev); 461 struct bcmgenet_priv *priv = netdev_priv(dev);
457 462
463 of_node_put(priv->phy_dn);
458 mdiobus_unregister(priv->mii_bus); 464 mdiobus_unregister(priv->mii_bus);
459 kfree(priv->mii_bus->irq); 465 kfree(priv->mii_bus->irq);
460 mdiobus_free(priv->mii_bus); 466 mdiobus_free(priv->mii_bus);
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c
index a3dd5dc64f4c..3ac5d23454a8 100644
--- a/drivers/net/ethernet/broadcom/tg3.c
+++ b/drivers/net/ethernet/broadcom/tg3.c
@@ -237,7 +237,7 @@ MODULE_PARM_DESC(tg3_debug, "Tigon3 bitmapped debugging message enable value");
237#define TG3_DRV_DATA_FLAG_10_100_ONLY 0x0001 237#define TG3_DRV_DATA_FLAG_10_100_ONLY 0x0001
238#define TG3_DRV_DATA_FLAG_5705_10_100 0x0002 238#define TG3_DRV_DATA_FLAG_5705_10_100 0x0002
239 239
240static DEFINE_PCI_DEVICE_TABLE(tg3_pci_tbl) = { 240static const struct pci_device_id tg3_pci_tbl[] = {
241 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5700)}, 241 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5700)},
242 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5701)}, 242 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5701)},
243 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5702)}, 243 {PCI_DEVICE(PCI_VENDOR_ID_BROADCOM, PCI_DEVICE_ID_TIGON3_5702)},
@@ -14093,8 +14093,9 @@ static struct rtnl_link_stats64 *tg3_get_stats64(struct net_device *dev,
14093 14093
14094 spin_lock_bh(&tp->lock); 14094 spin_lock_bh(&tp->lock);
14095 if (!tp->hw_stats) { 14095 if (!tp->hw_stats) {
14096 *stats = tp->net_stats_prev;
14096 spin_unlock_bh(&tp->lock); 14097 spin_unlock_bh(&tp->lock);
14097 return &tp->net_stats_prev; 14098 return stats;
14098 } 14099 }
14099 14100
14100 tg3_get_nstats(tp, stats); 14101 tg3_get_nstats(tp, stats);
@@ -15926,7 +15927,7 @@ static inline u32 tg3_rx_ret_ring_size(struct tg3 *tp)
15926 return TG3_RX_RET_MAX_SIZE_5705; 15927 return TG3_RX_RET_MAX_SIZE_5705;
15927} 15928}
15928 15929
15929static DEFINE_PCI_DEVICE_TABLE(tg3_write_reorder_chipsets) = { 15930static const struct pci_device_id tg3_write_reorder_chipsets[] = {
15930 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C) }, 15931 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_FE_GATE_700C) },
15931 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE) }, 15932 { PCI_DEVICE(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_8131_BRIDGE) },
15932 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8385_0) }, 15933 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8385_0) },
@@ -17185,7 +17186,7 @@ static int tg3_do_test_dma(struct tg3 *tp, u32 *buf, dma_addr_t buf_dma,
17185 17186
17186#define TEST_BUFFER_SIZE 0x2000 17187#define TEST_BUFFER_SIZE 0x2000
17187 17188
17188static DEFINE_PCI_DEVICE_TABLE(tg3_dma_wait_state_chipsets) = { 17189static const struct pci_device_id tg3_dma_wait_state_chipsets[] = {
17189 { PCI_DEVICE(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_PCI15) }, 17190 { PCI_DEVICE(PCI_VENDOR_ID_APPLE, PCI_DEVICE_ID_APPLE_UNI_N_PCI15) },
17190 { }, 17191 { },
17191}; 17192};
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c
index 556aab75f490..ff8cae5e2535 100644
--- a/drivers/net/ethernet/brocade/bna/bnad.c
+++ b/drivers/net/ethernet/brocade/bna/bnad.c
@@ -3836,7 +3836,7 @@ bnad_pci_remove(struct pci_dev *pdev)
3836 free_netdev(netdev); 3836 free_netdev(netdev);
3837} 3837}
3838 3838
3839static DEFINE_PCI_DEVICE_TABLE(bnad_pci_id_table) = { 3839static const struct pci_device_id bnad_pci_id_table[] = {
3840 { 3840 {
3841 PCI_DEVICE(PCI_VENDOR_ID_BROCADE, 3841 PCI_DEVICE(PCI_VENDOR_ID_BROCADE,
3842 PCI_DEVICE_ID_BROCADE_CT), 3842 PCI_DEVICE_ID_BROCADE_CT),
diff --git a/drivers/net/ethernet/chelsio/cxgb/subr.c b/drivers/net/ethernet/chelsio/cxgb/subr.c
index 816719314cc8..ea0f8741d7cf 100644
--- a/drivers/net/ethernet/chelsio/cxgb/subr.c
+++ b/drivers/net/ethernet/chelsio/cxgb/subr.c
@@ -522,7 +522,7 @@ static const struct board_info t1_board[] = {
522 522
523}; 523};
524 524
525DEFINE_PCI_DEVICE_TABLE(t1_pci_tbl) = { 525const struct pci_device_id t1_pci_tbl[] = {
526 CH_DEVICE(8, 0, CH_BRD_T110_1CU), 526 CH_DEVICE(8, 0, CH_BRD_T110_1CU),
527 CH_DEVICE(8, 1, CH_BRD_T110_1CU), 527 CH_DEVICE(8, 1, CH_BRD_T110_1CU),
528 CH_DEVICE(7, 0, CH_BRD_N110_1F), 528 CH_DEVICE(7, 0, CH_BRD_N110_1F),
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 5d9cce053cc9..db76f7040455 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -85,7 +85,7 @@ enum {
85#define CH_DEVICE(devid, idx) \ 85#define CH_DEVICE(devid, idx) \
86 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, PCI_ANY_ID, 0, 0, idx } 86 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, PCI_ANY_ID, 0, 0, idx }
87 87
88static DEFINE_PCI_DEVICE_TABLE(cxgb3_pci_tbl) = { 88static const struct pci_device_id cxgb3_pci_tbl[] = {
89 CH_DEVICE(0x20, 0), /* PE9000 */ 89 CH_DEVICE(0x20, 0), /* PE9000 */
90 CH_DEVICE(0x21, 1), /* T302E */ 90 CH_DEVICE(0x21, 1), /* T302E */
91 CH_DEVICE(0x22, 2), /* T310E */ 91 CH_DEVICE(0x22, 2), /* T310E */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index c9b922cc3e67..d57282172ea5 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -50,13 +50,13 @@
50#include "cxgb4_uld.h" 50#include "cxgb4_uld.h"
51 51
52#define T4FW_VERSION_MAJOR 0x01 52#define T4FW_VERSION_MAJOR 0x01
53#define T4FW_VERSION_MINOR 0x09 53#define T4FW_VERSION_MINOR 0x0B
54#define T4FW_VERSION_MICRO 0x17 54#define T4FW_VERSION_MICRO 0x1B
55#define T4FW_VERSION_BUILD 0x00 55#define T4FW_VERSION_BUILD 0x00
56 56
57#define T5FW_VERSION_MAJOR 0x01 57#define T5FW_VERSION_MAJOR 0x01
58#define T5FW_VERSION_MINOR 0x09 58#define T5FW_VERSION_MINOR 0x0B
59#define T5FW_VERSION_MICRO 0x17 59#define T5FW_VERSION_MICRO 0x1B
60#define T5FW_VERSION_BUILD 0x00 60#define T5FW_VERSION_BUILD 0x00
61 61
62#define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__) 62#define CH_WARN(adap, fmt, ...) dev_warn(adap->pdev_dev, fmt, ## __VA_ARGS__)
@@ -522,6 +522,9 @@ struct sge_txq {
522struct sge_eth_txq { /* state for an SGE Ethernet Tx queue */ 522struct sge_eth_txq { /* state for an SGE Ethernet Tx queue */
523 struct sge_txq q; 523 struct sge_txq q;
524 struct netdev_queue *txq; /* associated netdev TX queue */ 524 struct netdev_queue *txq; /* associated netdev TX queue */
525#ifdef CONFIG_CHELSIO_T4_DCB
526 u8 dcb_prio; /* DCB Priority bound to queue */
527#endif
525 unsigned long tso; /* # of TSO requests */ 528 unsigned long tso; /* # of TSO requests */
526 unsigned long tx_cso; /* # of Tx checksum offloads */ 529 unsigned long tx_cso; /* # of Tx checksum offloads */
527 unsigned long vlan_ins; /* # of Tx VLAN insertions */ 530 unsigned long vlan_ins; /* # of Tx VLAN insertions */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
index 0d3a9df5be36..8edf0f5bd679 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.c
@@ -20,6 +20,17 @@
20 20
21#include "cxgb4.h" 21#include "cxgb4.h"
22 22
23/* DCBx version control
24 */
25char *dcb_ver_array[] = {
26 "Unknown",
27 "DCBx-CIN",
28 "DCBx-CEE 1.01",
29 "DCBx-IEEE",
30 "", "", "",
31 "Auto Negotiated"
32};
33
23/* Initialize a port's Data Center Bridging state. Typically used after a 34/* Initialize a port's Data Center Bridging state. Typically used after a
24 * Link Down event. 35 * Link Down event.
25 */ 36 */
@@ -27,25 +38,45 @@ void cxgb4_dcb_state_init(struct net_device *dev)
27{ 38{
28 struct port_info *pi = netdev2pinfo(dev); 39 struct port_info *pi = netdev2pinfo(dev);
29 struct port_dcb_info *dcb = &pi->dcb; 40 struct port_dcb_info *dcb = &pi->dcb;
41 int version_temp = dcb->dcb_version;
30 42
31 memset(dcb, 0, sizeof(struct port_dcb_info)); 43 memset(dcb, 0, sizeof(struct port_dcb_info));
32 dcb->state = CXGB4_DCB_STATE_START; 44 dcb->state = CXGB4_DCB_STATE_START;
45 if (version_temp)
46 dcb->dcb_version = version_temp;
47
48 netdev_dbg(dev, "%s: Initializing DCB state for port[%d]\n",
49 __func__, pi->port_id);
50}
51
52void cxgb4_dcb_version_init(struct net_device *dev)
53{
54 struct port_info *pi = netdev2pinfo(dev);
55 struct port_dcb_info *dcb = &pi->dcb;
56
57 /* Any writes here are only done on kernels that exlicitly need
58 * a specific version, say < 2.6.38 which only support CEE
59 */
60 dcb->dcb_version = FW_PORT_DCB_VER_AUTO;
33} 61}
34 62
35/* Finite State machine for Data Center Bridging. 63/* Finite State machine for Data Center Bridging.
36 */ 64 */
37void cxgb4_dcb_state_fsm(struct net_device *dev, 65void cxgb4_dcb_state_fsm(struct net_device *dev,
38 enum cxgb4_dcb_state_input input) 66 enum cxgb4_dcb_state_input transition_to)
39{ 67{
40 struct port_info *pi = netdev2pinfo(dev); 68 struct port_info *pi = netdev2pinfo(dev);
41 struct port_dcb_info *dcb = &pi->dcb; 69 struct port_dcb_info *dcb = &pi->dcb;
42 struct adapter *adap = pi->adapter; 70 struct adapter *adap = pi->adapter;
71 enum cxgb4_dcb_state current_state = dcb->state;
43 72
44 switch (input) { 73 netdev_dbg(dev, "%s: State change from %d to %d for %s\n",
45 case CXGB4_DCB_INPUT_FW_DISABLED: { 74 __func__, dcb->state, transition_to, dev->name);
46 /* Firmware tells us it's not doing DCB */ 75
47 switch (dcb->state) { 76 switch (current_state) {
48 case CXGB4_DCB_STATE_START: { 77 case CXGB4_DCB_STATE_START: {
78 switch (transition_to) {
79 case CXGB4_DCB_INPUT_FW_DISABLED: {
49 /* we're going to use Host DCB */ 80 /* we're going to use Host DCB */
50 dcb->state = CXGB4_DCB_STATE_HOST; 81 dcb->state = CXGB4_DCB_STATE_HOST;
51 dcb->supported = CXGB4_DCBX_HOST_SUPPORT; 82 dcb->supported = CXGB4_DCBX_HOST_SUPPORT;
@@ -53,48 +84,62 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
53 break; 84 break;
54 } 85 }
55 86
56 case CXGB4_DCB_STATE_HOST: { 87 case CXGB4_DCB_INPUT_FW_ENABLED: {
57 /* we're alreaady in Host DCB mode */ 88 /* we're going to use Firmware DCB */
89 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
90 dcb->supported = CXGB4_DCBX_FW_SUPPORT;
91 break;
92 }
93
94 case CXGB4_DCB_INPUT_FW_INCOMPLETE: {
95 /* expected transition */
96 break;
97 }
98
99 case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
100 dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED;
58 break; 101 break;
59 } 102 }
60 103
61 default: 104 default:
62 goto bad_state_transition; 105 goto bad_state_input;
63 } 106 }
64 break; 107 break;
65 } 108 }
66 109
67 case CXGB4_DCB_INPUT_FW_ENABLED: { 110 case CXGB4_DCB_STATE_FW_INCOMPLETE: {
68 /* Firmware tells us that it is doing DCB */ 111 switch (transition_to) {
69 switch (dcb->state) { 112 case CXGB4_DCB_INPUT_FW_ENABLED: {
70 case CXGB4_DCB_STATE_START: { 113 /* we're alreaady in firmware DCB mode */
71 /* we're going to use Firmware DCB */
72 dcb->state = CXGB4_DCB_STATE_FW_INCOMPLETE;
73 dcb->supported = CXGB4_DCBX_FW_SUPPORT;
74 break; 114 break;
75 } 115 }
76 116
77 case CXGB4_DCB_STATE_FW_INCOMPLETE: 117 case CXGB4_DCB_INPUT_FW_INCOMPLETE: {
78 case CXGB4_DCB_STATE_FW_ALLSYNCED: { 118 /* we're already incomplete */
79 /* we're alreaady in firmware DCB mode */ 119 break;
120 }
121
122 case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
123 dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED;
124 dcb->enabled = 1;
125 linkwatch_fire_event(dev);
80 break; 126 break;
81 } 127 }
82 128
83 default: 129 default:
84 goto bad_state_transition; 130 goto bad_state_input;
85 } 131 }
86 break; 132 break;
87 } 133 }
88 134
89 case CXGB4_DCB_INPUT_FW_INCOMPLETE: { 135 case CXGB4_DCB_STATE_FW_ALLSYNCED: {
90 /* Firmware tells us that its DCB state is incomplete */ 136 switch (transition_to) {
91 switch (dcb->state) { 137 case CXGB4_DCB_INPUT_FW_ENABLED: {
92 case CXGB4_DCB_STATE_FW_INCOMPLETE: { 138 /* we're alreaady in firmware DCB mode */
93 /* we're already incomplete */
94 break; 139 break;
95 } 140 }
96 141
97 case CXGB4_DCB_STATE_FW_ALLSYNCED: { 142 case CXGB4_DCB_INPUT_FW_INCOMPLETE: {
98 /* We were successfully running with firmware DCB but 143 /* We were successfully running with firmware DCB but
99 * now it's telling us that it's in an "incomplete 144 * now it's telling us that it's in an "incomplete
100 * state. We need to reset back to a ground state 145 * state. We need to reset back to a ground state
@@ -107,46 +152,48 @@ void cxgb4_dcb_state_fsm(struct net_device *dev,
107 break; 152 break;
108 } 153 }
109 154
110 default: 155 case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
111 goto bad_state_transition; 156 /* we're already all sync'ed
112 } 157 * this is only applicable for IEEE or
113 break; 158 * when another VI already completed negotiaton
114 } 159 */
115
116 case CXGB4_DCB_INPUT_FW_ALLSYNCED: {
117 /* Firmware tells us that its DCB state is complete */
118 switch (dcb->state) {
119 case CXGB4_DCB_STATE_FW_INCOMPLETE: {
120 dcb->state = CXGB4_DCB_STATE_FW_ALLSYNCED;
121 dcb->enabled = 1; 160 dcb->enabled = 1;
122 linkwatch_fire_event(dev); 161 linkwatch_fire_event(dev);
123 break; 162 break;
124 } 163 }
125 164
126 case CXGB4_DCB_STATE_FW_ALLSYNCED: { 165 default:
127 /* we're already all sync'ed */ 166 goto bad_state_input;
167 }
168 break;
169 }
170
171 case CXGB4_DCB_STATE_HOST: {
172 switch (transition_to) {
173 case CXGB4_DCB_INPUT_FW_DISABLED: {
174 /* we're alreaady in Host DCB mode */
128 break; 175 break;
129 } 176 }
130 177
131 default: 178 default:
132 goto bad_state_transition; 179 goto bad_state_input;
133 } 180 }
134 break; 181 break;
135 } 182 }
136 183
137 default: 184 default:
138 goto bad_state_input; 185 goto bad_state_transition;
139 } 186 }
140 return; 187 return;
141 188
142bad_state_input: 189bad_state_input:
143 dev_err(adap->pdev_dev, "cxgb4_dcb_state_fsm: illegal input symbol %d\n", 190 dev_err(adap->pdev_dev, "cxgb4_dcb_state_fsm: illegal input symbol %d\n",
144 input); 191 transition_to);
145 return; 192 return;
146 193
147bad_state_transition: 194bad_state_transition:
148 dev_err(adap->pdev_dev, "cxgb4_dcb_state_fsm: bad state transition, state = %d, input = %d\n", 195 dev_err(adap->pdev_dev, "cxgb4_dcb_state_fsm: bad state transition, state = %d, input = %d\n",
149 dcb->state, input); 196 current_state, transition_to);
150} 197}
151 198
152/* Handle a DCB/DCBX update message from the firmware. 199/* Handle a DCB/DCBX update message from the firmware.
@@ -160,6 +207,7 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
160 struct port_info *pi = netdev_priv(dev); 207 struct port_info *pi = netdev_priv(dev);
161 struct port_dcb_info *dcb = &pi->dcb; 208 struct port_dcb_info *dcb = &pi->dcb;
162 int dcb_type = pcmd->u.dcb.pgid.type; 209 int dcb_type = pcmd->u.dcb.pgid.type;
210 int dcb_running_version;
163 211
164 /* Handle Firmware DCB Control messages separately since they drive 212 /* Handle Firmware DCB Control messages separately since they drive
165 * our state machine. 213 * our state machine.
@@ -171,6 +219,25 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
171 ? CXGB4_DCB_STATE_FW_ALLSYNCED 219 ? CXGB4_DCB_STATE_FW_ALLSYNCED
172 : CXGB4_DCB_STATE_FW_INCOMPLETE); 220 : CXGB4_DCB_STATE_FW_INCOMPLETE);
173 221
222 if (dcb->dcb_version != FW_PORT_DCB_VER_UNKNOWN) {
223 dcb_running_version = FW_PORT_CMD_DCB_VERSION_GET(
224 be16_to_cpu(
225 pcmd->u.dcb.control.dcb_version_to_app_state));
226 if (dcb_running_version == FW_PORT_DCB_VER_CEE1D01 ||
227 dcb_running_version == FW_PORT_DCB_VER_IEEE) {
228 dcb->dcb_version = dcb_running_version;
229 dev_warn(adap->pdev_dev, "Interface %s is running %s\n",
230 dev->name,
231 dcb_ver_array[dcb->dcb_version]);
232 } else {
233 dev_warn(adap->pdev_dev,
234 "Something screwed up, requested firmware for %s, but firmware returned %s instead\n",
235 dcb_ver_array[dcb->dcb_version],
236 dcb_ver_array[dcb_running_version]);
237 dcb->dcb_version = FW_PORT_DCB_VER_UNKNOWN;
238 }
239 }
240
174 cxgb4_dcb_state_fsm(dev, input); 241 cxgb4_dcb_state_fsm(dev, input);
175 return; 242 return;
176 } 243 }
@@ -199,7 +266,11 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
199 dcb->pg_num_tcs_supported = fwdcb->pgrate.num_tcs_supported; 266 dcb->pg_num_tcs_supported = fwdcb->pgrate.num_tcs_supported;
200 memcpy(dcb->pgrate, &fwdcb->pgrate.pgrate, 267 memcpy(dcb->pgrate, &fwdcb->pgrate.pgrate,
201 sizeof(dcb->pgrate)); 268 sizeof(dcb->pgrate));
269 memcpy(dcb->tsa, &fwdcb->pgrate.tsa,
270 sizeof(dcb->tsa));
202 dcb->msgs |= CXGB4_DCB_FW_PGRATE; 271 dcb->msgs |= CXGB4_DCB_FW_PGRATE;
272 if (dcb->msgs & CXGB4_DCB_FW_PGID)
273 IEEE_FAUX_SYNC(dev, dcb);
203 break; 274 break;
204 275
205 case FW_PORT_DCB_TYPE_PRIORATE: 276 case FW_PORT_DCB_TYPE_PRIORATE:
@@ -212,6 +283,7 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
212 dcb->pfcen = fwdcb->pfc.pfcen; 283 dcb->pfcen = fwdcb->pfc.pfcen;
213 dcb->pfc_num_tcs_supported = fwdcb->pfc.max_pfc_tcs; 284 dcb->pfc_num_tcs_supported = fwdcb->pfc.max_pfc_tcs;
214 dcb->msgs |= CXGB4_DCB_FW_PFC; 285 dcb->msgs |= CXGB4_DCB_FW_PFC;
286 IEEE_FAUX_SYNC(dev, dcb);
215 break; 287 break;
216 288
217 case FW_PORT_DCB_TYPE_APP_ID: { 289 case FW_PORT_DCB_TYPE_APP_ID: {
@@ -220,13 +292,25 @@ void cxgb4_dcb_handle_fw_update(struct adapter *adap,
220 struct app_priority *ap = &dcb->app_priority[idx]; 292 struct app_priority *ap = &dcb->app_priority[idx];
221 293
222 struct dcb_app app = { 294 struct dcb_app app = {
223 .selector = fwap->sel_field,
224 .protocol = be16_to_cpu(fwap->protocolid), 295 .protocol = be16_to_cpu(fwap->protocolid),
225 .priority = fwap->user_prio_map,
226 }; 296 };
227 int err; 297 int err;
228 298
229 err = dcb_setapp(dev, &app); 299 /* Convert from firmware format to relevant format
300 * when using app selector
301 */
302 if (dcb->dcb_version == FW_PORT_DCB_VER_IEEE) {
303 app.selector = (fwap->sel_field + 1);
304 app.priority = ffs(fwap->user_prio_map) - 1;
305 err = dcb_ieee_setapp(dev, &app);
306 IEEE_FAUX_SYNC(dev, dcb);
307 } else {
308 /* Default is CEE */
309 app.selector = !!(fwap->sel_field);
310 app.priority = fwap->user_prio_map;
311 err = dcb_setapp(dev, &app);
312 }
313
230 if (err) 314 if (err)
231 dev_err(adap->pdev_dev, 315 dev_err(adap->pdev_dev,
232 "Failed DCB Set Application Priority: sel=%d, prot=%d, prio=%d, err=%d\n", 316 "Failed DCB Set Application Priority: sel=%d, prot=%d, prio=%d, err=%d\n",
@@ -408,9 +492,10 @@ static void cxgb4_getpgbwgcfg(struct net_device *dev, int pgid, u8 *bw_per,
408 if (err != FW_PORT_DCB_CFG_SUCCESS) { 492 if (err != FW_PORT_DCB_CFG_SUCCESS) {
409 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n", 493 dev_err(adap->pdev_dev, "DCB read PGRATE failed with %d\n",
410 -err); 494 -err);
411 } else { 495 return;
412 *bw_per = pcmd.u.dcb.pgrate.pgrate[pgid];
413 } 496 }
497
498 *bw_per = pcmd.u.dcb.pgrate.pgrate[pgid];
414} 499}
415 500
416static void cxgb4_getpgbwgcfg_tx(struct net_device *dev, int pgid, u8 *bw_per) 501static void cxgb4_getpgbwgcfg_tx(struct net_device *dev, int pgid, u8 *bw_per)
@@ -637,7 +722,8 @@ static int __cxgb4_getapp(struct net_device *dev, u8 app_idtype, u16 app_id,
637 return err; 722 return err;
638 } 723 }
639 if (be16_to_cpu(pcmd.u.dcb.app_priority.protocolid) == app_id) 724 if (be16_to_cpu(pcmd.u.dcb.app_priority.protocolid) == app_id)
640 return pcmd.u.dcb.app_priority.user_prio_map; 725 if (pcmd.u.dcb.app_priority.sel_field == app_idtype)
726 return pcmd.u.dcb.app_priority.user_prio_map;
641 727
642 /* exhausted app list */ 728 /* exhausted app list */
643 if (!pcmd.u.dcb.app_priority.protocolid) 729 if (!pcmd.u.dcb.app_priority.protocolid)
@@ -657,8 +743,8 @@ static int cxgb4_getapp(struct net_device *dev, u8 app_idtype, u16 app_id)
657 743
658/* Write a new Application User Priority Map for the specified Application ID 744/* Write a new Application User Priority Map for the specified Application ID
659 */ 745 */
660static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id, 746static int __cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
661 u8 app_prio) 747 u8 app_prio)
662{ 748{
663 struct fw_port_cmd pcmd; 749 struct fw_port_cmd pcmd;
664 struct port_info *pi = netdev2pinfo(dev); 750 struct port_info *pi = netdev2pinfo(dev);
@@ -673,10 +759,6 @@ static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
673 if (!netif_carrier_ok(dev)) 759 if (!netif_carrier_ok(dev))
674 return -ENOLINK; 760 return -ENOLINK;
675 761
676 if (app_idtype != DCB_APP_IDTYPE_ETHTYPE &&
677 app_idtype != DCB_APP_IDTYPE_PORTNUM)
678 return -EINVAL;
679
680 for (i = 0; i < CXGB4_MAX_DCBX_APP_SUPPORTED; i++) { 762 for (i = 0; i < CXGB4_MAX_DCBX_APP_SUPPORTED; i++) {
681 INIT_PORT_DCB_READ_LOCAL_CMD(pcmd, pi->port_id); 763 INIT_PORT_DCB_READ_LOCAL_CMD(pcmd, pi->port_id);
682 pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID; 764 pcmd.u.dcb.app_priority.type = FW_PORT_DCB_TYPE_APP_ID;
@@ -725,6 +807,30 @@ static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
725 return 0; 807 return 0;
726} 808}
727 809
810/* Priority for CEE inside dcb_app is bitmask, with 0 being an invalid value */
811static int cxgb4_setapp(struct net_device *dev, u8 app_idtype, u16 app_id,
812 u8 app_prio)
813{
814 int ret;
815 struct dcb_app app = {
816 .selector = app_idtype,
817 .protocol = app_id,
818 .priority = app_prio,
819 };
820
821 if (app_idtype != DCB_APP_IDTYPE_ETHTYPE &&
822 app_idtype != DCB_APP_IDTYPE_PORTNUM)
823 return -EINVAL;
824
825 /* Convert app_idtype to a format that firmware understands */
826 ret = __cxgb4_setapp(dev, app_idtype == DCB_APP_IDTYPE_ETHTYPE ?
827 app_idtype : 3, app_id, app_prio);
828 if (ret)
829 return ret;
830
831 return dcb_setapp(dev, &app);
832}
833
728/* Return whether IEEE Data Center Bridging has been negotiated. 834/* Return whether IEEE Data Center Bridging has been negotiated.
729 */ 835 */
730static inline int cxgb4_ieee_negotiation_complete(struct net_device *dev) 836static inline int cxgb4_ieee_negotiation_complete(struct net_device *dev)
@@ -738,6 +844,7 @@ static inline int cxgb4_ieee_negotiation_complete(struct net_device *dev)
738 844
739/* Fill in the Application User Priority Map associated with the 845/* Fill in the Application User Priority Map associated with the
740 * specified Application. 846 * specified Application.
847 * Priority for IEEE dcb_app is an integer, with 0 being a valid value
741 */ 848 */
742static int cxgb4_ieee_getapp(struct net_device *dev, struct dcb_app *app) 849static int cxgb4_ieee_getapp(struct net_device *dev, struct dcb_app *app)
743{ 850{
@@ -748,28 +855,39 @@ static int cxgb4_ieee_getapp(struct net_device *dev, struct dcb_app *app)
748 if (!(app->selector && app->protocol)) 855 if (!(app->selector && app->protocol))
749 return -EINVAL; 856 return -EINVAL;
750 857
751 prio = dcb_getapp(dev, app); 858 /* Try querying firmware first, use firmware format */
752 if (prio == 0) { 859 prio = __cxgb4_getapp(dev, app->selector - 1, app->protocol, 0);
753 /* If app doesn't exist in dcb_app table, try firmware 860
754 * directly. 861 if (prio < 0)
755 */ 862 prio = dcb_ieee_getapp_mask(dev, app);
756 prio = __cxgb4_getapp(dev, app->selector, app->protocol, 0);
757 }
758 863
759 app->priority = prio; 864 app->priority = ffs(prio) - 1;
760 return 0; 865 return 0;
761} 866}
762 867
763/* Write a new Application User Priority Map for the specified App id. */ 868/* Write a new Application User Priority Map for the specified Application ID.
869 * Priority for IEEE dcb_app is an integer, with 0 being a valid value
870 */
764static int cxgb4_ieee_setapp(struct net_device *dev, struct dcb_app *app) 871static int cxgb4_ieee_setapp(struct net_device *dev, struct dcb_app *app)
765{ 872{
873 int ret;
874
766 if (!cxgb4_ieee_negotiation_complete(dev)) 875 if (!cxgb4_ieee_negotiation_complete(dev))
767 return -EINVAL; 876 return -EINVAL;
768 if (!(app->selector && app->protocol && app->priority)) 877 if (!(app->selector && app->protocol))
878 return -EINVAL;
879
880 if (!(app->selector > IEEE_8021QAZ_APP_SEL_ETHERTYPE &&
881 app->selector < IEEE_8021QAZ_APP_SEL_ANY))
769 return -EINVAL; 882 return -EINVAL;
770 883
771 cxgb4_setapp(dev, app->selector, app->protocol, app->priority); 884 /* change selector to a format that firmware understands */
772 return dcb_setapp(dev, app); 885 ret = __cxgb4_setapp(dev, app->selector - 1, app->protocol,
886 (1 << app->priority));
887 if (ret)
888 return ret;
889
890 return dcb_ieee_setapp(dev, app);
773} 891}
774 892
775/* Return our DCBX parameters. 893/* Return our DCBX parameters.
@@ -794,8 +912,9 @@ static u8 cxgb4_setdcbx(struct net_device *dev, u8 dcb_request)
794 != dcb_request) 912 != dcb_request)
795 return 1; 913 return 1;
796 914
797 /* Can't set DCBX capabilities if DCBX isn't enabled. */ 915 /* Can't enable DCB if we haven't successfully negotiated it.
798 if (!pi->dcb.state) 916 */
917 if (pi->dcb.state != CXGB4_DCB_STATE_FW_ALLSYNCED)
799 return 1; 918 return 1;
800 919
801 /* There's currently no mechanism to allow for the firmware DCBX 920 /* There's currently no mechanism to allow for the firmware DCBX
@@ -874,7 +993,8 @@ static int cxgb4_getpeerapp_tbl(struct net_device *dev, struct dcb_app *table)
874 table[i].selector = pcmd.u.dcb.app_priority.sel_field; 993 table[i].selector = pcmd.u.dcb.app_priority.sel_field;
875 table[i].protocol = 994 table[i].protocol =
876 be16_to_cpu(pcmd.u.dcb.app_priority.protocolid); 995 be16_to_cpu(pcmd.u.dcb.app_priority.protocolid);
877 table[i].priority = pcmd.u.dcb.app_priority.user_prio_map; 996 table[i].priority =
997 ffs(pcmd.u.dcb.app_priority.user_prio_map) - 1;
878 } 998 }
879 return err; 999 return err;
880} 1000}
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h
index 1ec1d834e257..2a6aa88984f4 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_dcb.h
@@ -63,6 +63,13 @@
63#define INIT_PORT_DCB_WRITE_CMD(__pcmd, __port) \ 63#define INIT_PORT_DCB_WRITE_CMD(__pcmd, __port) \
64 INIT_PORT_DCB_CMD(__pcmd, __port, EXEC, FW_PORT_ACTION_L2_DCB_CFG) 64 INIT_PORT_DCB_CMD(__pcmd, __port, EXEC, FW_PORT_ACTION_L2_DCB_CFG)
65 65
66#define IEEE_FAUX_SYNC(__dev, __dcb) \
67 do { \
68 if ((__dcb)->dcb_version == FW_PORT_DCB_VER_IEEE) \
69 cxgb4_dcb_state_fsm((__dev), \
70 CXGB4_DCB_STATE_FW_ALLSYNCED); \
71 } while (0)
72
66/* States we can be in for a port's Data Center Bridging. 73/* States we can be in for a port's Data Center Bridging.
67 */ 74 */
68enum cxgb4_dcb_state { 75enum cxgb4_dcb_state {
@@ -108,11 +115,13 @@ struct port_dcb_info {
108 * Native Endian format). 115 * Native Endian format).
109 */ 116 */
110 u32 pgid; /* Priority Group[0..7] */ 117 u32 pgid; /* Priority Group[0..7] */
118 u8 dcb_version; /* Running DCBx version */
111 u8 pfcen; /* Priority Flow Control[0..7] */ 119 u8 pfcen; /* Priority Flow Control[0..7] */
112 u8 pg_num_tcs_supported; /* max PG Traffic Classes */ 120 u8 pg_num_tcs_supported; /* max PG Traffic Classes */
113 u8 pfc_num_tcs_supported; /* max PFC Traffic Classes */ 121 u8 pfc_num_tcs_supported; /* max PFC Traffic Classes */
114 u8 pgrate[8]; /* Priority Group Rate[0..7] */ 122 u8 pgrate[8]; /* Priority Group Rate[0..7] */
115 u8 priorate[8]; /* Priority Rate[0..7] */ 123 u8 priorate[8]; /* Priority Rate[0..7] */
124 u8 tsa[8]; /* TSA Algorithm[0..7] */
116 struct app_priority { /* Application Information */ 125 struct app_priority { /* Application Information */
117 u8 user_prio_map; /* Priority Map bitfield */ 126 u8 user_prio_map; /* Priority Map bitfield */
118 u8 sel_field; /* Protocol ID interpretation */ 127 u8 sel_field; /* Protocol ID interpretation */
@@ -121,6 +130,7 @@ struct port_dcb_info {
121}; 130};
122 131
123void cxgb4_dcb_state_init(struct net_device *); 132void cxgb4_dcb_state_init(struct net_device *);
133void cxgb4_dcb_version_init(struct net_device *);
124void cxgb4_dcb_state_fsm(struct net_device *, enum cxgb4_dcb_state_input); 134void cxgb4_dcb_state_fsm(struct net_device *, enum cxgb4_dcb_state_input);
125void cxgb4_dcb_handle_fw_update(struct adapter *, const struct fw_port_cmd *); 135void cxgb4_dcb_handle_fw_update(struct adapter *, const struct fw_port_cmd *);
126void cxgb4_dcb_set_caps(struct adapter *, const struct fw_port_cmd *); 136void cxgb4_dcb_set_caps(struct adapter *, const struct fw_port_cmd *);
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index 4247356c16ff..1afee70ce856 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -212,7 +212,7 @@ struct filter_entry {
212 212
213#define CH_DEVICE(devid, data) { PCI_VDEVICE(CHELSIO, devid), (data) } 213#define CH_DEVICE(devid, data) { PCI_VDEVICE(CHELSIO, devid), (data) }
214 214
215static DEFINE_PCI_DEVICE_TABLE(cxgb4_pci_tbl) = { 215static const struct pci_device_id cxgb4_pci_tbl[] = {
216 CH_DEVICE(0xa000, 0), /* PE10K */ 216 CH_DEVICE(0xa000, 0), /* PE10K */
217 CH_DEVICE(0x4001, -1), 217 CH_DEVICE(0x4001, -1),
218 CH_DEVICE(0x4002, -1), 218 CH_DEVICE(0x4002, -1),
@@ -522,6 +522,8 @@ static void dcb_tx_queue_prio_enable(struct net_device *dev, int enable)
522 dev_err(adap->pdev_dev, 522 dev_err(adap->pdev_dev,
523 "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n", 523 "Can't %s DCB Priority on port %d, TX Queue %d: err=%d\n",
524 enable ? "set" : "unset", pi->port_id, i, -err); 524 enable ? "set" : "unset", pi->port_id, i, -err);
525 else
526 txq->dcb_prio = value;
525 } 527 }
526} 528}
527#endif /* CONFIG_CHELSIO_T4_DCB */ 529#endif /* CONFIG_CHELSIO_T4_DCB */
@@ -6527,11 +6529,9 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6527 6529
6528 /* We control everything through one PF */ 6530 /* We control everything through one PF */
6529 func = SOURCEPF_GET(readl(adapter->regs + PL_WHOAMI)); 6531 func = SOURCEPF_GET(readl(adapter->regs + PL_WHOAMI));
6530 if ((pdev->device == 0xa000 && func != 0) || 6532 if (func != ent->driver_data) {
6531 func != ent->driver_data) {
6532 pci_save_state(pdev); /* to restore SR-IOV later */ 6533 pci_save_state(pdev); /* to restore SR-IOV later */
6533 err = 0; 6534 goto sriov;
6534 goto out_unmap_bar0;
6535 } 6535 }
6536 6536
6537 adapter->pdev = pdev; 6537 adapter->pdev = pdev;
@@ -6697,6 +6697,7 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
6697 if (is_offload(adapter)) 6697 if (is_offload(adapter))
6698 attach_ulds(adapter); 6698 attach_ulds(adapter);
6699 6699
6700sriov:
6700#ifdef CONFIG_PCI_IOV 6701#ifdef CONFIG_PCI_IOV
6701 if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0) 6702 if (func < ARRAY_SIZE(num_vf) && num_vf[func] > 0)
6702 if (pci_enable_sriov(pdev, num_vf[func]) == 0) 6703 if (pci_enable_sriov(pdev, num_vf[func]) == 0)
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index ff709e3b3e7e..0549170d7e2e 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -1629,6 +1629,14 @@ enum fw_port_l2cfg_ctlbf {
1629 FW_PORT_L2_CTLBF_TXIPG = 0x20 1629 FW_PORT_L2_CTLBF_TXIPG = 0x20
1630}; 1630};
1631 1631
1632enum fw_port_dcb_versions {
1633 FW_PORT_DCB_VER_UNKNOWN,
1634 FW_PORT_DCB_VER_CEE1D0,
1635 FW_PORT_DCB_VER_CEE1D01,
1636 FW_PORT_DCB_VER_IEEE,
1637 FW_PORT_DCB_VER_AUTO = 7
1638};
1639
1632enum fw_port_dcb_cfg { 1640enum fw_port_dcb_cfg {
1633 FW_PORT_DCB_CFG_PG = 0x01, 1641 FW_PORT_DCB_CFG_PG = 0x01,
1634 FW_PORT_DCB_CFG_PFC = 0x02, 1642 FW_PORT_DCB_CFG_PFC = 0x02,
@@ -1709,6 +1717,7 @@ struct fw_port_cmd {
1709 __u8 r10_lo[5]; 1717 __u8 r10_lo[5];
1710 __u8 num_tcs_supported; 1718 __u8 num_tcs_supported;
1711 __u8 pgrate[8]; 1719 __u8 pgrate[8];
1720 __u8 tsa[8];
1712 } pgrate; 1721 } pgrate;
1713 struct fw_port_dcb_priorate { 1722 struct fw_port_dcb_priorate {
1714 __u8 type; 1723 __u8 type;
@@ -1735,7 +1744,7 @@ struct fw_port_cmd {
1735 struct fw_port_dcb_control { 1744 struct fw_port_dcb_control {
1736 __u8 type; 1745 __u8 type;
1737 __u8 all_syncd_pkd; 1746 __u8 all_syncd_pkd;
1738 __be16 pfc_state_to_app_state; 1747 __be16 dcb_version_to_app_state;
1739 __be32 r11; 1748 __be32 r11;
1740 __be64 r12; 1749 __be64 r12;
1741 } control; 1750 } control;
@@ -1778,6 +1787,7 @@ struct fw_port_cmd {
1778#define FW_PORT_CMD_DCBXDIS (1U << 7) 1787#define FW_PORT_CMD_DCBXDIS (1U << 7)
1779#define FW_PORT_CMD_APPLY (1U << 7) 1788#define FW_PORT_CMD_APPLY (1U << 7)
1780#define FW_PORT_CMD_ALL_SYNCD (1U << 7) 1789#define FW_PORT_CMD_ALL_SYNCD (1U << 7)
1790#define FW_PORT_CMD_DCB_VERSION_GET(x) (((x) >> 8) & 0xf)
1781 1791
1782#define FW_PORT_CMD_PPPEN(x) ((x) << 31) 1792#define FW_PORT_CMD_PPPEN(x) ((x) << 31)
1783#define FW_PORT_CMD_TPSRC(x) ((x) << 28) 1793#define FW_PORT_CMD_TPSRC(x) ((x) << 28)
diff --git a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
index d8d28e82ade1..2102a4c91737 100644
--- a/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4vf/cxgb4vf_main.c
@@ -2910,7 +2910,7 @@ static void cxgb4vf_pci_shutdown(struct pci_dev *pdev)
2910#define CH_DEVICE(devid, idx) \ 2910#define CH_DEVICE(devid, idx) \
2911 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, PCI_ANY_ID, 0, 0, idx } 2911 { PCI_VENDOR_ID_CHELSIO, devid, PCI_ANY_ID, PCI_ANY_ID, 0, 0, idx }
2912 2912
2913static DEFINE_PCI_DEVICE_TABLE(cxgb4vf_pci_tbl) = { 2913static const struct pci_device_id cxgb4vf_pci_tbl[] = {
2914 CH_DEVICE(0xb000, 0), /* PE10K FPGA */ 2914 CH_DEVICE(0xb000, 0), /* PE10K FPGA */
2915 CH_DEVICE(0x4800, 0), /* T440-dbg */ 2915 CH_DEVICE(0x4800, 0), /* T440-dbg */
2916 CH_DEVICE(0x4801, 0), /* T420-cr */ 2916 CH_DEVICE(0x4801, 0), /* T420-cr */
diff --git a/drivers/net/ethernet/cisco/enic/enic_main.c b/drivers/net/ethernet/cisco/enic/enic_main.c
index 9348febc0743..c8832bc1c5f7 100644
--- a/drivers/net/ethernet/cisco/enic/enic_main.c
+++ b/drivers/net/ethernet/cisco/enic/enic_main.c
@@ -67,7 +67,7 @@
67#define PCI_DEVICE_ID_CISCO_VIC_ENET_VF 0x0071 /* enet SRIOV VF */ 67#define PCI_DEVICE_ID_CISCO_VIC_ENET_VF 0x0071 /* enet SRIOV VF */
68 68
69/* Supported devices */ 69/* Supported devices */
70static DEFINE_PCI_DEVICE_TABLE(enic_id_table) = { 70static const struct pci_device_id enic_id_table[] = {
71 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET) }, 71 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET) },
72 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_DYN) }, 72 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_DYN) },
73 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_VF) }, 73 { PCI_VDEVICE(CISCO, PCI_DEVICE_ID_CISCO_VIC_ENET_VF) },
diff --git a/drivers/net/ethernet/cisco/enic/vnic_dev.c b/drivers/net/ethernet/cisco/enic/vnic_dev.c
index 5abc496bcf29..37472ce4fac3 100644
--- a/drivers/net/ethernet/cisco/enic/vnic_dev.c
+++ b/drivers/net/ethernet/cisco/enic/vnic_dev.c
@@ -432,14 +432,12 @@ int vnic_dev_fw_info(struct vnic_dev *vdev,
432 int err = 0; 432 int err = 0;
433 433
434 if (!vdev->fw_info) { 434 if (!vdev->fw_info) {
435 vdev->fw_info = pci_alloc_consistent(vdev->pdev, 435 vdev->fw_info = pci_zalloc_consistent(vdev->pdev,
436 sizeof(struct vnic_devcmd_fw_info), 436 sizeof(struct vnic_devcmd_fw_info),
437 &vdev->fw_info_pa); 437 &vdev->fw_info_pa);
438 if (!vdev->fw_info) 438 if (!vdev->fw_info)
439 return -ENOMEM; 439 return -ENOMEM;
440 440
441 memset(vdev->fw_info, 0, sizeof(struct vnic_devcmd_fw_info));
442
443 a0 = vdev->fw_info_pa; 441 a0 = vdev->fw_info_pa;
444 a1 = sizeof(struct vnic_devcmd_fw_info); 442 a1 = sizeof(struct vnic_devcmd_fw_info);
445 443
diff --git a/drivers/net/ethernet/davicom/dm9000.c b/drivers/net/ethernet/davicom/dm9000.c
index 23084fb2090e..9b33057a9477 100644
--- a/drivers/net/ethernet/davicom/dm9000.c
+++ b/drivers/net/ethernet/davicom/dm9000.c
@@ -93,7 +93,7 @@ enum dm9000_type {
93}; 93};
94 94
95/* Structure/enum declaration ------------------------------- */ 95/* Structure/enum declaration ------------------------------- */
96typedef struct board_info { 96struct board_info {
97 97
98 void __iomem *io_addr; /* Register I/O base address */ 98 void __iomem *io_addr; /* Register I/O base address */
99 void __iomem *io_data; /* Data I/O address */ 99 void __iomem *io_data; /* Data I/O address */
@@ -141,7 +141,7 @@ typedef struct board_info {
141 u32 wake_state; 141 u32 wake_state;
142 142
143 int ip_summed; 143 int ip_summed;
144} board_info_t; 144};
145 145
146/* debug code */ 146/* debug code */
147 147
@@ -151,7 +151,7 @@ typedef struct board_info {
151 } \ 151 } \
152} while (0) 152} while (0)
153 153
154static inline board_info_t *to_dm9000_board(struct net_device *dev) 154static inline struct board_info *to_dm9000_board(struct net_device *dev)
155{ 155{
156 return netdev_priv(dev); 156 return netdev_priv(dev);
157} 157}
@@ -162,7 +162,7 @@ static inline board_info_t *to_dm9000_board(struct net_device *dev)
162 * Read a byte from I/O port 162 * Read a byte from I/O port
163 */ 163 */
164static u8 164static u8
165ior(board_info_t *db, int reg) 165ior(struct board_info *db, int reg)
166{ 166{
167 writeb(reg, db->io_addr); 167 writeb(reg, db->io_addr);
168 return readb(db->io_data); 168 return readb(db->io_data);
@@ -173,14 +173,14 @@ ior(board_info_t *db, int reg)
173 */ 173 */
174 174
175static void 175static void
176iow(board_info_t *db, int reg, int value) 176iow(struct board_info *db, int reg, int value)
177{ 177{
178 writeb(reg, db->io_addr); 178 writeb(reg, db->io_addr);
179 writeb(value, db->io_data); 179 writeb(value, db->io_data);
180} 180}
181 181
182static void 182static void
183dm9000_reset(board_info_t *db) 183dm9000_reset(struct board_info *db)
184{ 184{
185 dev_dbg(db->dev, "resetting device\n"); 185 dev_dbg(db->dev, "resetting device\n");
186 186
@@ -272,7 +272,7 @@ static void dm9000_dumpblk_32bit(void __iomem *reg, int count)
272 * Sleep, either by using msleep() or if we are suspending, then 272 * Sleep, either by using msleep() or if we are suspending, then
273 * use mdelay() to sleep. 273 * use mdelay() to sleep.
274 */ 274 */
275static void dm9000_msleep(board_info_t *db, unsigned int ms) 275static void dm9000_msleep(struct board_info *db, unsigned int ms)
276{ 276{
277 if (db->in_suspend || db->in_timeout) 277 if (db->in_suspend || db->in_timeout)
278 mdelay(ms); 278 mdelay(ms);
@@ -284,7 +284,7 @@ static void dm9000_msleep(board_info_t *db, unsigned int ms)
284static int 284static int
285dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg) 285dm9000_phy_read(struct net_device *dev, int phy_reg_unused, int reg)
286{ 286{
287 board_info_t *db = netdev_priv(dev); 287 struct board_info *db = netdev_priv(dev);
288 unsigned long flags; 288 unsigned long flags;
289 unsigned int reg_save; 289 unsigned int reg_save;
290 int ret; 290 int ret;
@@ -330,7 +330,7 @@ static void
330dm9000_phy_write(struct net_device *dev, 330dm9000_phy_write(struct net_device *dev,
331 int phyaddr_unused, int reg, int value) 331 int phyaddr_unused, int reg, int value)
332{ 332{
333 board_info_t *db = netdev_priv(dev); 333 struct board_info *db = netdev_priv(dev);
334 unsigned long flags; 334 unsigned long flags;
335 unsigned long reg_save; 335 unsigned long reg_save;
336 336
@@ -408,7 +408,7 @@ static void dm9000_set_io(struct board_info *db, int byte_width)
408 } 408 }
409} 409}
410 410
411static void dm9000_schedule_poll(board_info_t *db) 411static void dm9000_schedule_poll(struct board_info *db)
412{ 412{
413 if (db->type == TYPE_DM9000E) 413 if (db->type == TYPE_DM9000E)
414 schedule_delayed_work(&db->phy_poll, HZ * 2); 414 schedule_delayed_work(&db->phy_poll, HZ * 2);
@@ -416,7 +416,7 @@ static void dm9000_schedule_poll(board_info_t *db)
416 416
417static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd) 417static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
418{ 418{
419 board_info_t *dm = to_dm9000_board(dev); 419 struct board_info *dm = to_dm9000_board(dev);
420 420
421 if (!netif_running(dev)) 421 if (!netif_running(dev))
422 return -EINVAL; 422 return -EINVAL;
@@ -425,7 +425,7 @@ static int dm9000_ioctl(struct net_device *dev, struct ifreq *req, int cmd)
425} 425}
426 426
427static unsigned int 427static unsigned int
428dm9000_read_locked(board_info_t *db, int reg) 428dm9000_read_locked(struct board_info *db, int reg)
429{ 429{
430 unsigned long flags; 430 unsigned long flags;
431 unsigned int ret; 431 unsigned int ret;
@@ -437,7 +437,7 @@ dm9000_read_locked(board_info_t *db, int reg)
437 return ret; 437 return ret;
438} 438}
439 439
440static int dm9000_wait_eeprom(board_info_t *db) 440static int dm9000_wait_eeprom(struct board_info *db)
441{ 441{
442 unsigned int status; 442 unsigned int status;
443 int timeout = 8; /* wait max 8msec */ 443 int timeout = 8; /* wait max 8msec */
@@ -474,7 +474,7 @@ static int dm9000_wait_eeprom(board_info_t *db)
474 * Read a word data from EEPROM 474 * Read a word data from EEPROM
475 */ 475 */
476static void 476static void
477dm9000_read_eeprom(board_info_t *db, int offset, u8 *to) 477dm9000_read_eeprom(struct board_info *db, int offset, u8 *to)
478{ 478{
479 unsigned long flags; 479 unsigned long flags;
480 480
@@ -514,7 +514,7 @@ dm9000_read_eeprom(board_info_t *db, int offset, u8 *to)
514 * Write a word data to SROM 514 * Write a word data to SROM
515 */ 515 */
516static void 516static void
517dm9000_write_eeprom(board_info_t *db, int offset, u8 *data) 517dm9000_write_eeprom(struct board_info *db, int offset, u8 *data)
518{ 518{
519 unsigned long flags; 519 unsigned long flags;
520 520
@@ -546,7 +546,7 @@ dm9000_write_eeprom(board_info_t *db, int offset, u8 *data)
546static void dm9000_get_drvinfo(struct net_device *dev, 546static void dm9000_get_drvinfo(struct net_device *dev,
547 struct ethtool_drvinfo *info) 547 struct ethtool_drvinfo *info)
548{ 548{
549 board_info_t *dm = to_dm9000_board(dev); 549 struct board_info *dm = to_dm9000_board(dev);
550 550
551 strlcpy(info->driver, CARDNAME, sizeof(info->driver)); 551 strlcpy(info->driver, CARDNAME, sizeof(info->driver));
552 strlcpy(info->version, DRV_VERSION, sizeof(info->version)); 552 strlcpy(info->version, DRV_VERSION, sizeof(info->version));
@@ -556,21 +556,21 @@ static void dm9000_get_drvinfo(struct net_device *dev,
556 556
557static u32 dm9000_get_msglevel(struct net_device *dev) 557static u32 dm9000_get_msglevel(struct net_device *dev)
558{ 558{
559 board_info_t *dm = to_dm9000_board(dev); 559 struct board_info *dm = to_dm9000_board(dev);
560 560
561 return dm->msg_enable; 561 return dm->msg_enable;
562} 562}
563 563
564static void dm9000_set_msglevel(struct net_device *dev, u32 value) 564static void dm9000_set_msglevel(struct net_device *dev, u32 value)
565{ 565{
566 board_info_t *dm = to_dm9000_board(dev); 566 struct board_info *dm = to_dm9000_board(dev);
567 567
568 dm->msg_enable = value; 568 dm->msg_enable = value;
569} 569}
570 570
571static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd) 571static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
572{ 572{
573 board_info_t *dm = to_dm9000_board(dev); 573 struct board_info *dm = to_dm9000_board(dev);
574 574
575 mii_ethtool_gset(&dm->mii, cmd); 575 mii_ethtool_gset(&dm->mii, cmd);
576 return 0; 576 return 0;
@@ -578,21 +578,21 @@ static int dm9000_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
578 578
579static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd) 579static int dm9000_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
580{ 580{
581 board_info_t *dm = to_dm9000_board(dev); 581 struct board_info *dm = to_dm9000_board(dev);
582 582
583 return mii_ethtool_sset(&dm->mii, cmd); 583 return mii_ethtool_sset(&dm->mii, cmd);
584} 584}
585 585
586static int dm9000_nway_reset(struct net_device *dev) 586static int dm9000_nway_reset(struct net_device *dev)
587{ 587{
588 board_info_t *dm = to_dm9000_board(dev); 588 struct board_info *dm = to_dm9000_board(dev);
589 return mii_nway_restart(&dm->mii); 589 return mii_nway_restart(&dm->mii);
590} 590}
591 591
592static int dm9000_set_features(struct net_device *dev, 592static int dm9000_set_features(struct net_device *dev,
593 netdev_features_t features) 593 netdev_features_t features)
594{ 594{
595 board_info_t *dm = to_dm9000_board(dev); 595 struct board_info *dm = to_dm9000_board(dev);
596 netdev_features_t changed = dev->features ^ features; 596 netdev_features_t changed = dev->features ^ features;
597 unsigned long flags; 597 unsigned long flags;
598 598
@@ -608,7 +608,7 @@ static int dm9000_set_features(struct net_device *dev,
608 608
609static u32 dm9000_get_link(struct net_device *dev) 609static u32 dm9000_get_link(struct net_device *dev)
610{ 610{
611 board_info_t *dm = to_dm9000_board(dev); 611 struct board_info *dm = to_dm9000_board(dev);
612 u32 ret; 612 u32 ret;
613 613
614 if (dm->flags & DM9000_PLATF_EXT_PHY) 614 if (dm->flags & DM9000_PLATF_EXT_PHY)
@@ -629,7 +629,7 @@ static int dm9000_get_eeprom_len(struct net_device *dev)
629static int dm9000_get_eeprom(struct net_device *dev, 629static int dm9000_get_eeprom(struct net_device *dev,
630 struct ethtool_eeprom *ee, u8 *data) 630 struct ethtool_eeprom *ee, u8 *data)
631{ 631{
632 board_info_t *dm = to_dm9000_board(dev); 632 struct board_info *dm = to_dm9000_board(dev);
633 int offset = ee->offset; 633 int offset = ee->offset;
634 int len = ee->len; 634 int len = ee->len;
635 int i; 635 int i;
@@ -653,7 +653,7 @@ static int dm9000_get_eeprom(struct net_device *dev,
653static int dm9000_set_eeprom(struct net_device *dev, 653static int dm9000_set_eeprom(struct net_device *dev,
654 struct ethtool_eeprom *ee, u8 *data) 654 struct ethtool_eeprom *ee, u8 *data)
655{ 655{
656 board_info_t *dm = to_dm9000_board(dev); 656 struct board_info *dm = to_dm9000_board(dev);
657 int offset = ee->offset; 657 int offset = ee->offset;
658 int len = ee->len; 658 int len = ee->len;
659 int done; 659 int done;
@@ -691,7 +691,7 @@ static int dm9000_set_eeprom(struct net_device *dev,
691 691
692static void dm9000_get_wol(struct net_device *dev, struct ethtool_wolinfo *w) 692static void dm9000_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
693{ 693{
694 board_info_t *dm = to_dm9000_board(dev); 694 struct board_info *dm = to_dm9000_board(dev);
695 695
696 memset(w, 0, sizeof(struct ethtool_wolinfo)); 696 memset(w, 0, sizeof(struct ethtool_wolinfo));
697 697
@@ -702,7 +702,7 @@ static void dm9000_get_wol(struct net_device *dev, struct ethtool_wolinfo *w)
702 702
703static int dm9000_set_wol(struct net_device *dev, struct ethtool_wolinfo *w) 703static int dm9000_set_wol(struct net_device *dev, struct ethtool_wolinfo *w)
704{ 704{
705 board_info_t *dm = to_dm9000_board(dev); 705 struct board_info *dm = to_dm9000_board(dev);
706 unsigned long flags; 706 unsigned long flags;
707 u32 opts = w->wolopts; 707 u32 opts = w->wolopts;
708 u32 wcr = 0; 708 u32 wcr = 0;
@@ -752,7 +752,7 @@ static const struct ethtool_ops dm9000_ethtool_ops = {
752 .set_eeprom = dm9000_set_eeprom, 752 .set_eeprom = dm9000_set_eeprom,
753}; 753};
754 754
755static void dm9000_show_carrier(board_info_t *db, 755static void dm9000_show_carrier(struct board_info *db,
756 unsigned carrier, unsigned nsr) 756 unsigned carrier, unsigned nsr)
757{ 757{
758 int lpa; 758 int lpa;
@@ -775,7 +775,7 @@ static void
775dm9000_poll_work(struct work_struct *w) 775dm9000_poll_work(struct work_struct *w)
776{ 776{
777 struct delayed_work *dw = to_delayed_work(w); 777 struct delayed_work *dw = to_delayed_work(w);
778 board_info_t *db = container_of(dw, board_info_t, phy_poll); 778 struct board_info *db = container_of(dw, struct board_info, phy_poll);
779 struct net_device *ndev = db->ndev; 779 struct net_device *ndev = db->ndev;
780 780
781 if (db->flags & DM9000_PLATF_SIMPLE_PHY && 781 if (db->flags & DM9000_PLATF_SIMPLE_PHY &&
@@ -843,7 +843,7 @@ static unsigned char dm9000_type_to_char(enum dm9000_type type)
843static void 843static void
844dm9000_hash_table_unlocked(struct net_device *dev) 844dm9000_hash_table_unlocked(struct net_device *dev)
845{ 845{
846 board_info_t *db = netdev_priv(dev); 846 struct board_info *db = netdev_priv(dev);
847 struct netdev_hw_addr *ha; 847 struct netdev_hw_addr *ha;
848 int i, oft; 848 int i, oft;
849 u32 hash_val; 849 u32 hash_val;
@@ -879,7 +879,7 @@ dm9000_hash_table_unlocked(struct net_device *dev)
879static void 879static void
880dm9000_hash_table(struct net_device *dev) 880dm9000_hash_table(struct net_device *dev)
881{ 881{
882 board_info_t *db = netdev_priv(dev); 882 struct board_info *db = netdev_priv(dev);
883 unsigned long flags; 883 unsigned long flags;
884 884
885 spin_lock_irqsave(&db->lock, flags); 885 spin_lock_irqsave(&db->lock, flags);
@@ -888,13 +888,13 @@ dm9000_hash_table(struct net_device *dev)
888} 888}
889 889
890static void 890static void
891dm9000_mask_interrupts(board_info_t *db) 891dm9000_mask_interrupts(struct board_info *db)
892{ 892{
893 iow(db, DM9000_IMR, IMR_PAR); 893 iow(db, DM9000_IMR, IMR_PAR);
894} 894}
895 895
896static void 896static void
897dm9000_unmask_interrupts(board_info_t *db) 897dm9000_unmask_interrupts(struct board_info *db)
898{ 898{
899 iow(db, DM9000_IMR, db->imr_all); 899 iow(db, DM9000_IMR, db->imr_all);
900} 900}
@@ -905,7 +905,7 @@ dm9000_unmask_interrupts(board_info_t *db)
905static void 905static void
906dm9000_init_dm9000(struct net_device *dev) 906dm9000_init_dm9000(struct net_device *dev)
907{ 907{
908 board_info_t *db = netdev_priv(dev); 908 struct board_info *db = netdev_priv(dev);
909 unsigned int imr; 909 unsigned int imr;
910 unsigned int ncr; 910 unsigned int ncr;
911 911
@@ -970,7 +970,7 @@ dm9000_init_dm9000(struct net_device *dev)
970/* Our watchdog timed out. Called by the networking layer */ 970/* Our watchdog timed out. Called by the networking layer */
971static void dm9000_timeout(struct net_device *dev) 971static void dm9000_timeout(struct net_device *dev)
972{ 972{
973 board_info_t *db = netdev_priv(dev); 973 struct board_info *db = netdev_priv(dev);
974 u8 reg_save; 974 u8 reg_save;
975 unsigned long flags; 975 unsigned long flags;
976 976
@@ -996,7 +996,7 @@ static void dm9000_send_packet(struct net_device *dev,
996 int ip_summed, 996 int ip_summed,
997 u16 pkt_len) 997 u16 pkt_len)
998{ 998{
999 board_info_t *dm = to_dm9000_board(dev); 999 struct board_info *dm = to_dm9000_board(dev);
1000 1000
1001 /* The DM9000 is not smart enough to leave fragmented packets alone. */ 1001 /* The DM9000 is not smart enough to leave fragmented packets alone. */
1002 if (dm->ip_summed != ip_summed) { 1002 if (dm->ip_summed != ip_summed) {
@@ -1023,7 +1023,7 @@ static int
1023dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev) 1023dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
1024{ 1024{
1025 unsigned long flags; 1025 unsigned long flags;
1026 board_info_t *db = netdev_priv(dev); 1026 struct board_info *db = netdev_priv(dev);
1027 1027
1028 dm9000_dbg(db, 3, "%s:\n", __func__); 1028 dm9000_dbg(db, 3, "%s:\n", __func__);
1029 1029
@@ -1062,7 +1062,7 @@ dm9000_start_xmit(struct sk_buff *skb, struct net_device *dev)
1062 * receive the packet to upper layer, free the transmitted packet 1062 * receive the packet to upper layer, free the transmitted packet
1063 */ 1063 */
1064 1064
1065static void dm9000_tx_done(struct net_device *dev, board_info_t *db) 1065static void dm9000_tx_done(struct net_device *dev, struct board_info *db)
1066{ 1066{
1067 int tx_status = ior(db, DM9000_NSR); /* Got TX status */ 1067 int tx_status = ior(db, DM9000_NSR); /* Got TX status */
1068 1068
@@ -1094,7 +1094,7 @@ struct dm9000_rxhdr {
1094static void 1094static void
1095dm9000_rx(struct net_device *dev) 1095dm9000_rx(struct net_device *dev)
1096{ 1096{
1097 board_info_t *db = netdev_priv(dev); 1097 struct board_info *db = netdev_priv(dev);
1098 struct dm9000_rxhdr rxhdr; 1098 struct dm9000_rxhdr rxhdr;
1099 struct sk_buff *skb; 1099 struct sk_buff *skb;
1100 u8 rxbyte, *rdptr; 1100 u8 rxbyte, *rdptr;
@@ -1196,7 +1196,7 @@ dm9000_rx(struct net_device *dev)
1196static irqreturn_t dm9000_interrupt(int irq, void *dev_id) 1196static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
1197{ 1197{
1198 struct net_device *dev = dev_id; 1198 struct net_device *dev = dev_id;
1199 board_info_t *db = netdev_priv(dev); 1199 struct board_info *db = netdev_priv(dev);
1200 int int_status; 1200 int int_status;
1201 unsigned long flags; 1201 unsigned long flags;
1202 u8 reg_save; 1202 u8 reg_save;
@@ -1246,7 +1246,7 @@ static irqreturn_t dm9000_interrupt(int irq, void *dev_id)
1246static irqreturn_t dm9000_wol_interrupt(int irq, void *dev_id) 1246static irqreturn_t dm9000_wol_interrupt(int irq, void *dev_id)
1247{ 1247{
1248 struct net_device *dev = dev_id; 1248 struct net_device *dev = dev_id;
1249 board_info_t *db = netdev_priv(dev); 1249 struct board_info *db = netdev_priv(dev);
1250 unsigned long flags; 1250 unsigned long flags;
1251 unsigned nsr, wcr; 1251 unsigned nsr, wcr;
1252 1252
@@ -1296,7 +1296,7 @@ static void dm9000_poll_controller(struct net_device *dev)
1296static int 1296static int
1297dm9000_open(struct net_device *dev) 1297dm9000_open(struct net_device *dev)
1298{ 1298{
1299 board_info_t *db = netdev_priv(dev); 1299 struct board_info *db = netdev_priv(dev);
1300 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK; 1300 unsigned long irqflags = db->irq_res->flags & IRQF_TRIGGER_MASK;
1301 1301
1302 if (netif_msg_ifup(db)) 1302 if (netif_msg_ifup(db))
@@ -1342,7 +1342,7 @@ dm9000_open(struct net_device *dev)
1342static void 1342static void
1343dm9000_shutdown(struct net_device *dev) 1343dm9000_shutdown(struct net_device *dev)
1344{ 1344{
1345 board_info_t *db = netdev_priv(dev); 1345 struct board_info *db = netdev_priv(dev);
1346 1346
1347 /* RESET device */ 1347 /* RESET device */
1348 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */ 1348 dm9000_phy_write(dev, 0, MII_BMCR, BMCR_RESET); /* PHY RESET */
@@ -1358,7 +1358,7 @@ dm9000_shutdown(struct net_device *dev)
1358static int 1358static int
1359dm9000_stop(struct net_device *ndev) 1359dm9000_stop(struct net_device *ndev)
1360{ 1360{
1361 board_info_t *db = netdev_priv(ndev); 1361 struct board_info *db = netdev_priv(ndev);
1362 1362
1363 if (netif_msg_ifdown(db)) 1363 if (netif_msg_ifdown(db))
1364 dev_dbg(db->dev, "shutting down %s\n", ndev->name); 1364 dev_dbg(db->dev, "shutting down %s\n", ndev->name);
@@ -1681,7 +1681,7 @@ dm9000_drv_suspend(struct device *dev)
1681{ 1681{
1682 struct platform_device *pdev = to_platform_device(dev); 1682 struct platform_device *pdev = to_platform_device(dev);
1683 struct net_device *ndev = platform_get_drvdata(pdev); 1683 struct net_device *ndev = platform_get_drvdata(pdev);
1684 board_info_t *db; 1684 struct board_info *db;
1685 1685
1686 if (ndev) { 1686 if (ndev) {
1687 db = netdev_priv(ndev); 1687 db = netdev_priv(ndev);
@@ -1704,7 +1704,7 @@ dm9000_drv_resume(struct device *dev)
1704{ 1704{
1705 struct platform_device *pdev = to_platform_device(dev); 1705 struct platform_device *pdev = to_platform_device(dev);
1706 struct net_device *ndev = platform_get_drvdata(pdev); 1706 struct net_device *ndev = platform_get_drvdata(pdev);
1707 board_info_t *db = netdev_priv(ndev); 1707 struct board_info *db = netdev_priv(ndev);
1708 1708
1709 if (ndev) { 1709 if (ndev) {
1710 if (netif_running(ndev)) { 1710 if (netif_running(ndev)) {
diff --git a/drivers/net/ethernet/dec/tulip/de2104x.c b/drivers/net/ethernet/dec/tulip/de2104x.c
index 38148b0e3a95..a02ecc4f9002 100644
--- a/drivers/net/ethernet/dec/tulip/de2104x.c
+++ b/drivers/net/ethernet/dec/tulip/de2104x.c
@@ -340,7 +340,7 @@ static void de21041_media_timer (unsigned long data);
340static unsigned int de_ok_to_advertise (struct de_private *de, u32 new_media); 340static unsigned int de_ok_to_advertise (struct de_private *de, u32 new_media);
341 341
342 342
343static DEFINE_PCI_DEVICE_TABLE(de_pci_tbl) = { 343static const struct pci_device_id de_pci_tbl[] = {
344 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP, 344 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP,
345 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 345 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
346 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS, 346 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS,
diff --git a/drivers/net/ethernet/dec/tulip/de4x5.c b/drivers/net/ethernet/dec/tulip/de4x5.c
index 7091fa6ed096..cf8b6ff21613 100644
--- a/drivers/net/ethernet/dec/tulip/de4x5.c
+++ b/drivers/net/ethernet/dec/tulip/de4x5.c
@@ -2328,7 +2328,7 @@ static void de4x5_pci_remove(struct pci_dev *pdev)
2328 pci_disable_device (pdev); 2328 pci_disable_device (pdev);
2329} 2329}
2330 2330
2331static DEFINE_PCI_DEVICE_TABLE(de4x5_pci_tbl) = { 2331static const struct pci_device_id de4x5_pci_tbl[] = {
2332 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP, 2332 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP,
2333 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 2333 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
2334 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS, 2334 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_PLUS,
diff --git a/drivers/net/ethernet/dec/tulip/dmfe.c b/drivers/net/ethernet/dec/tulip/dmfe.c
index 53f0c618045c..322213d901d5 100644
--- a/drivers/net/ethernet/dec/tulip/dmfe.c
+++ b/drivers/net/ethernet/dec/tulip/dmfe.c
@@ -2096,7 +2096,7 @@ static void dmfe_HPNA_remote_cmd_chk(struct dmfe_board_info * db)
2096 2096
2097 2097
2098 2098
2099static DEFINE_PCI_DEVICE_TABLE(dmfe_pci_tbl) = { 2099static const struct pci_device_id dmfe_pci_tbl[] = {
2100 { 0x1282, 0x9132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_DM9132_ID }, 2100 { 0x1282, 0x9132, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_DM9132_ID },
2101 { 0x1282, 0x9102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_DM9102_ID }, 2101 { 0x1282, 0x9102, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_DM9102_ID },
2102 { 0x1282, 0x9100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_DM9100_ID }, 2102 { 0x1282, 0x9100, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_DM9100_ID },
diff --git a/drivers/net/ethernet/dec/tulip/tulip_core.c b/drivers/net/ethernet/dec/tulip/tulip_core.c
index 861660841ce2..3b42556f7f8d 100644
--- a/drivers/net/ethernet/dec/tulip/tulip_core.c
+++ b/drivers/net/ethernet/dec/tulip/tulip_core.c
@@ -207,7 +207,7 @@ struct tulip_chip_table tulip_tbl[] = {
207}; 207};
208 208
209 209
210static DEFINE_PCI_DEVICE_TABLE(tulip_pci_tbl) = { 210static const struct pci_device_id tulip_pci_tbl[] = {
211 { 0x1011, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 }, 211 { 0x1011, 0x0009, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21140 },
212 { 0x1011, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21143 }, 212 { 0x1011, 0x0019, PCI_ANY_ID, PCI_ANY_ID, 0, 0, DC21143 },
213 { 0x11AD, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, LC82C168 }, 213 { 0x11AD, 0x0002, PCI_ANY_ID, PCI_ANY_ID, 0, 0, LC82C168 },
@@ -1294,7 +1294,7 @@ static const struct net_device_ops tulip_netdev_ops = {
1294#endif 1294#endif
1295}; 1295};
1296 1296
1297DEFINE_PCI_DEVICE_TABLE(early_486_chipsets) = { 1297const struct pci_device_id early_486_chipsets[] = {
1298 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82424) }, 1298 { PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82424) },
1299 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496) }, 1299 { PCI_DEVICE(PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_496) },
1300 { }, 1300 { },
diff --git a/drivers/net/ethernet/dec/tulip/uli526x.c b/drivers/net/ethernet/dec/tulip/uli526x.c
index 80afec335a11..4061f9b22812 100644
--- a/drivers/net/ethernet/dec/tulip/uli526x.c
+++ b/drivers/net/ethernet/dec/tulip/uli526x.c
@@ -1768,7 +1768,7 @@ static u16 phy_read_1bit(struct uli526x_board_info *db)
1768} 1768}
1769 1769
1770 1770
1771static DEFINE_PCI_DEVICE_TABLE(uli526x_pci_tbl) = { 1771static const struct pci_device_id uli526x_pci_tbl[] = {
1772 { 0x10B9, 0x5261, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_ULI5261_ID }, 1772 { 0x10B9, 0x5261, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_ULI5261_ID },
1773 { 0x10B9, 0x5263, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_ULI5263_ID }, 1773 { 0x10B9, 0x5263, PCI_ANY_ID, PCI_ANY_ID, 0, 0, PCI_ULI5263_ID },
1774 { 0, } 1774 { 0, }
diff --git a/drivers/net/ethernet/dec/tulip/winbond-840.c b/drivers/net/ethernet/dec/tulip/winbond-840.c
index 62fe512bb216..6aa887e0e1cb 100644
--- a/drivers/net/ethernet/dec/tulip/winbond-840.c
+++ b/drivers/net/ethernet/dec/tulip/winbond-840.c
@@ -219,7 +219,7 @@ enum chip_capability_flags {
219 CanHaveMII=1, HasBrokenTx=2, AlwaysFDX=4, FDXOnNoMII=8, 219 CanHaveMII=1, HasBrokenTx=2, AlwaysFDX=4, FDXOnNoMII=8,
220}; 220};
221 221
222static DEFINE_PCI_DEVICE_TABLE(w840_pci_tbl) = { 222static const struct pci_device_id w840_pci_tbl[] = {
223 { 0x1050, 0x0840, PCI_ANY_ID, 0x8153, 0, 0, 0 }, 223 { 0x1050, 0x0840, PCI_ANY_ID, 0x8153, 0, 0, 0 },
224 { 0x1050, 0x0840, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 224 { 0x1050, 0x0840, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
225 { 0x11f6, 0x2011, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 }, 225 { 0x11f6, 0x2011, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2 },
diff --git a/drivers/net/ethernet/dec/tulip/xircom_cb.c b/drivers/net/ethernet/dec/tulip/xircom_cb.c
index 6204cdfe43a6..0e721cedfa67 100644
--- a/drivers/net/ethernet/dec/tulip/xircom_cb.c
+++ b/drivers/net/ethernet/dec/tulip/xircom_cb.c
@@ -137,7 +137,7 @@ static int link_status(struct xircom_private *card);
137 137
138 138
139 139
140static DEFINE_PCI_DEVICE_TABLE(xircom_pci_table) = { 140static const struct pci_device_id xircom_pci_table[] = {
141 { PCI_VDEVICE(XIRCOM, 0x0003), }, 141 { PCI_VDEVICE(XIRCOM, 0x0003), },
142 {0,}, 142 {0,},
143}; 143};
diff --git a/drivers/net/ethernet/dlink/dl2k.h b/drivers/net/ethernet/dlink/dl2k.h
index 7d07a0f5320d..23c07b007069 100644
--- a/drivers/net/ethernet/dlink/dl2k.h
+++ b/drivers/net/ethernet/dlink/dl2k.h
@@ -408,7 +408,7 @@ struct netdev_private {
408 driver_data Data private to the driver. 408 driver_data Data private to the driver.
409*/ 409*/
410 410
411static DEFINE_PCI_DEVICE_TABLE(rio_pci_tbl) = { 411static const struct pci_device_id rio_pci_tbl[] = {
412 {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, }, 412 {0x1186, 0x4000, PCI_ANY_ID, PCI_ANY_ID, },
413 {0x13f0, 0x1021, PCI_ANY_ID, PCI_ANY_ID, }, 413 {0x13f0, 0x1021, PCI_ANY_ID, PCI_ANY_ID, },
414 { } 414 { }
diff --git a/drivers/net/ethernet/dlink/sundance.c b/drivers/net/ethernet/dlink/sundance.c
index 433c1e185442..a28a2e583f0f 100644
--- a/drivers/net/ethernet/dlink/sundance.c
+++ b/drivers/net/ethernet/dlink/sundance.c
@@ -199,7 +199,7 @@ IVc. Errata
199#define USE_IO_OPS 1 199#define USE_IO_OPS 1
200#endif 200#endif
201 201
202static DEFINE_PCI_DEVICE_TABLE(sundance_pci_tbl) = { 202static const struct pci_device_id sundance_pci_tbl[] = {
203 { 0x1186, 0x1002, 0x1186, 0x1002, 0, 0, 0 }, 203 { 0x1186, 0x1002, 0x1186, 0x1002, 0, 0, 0 },
204 { 0x1186, 0x1002, 0x1186, 0x1003, 0, 0, 1 }, 204 { 0x1186, 0x1002, 0x1186, 0x1003, 0, 0, 1 },
205 { 0x1186, 0x1002, 0x1186, 0x1012, 0, 0, 2 }, 205 { 0x1186, 0x1002, 0x1186, 0x1012, 0, 0, 2 },
diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index 811f1351db7a..43e08d0bc3d3 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -897,5 +897,6 @@ void be_roce_dev_remove(struct be_adapter *);
897 */ 897 */
898void be_roce_dev_open(struct be_adapter *); 898void be_roce_dev_open(struct be_adapter *);
899void be_roce_dev_close(struct be_adapter *); 899void be_roce_dev_close(struct be_adapter *);
900void be_roce_dev_shutdown(struct be_adapter *);
900 901
901#endif /* BE_H */ 902#endif /* BE_H */
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index db4ff14ff18f..93ff8ef39352 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -39,7 +39,7 @@ static ushort rx_frag_size = 2048;
39module_param(rx_frag_size, ushort, S_IRUGO); 39module_param(rx_frag_size, ushort, S_IRUGO);
40MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data."); 40MODULE_PARM_DESC(rx_frag_size, "Size of a fragment that holds rcvd data.");
41 41
42static DEFINE_PCI_DEVICE_TABLE(be_dev_ids) = { 42static const struct pci_device_id be_dev_ids[] = {
43 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) }, 43 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID1) },
44 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) }, 44 { PCI_DEVICE(BE_VENDOR_ID, BE_DEVICE_ID2) },
45 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) }, 45 { PCI_DEVICE(BE_VENDOR_ID, OC_DEVICE_ID1) },
@@ -5014,6 +5014,7 @@ static void be_shutdown(struct pci_dev *pdev)
5014 if (!adapter) 5014 if (!adapter)
5015 return; 5015 return;
5016 5016
5017 be_roce_dev_shutdown(adapter);
5017 cancel_delayed_work_sync(&adapter->work); 5018 cancel_delayed_work_sync(&adapter->work);
5018 cancel_delayed_work_sync(&adapter->func_recovery_work); 5019 cancel_delayed_work_sync(&adapter->func_recovery_work);
5019 5020
diff --git a/drivers/net/ethernet/emulex/benet/be_roce.c b/drivers/net/ethernet/emulex/benet/be_roce.c
index 5bf16603a3e9..ef4672dc7357 100644
--- a/drivers/net/ethernet/emulex/benet/be_roce.c
+++ b/drivers/net/ethernet/emulex/benet/be_roce.c
@@ -120,7 +120,8 @@ static void _be_roce_dev_open(struct be_adapter *adapter)
120{ 120{
121 if (ocrdma_drv && adapter->ocrdma_dev && 121 if (ocrdma_drv && adapter->ocrdma_dev &&
122 ocrdma_drv->state_change_handler) 122 ocrdma_drv->state_change_handler)
123 ocrdma_drv->state_change_handler(adapter->ocrdma_dev, 0); 123 ocrdma_drv->state_change_handler(adapter->ocrdma_dev,
124 BE_DEV_UP);
124} 125}
125 126
126void be_roce_dev_open(struct be_adapter *adapter) 127void be_roce_dev_open(struct be_adapter *adapter)
@@ -136,7 +137,8 @@ static void _be_roce_dev_close(struct be_adapter *adapter)
136{ 137{
137 if (ocrdma_drv && adapter->ocrdma_dev && 138 if (ocrdma_drv && adapter->ocrdma_dev &&
138 ocrdma_drv->state_change_handler) 139 ocrdma_drv->state_change_handler)
139 ocrdma_drv->state_change_handler(adapter->ocrdma_dev, 1); 140 ocrdma_drv->state_change_handler(adapter->ocrdma_dev,
141 BE_DEV_DOWN);
140} 142}
141 143
142void be_roce_dev_close(struct be_adapter *adapter) 144void be_roce_dev_close(struct be_adapter *adapter)
@@ -148,6 +150,18 @@ void be_roce_dev_close(struct be_adapter *adapter)
148 } 150 }
149} 151}
150 152
153void be_roce_dev_shutdown(struct be_adapter *adapter)
154{
155 if (be_roce_supported(adapter)) {
156 mutex_lock(&be_adapter_list_lock);
157 if (ocrdma_drv && adapter->ocrdma_dev &&
158 ocrdma_drv->state_change_handler)
159 ocrdma_drv->state_change_handler(adapter->ocrdma_dev,
160 BE_DEV_SHUTDOWN);
161 mutex_unlock(&be_adapter_list_lock);
162 }
163}
164
151int be_roce_register_driver(struct ocrdma_driver *drv) 165int be_roce_register_driver(struct ocrdma_driver *drv)
152{ 166{
153 struct be_adapter *dev; 167 struct be_adapter *dev;
diff --git a/drivers/net/ethernet/emulex/benet/be_roce.h b/drivers/net/ethernet/emulex/benet/be_roce.h
index a3d9e96c18eb..e6f7eb1a7d87 100644
--- a/drivers/net/ethernet/emulex/benet/be_roce.h
+++ b/drivers/net/ethernet/emulex/benet/be_roce.h
@@ -62,7 +62,8 @@ struct ocrdma_driver {
62 62
63enum { 63enum {
64 BE_DEV_UP = 0, 64 BE_DEV_UP = 0,
65 BE_DEV_DOWN = 1 65 BE_DEV_DOWN = 1,
66 BE_DEV_SHUTDOWN = 2
66}; 67};
67 68
68/* APIs for RoCE driver to register callback handlers, 69/* APIs for RoCE driver to register callback handlers,
diff --git a/drivers/net/ethernet/fealnx.c b/drivers/net/ethernet/fealnx.c
index 4b22a9579f85..b1b9ebafb354 100644
--- a/drivers/net/ethernet/fealnx.c
+++ b/drivers/net/ethernet/fealnx.c
@@ -1936,7 +1936,7 @@ static int netdev_close(struct net_device *dev)
1936 return 0; 1936 return 0;
1937} 1937}
1938 1938
1939static DEFINE_PCI_DEVICE_TABLE(fealnx_pci_tbl) = { 1939static const struct pci_device_id fealnx_pci_tbl[] = {
1940 {0x1516, 0x0800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 1940 {0x1516, 0x0800, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
1941 {0x1516, 0x0803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1}, 1941 {0x1516, 0x0803, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1},
1942 {0x1516, 0x0891, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2}, 1942 {0x1516, 0x0891, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 2},
diff --git a/drivers/net/ethernet/freescale/fec.h b/drivers/net/ethernet/freescale/fec.h
index bd53caf1c1eb..9f7fa644a397 100644
--- a/drivers/net/ethernet/freescale/fec.h
+++ b/drivers/net/ethernet/freescale/fec.h
@@ -310,6 +310,7 @@ struct fec_enet_private {
310 int mii_timeout; 310 int mii_timeout;
311 uint phy_speed; 311 uint phy_speed;
312 phy_interface_t phy_interface; 312 phy_interface_t phy_interface;
313 struct device_node *phy_node;
313 int link; 314 int link;
314 int full_duplex; 315 int full_duplex;
315 int speed; 316 int speed;
diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c
index 66fe1f672499..4f87dffcb9b2 100644
--- a/drivers/net/ethernet/freescale/fec_main.c
+++ b/drivers/net/ethernet/freescale/fec_main.c
@@ -52,6 +52,7 @@
52#include <linux/of.h> 52#include <linux/of.h>
53#include <linux/of_device.h> 53#include <linux/of_device.h>
54#include <linux/of_gpio.h> 54#include <linux/of_gpio.h>
55#include <linux/of_mdio.h>
55#include <linux/of_net.h> 56#include <linux/of_net.h>
56#include <linux/regulator/consumer.h> 57#include <linux/regulator/consumer.h>
57#include <linux/if_vlan.h> 58#include <linux/if_vlan.h>
@@ -1648,29 +1649,37 @@ static int fec_enet_mii_probe(struct net_device *ndev)
1648 1649
1649 fep->phy_dev = NULL; 1650 fep->phy_dev = NULL;
1650 1651
1651 /* check for attached phy */ 1652 if (fep->phy_node) {
1652 for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) { 1653 phy_dev = of_phy_connect(ndev, fep->phy_node,
1653 if ((fep->mii_bus->phy_mask & (1 << phy_id))) 1654 &fec_enet_adjust_link, 0,
1654 continue; 1655 fep->phy_interface);
1655 if (fep->mii_bus->phy_map[phy_id] == NULL) 1656 } else {
1656 continue; 1657 /* check for attached phy */
1657 if (fep->mii_bus->phy_map[phy_id]->phy_id == 0) 1658 for (phy_id = 0; (phy_id < PHY_MAX_ADDR); phy_id++) {
1658 continue; 1659 if ((fep->mii_bus->phy_mask & (1 << phy_id)))
1659 if (dev_id--) 1660 continue;
1660 continue; 1661 if (fep->mii_bus->phy_map[phy_id] == NULL)
1661 strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE); 1662 continue;
1662 break; 1663 if (fep->mii_bus->phy_map[phy_id]->phy_id == 0)
1663 } 1664 continue;
1665 if (dev_id--)
1666 continue;
1667 strncpy(mdio_bus_id, fep->mii_bus->id, MII_BUS_ID_SIZE);
1668 break;
1669 }
1664 1670
1665 if (phy_id >= PHY_MAX_ADDR) { 1671 if (phy_id >= PHY_MAX_ADDR) {
1666 netdev_info(ndev, "no PHY, assuming direct connection to switch\n"); 1672 netdev_info(ndev, "no PHY, assuming direct connection to switch\n");
1667 strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); 1673 strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE);
1668 phy_id = 0; 1674 phy_id = 0;
1675 }
1676
1677 snprintf(phy_name, sizeof(phy_name),
1678 PHY_ID_FMT, mdio_bus_id, phy_id);
1679 phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link,
1680 fep->phy_interface);
1669 } 1681 }
1670 1682
1671 snprintf(phy_name, sizeof(phy_name), PHY_ID_FMT, mdio_bus_id, phy_id);
1672 phy_dev = phy_connect(ndev, phy_name, &fec_enet_adjust_link,
1673 fep->phy_interface);
1674 if (IS_ERR(phy_dev)) { 1683 if (IS_ERR(phy_dev)) {
1675 netdev_err(ndev, "could not attach to PHY\n"); 1684 netdev_err(ndev, "could not attach to PHY\n");
1676 return PTR_ERR(phy_dev); 1685 return PTR_ERR(phy_dev);
@@ -1707,6 +1716,7 @@ static int fec_enet_mii_init(struct platform_device *pdev)
1707 struct fec_enet_private *fep = netdev_priv(ndev); 1716 struct fec_enet_private *fep = netdev_priv(ndev);
1708 const struct platform_device_id *id_entry = 1717 const struct platform_device_id *id_entry =
1709 platform_get_device_id(fep->pdev); 1718 platform_get_device_id(fep->pdev);
1719 struct device_node *node;
1710 int err = -ENXIO, i; 1720 int err = -ENXIO, i;
1711 1721
1712 /* 1722 /*
@@ -1774,7 +1784,15 @@ static int fec_enet_mii_init(struct platform_device *pdev)
1774 for (i = 0; i < PHY_MAX_ADDR; i++) 1784 for (i = 0; i < PHY_MAX_ADDR; i++)
1775 fep->mii_bus->irq[i] = PHY_POLL; 1785 fep->mii_bus->irq[i] = PHY_POLL;
1776 1786
1777 if (mdiobus_register(fep->mii_bus)) 1787 node = of_get_child_by_name(pdev->dev.of_node, "mdio");
1788 if (node) {
1789 err = of_mdiobus_register(fep->mii_bus, node);
1790 of_node_put(node);
1791 } else {
1792 err = mdiobus_register(fep->mii_bus);
1793 }
1794
1795 if (err)
1778 goto err_out_free_mdio_irq; 1796 goto err_out_free_mdio_irq;
1779 1797
1780 mii_cnt++; 1798 mii_cnt++;
@@ -2527,6 +2545,7 @@ fec_probe(struct platform_device *pdev)
2527 struct resource *r; 2545 struct resource *r;
2528 const struct of_device_id *of_id; 2546 const struct of_device_id *of_id;
2529 static int dev_id; 2547 static int dev_id;
2548 struct device_node *np = pdev->dev.of_node, *phy_node;
2530 2549
2531 of_id = of_match_device(fec_dt_ids, &pdev->dev); 2550 of_id = of_match_device(fec_dt_ids, &pdev->dev);
2532 if (of_id) 2551 if (of_id)
@@ -2566,6 +2585,18 @@ fec_probe(struct platform_device *pdev)
2566 2585
2567 platform_set_drvdata(pdev, ndev); 2586 platform_set_drvdata(pdev, ndev);
2568 2587
2588 phy_node = of_parse_phandle(np, "phy-handle", 0);
2589 if (!phy_node && of_phy_is_fixed_link(np)) {
2590 ret = of_phy_register_fixed_link(np);
2591 if (ret < 0) {
2592 dev_err(&pdev->dev,
2593 "broken fixed-link specification\n");
2594 goto failed_phy;
2595 }
2596 phy_node = of_node_get(np);
2597 }
2598 fep->phy_node = phy_node;
2599
2569 ret = of_get_phy_mode(pdev->dev.of_node); 2600 ret = of_get_phy_mode(pdev->dev.of_node);
2570 if (ret < 0) { 2601 if (ret < 0) {
2571 pdata = dev_get_platdata(&pdev->dev); 2602 pdata = dev_get_platdata(&pdev->dev);
@@ -2670,6 +2701,8 @@ failed_init:
2670failed_regulator: 2701failed_regulator:
2671 fec_enet_clk_enable(ndev, false); 2702 fec_enet_clk_enable(ndev, false);
2672failed_clk: 2703failed_clk:
2704failed_phy:
2705 of_node_put(phy_node);
2673failed_ioremap: 2706failed_ioremap:
2674 free_netdev(ndev); 2707 free_netdev(ndev);
2675 2708
@@ -2691,6 +2724,7 @@ fec_drv_remove(struct platform_device *pdev)
2691 if (fep->ptp_clock) 2724 if (fep->ptp_clock)
2692 ptp_clock_unregister(fep->ptp_clock); 2725 ptp_clock_unregister(fep->ptp_clock);
2693 fec_enet_clk_enable(ndev, false); 2726 fec_enet_clk_enable(ndev, false);
2727 of_node_put(fep->phy_node);
2694 free_netdev(ndev); 2728 free_netdev(ndev);
2695 2729
2696 return 0; 2730 return 0;
diff --git a/drivers/net/ethernet/freescale/fec_mpc52xx.c b/drivers/net/ethernet/freescale/fec_mpc52xx.c
index 9947765e90c5..ff55fbb20a75 100644
--- a/drivers/net/ethernet/freescale/fec_mpc52xx.c
+++ b/drivers/net/ethernet/freescale/fec_mpc52xx.c
@@ -1015,8 +1015,7 @@ mpc52xx_fec_remove(struct platform_device *op)
1015 1015
1016 unregister_netdev(ndev); 1016 unregister_netdev(ndev);
1017 1017
1018 if (priv->phy_node) 1018 of_node_put(priv->phy_node);
1019 of_node_put(priv->phy_node);
1020 priv->phy_node = NULL; 1019 priv->phy_node = NULL;
1021 1020
1022 irq_dispose_mapping(ndev->irq); 1021 irq_dispose_mapping(ndev->irq);
diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
index cfaf17b70f3f..748fd24d3d9e 100644
--- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
+++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c
@@ -1033,7 +1033,7 @@ static int fs_enet_probe(struct platform_device *ofdev)
1033 /* In the case of a fixed PHY, the DT node associated 1033 /* In the case of a fixed PHY, the DT node associated
1034 * to the PHY is the Ethernet MAC DT node. 1034 * to the PHY is the Ethernet MAC DT node.
1035 */ 1035 */
1036 fpi->phy_node = ofdev->dev.of_node; 1036 fpi->phy_node = of_node_get(ofdev->dev.of_node);
1037 } 1037 }
1038 1038
1039 if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec")) { 1039 if (of_device_is_compatible(ofdev->dev.of_node, "fsl,mpc5125-fec")) {
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
index fc5413488496..1eedfba2ad3c 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-fec.c
@@ -41,7 +41,6 @@
41#ifdef CONFIG_8xx 41#ifdef CONFIG_8xx
42#include <asm/8xx_immap.h> 42#include <asm/8xx_immap.h>
43#include <asm/pgtable.h> 43#include <asm/pgtable.h>
44#include <asm/mpc8xx.h>
45#include <asm/cpm1.h> 44#include <asm/cpm1.h>
46#endif 45#endif
47 46
diff --git a/drivers/net/ethernet/freescale/fs_enet/mac-scc.c b/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
index b4bf02f57d43..90b3b19b7cd3 100644
--- a/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
+++ b/drivers/net/ethernet/freescale/fs_enet/mac-scc.c
@@ -40,7 +40,6 @@
40#ifdef CONFIG_8xx 40#ifdef CONFIG_8xx
41#include <asm/8xx_immap.h> 41#include <asm/8xx_immap.h>
42#include <asm/pgtable.h> 42#include <asm/pgtable.h>
43#include <asm/mpc8xx.h>
44#include <asm/cpm1.h> 43#include <asm/cpm1.h>
45#endif 44#endif
46 45
diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index a6cf40e62f3a..fb29d049f4e1 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -892,12 +892,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
892 /* In the case of a fixed PHY, the DT node associated 892 /* In the case of a fixed PHY, the DT node associated
893 * to the PHY is the Ethernet MAC DT node. 893 * to the PHY is the Ethernet MAC DT node.
894 */ 894 */
895 if (of_phy_is_fixed_link(np)) { 895 if (!priv->phy_node && of_phy_is_fixed_link(np)) {
896 err = of_phy_register_fixed_link(np); 896 err = of_phy_register_fixed_link(np);
897 if (err) 897 if (err)
898 goto err_grp_init; 898 goto err_grp_init;
899 899
900 priv->phy_node = np; 900 priv->phy_node = of_node_get(np);
901 } 901 }
902 902
903 /* Find the TBI PHY. If it's not there, we don't support SGMII */ 903 /* Find the TBI PHY. If it's not there, we don't support SGMII */
@@ -1435,10 +1435,8 @@ register_fail:
1435 unmap_group_regs(priv); 1435 unmap_group_regs(priv);
1436 gfar_free_rx_queues(priv); 1436 gfar_free_rx_queues(priv);
1437 gfar_free_tx_queues(priv); 1437 gfar_free_tx_queues(priv);
1438 if (priv->phy_node) 1438 of_node_put(priv->phy_node);
1439 of_node_put(priv->phy_node); 1439 of_node_put(priv->tbi_node);
1440 if (priv->tbi_node)
1441 of_node_put(priv->tbi_node);
1442 free_gfar_dev(priv); 1440 free_gfar_dev(priv);
1443 return err; 1441 return err;
1444} 1442}
@@ -1447,10 +1445,8 @@ static int gfar_remove(struct platform_device *ofdev)
1447{ 1445{
1448 struct gfar_private *priv = platform_get_drvdata(ofdev); 1446 struct gfar_private *priv = platform_get_drvdata(ofdev);
1449 1447
1450 if (priv->phy_node) 1448 of_node_put(priv->phy_node);
1451 of_node_put(priv->phy_node); 1449 of_node_put(priv->tbi_node);
1452 if (priv->tbi_node)
1453 of_node_put(priv->tbi_node);
1454 1450
1455 unregister_netdev(priv->ndev); 1451 unregister_netdev(priv->ndev);
1456 unmap_group_regs(priv); 1452 unmap_group_regs(priv);
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c
index 8ceaf7a2660c..3cf0478b3728 100644
--- a/drivers/net/ethernet/freescale/ucc_geth.c
+++ b/drivers/net/ethernet/freescale/ucc_geth.c
@@ -3785,16 +3785,15 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3785 ug_info->uf_info.irq = irq_of_parse_and_map(np, 0); 3785 ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
3786 3786
3787 ug_info->phy_node = of_parse_phandle(np, "phy-handle", 0); 3787 ug_info->phy_node = of_parse_phandle(np, "phy-handle", 0);
3788 if (!ug_info->phy_node) { 3788 if (!ug_info->phy_node && of_phy_is_fixed_link(np)) {
3789 /* In the case of a fixed PHY, the DT node associated 3789 /*
3790 * In the case of a fixed PHY, the DT node associated
3790 * to the PHY is the Ethernet MAC DT node. 3791 * to the PHY is the Ethernet MAC DT node.
3791 */ 3792 */
3792 if (of_phy_is_fixed_link(np)) { 3793 err = of_phy_register_fixed_link(np);
3793 err = of_phy_register_fixed_link(np); 3794 if (err)
3794 if (err) 3795 return err;
3795 return err; 3796 ug_info->phy_node = of_node_get(np);
3796 }
3797 ug_info->phy_node = np;
3798 } 3797 }
3799 3798
3800 /* Find the TBI PHY node. If it's not there, we don't support SGMII */ 3799 /* Find the TBI PHY node. If it's not there, we don't support SGMII */
@@ -3862,8 +3861,11 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3862 /* Create an ethernet device instance */ 3861 /* Create an ethernet device instance */
3863 dev = alloc_etherdev(sizeof(*ugeth)); 3862 dev = alloc_etherdev(sizeof(*ugeth));
3864 3863
3865 if (dev == NULL) 3864 if (dev == NULL) {
3865 of_node_put(ug_info->tbi_node);
3866 of_node_put(ug_info->phy_node);
3866 return -ENOMEM; 3867 return -ENOMEM;
3868 }
3867 3869
3868 ugeth = netdev_priv(dev); 3870 ugeth = netdev_priv(dev);
3869 spin_lock_init(&ugeth->lock); 3871 spin_lock_init(&ugeth->lock);
@@ -3897,6 +3899,8 @@ static int ucc_geth_probe(struct platform_device* ofdev)
3897 pr_err("%s: Cannot register net device, aborting\n", 3899 pr_err("%s: Cannot register net device, aborting\n",
3898 dev->name); 3900 dev->name);
3899 free_netdev(dev); 3901 free_netdev(dev);
3902 of_node_put(ug_info->tbi_node);
3903 of_node_put(ug_info->phy_node);
3900 return err; 3904 return err;
3901 } 3905 }
3902 3906
@@ -3920,6 +3924,8 @@ static int ucc_geth_remove(struct platform_device* ofdev)
3920 unregister_netdev(dev); 3924 unregister_netdev(dev);
3921 free_netdev(dev); 3925 free_netdev(dev);
3922 ucc_geth_memclean(ugeth); 3926 ucc_geth_memclean(ugeth);
3927 of_node_put(ugeth->ug_info->tbi_node);
3928 of_node_put(ugeth->ug_info->phy_node);
3923 3929
3924 return 0; 3930 return 0;
3925} 3931}
diff --git a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
index cfe7a7431730..a7139f588ad2 100644
--- a/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
+++ b/drivers/net/ethernet/fujitsu/fmvj18x_cs.c
@@ -99,23 +99,23 @@ static const struct ethtool_ops netdev_ethtool_ops;
99/* 99/*
100 card type 100 card type
101 */ 101 */
102typedef enum { MBH10302, MBH10304, TDK, CONTEC, LA501, UNGERMANN, 102enum cardtype { MBH10302, MBH10304, TDK, CONTEC, LA501, UNGERMANN,
103 XXX10304, NEC, KME 103 XXX10304, NEC, KME
104} cardtype_t; 104};
105 105
106/* 106/*
107 driver specific data structure 107 driver specific data structure
108*/ 108*/
109typedef struct local_info_t { 109struct local_info {
110 struct pcmcia_device *p_dev; 110 struct pcmcia_device *p_dev;
111 long open_time; 111 long open_time;
112 uint tx_started:1; 112 uint tx_started:1;
113 uint tx_queue; 113 uint tx_queue;
114 u_short tx_queue_len; 114 u_short tx_queue_len;
115 cardtype_t cardtype; 115 enum cardtype cardtype;
116 u_short sent; 116 u_short sent;
117 u_char __iomem *base; 117 u_char __iomem *base;
118} local_info_t; 118};
119 119
120#define MC_FILTERBREAK 64 120#define MC_FILTERBREAK 64
121 121
@@ -232,13 +232,13 @@ static const struct net_device_ops fjn_netdev_ops = {
232 232
233static int fmvj18x_probe(struct pcmcia_device *link) 233static int fmvj18x_probe(struct pcmcia_device *link)
234{ 234{
235 local_info_t *lp; 235 struct local_info *lp;
236 struct net_device *dev; 236 struct net_device *dev;
237 237
238 dev_dbg(&link->dev, "fmvj18x_attach()\n"); 238 dev_dbg(&link->dev, "fmvj18x_attach()\n");
239 239
240 /* Make up a FMVJ18x specific data structure */ 240 /* Make up a FMVJ18x specific data structure */
241 dev = alloc_etherdev(sizeof(local_info_t)); 241 dev = alloc_etherdev(sizeof(struct local_info));
242 if (!dev) 242 if (!dev)
243 return -ENOMEM; 243 return -ENOMEM;
244 lp = netdev_priv(dev); 244 lp = netdev_priv(dev);
@@ -327,10 +327,10 @@ static int fmvj18x_ioprobe(struct pcmcia_device *p_dev, void *priv_data)
327static int fmvj18x_config(struct pcmcia_device *link) 327static int fmvj18x_config(struct pcmcia_device *link)
328{ 328{
329 struct net_device *dev = link->priv; 329 struct net_device *dev = link->priv;
330 local_info_t *lp = netdev_priv(dev); 330 struct local_info *lp = netdev_priv(dev);
331 int i, ret; 331 int i, ret;
332 unsigned int ioaddr; 332 unsigned int ioaddr;
333 cardtype_t cardtype; 333 enum cardtype cardtype;
334 char *card_name = "unknown"; 334 char *card_name = "unknown";
335 u8 *buf; 335 u8 *buf;
336 size_t len; 336 size_t len;
@@ -584,7 +584,7 @@ static int fmvj18x_setup_mfc(struct pcmcia_device *link)
584 int i; 584 int i;
585 struct net_device *dev = link->priv; 585 struct net_device *dev = link->priv;
586 unsigned int ioaddr; 586 unsigned int ioaddr;
587 local_info_t *lp = netdev_priv(dev); 587 struct local_info *lp = netdev_priv(dev);
588 588
589 /* Allocate a small memory window */ 589 /* Allocate a small memory window */
590 link->resource[3]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE; 590 link->resource[3]->flags = WIN_DATA_WIDTH_8|WIN_MEMORY_TYPE_AM|WIN_ENABLE;
@@ -626,7 +626,7 @@ static void fmvj18x_release(struct pcmcia_device *link)
626{ 626{
627 627
628 struct net_device *dev = link->priv; 628 struct net_device *dev = link->priv;
629 local_info_t *lp = netdev_priv(dev); 629 struct local_info *lp = netdev_priv(dev);
630 u_char __iomem *tmp; 630 u_char __iomem *tmp;
631 631
632 dev_dbg(&link->dev, "fmvj18x_release\n"); 632 dev_dbg(&link->dev, "fmvj18x_release\n");
@@ -711,7 +711,7 @@ module_pcmcia_driver(fmvj18x_cs_driver);
711static irqreturn_t fjn_interrupt(int dummy, void *dev_id) 711static irqreturn_t fjn_interrupt(int dummy, void *dev_id)
712{ 712{
713 struct net_device *dev = dev_id; 713 struct net_device *dev = dev_id;
714 local_info_t *lp = netdev_priv(dev); 714 struct local_info *lp = netdev_priv(dev);
715 unsigned int ioaddr; 715 unsigned int ioaddr;
716 unsigned short tx_stat, rx_stat; 716 unsigned short tx_stat, rx_stat;
717 717
@@ -772,7 +772,7 @@ static irqreturn_t fjn_interrupt(int dummy, void *dev_id)
772 772
773static void fjn_tx_timeout(struct net_device *dev) 773static void fjn_tx_timeout(struct net_device *dev)
774{ 774{
775 struct local_info_t *lp = netdev_priv(dev); 775 struct local_info *lp = netdev_priv(dev);
776 unsigned int ioaddr = dev->base_addr; 776 unsigned int ioaddr = dev->base_addr;
777 777
778 netdev_notice(dev, "transmit timed out with status %04x, %s?\n", 778 netdev_notice(dev, "transmit timed out with status %04x, %s?\n",
@@ -802,7 +802,7 @@ static void fjn_tx_timeout(struct net_device *dev)
802static netdev_tx_t fjn_start_xmit(struct sk_buff *skb, 802static netdev_tx_t fjn_start_xmit(struct sk_buff *skb,
803 struct net_device *dev) 803 struct net_device *dev)
804{ 804{
805 struct local_info_t *lp = netdev_priv(dev); 805 struct local_info *lp = netdev_priv(dev);
806 unsigned int ioaddr = dev->base_addr; 806 unsigned int ioaddr = dev->base_addr;
807 short length = skb->len; 807 short length = skb->len;
808 808
@@ -874,7 +874,7 @@ static netdev_tx_t fjn_start_xmit(struct sk_buff *skb,
874 874
875static void fjn_reset(struct net_device *dev) 875static void fjn_reset(struct net_device *dev)
876{ 876{
877 struct local_info_t *lp = netdev_priv(dev); 877 struct local_info *lp = netdev_priv(dev);
878 unsigned int ioaddr = dev->base_addr; 878 unsigned int ioaddr = dev->base_addr;
879 int i; 879 int i;
880 880
@@ -1058,7 +1058,7 @@ static int fjn_config(struct net_device *dev, struct ifmap *map){
1058 1058
1059static int fjn_open(struct net_device *dev) 1059static int fjn_open(struct net_device *dev)
1060{ 1060{
1061 struct local_info_t *lp = netdev_priv(dev); 1061 struct local_info *lp = netdev_priv(dev);
1062 struct pcmcia_device *link = lp->p_dev; 1062 struct pcmcia_device *link = lp->p_dev;
1063 1063
1064 pr_debug("fjn_open('%s').\n", dev->name); 1064 pr_debug("fjn_open('%s').\n", dev->name);
@@ -1083,7 +1083,7 @@ static int fjn_open(struct net_device *dev)
1083 1083
1084static int fjn_close(struct net_device *dev) 1084static int fjn_close(struct net_device *dev)
1085{ 1085{
1086 struct local_info_t *lp = netdev_priv(dev); 1086 struct local_info *lp = netdev_priv(dev);
1087 struct pcmcia_device *link = lp->p_dev; 1087 struct pcmcia_device *link = lp->p_dev;
1088 unsigned int ioaddr = dev->base_addr; 1088 unsigned int ioaddr = dev->base_addr;
1089 1089
diff --git a/drivers/net/ethernet/hp/hp100.c b/drivers/net/ethernet/hp/hp100.c
index 37860096f744..ed7916f6fbcf 100644
--- a/drivers/net/ethernet/hp/hp100.c
+++ b/drivers/net/ethernet/hp/hp100.c
@@ -208,7 +208,7 @@ MODULE_DEVICE_TABLE(eisa, hp100_eisa_tbl);
208#endif 208#endif
209 209
210#ifdef CONFIG_PCI 210#ifdef CONFIG_PCI
211static DEFINE_PCI_DEVICE_TABLE(hp100_pci_tbl) = { 211static const struct pci_device_id hp100_pci_tbl[] = {
212 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585A, PCI_ANY_ID, PCI_ANY_ID,}, 212 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585A, PCI_ANY_ID, PCI_ANY_ID,},
213 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585B, PCI_ANY_ID, PCI_ANY_ID,}, 213 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2585B, PCI_ANY_ID, PCI_ANY_ID,},
214 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2970A, PCI_ANY_ID, PCI_ANY_ID,}, 214 {PCI_VENDOR_ID_HP, PCI_DEVICE_ID_HP_J2970A, PCI_ANY_ID, PCI_ANY_ID,},
diff --git a/drivers/net/ethernet/ibm/ehea/Makefile b/drivers/net/ethernet/ibm/ehea/Makefile
index 775d9969b5c2..cd473e295242 100644
--- a/drivers/net/ethernet/ibm/ehea/Makefile
+++ b/drivers/net/ethernet/ibm/ehea/Makefile
@@ -1,6 +1,6 @@
1# 1#
2# Makefile for the eHEA ethernet device driver for IBM eServer System p 2# Makefile for the eHEA ethernet device driver for IBM eServer System p
3# 3#
4ehea-y = ehea_main.o ehea_phyp.o ehea_qmr.o ehea_ethtool.o ehea_phyp.o 4ehea-y = ehea_main.o ehea_phyp.o ehea_qmr.o ehea_ethtool.o
5obj-$(CONFIG_EHEA) += ehea.o 5obj-$(CONFIG_EHEA) += ehea.o
6 6
diff --git a/drivers/net/ethernet/icplus/ipg.c b/drivers/net/ethernet/icplus/ipg.c
index 5727779a7df2..ff2903652f4b 100644
--- a/drivers/net/ethernet/icplus/ipg.c
+++ b/drivers/net/ethernet/icplus/ipg.c
@@ -95,7 +95,7 @@ static const char * const ipg_brand_name[] = {
95 "D-Link NIC IP1000A" 95 "D-Link NIC IP1000A"
96}; 96};
97 97
98static DEFINE_PCI_DEVICE_TABLE(ipg_pci_tbl) = { 98static const struct pci_device_id ipg_pci_tbl[] = {
99 { PCI_VDEVICE(SUNDANCE, 0x1023), 0 }, 99 { PCI_VDEVICE(SUNDANCE, 0x1023), 0 },
100 { PCI_VDEVICE(SUNDANCE, 0x2021), 1 }, 100 { PCI_VDEVICE(SUNDANCE, 0x2021), 1 },
101 { PCI_VDEVICE(DLINK, 0x9021), 2 }, 101 { PCI_VDEVICE(DLINK, 0x9021), 2 },
diff --git a/drivers/net/ethernet/intel/e100.c b/drivers/net/ethernet/intel/e100.c
index 9d979d7debef..781065eb5431 100644
--- a/drivers/net/ethernet/intel/e100.c
+++ b/drivers/net/ethernet/intel/e100.c
@@ -208,7 +208,7 @@ MODULE_PARM_DESC(use_io, "Force use of i/o access mode");
208#define INTEL_8255X_ETHERNET_DEVICE(device_id, ich) {\ 208#define INTEL_8255X_ETHERNET_DEVICE(device_id, ich) {\
209 PCI_VENDOR_ID_INTEL, device_id, PCI_ANY_ID, PCI_ANY_ID, \ 209 PCI_VENDOR_ID_INTEL, device_id, PCI_ANY_ID, PCI_ANY_ID, \
210 PCI_CLASS_NETWORK_ETHERNET << 8, 0xFFFF00, ich } 210 PCI_CLASS_NETWORK_ETHERNET << 8, 0xFFFF00, ich }
211static DEFINE_PCI_DEVICE_TABLE(e100_id_table) = { 211static const struct pci_device_id e100_id_table[] = {
212 INTEL_8255X_ETHERNET_DEVICE(0x1029, 0), 212 INTEL_8255X_ETHERNET_DEVICE(0x1029, 0),
213 INTEL_8255X_ETHERNET_DEVICE(0x1030, 0), 213 INTEL_8255X_ETHERNET_DEVICE(0x1030, 0),
214 INTEL_8255X_ETHERNET_DEVICE(0x1031, 3), 214 INTEL_8255X_ETHERNET_DEVICE(0x1031, 3),
diff --git a/drivers/net/ethernet/intel/e1000/e1000_main.c b/drivers/net/ethernet/intel/e1000/e1000_main.c
index 660971f304b2..cbc330b301cd 100644
--- a/drivers/net/ethernet/intel/e1000/e1000_main.c
+++ b/drivers/net/ethernet/intel/e1000/e1000_main.c
@@ -46,7 +46,7 @@ static const char e1000_copyright[] = "Copyright (c) 1999-2006 Intel Corporation
46 * Macro expands to... 46 * Macro expands to...
47 * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)} 47 * {PCI_DEVICE(PCI_VENDOR_ID_INTEL, device_id)}
48 */ 48 */
49static DEFINE_PCI_DEVICE_TABLE(e1000_pci_tbl) = { 49static const struct pci_device_id e1000_pci_tbl[] = {
50 INTEL_E1000_ETHERNET_DEVICE(0x1000), 50 INTEL_E1000_ETHERNET_DEVICE(0x1000),
51 INTEL_E1000_ETHERNET_DEVICE(0x1001), 51 INTEL_E1000_ETHERNET_DEVICE(0x1001),
52 INTEL_E1000_ETHERNET_DEVICE(0x1004), 52 INTEL_E1000_ETHERNET_DEVICE(0x1004),
diff --git a/drivers/net/ethernet/intel/e1000e/manage.c b/drivers/net/ethernet/intel/e1000e/manage.c
index 58856032298d..06edfca1a35e 100644
--- a/drivers/net/ethernet/intel/e1000e/manage.c
+++ b/drivers/net/ethernet/intel/e1000e/manage.c
@@ -47,7 +47,7 @@ static u8 e1000_calculate_checksum(u8 *buffer, u32 length)
47 * e1000_mng_enable_host_if - Checks host interface is enabled 47 * e1000_mng_enable_host_if - Checks host interface is enabled
48 * @hw: pointer to the HW structure 48 * @hw: pointer to the HW structure
49 * 49 *
50 * Returns E1000_success upon success, else E1000_ERR_HOST_INTERFACE_COMMAND 50 * Returns 0 upon success, else -E1000_ERR_HOST_INTERFACE_COMMAND
51 * 51 *
52 * This function checks whether the HOST IF is enabled for command operation 52 * This function checks whether the HOST IF is enabled for command operation
53 * and also checks whether the previous command is completed. It busy waits 53 * and also checks whether the previous command is completed. It busy waits
@@ -78,7 +78,7 @@ static s32 e1000_mng_enable_host_if(struct e1000_hw *hw)
78 } 78 }
79 79
80 if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) { 80 if (i == E1000_MNG_DHCP_COMMAND_TIMEOUT) {
81 e_dbg("Previous command timeout failed .\n"); 81 e_dbg("Previous command timeout failed.\n");
82 return -E1000_ERR_HOST_INTERFACE_COMMAND; 82 return -E1000_ERR_HOST_INTERFACE_COMMAND;
83 } 83 }
84 84
diff --git a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
index 681a9e81ff51..e8ba7470700a 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_ethtool.c
@@ -1948,7 +1948,7 @@ static int i40e_update_ethtool_fdir_entry(struct i40e_vsi *vsi,
1948 1948
1949 /* add filter to the list */ 1949 /* add filter to the list */
1950 if (parent) 1950 if (parent)
1951 hlist_add_after(&parent->fdir_node, &input->fdir_node); 1951 hlist_add_behind(&input->fdir_node, &parent->fdir_node);
1952 else 1952 else
1953 hlist_add_head(&input->fdir_node, 1953 hlist_add_head(&input->fdir_node,
1954 &pf->fdir_filter_list); 1954 &pf->fdir_filter_list);
diff --git a/drivers/net/ethernet/intel/i40e/i40e_fcoe.c b/drivers/net/ethernet/intel/i40e/i40e_fcoe.c
index 6938fc1ad877..5d01db1d789b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_fcoe.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_fcoe.c
@@ -33,6 +33,7 @@
33#include <scsi/fc/fc_fcoe.h> 33#include <scsi/fc/fc_fcoe.h>
34#include <scsi/libfc.h> 34#include <scsi/libfc.h>
35#include <scsi/libfcoe.h> 35#include <scsi/libfcoe.h>
36#include <uapi/linux/dcbnl.h>
36 37
37#include "i40e.h" 38#include "i40e.h"
38#include "i40e_fcoe.h" 39#include "i40e_fcoe.h"
diff --git a/drivers/net/ethernet/intel/i40e/i40e_main.c b/drivers/net/ethernet/intel/i40e/i40e_main.c
index 51bc03072ed3..eddec6ba095b 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_main.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_main.c
@@ -65,7 +65,7 @@ static int i40e_veb_get_bw_info(struct i40e_veb *veb);
65 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, 65 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
66 * Class, Class Mask, private data (not used) } 66 * Class, Class Mask, private data (not used) }
67 */ 67 */
68static DEFINE_PCI_DEVICE_TABLE(i40e_pci_tbl) = { 68static const struct pci_device_id i40e_pci_tbl[] = {
69 {PCI_VDEVICE(INTEL, I40E_DEV_ID_SFP_XL710), 0}, 69 {PCI_VDEVICE(INTEL, I40E_DEV_ID_SFP_XL710), 0},
70 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QEMU), 0}, 70 {PCI_VDEVICE(INTEL, I40E_DEV_ID_QEMU), 0},
71 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_A), 0}, 71 {PCI_VDEVICE(INTEL, I40E_DEV_ID_KX_A), 0},
@@ -4415,13 +4415,13 @@ static void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
4415 4415
4416 switch (vsi->back->hw.phy.link_info.link_speed) { 4416 switch (vsi->back->hw.phy.link_info.link_speed) {
4417 case I40E_LINK_SPEED_40GB: 4417 case I40E_LINK_SPEED_40GB:
4418 strncpy(speed, "40 Gbps", SPEED_SIZE); 4418 strlcpy(speed, "40 Gbps", SPEED_SIZE);
4419 break; 4419 break;
4420 case I40E_LINK_SPEED_10GB: 4420 case I40E_LINK_SPEED_10GB:
4421 strncpy(speed, "10 Gbps", SPEED_SIZE); 4421 strlcpy(speed, "10 Gbps", SPEED_SIZE);
4422 break; 4422 break;
4423 case I40E_LINK_SPEED_1GB: 4423 case I40E_LINK_SPEED_1GB:
4424 strncpy(speed, "1000 Mbps", SPEED_SIZE); 4424 strlcpy(speed, "1000 Mbps", SPEED_SIZE);
4425 break; 4425 break;
4426 default: 4426 default:
4427 break; 4427 break;
@@ -4429,16 +4429,16 @@ static void i40e_print_link_message(struct i40e_vsi *vsi, bool isup)
4429 4429
4430 switch (vsi->back->hw.fc.current_mode) { 4430 switch (vsi->back->hw.fc.current_mode) {
4431 case I40E_FC_FULL: 4431 case I40E_FC_FULL:
4432 strncpy(fc, "RX/TX", FC_SIZE); 4432 strlcpy(fc, "RX/TX", FC_SIZE);
4433 break; 4433 break;
4434 case I40E_FC_TX_PAUSE: 4434 case I40E_FC_TX_PAUSE:
4435 strncpy(fc, "TX", FC_SIZE); 4435 strlcpy(fc, "TX", FC_SIZE);
4436 break; 4436 break;
4437 case I40E_FC_RX_PAUSE: 4437 case I40E_FC_RX_PAUSE:
4438 strncpy(fc, "RX", FC_SIZE); 4438 strlcpy(fc, "RX", FC_SIZE);
4439 break; 4439 break;
4440 default: 4440 default:
4441 strncpy(fc, "None", FC_SIZE); 4441 strlcpy(fc, "None", FC_SIZE);
4442 break; 4442 break;
4443 } 4443 }
4444 4444
@@ -5839,7 +5839,7 @@ static void i40e_send_version(struct i40e_pf *pf)
5839 dv.minor_version = DRV_VERSION_MINOR; 5839 dv.minor_version = DRV_VERSION_MINOR;
5840 dv.build_version = DRV_VERSION_BUILD; 5840 dv.build_version = DRV_VERSION_BUILD;
5841 dv.subbuild_version = 0; 5841 dv.subbuild_version = 0;
5842 strncpy(dv.driver_string, DRV_VERSION, sizeof(dv.driver_string)); 5842 strlcpy(dv.driver_string, DRV_VERSION, sizeof(dv.driver_string));
5843 i40e_aq_send_driver_version(&pf->hw, &dv, NULL); 5843 i40e_aq_send_driver_version(&pf->hw, &dv, NULL);
5844} 5844}
5845 5845
@@ -6293,7 +6293,7 @@ static int i40e_vsi_alloc_arrays(struct i40e_vsi *vsi, bool alloc_qvectors)
6293 6293
6294 if (alloc_qvectors) { 6294 if (alloc_qvectors) {
6295 /* allocate memory for q_vector pointers */ 6295 /* allocate memory for q_vector pointers */
6296 size = sizeof(struct i40e_q_vectors *) * vsi->num_q_vectors; 6296 size = sizeof(struct i40e_q_vector *) * vsi->num_q_vectors;
6297 vsi->q_vectors = kzalloc(size, GFP_KERNEL); 6297 vsi->q_vectors = kzalloc(size, GFP_KERNEL);
6298 if (!vsi->q_vectors) { 6298 if (!vsi->q_vectors) {
6299 ret = -ENOMEM; 6299 ret = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/i40e/i40e_nvm.c b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
index 97bda3dffd49..25c4f9a3011f 100644
--- a/drivers/net/ethernet/intel/i40e/i40e_nvm.c
+++ b/drivers/net/ethernet/intel/i40e/i40e_nvm.c
@@ -251,9 +251,9 @@ i40e_status i40e_read_nvm_buffer(struct i40e_hw *hw, u16 offset,
251 * 251 *
252 * Writes a 16 bit words buffer to the Shadow RAM using the admin command. 252 * Writes a 16 bit words buffer to the Shadow RAM using the admin command.
253 **/ 253 **/
254i40e_status i40e_write_nvm_aq(struct i40e_hw *hw, u8 module_pointer, 254static i40e_status i40e_write_nvm_aq(struct i40e_hw *hw, u8 module_pointer,
255 u32 offset, u16 words, void *data, 255 u32 offset, u16 words, void *data,
256 bool last_command) 256 bool last_command)
257{ 257{
258 i40e_status ret_code = I40E_ERR_NVM; 258 i40e_status ret_code = I40E_ERR_NVM;
259 259
diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index ab15f4d07e41..38429fae4fcf 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -49,7 +49,7 @@ static const char i40evf_copyright[] =
49 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, 49 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
50 * Class, Class Mask, private data (not used) } 50 * Class, Class Mask, private data (not used) }
51 */ 51 */
52static DEFINE_PCI_DEVICE_TABLE(i40evf_pci_tbl) = { 52static const struct pci_device_id i40evf_pci_tbl[] = {
53 {PCI_VDEVICE(INTEL, I40E_DEV_ID_VF), 0}, 53 {PCI_VDEVICE(INTEL, I40E_DEV_ID_VF), 0},
54 /* required last entry */ 54 /* required last entry */
55 {0, } 55 {0, }
diff --git a/drivers/net/ethernet/intel/igbvf/netdev.c b/drivers/net/ethernet/intel/igbvf/netdev.c
index d608599e123a..63c807c9b21c 100644
--- a/drivers/net/ethernet/intel/igbvf/netdev.c
+++ b/drivers/net/ethernet/intel/igbvf/netdev.c
@@ -2853,7 +2853,7 @@ static const struct pci_error_handlers igbvf_err_handler = {
2853 .resume = igbvf_io_resume, 2853 .resume = igbvf_io_resume,
2854}; 2854};
2855 2855
2856static DEFINE_PCI_DEVICE_TABLE(igbvf_pci_tbl) = { 2856static const struct pci_device_id igbvf_pci_tbl[] = {
2857 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_VF), board_vf }, 2857 { PCI_VDEVICE(INTEL, E1000_DEV_ID_82576_VF), board_vf },
2858 { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_VF), board_i350_vf }, 2858 { PCI_VDEVICE(INTEL, E1000_DEV_ID_I350_VF), board_i350_vf },
2859 { } /* terminate list */ 2859 { } /* terminate list */
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
index 60801273915c..055961b0f24b 100644
--- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c
+++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c
@@ -53,7 +53,7 @@ MODULE_PARM_DESC(copybreak,
53 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, 53 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
54 * Class, Class Mask, private data (not used) } 54 * Class, Class Mask, private data (not used) }
55 */ 55 */
56static DEFINE_PCI_DEVICE_TABLE(ixgb_pci_tbl) = { 56static const struct pci_device_id ixgb_pci_tbl[] = {
57 {PCI_VENDOR_ID_INTEL, IXGB_DEVICE_ID_82597EX, 57 {PCI_VENDOR_ID_INTEL, IXGB_DEVICE_ID_82597EX,
58 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0}, 58 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0},
59 {PCI_VENDOR_ID_INTEL, IXGB_DEVICE_ID_82597EX_CX4, 59 {PCI_VENDOR_ID_INTEL, IXGB_DEVICE_ID_82597EX_CX4,
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index 94a1c07efeb0..e4100b5737b6 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -2517,7 +2517,7 @@ static int ixgbe_update_ethtool_fdir_entry(struct ixgbe_adapter *adapter,
2517 2517
2518 /* add filter to the list */ 2518 /* add filter to the list */
2519 if (parent) 2519 if (parent)
2520 hlist_add_after(&parent->fdir_node, &input->fdir_node); 2520 hlist_add_behind(&input->fdir_node, &parent->fdir_node);
2521 else 2521 else
2522 hlist_add_head(&input->fdir_node, 2522 hlist_add_head(&input->fdir_node,
2523 &adapter->fdir_filter_list); 2523 &adapter->fdir_filter_list);
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
index 5384ed30298a..87bd53fdd209 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
@@ -84,7 +84,7 @@ static const struct ixgbe_info *ixgbe_info_tbl[] = {
84 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, 84 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
85 * Class, Class Mask, private data (not used) } 85 * Class, Class Mask, private data (not used) }
86 */ 86 */
87static DEFINE_PCI_DEVICE_TABLE(ixgbe_pci_tbl) = { 87static const struct pci_device_id ixgbe_pci_tbl[] = {
88 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598), board_82598 }, 88 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598), board_82598 },
89 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_DUAL_PORT), board_82598 }, 89 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_DUAL_PORT), board_82598 },
90 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_SINGLE_PORT), board_82598 }, 90 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82598AF_SINGLE_PORT), board_82598 },
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index 75467f83772c..c22a00c3621a 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -76,7 +76,7 @@ static const struct ixgbevf_info *ixgbevf_info_tbl[] = {
76 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID, 76 * { Vendor ID, Device ID, SubVendor ID, SubDevice ID,
77 * Class, Class Mask, private data (not used) } 77 * Class, Class Mask, private data (not used) }
78 */ 78 */
79static DEFINE_PCI_DEVICE_TABLE(ixgbevf_pci_tbl) = { 79static const struct pci_device_id ixgbevf_pci_tbl[] = {
80 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_VF), board_82599_vf }, 80 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_82599_VF), board_82599_vf },
81 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X540_VF), board_X540_vf }, 81 {PCI_VDEVICE(INTEL, IXGBE_DEV_ID_X540_VF), board_X540_vf },
82 /* required last entry */ 82 /* required last entry */
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c
index b78378cea5e3..4a1be34d7214 100644
--- a/drivers/net/ethernet/jme.c
+++ b/drivers/net/ethernet/jme.c
@@ -3334,7 +3334,7 @@ static SIMPLE_DEV_PM_OPS(jme_pm_ops, jme_suspend, jme_resume);
3334#define JME_PM_OPS NULL 3334#define JME_PM_OPS NULL
3335#endif 3335#endif
3336 3336
3337static DEFINE_PCI_DEVICE_TABLE(jme_pci_tbl) = { 3337static const struct pci_device_id jme_pci_tbl[] = {
3338 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMC250) }, 3338 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMC250) },
3339 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMC260) }, 3339 { PCI_VDEVICE(JMICRON, PCI_DEVICE_ID_JMICRON_JMC260) },
3340 { } 3340 { }
diff --git a/drivers/net/ethernet/marvell/mvneta.c b/drivers/net/ethernet/marvell/mvneta.c
index dadd9a5f6323..c9f1d1b7ef37 100644
--- a/drivers/net/ethernet/marvell/mvneta.c
+++ b/drivers/net/ethernet/marvell/mvneta.c
@@ -2969,14 +2969,14 @@ static int mvneta_probe(struct platform_device *pdev)
2969 /* In the case of a fixed PHY, the DT node associated 2969 /* In the case of a fixed PHY, the DT node associated
2970 * to the PHY is the Ethernet MAC DT node. 2970 * to the PHY is the Ethernet MAC DT node.
2971 */ 2971 */
2972 phy_node = dn; 2972 phy_node = of_node_get(dn);
2973 } 2973 }
2974 2974
2975 phy_mode = of_get_phy_mode(dn); 2975 phy_mode = of_get_phy_mode(dn);
2976 if (phy_mode < 0) { 2976 if (phy_mode < 0) {
2977 dev_err(&pdev->dev, "incorrect phy-mode\n"); 2977 dev_err(&pdev->dev, "incorrect phy-mode\n");
2978 err = -EINVAL; 2978 err = -EINVAL;
2979 goto err_free_irq; 2979 goto err_put_phy_node;
2980 } 2980 }
2981 2981
2982 dev->tx_queue_len = MVNETA_MAX_TXD; 2982 dev->tx_queue_len = MVNETA_MAX_TXD;
@@ -2992,7 +2992,7 @@ static int mvneta_probe(struct platform_device *pdev)
2992 pp->clk = devm_clk_get(&pdev->dev, NULL); 2992 pp->clk = devm_clk_get(&pdev->dev, NULL);
2993 if (IS_ERR(pp->clk)) { 2993 if (IS_ERR(pp->clk)) {
2994 err = PTR_ERR(pp->clk); 2994 err = PTR_ERR(pp->clk);
2995 goto err_free_irq; 2995 goto err_put_phy_node;
2996 } 2996 }
2997 2997
2998 clk_prepare_enable(pp->clk); 2998 clk_prepare_enable(pp->clk);
@@ -3071,6 +3071,8 @@ err_free_stats:
3071 free_percpu(pp->stats); 3071 free_percpu(pp->stats);
3072err_clk: 3072err_clk:
3073 clk_disable_unprepare(pp->clk); 3073 clk_disable_unprepare(pp->clk);
3074err_put_phy_node:
3075 of_node_put(phy_node);
3074err_free_irq: 3076err_free_irq:
3075 irq_dispose_mapping(dev->irq); 3077 irq_dispose_mapping(dev->irq);
3076err_free_netdev: 3078err_free_netdev:
@@ -3088,6 +3090,7 @@ static int mvneta_remove(struct platform_device *pdev)
3088 clk_disable_unprepare(pp->clk); 3090 clk_disable_unprepare(pp->clk);
3089 free_percpu(pp->stats); 3091 free_percpu(pp->stats);
3090 irq_dispose_mapping(dev->irq); 3092 irq_dispose_mapping(dev->irq);
3093 of_node_put(pp->phy_node);
3091 free_netdev(dev); 3094 free_netdev(dev);
3092 3095
3093 return 0; 3096 return 0;
diff --git a/drivers/net/ethernet/marvell/skge.c b/drivers/net/ethernet/marvell/skge.c
index e912b6887d40..24b242277ea1 100644
--- a/drivers/net/ethernet/marvell/skge.c
+++ b/drivers/net/ethernet/marvell/skge.c
@@ -82,7 +82,7 @@ static int debug = -1; /* defaults above */
82module_param(debug, int, 0); 82module_param(debug, int, 0);
83MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)"); 83MODULE_PARM_DESC(debug, "Debug level (0=none,...,16=all)");
84 84
85static DEFINE_PCI_DEVICE_TABLE(skge_id_table) = { 85static const struct pci_device_id skge_id_table[] = {
86 { PCI_DEVICE(PCI_VENDOR_ID_3COM, 0x1700) }, /* 3Com 3C940 */ 86 { PCI_DEVICE(PCI_VENDOR_ID_3COM, 0x1700) }, /* 3Com 3C940 */
87 { PCI_DEVICE(PCI_VENDOR_ID_3COM, 0x80EB) }, /* 3Com 3C940B */ 87 { PCI_DEVICE(PCI_VENDOR_ID_3COM, 0x80EB) }, /* 3Com 3C940B */
88#ifdef CONFIG_SKGE_GENESIS 88#ifdef CONFIG_SKGE_GENESIS
diff --git a/drivers/net/ethernet/marvell/sky2.c b/drivers/net/ethernet/marvell/sky2.c
index 69693384b58c..dba48a5ce7ab 100644
--- a/drivers/net/ethernet/marvell/sky2.c
+++ b/drivers/net/ethernet/marvell/sky2.c
@@ -101,7 +101,7 @@ static int legacy_pme = 0;
101module_param(legacy_pme, int, 0); 101module_param(legacy_pme, int, 0);
102MODULE_PARM_DESC(legacy_pme, "Legacy power management"); 102MODULE_PARM_DESC(legacy_pme, "Legacy power management");
103 103
104static DEFINE_PCI_DEVICE_TABLE(sky2_id_table) = { 104static const struct pci_device_id sky2_id_table[] = {
105 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */ 105 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9000) }, /* SK-9Sxx */
106 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */ 106 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E00) }, /* SK-9Exx */
107 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E01) }, /* SK-9E21M */ 107 { PCI_DEVICE(PCI_VENDOR_ID_SYSKONNECT, 0x9E01) }, /* SK-9E21M */
@@ -1622,11 +1622,10 @@ static int sky2_alloc_buffers(struct sky2_port *sky2)
1622 if (!sky2->tx_ring) 1622 if (!sky2->tx_ring)
1623 goto nomem; 1623 goto nomem;
1624 1624
1625 sky2->rx_le = pci_alloc_consistent(hw->pdev, RX_LE_BYTES, 1625 sky2->rx_le = pci_zalloc_consistent(hw->pdev, RX_LE_BYTES,
1626 &sky2->rx_le_map); 1626 &sky2->rx_le_map);
1627 if (!sky2->rx_le) 1627 if (!sky2->rx_le)
1628 goto nomem; 1628 goto nomem;
1629 memset(sky2->rx_le, 0, RX_LE_BYTES);
1630 1629
1631 sky2->rx_ring = kcalloc(sky2->rx_pending, sizeof(struct rx_ring_info), 1630 sky2->rx_ring = kcalloc(sky2->rx_pending, sizeof(struct rx_ring_info),
1632 GFP_KERNEL); 1631 GFP_KERNEL);
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index 5d940a26055c..65a4a0f88ea0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -1311,6 +1311,15 @@ static struct mlx4_cmd_info cmd_info[] = {
1311 .wrapper = mlx4_MAD_IFC_wrapper 1311 .wrapper = mlx4_MAD_IFC_wrapper
1312 }, 1312 },
1313 { 1313 {
1314 .opcode = MLX4_CMD_MAD_DEMUX,
1315 .has_inbox = false,
1316 .has_outbox = false,
1317 .out_is_imm = false,
1318 .encode_slave_id = false,
1319 .verify = NULL,
1320 .wrapper = mlx4_CMD_EPERM_wrapper
1321 },
1322 {
1314 .opcode = MLX4_CMD_QUERY_IF_STAT, 1323 .opcode = MLX4_CMD_QUERY_IF_STAT,
1315 .has_inbox = false, 1324 .has_inbox = false,
1316 .has_outbox = true, 1325 .has_outbox = true,
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index 688e1eabab29..494753e44ae3 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -136,7 +136,8 @@ static void dump_dev_cap_flags2(struct mlx4_dev *dev, u64 flags)
136 [7] = "FSM (MAC anti-spoofing) support", 136 [7] = "FSM (MAC anti-spoofing) support",
137 [8] = "Dynamic QP updates support", 137 [8] = "Dynamic QP updates support",
138 [9] = "Device managed flow steering IPoIB support", 138 [9] = "Device managed flow steering IPoIB support",
139 [10] = "TCP/IP offloads/flow-steering for VXLAN support" 139 [10] = "TCP/IP offloads/flow-steering for VXLAN support",
140 [11] = "MAD DEMUX (Secure-Host) support"
140 }; 141 };
141 int i; 142 int i;
142 143
@@ -571,6 +572,7 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
571#define QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET 0xa0 572#define QUERY_DEV_CAP_MAX_ICM_SZ_OFFSET 0xa0
572#define QUERY_DEV_CAP_FW_REASSIGN_MAC 0x9d 573#define QUERY_DEV_CAP_FW_REASSIGN_MAC 0x9d
573#define QUERY_DEV_CAP_VXLAN 0x9e 574#define QUERY_DEV_CAP_VXLAN 0x9e
575#define QUERY_DEV_CAP_MAD_DEMUX_OFFSET 0xb0
574 576
575 dev_cap->flags2 = 0; 577 dev_cap->flags2 = 0;
576 mailbox = mlx4_alloc_cmd_mailbox(dev); 578 mailbox = mlx4_alloc_cmd_mailbox(dev);
@@ -748,6 +750,11 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
748 MLX4_GET(dev_cap->max_counters, outbox, 750 MLX4_GET(dev_cap->max_counters, outbox,
749 QUERY_DEV_CAP_MAX_COUNTERS_OFFSET); 751 QUERY_DEV_CAP_MAX_COUNTERS_OFFSET);
750 752
753 MLX4_GET(field32, outbox,
754 QUERY_DEV_CAP_MAD_DEMUX_OFFSET);
755 if (field32 & (1 << 0))
756 dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_MAD_DEMUX;
757
751 MLX4_GET(field32, outbox, QUERY_DEV_CAP_EXT_2_FLAGS_OFFSET); 758 MLX4_GET(field32, outbox, QUERY_DEV_CAP_EXT_2_FLAGS_OFFSET);
752 if (field32 & (1 << 16)) 759 if (field32 & (1 << 16))
753 dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_UPDATE_QP; 760 dev_cap->flags2 |= MLX4_DEV_CAP_FLAG2_UPDATE_QP;
@@ -2016,3 +2023,85 @@ void mlx4_opreq_action(struct work_struct *work)
2016out: 2023out:
2017 mlx4_free_cmd_mailbox(dev, mailbox); 2024 mlx4_free_cmd_mailbox(dev, mailbox);
2018} 2025}
2026
2027static int mlx4_check_smp_firewall_active(struct mlx4_dev *dev,
2028 struct mlx4_cmd_mailbox *mailbox)
2029{
2030#define MLX4_CMD_MAD_DEMUX_SET_ATTR_OFFSET 0x10
2031#define MLX4_CMD_MAD_DEMUX_GETRESP_ATTR_OFFSET 0x20
2032#define MLX4_CMD_MAD_DEMUX_TRAP_ATTR_OFFSET 0x40
2033#define MLX4_CMD_MAD_DEMUX_TRAP_REPRESS_ATTR_OFFSET 0x70
2034
2035 u32 set_attr_mask, getresp_attr_mask;
2036 u32 trap_attr_mask, traprepress_attr_mask;
2037
2038 MLX4_GET(set_attr_mask, mailbox->buf,
2039 MLX4_CMD_MAD_DEMUX_SET_ATTR_OFFSET);
2040 mlx4_dbg(dev, "SMP firewall set_attribute_mask = 0x%x\n",
2041 set_attr_mask);
2042
2043 MLX4_GET(getresp_attr_mask, mailbox->buf,
2044 MLX4_CMD_MAD_DEMUX_GETRESP_ATTR_OFFSET);
2045 mlx4_dbg(dev, "SMP firewall getresp_attribute_mask = 0x%x\n",
2046 getresp_attr_mask);
2047
2048 MLX4_GET(trap_attr_mask, mailbox->buf,
2049 MLX4_CMD_MAD_DEMUX_TRAP_ATTR_OFFSET);
2050 mlx4_dbg(dev, "SMP firewall trap_attribute_mask = 0x%x\n",
2051 trap_attr_mask);
2052
2053 MLX4_GET(traprepress_attr_mask, mailbox->buf,
2054 MLX4_CMD_MAD_DEMUX_TRAP_REPRESS_ATTR_OFFSET);
2055 mlx4_dbg(dev, "SMP firewall traprepress_attribute_mask = 0x%x\n",
2056 traprepress_attr_mask);
2057
2058 if (set_attr_mask && getresp_attr_mask && trap_attr_mask &&
2059 traprepress_attr_mask)
2060 return 1;
2061
2062 return 0;
2063}
2064
2065int mlx4_config_mad_demux(struct mlx4_dev *dev)
2066{
2067 struct mlx4_cmd_mailbox *mailbox;
2068 int secure_host_active;
2069 int err;
2070
2071 /* Check if mad_demux is supported */
2072 if (!(dev->caps.flags2 & MLX4_DEV_CAP_FLAG2_MAD_DEMUX))
2073 return 0;
2074
2075 mailbox = mlx4_alloc_cmd_mailbox(dev);
2076 if (IS_ERR(mailbox)) {
2077 mlx4_warn(dev, "Failed to allocate mailbox for cmd MAD_DEMUX");
2078 return -ENOMEM;
2079 }
2080
2081 /* Query mad_demux to find out which MADs are handled by internal sma */
2082 err = mlx4_cmd_box(dev, 0, mailbox->dma, 0x01 /* subn mgmt class */,
2083 MLX4_CMD_MAD_DEMUX_QUERY_RESTR, MLX4_CMD_MAD_DEMUX,
2084 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
2085 if (err) {
2086 mlx4_warn(dev, "MLX4_CMD_MAD_DEMUX: query restrictions failed (%d)\n",
2087 err);
2088 goto out;
2089 }
2090
2091 secure_host_active = mlx4_check_smp_firewall_active(dev, mailbox);
2092
2093 /* Config mad_demux to handle all MADs returned by the query above */
2094 err = mlx4_cmd(dev, mailbox->dma, 0x01 /* subn mgmt class */,
2095 MLX4_CMD_MAD_DEMUX_CONFIG, MLX4_CMD_MAD_DEMUX,
2096 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_NATIVE);
2097 if (err) {
2098 mlx4_warn(dev, "MLX4_CMD_MAD_DEMUX: configure failed (%d)\n", err);
2099 goto out;
2100 }
2101
2102 if (secure_host_active)
2103 mlx4_warn(dev, "HCA operating in secure-host mode. SMP firewall activated.\n");
2104out:
2105 mlx4_free_cmd_mailbox(dev, mailbox);
2106 return err;
2107}
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 80b8c5f30e4e..7e2d5d57c598 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -1853,6 +1853,11 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
1853 mlx4_err(dev, "Failed to initialize multicast group table, aborting\n"); 1853 mlx4_err(dev, "Failed to initialize multicast group table, aborting\n");
1854 goto err_mr_table_free; 1854 goto err_mr_table_free;
1855 } 1855 }
1856 err = mlx4_config_mad_demux(dev);
1857 if (err) {
1858 mlx4_err(dev, "Failed in config_mad_demux, aborting\n");
1859 goto err_mcg_table_free;
1860 }
1856 } 1861 }
1857 1862
1858 err = mlx4_init_eq_table(dev); 1863 err = mlx4_init_eq_table(dev);
@@ -2727,7 +2732,7 @@ int mlx4_restart_one(struct pci_dev *pdev)
2727 return __mlx4_init_one(pdev, pci_dev_data); 2732 return __mlx4_init_one(pdev, pci_dev_data);
2728} 2733}
2729 2734
2730static DEFINE_PCI_DEVICE_TABLE(mlx4_pci_table) = { 2735static const struct pci_device_id mlx4_pci_table[] = {
2731 /* MT25408 "Hermon" SDR */ 2736 /* MT25408 "Hermon" SDR */
2732 { PCI_VDEVICE(MELLANOX, 0x6340), MLX4_PCI_DEV_FORCE_SENSE_PORT }, 2737 { PCI_VDEVICE(MELLANOX, 0x6340), MLX4_PCI_DEV_FORCE_SENSE_PORT },
2733 /* MT25408 "Hermon" DDR */ 2738 /* MT25408 "Hermon" DDR */
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4.h b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
index 13fbcd03c3e4..b508c7887ef8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mlx4.h
+++ b/drivers/net/ethernet/mellanox/mlx4/mlx4.h
@@ -274,6 +274,8 @@ struct mlx4_icm_table {
274#define MLX4_MPT_FLAG_PHYSICAL (1 << 9) 274#define MLX4_MPT_FLAG_PHYSICAL (1 << 9)
275#define MLX4_MPT_FLAG_REGION (1 << 8) 275#define MLX4_MPT_FLAG_REGION (1 << 8)
276 276
277#define MLX4_MPT_PD_MASK (0x1FFFFUL)
278#define MLX4_MPT_PD_VF_MASK (0xFE0000UL)
277#define MLX4_MPT_PD_FLAG_FAST_REG (1 << 27) 279#define MLX4_MPT_PD_FLAG_FAST_REG (1 << 27)
278#define MLX4_MPT_PD_FLAG_RAE (1 << 28) 280#define MLX4_MPT_PD_FLAG_RAE (1 << 28)
279#define MLX4_MPT_PD_FLAG_EN_INV (3 << 24) 281#define MLX4_MPT_PD_FLAG_EN_INV (3 << 24)
@@ -1306,5 +1308,6 @@ void mlx4_init_quotas(struct mlx4_dev *dev);
1306int mlx4_get_slave_num_gids(struct mlx4_dev *dev, int slave, int port); 1308int mlx4_get_slave_num_gids(struct mlx4_dev *dev, int slave, int port);
1307/* Returns the VF index of slave */ 1309/* Returns the VF index of slave */
1308int mlx4_get_vf_indx(struct mlx4_dev *dev, int slave); 1310int mlx4_get_vf_indx(struct mlx4_dev *dev, int slave);
1311int mlx4_config_mad_demux(struct mlx4_dev *dev);
1309 1312
1310#endif /* MLX4_H */ 1313#endif /* MLX4_H */
diff --git a/drivers/net/ethernet/mellanox/mlx4/mr.c b/drivers/net/ethernet/mellanox/mlx4/mr.c
index 2839abb878a6..7d717eccb7b0 100644
--- a/drivers/net/ethernet/mellanox/mlx4/mr.c
+++ b/drivers/net/ethernet/mellanox/mlx4/mr.c
@@ -298,6 +298,131 @@ static int mlx4_HW2SW_MPT(struct mlx4_dev *dev, struct mlx4_cmd_mailbox *mailbox
298 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED); 298 MLX4_CMD_TIME_CLASS_B, MLX4_CMD_WRAPPED);
299} 299}
300 300
301int mlx4_mr_hw_get_mpt(struct mlx4_dev *dev, struct mlx4_mr *mmr,
302 struct mlx4_mpt_entry ***mpt_entry)
303{
304 int err;
305 int key = key_to_hw_index(mmr->key) & (dev->caps.num_mpts - 1);
306 struct mlx4_cmd_mailbox *mailbox = NULL;
307
308 /* Make sure that at this point we have single-threaded access only */
309
310 if (mmr->enabled != MLX4_MPT_EN_HW)
311 return -EINVAL;
312
313 err = mlx4_HW2SW_MPT(dev, NULL, key);
314
315 if (err) {
316 mlx4_warn(dev, "HW2SW_MPT failed (%d).", err);
317 mlx4_warn(dev, "Most likely the MR has MWs bound to it.\n");
318 return err;
319 }
320
321 mmr->enabled = MLX4_MPT_EN_SW;
322
323 if (!mlx4_is_mfunc(dev)) {
324 **mpt_entry = mlx4_table_find(
325 &mlx4_priv(dev)->mr_table.dmpt_table,
326 key, NULL);
327 } else {
328 mailbox = mlx4_alloc_cmd_mailbox(dev);
329 if (IS_ERR_OR_NULL(mailbox))
330 return PTR_ERR(mailbox);
331
332 err = mlx4_cmd_box(dev, 0, mailbox->dma, key,
333 0, MLX4_CMD_QUERY_MPT,
334 MLX4_CMD_TIME_CLASS_B,
335 MLX4_CMD_WRAPPED);
336
337 if (err)
338 goto free_mailbox;
339
340 *mpt_entry = (struct mlx4_mpt_entry **)&mailbox->buf;
341 }
342
343 if (!(*mpt_entry) || !(**mpt_entry)) {
344 err = -ENOMEM;
345 goto free_mailbox;
346 }
347
348 return 0;
349
350free_mailbox:
351 mlx4_free_cmd_mailbox(dev, mailbox);
352 return err;
353}
354EXPORT_SYMBOL_GPL(mlx4_mr_hw_get_mpt);
355
356int mlx4_mr_hw_write_mpt(struct mlx4_dev *dev, struct mlx4_mr *mmr,
357 struct mlx4_mpt_entry **mpt_entry)
358{
359 int err;
360
361 if (!mlx4_is_mfunc(dev)) {
362 /* Make sure any changes to this entry are flushed */
363 wmb();
364
365 *(u8 *)(*mpt_entry) = MLX4_MPT_STATUS_HW;
366
367 /* Make sure the new status is written */
368 wmb();
369
370 err = mlx4_SYNC_TPT(dev);
371 } else {
372 int key = key_to_hw_index(mmr->key) & (dev->caps.num_mpts - 1);
373
374 struct mlx4_cmd_mailbox *mailbox =
375 container_of((void *)mpt_entry, struct mlx4_cmd_mailbox,
376 buf);
377
378 err = mlx4_SW2HW_MPT(dev, mailbox, key);
379 }
380
381 mmr->pd = be32_to_cpu((*mpt_entry)->pd_flags) & MLX4_MPT_PD_MASK;
382 if (!err)
383 mmr->enabled = MLX4_MPT_EN_HW;
384 return err;
385}
386EXPORT_SYMBOL_GPL(mlx4_mr_hw_write_mpt);
387
388void mlx4_mr_hw_put_mpt(struct mlx4_dev *dev,
389 struct mlx4_mpt_entry **mpt_entry)
390{
391 if (mlx4_is_mfunc(dev)) {
392 struct mlx4_cmd_mailbox *mailbox =
393 container_of((void *)mpt_entry, struct mlx4_cmd_mailbox,
394 buf);
395 mlx4_free_cmd_mailbox(dev, mailbox);
396 }
397}
398EXPORT_SYMBOL_GPL(mlx4_mr_hw_put_mpt);
399
400int mlx4_mr_hw_change_pd(struct mlx4_dev *dev, struct mlx4_mpt_entry *mpt_entry,
401 u32 pdn)
402{
403 u32 pd_flags = be32_to_cpu(mpt_entry->pd_flags);
404 /* The wrapper function will put the slave's id here */
405 if (mlx4_is_mfunc(dev))
406 pd_flags &= ~MLX4_MPT_PD_VF_MASK;
407 mpt_entry->pd_flags = cpu_to_be32((pd_flags & ~MLX4_MPT_PD_MASK) |
408 (pdn & MLX4_MPT_PD_MASK)
409 | MLX4_MPT_PD_FLAG_EN_INV);
410 return 0;
411}
412EXPORT_SYMBOL_GPL(mlx4_mr_hw_change_pd);
413
414int mlx4_mr_hw_change_access(struct mlx4_dev *dev,
415 struct mlx4_mpt_entry *mpt_entry,
416 u32 access)
417{
418 u32 flags = (be32_to_cpu(mpt_entry->flags) & ~MLX4_PERM_MASK) |
419 (access & MLX4_PERM_MASK);
420
421 mpt_entry->flags = cpu_to_be32(flags);
422 return 0;
423}
424EXPORT_SYMBOL_GPL(mlx4_mr_hw_change_access);
425
301static int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd, 426static int mlx4_mr_alloc_reserved(struct mlx4_dev *dev, u32 mridx, u32 pd,
302 u64 iova, u64 size, u32 access, int npages, 427 u64 iova, u64 size, u32 access, int npages,
303 int page_shift, struct mlx4_mr *mr) 428 int page_shift, struct mlx4_mr *mr)
@@ -463,6 +588,41 @@ int mlx4_mr_free(struct mlx4_dev *dev, struct mlx4_mr *mr)
463} 588}
464EXPORT_SYMBOL_GPL(mlx4_mr_free); 589EXPORT_SYMBOL_GPL(mlx4_mr_free);
465 590
591void mlx4_mr_rereg_mem_cleanup(struct mlx4_dev *dev, struct mlx4_mr *mr)
592{
593 mlx4_mtt_cleanup(dev, &mr->mtt);
594}
595EXPORT_SYMBOL_GPL(mlx4_mr_rereg_mem_cleanup);
596
597int mlx4_mr_rereg_mem_write(struct mlx4_dev *dev, struct mlx4_mr *mr,
598 u64 iova, u64 size, int npages,
599 int page_shift, struct mlx4_mpt_entry *mpt_entry)
600{
601 int err;
602
603 mpt_entry->start = cpu_to_be64(mr->iova);
604 mpt_entry->length = cpu_to_be64(mr->size);
605 mpt_entry->entity_size = cpu_to_be32(mr->mtt.page_shift);
606
607 err = mlx4_mtt_init(dev, npages, page_shift, &mr->mtt);
608 if (err)
609 return err;
610
611 if (mr->mtt.order < 0) {
612 mpt_entry->flags |= cpu_to_be32(MLX4_MPT_FLAG_PHYSICAL);
613 mpt_entry->mtt_addr = 0;
614 } else {
615 mpt_entry->mtt_addr = cpu_to_be64(mlx4_mtt_addr(dev,
616 &mr->mtt));
617 if (mr->mtt.page_shift == 0)
618 mpt_entry->mtt_sz = cpu_to_be32(1 << mr->mtt.order);
619 }
620 mr->enabled = MLX4_MPT_EN_SW;
621
622 return 0;
623}
624EXPORT_SYMBOL_GPL(mlx4_mr_rereg_mem_write);
625
466int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr) 626int mlx4_mr_enable(struct mlx4_dev *dev, struct mlx4_mr *mr)
467{ 627{
468 struct mlx4_cmd_mailbox *mailbox; 628 struct mlx4_cmd_mailbox *mailbox;
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index 0efc1368e5a8..1089367fed22 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -2613,12 +2613,34 @@ int mlx4_QUERY_MPT_wrapper(struct mlx4_dev *dev, int slave,
2613 if (err) 2613 if (err)
2614 return err; 2614 return err;
2615 2615
2616 if (mpt->com.from_state != RES_MPT_HW) { 2616 if (mpt->com.from_state == RES_MPT_MAPPED) {
2617 /* In order to allow rereg in SRIOV, we need to alter the MPT entry. To do
2618 * that, the VF must read the MPT. But since the MPT entry memory is not
2619 * in the VF's virtual memory space, it must use QUERY_MPT to obtain the
2620 * entry contents. To guarantee that the MPT cannot be changed, the driver
2621 * must perform HW2SW_MPT before this query and return the MPT entry to HW
2622 * ownership fofollowing the change. The change here allows the VF to
2623 * perform QUERY_MPT also when the entry is in SW ownership.
2624 */
2625 struct mlx4_mpt_entry *mpt_entry = mlx4_table_find(
2626 &mlx4_priv(dev)->mr_table.dmpt_table,
2627 mpt->key, NULL);
2628
2629 if (NULL == mpt_entry || NULL == outbox->buf) {
2630 err = -EINVAL;
2631 goto out;
2632 }
2633
2634 memcpy(outbox->buf, mpt_entry, sizeof(*mpt_entry));
2635
2636 err = 0;
2637 } else if (mpt->com.from_state == RES_MPT_HW) {
2638 err = mlx4_DMA_wrapper(dev, slave, vhcr, inbox, outbox, cmd);
2639 } else {
2617 err = -EBUSY; 2640 err = -EBUSY;
2618 goto out; 2641 goto out;
2619 } 2642 }
2620 2643
2621 err = mlx4_DMA_wrapper(dev, slave, vhcr, inbox, outbox, cmd);
2622 2644
2623out: 2645out:
2624 put_res(dev, slave, id, RES_MPT); 2646 put_res(dev, slave, id, RES_MPT);
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c
index 064a48d0c368..f1ebed6c63b1 100644
--- a/drivers/net/ethernet/micrel/ksz884x.c
+++ b/drivers/net/ethernet/micrel/ksz884x.c
@@ -4409,14 +4409,13 @@ static int ksz_alloc_desc(struct dev_info *adapter)
4409 DESC_ALIGNMENT; 4409 DESC_ALIGNMENT;
4410 4410
4411 adapter->desc_pool.alloc_virt = 4411 adapter->desc_pool.alloc_virt =
4412 pci_alloc_consistent( 4412 pci_zalloc_consistent(adapter->pdev,
4413 adapter->pdev, adapter->desc_pool.alloc_size, 4413 adapter->desc_pool.alloc_size,
4414 &adapter->desc_pool.dma_addr); 4414 &adapter->desc_pool.dma_addr);
4415 if (adapter->desc_pool.alloc_virt == NULL) { 4415 if (adapter->desc_pool.alloc_virt == NULL) {
4416 adapter->desc_pool.alloc_size = 0; 4416 adapter->desc_pool.alloc_size = 0;
4417 return 1; 4417 return 1;
4418 } 4418 }
4419 memset(adapter->desc_pool.alloc_virt, 0, adapter->desc_pool.alloc_size);
4420 4419
4421 /* Align to the next cache line boundary. */ 4420 /* Align to the next cache line boundary. */
4422 offset = (((ulong) adapter->desc_pool.alloc_virt % DESC_ALIGNMENT) ? 4421 offset = (((ulong) adapter->desc_pool.alloc_virt % DESC_ALIGNMENT) ?
@@ -7222,7 +7221,7 @@ static int pcidev_suspend(struct pci_dev *pdev, pm_message_t state)
7222 7221
7223static char pcidev_name[] = "ksz884xp"; 7222static char pcidev_name[] = "ksz884xp";
7224 7223
7225static DEFINE_PCI_DEVICE_TABLE(pcidev_table) = { 7224static const struct pci_device_id pcidev_table[] = {
7226 { PCI_VENDOR_ID_MICREL_KS, 0x8841, 7225 { PCI_VENDOR_ID_MICREL_KS, 0x8841,
7227 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 7226 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
7228 { PCI_VENDOR_ID_MICREL_KS, 0x8842, 7227 { PCI_VENDOR_ID_MICREL_KS, 0x8842,
diff --git a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
index f3d5d79f1cd1..9e7e3f1dce3e 100644
--- a/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
+++ b/drivers/net/ethernet/myricom/myri10ge/myri10ge.c
@@ -574,6 +574,7 @@ myri10ge_validate_firmware(struct myri10ge_priv *mgp,
574 574
575 /* save firmware version for ethtool */ 575 /* save firmware version for ethtool */
576 strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version)); 576 strncpy(mgp->fw_version, hdr->version, sizeof(mgp->fw_version));
577 mgp->fw_version[sizeof(mgp->fw_version) - 1] = '\0';
577 578
578 sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major, 579 sscanf(mgp->fw_version, "%d.%d.%d", &mgp->fw_ver_major,
579 &mgp->fw_ver_minor, &mgp->fw_ver_tiny); 580 &mgp->fw_ver_minor, &mgp->fw_ver_tiny);
@@ -872,6 +873,10 @@ static int myri10ge_dma_test(struct myri10ge_priv *mgp, int test_type)
872 return -ENOMEM; 873 return -ENOMEM;
873 dmatest_bus = pci_map_page(mgp->pdev, dmatest_page, 0, PAGE_SIZE, 874 dmatest_bus = pci_map_page(mgp->pdev, dmatest_page, 0, PAGE_SIZE,
874 DMA_BIDIRECTIONAL); 875 DMA_BIDIRECTIONAL);
876 if (unlikely(pci_dma_mapping_error(mgp->pdev, dmatest_bus))) {
877 __free_page(dmatest_page);
878 return -ENOMEM;
879 }
875 880
876 /* Run a small DMA test. 881 /* Run a small DMA test.
877 * The magic multipliers to the length tell the firmware 882 * The magic multipliers to the length tell the firmware
@@ -1293,6 +1298,7 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
1293 int bytes, int watchdog) 1298 int bytes, int watchdog)
1294{ 1299{
1295 struct page *page; 1300 struct page *page;
1301 dma_addr_t bus;
1296 int idx; 1302 int idx;
1297#if MYRI10GE_ALLOC_SIZE > 4096 1303#if MYRI10GE_ALLOC_SIZE > 4096
1298 int end_offset; 1304 int end_offset;
@@ -1317,11 +1323,21 @@ myri10ge_alloc_rx_pages(struct myri10ge_priv *mgp, struct myri10ge_rx_buf *rx,
1317 rx->watchdog_needed = 1; 1323 rx->watchdog_needed = 1;
1318 return; 1324 return;
1319 } 1325 }
1326
1327 bus = pci_map_page(mgp->pdev, page, 0,
1328 MYRI10GE_ALLOC_SIZE,
1329 PCI_DMA_FROMDEVICE);
1330 if (unlikely(pci_dma_mapping_error(mgp->pdev, bus))) {
1331 __free_pages(page, MYRI10GE_ALLOC_ORDER);
1332 if (rx->fill_cnt - rx->cnt < 16)
1333 rx->watchdog_needed = 1;
1334 return;
1335 }
1336
1320 rx->page = page; 1337 rx->page = page;
1321 rx->page_offset = 0; 1338 rx->page_offset = 0;
1322 rx->bus = pci_map_page(mgp->pdev, page, 0, 1339 rx->bus = bus;
1323 MYRI10GE_ALLOC_SIZE, 1340
1324 PCI_DMA_FROMDEVICE);
1325 } 1341 }
1326 rx->info[idx].page = rx->page; 1342 rx->info[idx].page = rx->page;
1327 rx->info[idx].page_offset = rx->page_offset; 1343 rx->info[idx].page_offset = rx->page_offset;
@@ -2763,6 +2779,35 @@ myri10ge_submit_req(struct myri10ge_tx_buf *tx, struct mcp_kreq_ether_send *src,
2763 mb(); 2779 mb();
2764} 2780}
2765 2781
2782static void myri10ge_unmap_tx_dma(struct myri10ge_priv *mgp,
2783 struct myri10ge_tx_buf *tx, int idx)
2784{
2785 unsigned int len;
2786 int last_idx;
2787
2788 /* Free any DMA resources we've alloced and clear out the skb slot */
2789 last_idx = (idx + 1) & tx->mask;
2790 idx = tx->req & tx->mask;
2791 do {
2792 len = dma_unmap_len(&tx->info[idx], len);
2793 if (len) {
2794 if (tx->info[idx].skb != NULL)
2795 pci_unmap_single(mgp->pdev,
2796 dma_unmap_addr(&tx->info[idx],
2797 bus), len,
2798 PCI_DMA_TODEVICE);
2799 else
2800 pci_unmap_page(mgp->pdev,
2801 dma_unmap_addr(&tx->info[idx],
2802 bus), len,
2803 PCI_DMA_TODEVICE);
2804 dma_unmap_len_set(&tx->info[idx], len, 0);
2805 tx->info[idx].skb = NULL;
2806 }
2807 idx = (idx + 1) & tx->mask;
2808 } while (idx != last_idx);
2809}
2810
2766/* 2811/*
2767 * Transmit a packet. We need to split the packet so that a single 2812 * Transmit a packet. We need to split the packet so that a single
2768 * segment does not cross myri10ge->tx_boundary, so this makes segment 2813 * segment does not cross myri10ge->tx_boundary, so this makes segment
@@ -2786,7 +2831,7 @@ static netdev_tx_t myri10ge_xmit(struct sk_buff *skb,
2786 u32 low; 2831 u32 low;
2787 __be32 high_swapped; 2832 __be32 high_swapped;
2788 unsigned int len; 2833 unsigned int len;
2789 int idx, last_idx, avail, frag_cnt, frag_idx, count, mss, max_segments; 2834 int idx, avail, frag_cnt, frag_idx, count, mss, max_segments;
2790 u16 pseudo_hdr_offset, cksum_offset, queue; 2835 u16 pseudo_hdr_offset, cksum_offset, queue;
2791 int cum_len, seglen, boundary, rdma_count; 2836 int cum_len, seglen, boundary, rdma_count;
2792 u8 flags, odd_flag; 2837 u8 flags, odd_flag;
@@ -2883,9 +2928,12 @@ again:
2883 2928
2884 /* map the skb for DMA */ 2929 /* map the skb for DMA */
2885 len = skb_headlen(skb); 2930 len = skb_headlen(skb);
2931 bus = pci_map_single(mgp->pdev, skb->data, len, PCI_DMA_TODEVICE);
2932 if (unlikely(pci_dma_mapping_error(mgp->pdev, bus)))
2933 goto drop;
2934
2886 idx = tx->req & tx->mask; 2935 idx = tx->req & tx->mask;
2887 tx->info[idx].skb = skb; 2936 tx->info[idx].skb = skb;
2888 bus = pci_map_single(mgp->pdev, skb->data, len, PCI_DMA_TODEVICE);
2889 dma_unmap_addr_set(&tx->info[idx], bus, bus); 2937 dma_unmap_addr_set(&tx->info[idx], bus, bus);
2890 dma_unmap_len_set(&tx->info[idx], len, len); 2938 dma_unmap_len_set(&tx->info[idx], len, len);
2891 2939
@@ -2984,12 +3032,16 @@ again:
2984 break; 3032 break;
2985 3033
2986 /* map next fragment for DMA */ 3034 /* map next fragment for DMA */
2987 idx = (count + tx->req) & tx->mask;
2988 frag = &skb_shinfo(skb)->frags[frag_idx]; 3035 frag = &skb_shinfo(skb)->frags[frag_idx];
2989 frag_idx++; 3036 frag_idx++;
2990 len = skb_frag_size(frag); 3037 len = skb_frag_size(frag);
2991 bus = skb_frag_dma_map(&mgp->pdev->dev, frag, 0, len, 3038 bus = skb_frag_dma_map(&mgp->pdev->dev, frag, 0, len,
2992 DMA_TO_DEVICE); 3039 DMA_TO_DEVICE);
3040 if (unlikely(pci_dma_mapping_error(mgp->pdev, bus))) {
3041 myri10ge_unmap_tx_dma(mgp, tx, idx);
3042 goto drop;
3043 }
3044 idx = (count + tx->req) & tx->mask;
2993 dma_unmap_addr_set(&tx->info[idx], bus, bus); 3045 dma_unmap_addr_set(&tx->info[idx], bus, bus);
2994 dma_unmap_len_set(&tx->info[idx], len, len); 3046 dma_unmap_len_set(&tx->info[idx], len, len);
2995 } 3047 }
@@ -3020,31 +3072,8 @@ again:
3020 return NETDEV_TX_OK; 3072 return NETDEV_TX_OK;
3021 3073
3022abort_linearize: 3074abort_linearize:
3023 /* Free any DMA resources we've alloced and clear out the skb 3075 myri10ge_unmap_tx_dma(mgp, tx, idx);
3024 * slot so as to not trip up assertions, and to avoid a
3025 * double-free if linearizing fails */
3026 3076
3027 last_idx = (idx + 1) & tx->mask;
3028 idx = tx->req & tx->mask;
3029 tx->info[idx].skb = NULL;
3030 do {
3031 len = dma_unmap_len(&tx->info[idx], len);
3032 if (len) {
3033 if (tx->info[idx].skb != NULL)
3034 pci_unmap_single(mgp->pdev,
3035 dma_unmap_addr(&tx->info[idx],
3036 bus), len,
3037 PCI_DMA_TODEVICE);
3038 else
3039 pci_unmap_page(mgp->pdev,
3040 dma_unmap_addr(&tx->info[idx],
3041 bus), len,
3042 PCI_DMA_TODEVICE);
3043 dma_unmap_len_set(&tx->info[idx], len, 0);
3044 tx->info[idx].skb = NULL;
3045 }
3046 idx = (idx + 1) & tx->mask;
3047 } while (idx != last_idx);
3048 if (skb_is_gso(skb)) { 3077 if (skb_is_gso(skb)) {
3049 netdev_err(mgp->dev, "TSO but wanted to linearize?!?!?\n"); 3078 netdev_err(mgp->dev, "TSO but wanted to linearize?!?!?\n");
3050 goto drop; 3079 goto drop;
@@ -4213,7 +4242,7 @@ static void myri10ge_remove(struct pci_dev *pdev)
4213#define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E 0x0008 4242#define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E 0x0008
4214#define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E_9 0x0009 4243#define PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E_9 0x0009
4215 4244
4216static DEFINE_PCI_DEVICE_TABLE(myri10ge_pci_tbl) = { 4245static const struct pci_device_id myri10ge_pci_tbl[] = {
4217 {PCI_DEVICE(PCI_VENDOR_ID_MYRICOM, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E)}, 4246 {PCI_DEVICE(PCI_VENDOR_ID_MYRICOM, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E)},
4218 {PCI_DEVICE 4247 {PCI_DEVICE
4219 (PCI_VENDOR_ID_MYRICOM, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E_9)}, 4248 (PCI_VENDOR_ID_MYRICOM, PCI_DEVICE_ID_MYRICOM_MYRI10GE_Z8E_9)},
diff --git a/drivers/net/ethernet/natsemi/natsemi.c b/drivers/net/ethernet/natsemi/natsemi.c
index 291fba8b9f07..b83f7c0fcf99 100644
--- a/drivers/net/ethernet/natsemi/natsemi.c
+++ b/drivers/net/ethernet/natsemi/natsemi.c
@@ -247,7 +247,7 @@ static struct {
247 { "NatSemi DP8381[56]", 0, 24 }, 247 { "NatSemi DP8381[56]", 0, 24 },
248}; 248};
249 249
250static DEFINE_PCI_DEVICE_TABLE(natsemi_pci_tbl) = { 250static const struct pci_device_id natsemi_pci_tbl[] = {
251 { PCI_VENDOR_ID_NS, 0x0020, 0x12d9, 0x000c, 0, 0, 0 }, 251 { PCI_VENDOR_ID_NS, 0x0020, 0x12d9, 0x000c, 0, 0, 0 },
252 { PCI_VENDOR_ID_NS, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 252 { PCI_VENDOR_ID_NS, 0x0020, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
253 { } /* terminate list */ 253 { } /* terminate list */
diff --git a/drivers/net/ethernet/natsemi/ns83820.c b/drivers/net/ethernet/natsemi/ns83820.c
index 19bb8244b9e3..2552e550a78c 100644
--- a/drivers/net/ethernet/natsemi/ns83820.c
+++ b/drivers/net/ethernet/natsemi/ns83820.c
@@ -2260,7 +2260,7 @@ static void ns83820_remove_one(struct pci_dev *pci_dev)
2260 free_netdev(ndev); 2260 free_netdev(ndev);
2261} 2261}
2262 2262
2263static DEFINE_PCI_DEVICE_TABLE(ns83820_pci_tbl) = { 2263static const struct pci_device_id ns83820_pci_tbl[] = {
2264 { 0x100b, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, .driver_data = 0, }, 2264 { 0x100b, 0x0022, PCI_ANY_ID, PCI_ANY_ID, 0, .driver_data = 0, },
2265 { 0, }, 2265 { 0, },
2266}; 2266};
diff --git a/drivers/net/ethernet/neterion/s2io.c b/drivers/net/ethernet/neterion/s2io.c
index be587647c706..f5e4b820128b 100644
--- a/drivers/net/ethernet/neterion/s2io.c
+++ b/drivers/net/ethernet/neterion/s2io.c
@@ -471,7 +471,7 @@ module_param_array(rts_frm_len, uint, NULL, 0);
471 * S2IO device table. 471 * S2IO device table.
472 * This table lists all the devices that this driver supports. 472 * This table lists all the devices that this driver supports.
473 */ 473 */
474static DEFINE_PCI_DEVICE_TABLE(s2io_tbl) = { 474static const struct pci_device_id s2io_tbl[] = {
475 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_WIN, 475 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_WIN,
476 PCI_ANY_ID, PCI_ANY_ID}, 476 PCI_ANY_ID, PCI_ANY_ID},
477 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_UNI, 477 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_S2IO_UNI,
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c
index 2eda153cb1e0..4f40d7b8629e 100644
--- a/drivers/net/ethernet/neterion/vxge/vxge-main.c
+++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c
@@ -63,7 +63,7 @@ MODULE_LICENSE("Dual BSD/GPL");
63MODULE_DESCRIPTION("Neterion's X3100 Series 10GbE PCIe I/O" 63MODULE_DESCRIPTION("Neterion's X3100 Series 10GbE PCIe I/O"
64 "Virtualized Server Adapter"); 64 "Virtualized Server Adapter");
65 65
66static DEFINE_PCI_DEVICE_TABLE(vxge_id_table) = { 66static const struct pci_device_id vxge_id_table[] = {
67 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_TITAN_WIN, PCI_ANY_ID, 67 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_TITAN_WIN, PCI_ANY_ID,
68 PCI_ANY_ID}, 68 PCI_ANY_ID},
69 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_TITAN_UNI, PCI_ANY_ID, 69 {PCI_VENDOR_ID_S2IO, PCI_DEVICE_ID_TITAN_UNI, PCI_ANY_ID,
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c
index 9afc536c5734..925b296d8ab8 100644
--- a/drivers/net/ethernet/nvidia/forcedeth.c
+++ b/drivers/net/ethernet/nvidia/forcedeth.c
@@ -6185,7 +6185,7 @@ static void nv_shutdown(struct pci_dev *pdev)
6185#define nv_shutdown NULL 6185#define nv_shutdown NULL
6186#endif /* CONFIG_PM */ 6186#endif /* CONFIG_PM */
6187 6187
6188static DEFINE_PCI_DEVICE_TABLE(pci_tbl) = { 6188static const struct pci_device_id pci_tbl[] = {
6189 { /* nForce Ethernet Controller */ 6189 { /* nForce Ethernet Controller */
6190 PCI_DEVICE(0x10DE, 0x01C3), 6190 PCI_DEVICE(0x10DE, 0x01C3),
6191 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER, 6191 .driver_data = DEV_NEED_TIMERIRQ|DEV_NEED_LINKTIMER,
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
index 73e66838cfef..3b98b263bad0 100644
--- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
+++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c
@@ -2743,7 +2743,7 @@ static struct pch_gbe_privdata pch_gbe_minnow_privdata = {
2743 .platform_init = pch_gbe_minnow_platform_init, 2743 .platform_init = pch_gbe_minnow_platform_init,
2744}; 2744};
2745 2745
2746static DEFINE_PCI_DEVICE_TABLE(pch_gbe_pcidev_id) = { 2746static const struct pci_device_id pch_gbe_pcidev_id[] = {
2747 {.vendor = PCI_VENDOR_ID_INTEL, 2747 {.vendor = PCI_VENDOR_ID_INTEL,
2748 .device = PCI_DEVICE_ID_INTEL_IOH1_GBE, 2748 .device = PCI_DEVICE_ID_INTEL_IOH1_GBE,
2749 .subvendor = PCI_VENDOR_ID_CIRCUITCO, 2749 .subvendor = PCI_VENDOR_ID_CIRCUITCO,
diff --git a/drivers/net/ethernet/packetengines/hamachi.c b/drivers/net/ethernet/packetengines/hamachi.c
index 9a997e4c3e08..319d9d40f922 100644
--- a/drivers/net/ethernet/packetengines/hamachi.c
+++ b/drivers/net/ethernet/packetengines/hamachi.c
@@ -1911,7 +1911,7 @@ static void hamachi_remove_one(struct pci_dev *pdev)
1911 } 1911 }
1912} 1912}
1913 1913
1914static DEFINE_PCI_DEVICE_TABLE(hamachi_pci_tbl) = { 1914static const struct pci_device_id hamachi_pci_tbl[] = {
1915 { 0x1318, 0x0911, PCI_ANY_ID, PCI_ANY_ID, }, 1915 { 0x1318, 0x0911, PCI_ANY_ID, PCI_ANY_ID, },
1916 { 0, } 1916 { 0, }
1917}; 1917};
diff --git a/drivers/net/ethernet/packetengines/yellowfin.c b/drivers/net/ethernet/packetengines/yellowfin.c
index 69a8dc095072..2d6b148528dd 100644
--- a/drivers/net/ethernet/packetengines/yellowfin.c
+++ b/drivers/net/ethernet/packetengines/yellowfin.c
@@ -236,7 +236,7 @@ static const struct pci_id_info pci_id_tbl[] = {
236 { } 236 { }
237}; 237};
238 238
239static DEFINE_PCI_DEVICE_TABLE(yellowfin_pci_tbl) = { 239static const struct pci_device_id yellowfin_pci_tbl[] = {
240 { 0x1000, 0x0702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 240 { 0x1000, 0x0702, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
241 { 0x1000, 0x0701, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 }, 241 { 0x1000, 0x0701, PCI_ANY_ID, PCI_ANY_ID, 0, 0, 1 },
242 { } 242 { }
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c
index 9abf70d74b31..30d934d66356 100644
--- a/drivers/net/ethernet/pasemi/pasemi_mac.c
+++ b/drivers/net/ethernet/pasemi/pasemi_mac.c
@@ -1871,7 +1871,7 @@ static void pasemi_mac_remove(struct pci_dev *pdev)
1871 free_netdev(netdev); 1871 free_netdev(netdev);
1872} 1872}
1873 1873
1874static DEFINE_PCI_DEVICE_TABLE(pasemi_mac_pci_tbl) = { 1874static const struct pci_device_id pasemi_mac_pci_tbl[] = {
1875 { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa005) }, 1875 { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa005) },
1876 { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa006) }, 1876 { PCI_DEVICE(PCI_VENDOR_ID_PASEMI, 0xa006) },
1877 { }, 1877 { },
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
index 6f6be57f4690..b8d5270359cd 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_ctx.c
@@ -129,14 +129,12 @@ netxen_get_minidump_template(struct netxen_adapter *adapter)
129 return NX_RCODE_INVALID_ARGS; 129 return NX_RCODE_INVALID_ARGS;
130 } 130 }
131 131
132 addr = pci_alloc_consistent(adapter->pdev, size, &md_template_addr); 132 addr = pci_zalloc_consistent(adapter->pdev, size, &md_template_addr);
133
134 if (!addr) { 133 if (!addr) {
135 dev_err(&adapter->pdev->dev, "Unable to allocate dmable memory for template.\n"); 134 dev_err(&adapter->pdev->dev, "Unable to allocate dmable memory for template.\n");
136 return -ENOMEM; 135 return -ENOMEM;
137 } 136 }
138 137
139 memset(addr, 0, size);
140 memset(&cmd, 0, sizeof(cmd)); 138 memset(&cmd, 0, sizeof(cmd));
141 memset(&cmd.rsp, 1, sizeof(struct _cdrp_cmd)); 139 memset(&cmd.rsp, 1, sizeof(struct _cdrp_cmd));
142 cmd.req.cmd = NX_CDRP_CMD_GET_TEMP_HDR; 140 cmd.req.cmd = NX_CDRP_CMD_GET_TEMP_HDR;
diff --git a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
index 5bf05818a12c..1159031f885b 100644
--- a/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
+++ b/drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c
@@ -99,7 +99,7 @@ static int netxen_nic_set_mac(struct net_device *netdev, void *p);
99 {PCI_DEVICE(PCI_VENDOR_ID_NETXEN, (device)), \ 99 {PCI_DEVICE(PCI_VENDOR_ID_NETXEN, (device)), \
100 .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0} 100 .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0}
101 101
102static DEFINE_PCI_DEVICE_TABLE(netxen_pci_tbl) = { 102static const struct pci_device_id netxen_pci_tbl[] = {
103 ENTRY(PCI_DEVICE_ID_NX2031_10GXSR), 103 ENTRY(PCI_DEVICE_ID_NX2031_10GXSR),
104 ENTRY(PCI_DEVICE_ID_NX2031_10GCX4), 104 ENTRY(PCI_DEVICE_ID_NX2031_10GCX4),
105 ENTRY(PCI_DEVICE_ID_NX2031_4GCU), 105 ENTRY(PCI_DEVICE_ID_NX2031_4GCU),
diff --git a/drivers/net/ethernet/qlogic/qla3xxx.c b/drivers/net/ethernet/qlogic/qla3xxx.c
index b5d6bc1a8b00..c2f09af5c25b 100644
--- a/drivers/net/ethernet/qlogic/qla3xxx.c
+++ b/drivers/net/ethernet/qlogic/qla3xxx.c
@@ -65,7 +65,7 @@ static int msi;
65module_param(msi, int, 0); 65module_param(msi, int, 0);
66MODULE_PARM_DESC(msi, "Turn on Message Signaled Interrupts."); 66MODULE_PARM_DESC(msi, "Turn on Message Signaled Interrupts.");
67 67
68static DEFINE_PCI_DEVICE_TABLE(ql3xxx_pci_tbl) = { 68static const struct pci_device_id ql3xxx_pci_tbl[] = {
69 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QL3022_DEVICE_ID)}, 69 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QL3022_DEVICE_ID)},
70 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QL3032_DEVICE_ID)}, 70 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QL3032_DEVICE_ID)},
71 /* required last entry */ 71 /* required last entry */
diff --git a/drivers/net/ethernet/qlogic/qlcnic/Makefile b/drivers/net/ethernet/qlogic/qlcnic/Makefile
index a848d2979722..3c2c2c7c1559 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/Makefile
+++ b/drivers/net/ethernet/qlogic/qlcnic/Makefile
@@ -8,7 +8,7 @@ qlcnic-y := qlcnic_hw.o qlcnic_main.o qlcnic_init.o \
8 qlcnic_ethtool.o qlcnic_ctx.o qlcnic_io.o \ 8 qlcnic_ethtool.o qlcnic_ctx.o qlcnic_io.o \
9 qlcnic_sysfs.o qlcnic_minidump.o qlcnic_83xx_hw.o \ 9 qlcnic_sysfs.o qlcnic_minidump.o qlcnic_83xx_hw.o \
10 qlcnic_83xx_init.o qlcnic_83xx_vnic.o \ 10 qlcnic_83xx_init.o qlcnic_83xx_vnic.o \
11 qlcnic_minidump.o qlcnic_sriov_common.o 11 qlcnic_sriov_common.o
12 12
13qlcnic-$(CONFIG_QLCNIC_SRIOV) += qlcnic_sriov_pf.o 13qlcnic-$(CONFIG_QLCNIC_SRIOV) += qlcnic_sriov_pf.o
14 14
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
index 59846daf1379..cf08b2de071e 100644
--- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
+++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
@@ -108,7 +108,7 @@ static u32 qlcnic_vlan_tx_check(struct qlcnic_adapter *adapter)
108 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, (device)), \ 108 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, (device)), \
109 .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0} 109 .class = PCI_CLASS_NETWORK_ETHERNET << 8, .class_mask = ~0}
110 110
111static DEFINE_PCI_DEVICE_TABLE(qlcnic_pci_tbl) = { 111static const struct pci_device_id qlcnic_pci_tbl[] = {
112 ENTRY(PCI_DEVICE_ID_QLOGIC_QLE824X), 112 ENTRY(PCI_DEVICE_ID_QLOGIC_QLE824X),
113 ENTRY(PCI_DEVICE_ID_QLOGIC_QLE834X), 113 ENTRY(PCI_DEVICE_ID_QLOGIC_QLE834X),
114 ENTRY(PCI_DEVICE_ID_QLOGIC_VF_QLE834X), 114 ENTRY(PCI_DEVICE_ID_QLOGIC_VF_QLE834X),
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
index b40050e03a56..188626e2a861 100644
--- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c
+++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c
@@ -86,7 +86,7 @@ MODULE_PARM_DESC(qlge_force_coredump,
86 "Option to allow force of firmware core dump. " 86 "Option to allow force of firmware core dump. "
87 "Default is OFF - Do not allow."); 87 "Default is OFF - Do not allow.");
88 88
89static DEFINE_PCI_DEVICE_TABLE(qlge_pci_tbl) = { 89static const struct pci_device_id qlge_pci_tbl[] = {
90 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID_8012)}, 90 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID_8012)},
91 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID_8000)}, 91 {PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, QLGE_DEVICE_ID_8000)},
92 /* required last entry */ 92 /* required last entry */
@@ -2727,23 +2727,22 @@ static void ql_free_shadow_space(struct ql_adapter *qdev)
2727static int ql_alloc_shadow_space(struct ql_adapter *qdev) 2727static int ql_alloc_shadow_space(struct ql_adapter *qdev)
2728{ 2728{
2729 qdev->rx_ring_shadow_reg_area = 2729 qdev->rx_ring_shadow_reg_area =
2730 pci_alloc_consistent(qdev->pdev, 2730 pci_zalloc_consistent(qdev->pdev, PAGE_SIZE,
2731 PAGE_SIZE, &qdev->rx_ring_shadow_reg_dma); 2731 &qdev->rx_ring_shadow_reg_dma);
2732 if (qdev->rx_ring_shadow_reg_area == NULL) { 2732 if (qdev->rx_ring_shadow_reg_area == NULL) {
2733 netif_err(qdev, ifup, qdev->ndev, 2733 netif_err(qdev, ifup, qdev->ndev,
2734 "Allocation of RX shadow space failed.\n"); 2734 "Allocation of RX shadow space failed.\n");
2735 return -ENOMEM; 2735 return -ENOMEM;
2736 } 2736 }
2737 memset(qdev->rx_ring_shadow_reg_area, 0, PAGE_SIZE); 2737
2738 qdev->tx_ring_shadow_reg_area = 2738 qdev->tx_ring_shadow_reg_area =
2739 pci_alloc_consistent(qdev->pdev, PAGE_SIZE, 2739 pci_zalloc_consistent(qdev->pdev, PAGE_SIZE,
2740 &qdev->tx_ring_shadow_reg_dma); 2740 &qdev->tx_ring_shadow_reg_dma);
2741 if (qdev->tx_ring_shadow_reg_area == NULL) { 2741 if (qdev->tx_ring_shadow_reg_area == NULL) {
2742 netif_err(qdev, ifup, qdev->ndev, 2742 netif_err(qdev, ifup, qdev->ndev,
2743 "Allocation of TX shadow space failed.\n"); 2743 "Allocation of TX shadow space failed.\n");
2744 goto err_wqp_sh_area; 2744 goto err_wqp_sh_area;
2745 } 2745 }
2746 memset(qdev->tx_ring_shadow_reg_area, 0, PAGE_SIZE);
2747 return 0; 2746 return 0;
2748 2747
2749err_wqp_sh_area: 2748err_wqp_sh_area:
diff --git a/drivers/net/ethernet/rdc/r6040.c b/drivers/net/ethernet/rdc/r6040.c
index cd045ecb9816..9a37247cf4b8 100644
--- a/drivers/net/ethernet/rdc/r6040.c
+++ b/drivers/net/ethernet/rdc/r6040.c
@@ -1254,7 +1254,7 @@ static void r6040_remove_one(struct pci_dev *pdev)
1254} 1254}
1255 1255
1256 1256
1257static DEFINE_PCI_DEVICE_TABLE(r6040_pci_tbl) = { 1257static const struct pci_device_id r6040_pci_tbl[] = {
1258 { PCI_DEVICE(PCI_VENDOR_ID_RDC, 0x6040) }, 1258 { PCI_DEVICE(PCI_VENDOR_ID_RDC, 0x6040) },
1259 { 0 } 1259 { 0 }
1260}; 1260};
diff --git a/drivers/net/ethernet/realtek/8139too.c b/drivers/net/ethernet/realtek/8139too.c
index 2e5df148af4c..007b38cce69a 100644
--- a/drivers/net/ethernet/realtek/8139too.c
+++ b/drivers/net/ethernet/realtek/8139too.c
@@ -234,7 +234,7 @@ static const struct {
234}; 234};
235 235
236 236
237static DEFINE_PCI_DEVICE_TABLE(rtl8139_pci_tbl) = { 237static const struct pci_device_id rtl8139_pci_tbl[] = {
238 {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 238 {0x10ec, 0x8139, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
239 {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 239 {0x10ec, 0x8138, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
240 {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 }, 240 {0x1113, 0x1211, PCI_ANY_ID, PCI_ANY_ID, 0, 0, RTL8139 },
diff --git a/drivers/net/ethernet/realtek/r8169.c b/drivers/net/ethernet/realtek/r8169.c
index 9887bcb45b84..91652e7235e4 100644
--- a/drivers/net/ethernet/realtek/r8169.c
+++ b/drivers/net/ethernet/realtek/r8169.c
@@ -291,7 +291,7 @@ enum cfg_version {
291 RTL_CFG_2 291 RTL_CFG_2
292}; 292};
293 293
294static DEFINE_PCI_DEVICE_TABLE(rtl8169_pci_tbl) = { 294static const struct pci_device_id rtl8169_pci_tbl[] = {
295 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 }, 295 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8129), 0, 0, RTL_CFG_0 },
296 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 }, 296 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8136), 0, 0, RTL_CFG_2 },
297 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 }, 297 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8167), 0, 0, RTL_CFG_0 },
diff --git a/drivers/net/ethernet/sfc/efx.c b/drivers/net/ethernet/sfc/efx.c
index 4cebe9d37816..b2cc590dd1dd 100644
--- a/drivers/net/ethernet/sfc/efx.c
+++ b/drivers/net/ethernet/sfc/efx.c
@@ -2642,7 +2642,7 @@ void efx_schedule_reset(struct efx_nic *efx, enum reset_type type)
2642 **************************************************************************/ 2642 **************************************************************************/
2643 2643
2644/* PCI device ID table */ 2644/* PCI device ID table */
2645static DEFINE_PCI_DEVICE_TABLE(efx_pci_table) = { 2645static const struct pci_device_id efx_pci_table[] = {
2646 {PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE, 2646 {PCI_DEVICE(PCI_VENDOR_ID_SOLARFLARE,
2647 PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0), 2647 PCI_DEVICE_ID_SOLARFLARE_SFC4000A_0),
2648 .driver_data = (unsigned long) &falcon_a1_nic_type}, 2648 .driver_data = (unsigned long) &falcon_a1_nic_type},
diff --git a/drivers/net/ethernet/sgi/ioc3-eth.c b/drivers/net/ethernet/sgi/ioc3-eth.c
index 7984ad05357d..7a254da85dd7 100644
--- a/drivers/net/ethernet/sgi/ioc3-eth.c
+++ b/drivers/net/ethernet/sgi/ioc3-eth.c
@@ -1384,7 +1384,7 @@ static void ioc3_remove_one(struct pci_dev *pdev)
1384 */ 1384 */
1385} 1385}
1386 1386
1387static DEFINE_PCI_DEVICE_TABLE(ioc3_pci_tbl) = { 1387static const struct pci_device_id ioc3_pci_tbl[] = {
1388 { PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3, PCI_ANY_ID, PCI_ANY_ID }, 1388 { PCI_VENDOR_ID_SGI, PCI_DEVICE_ID_SGI_IOC3, PCI_ANY_ID, PCI_ANY_ID },
1389 { 0 } 1389 { 0 }
1390}; 1390};
diff --git a/drivers/net/ethernet/silan/sc92031.c b/drivers/net/ethernet/silan/sc92031.c
index 7daa7d433099..7426f8b21252 100644
--- a/drivers/net/ethernet/silan/sc92031.c
+++ b/drivers/net/ethernet/silan/sc92031.c
@@ -1561,7 +1561,7 @@ out:
1561 return 0; 1561 return 0;
1562} 1562}
1563 1563
1564static DEFINE_PCI_DEVICE_TABLE(sc92031_pci_device_id_table) = { 1564static const struct pci_device_id sc92031_pci_device_id_table[] = {
1565 { PCI_DEVICE(PCI_VENDOR_ID_SILAN, 0x2031) }, 1565 { PCI_DEVICE(PCI_VENDOR_ID_SILAN, 0x2031) },
1566 { PCI_DEVICE(PCI_VENDOR_ID_SILAN, 0x8139) }, 1566 { PCI_DEVICE(PCI_VENDOR_ID_SILAN, 0x8139) },
1567 { PCI_DEVICE(0x1088, 0x2031) }, 1567 { PCI_DEVICE(0x1088, 0x2031) },
diff --git a/drivers/net/ethernet/sis/sis190.c b/drivers/net/ethernet/sis/sis190.c
index a86339903b9b..27be6c869315 100644
--- a/drivers/net/ethernet/sis/sis190.c
+++ b/drivers/net/ethernet/sis/sis190.c
@@ -330,7 +330,7 @@ static const struct {
330 { "SiS 191 PCI Gigabit Ethernet adapter" }, 330 { "SiS 191 PCI Gigabit Ethernet adapter" },
331}; 331};
332 332
333static DEFINE_PCI_DEVICE_TABLE(sis190_pci_tbl) = { 333static const struct pci_device_id sis190_pci_tbl[] = {
334 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x0190), 0, 0, 0 }, 334 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x0190), 0, 0, 0 },
335 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x0191), 0, 0, 1 }, 335 { PCI_DEVICE(PCI_VENDOR_ID_SI, 0x0191), 0, 0, 1 },
336 { 0, }, 336 { 0, },
diff --git a/drivers/net/ethernet/sis/sis900.c b/drivers/net/ethernet/sis/sis900.c
index 7bea17c41dc9..fd812d2e5e1c 100644
--- a/drivers/net/ethernet/sis/sis900.c
+++ b/drivers/net/ethernet/sis/sis900.c
@@ -106,7 +106,8 @@ static const char * card_names[] = {
106 "SiS 900 PCI Fast Ethernet", 106 "SiS 900 PCI Fast Ethernet",
107 "SiS 7016 PCI Fast Ethernet" 107 "SiS 7016 PCI Fast Ethernet"
108}; 108};
109static DEFINE_PCI_DEVICE_TABLE(sis900_pci_tbl) = { 109
110static const struct pci_device_id sis900_pci_tbl[] = {
110 {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_900, 111 {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_900,
111 PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_900}, 112 PCI_ANY_ID, PCI_ANY_ID, 0, 0, SIS_900},
112 {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_7016, 113 {PCI_VENDOR_ID_SI, PCI_DEVICE_ID_SI_7016,
diff --git a/drivers/net/ethernet/smsc/epic100.c b/drivers/net/ethernet/smsc/epic100.c
index 8ae1f8a7bf38..443f1da9fc9e 100644
--- a/drivers/net/ethernet/smsc/epic100.c
+++ b/drivers/net/ethernet/smsc/epic100.c
@@ -173,7 +173,7 @@ static const struct epic_chip_info pci_id_tbl[] = {
173}; 173};
174 174
175 175
176static DEFINE_PCI_DEVICE_TABLE(epic_pci_tbl) = { 176static const struct pci_device_id epic_pci_tbl[] = {
177 { 0x10B8, 0x0005, 0x1092, 0x0AB4, 0, 0, SMSC_83C170_0 }, 177 { 0x10B8, 0x0005, 0x1092, 0x0AB4, 0, 0, SMSC_83C170_0 },
178 { 0x10B8, 0x0005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SMSC_83C170 }, 178 { 0x10B8, 0x0005, PCI_ANY_ID, PCI_ANY_ID, 0, 0, SMSC_83C170 },
179 { 0x10B8, 0x0006, PCI_ANY_ID, PCI_ANY_ID, 179 { 0x10B8, 0x0006, PCI_ANY_ID, PCI_ANY_ID,
diff --git a/drivers/net/ethernet/smsc/smsc911x.h b/drivers/net/ethernet/smsc/smsc911x.h
index 23953957fed8..54d648920a1b 100644
--- a/drivers/net/ethernet/smsc/smsc911x.h
+++ b/drivers/net/ethernet/smsc/smsc911x.h
@@ -51,7 +51,7 @@
51 51
52#ifdef CONFIG_DEBUG_SPINLOCK 52#ifdef CONFIG_DEBUG_SPINLOCK
53#define SMSC_ASSERT_MAC_LOCK(pdata) \ 53#define SMSC_ASSERT_MAC_LOCK(pdata) \
54 WARN_ON(!spin_is_locked(&pdata->mac_lock)) 54 WARN_ON_SMP(!spin_is_locked(&pdata->mac_lock))
55#else 55#else
56#define SMSC_ASSERT_MAC_LOCK(pdata) do {} while (0) 56#define SMSC_ASSERT_MAC_LOCK(pdata) do {} while (0)
57#endif /* CONFIG_DEBUG_SPINLOCK */ 57#endif /* CONFIG_DEBUG_SPINLOCK */
diff --git a/drivers/net/ethernet/smsc/smsc9420.c b/drivers/net/ethernet/smsc/smsc9420.c
index d3b967aff9e0..4a90cdae5444 100644
--- a/drivers/net/ethernet/smsc/smsc9420.c
+++ b/drivers/net/ethernet/smsc/smsc9420.c
@@ -83,7 +83,7 @@ struct smsc9420_pdata {
83 int last_carrier; 83 int last_carrier;
84}; 84};
85 85
86static DEFINE_PCI_DEVICE_TABLE(smsc9420_id_table) = { 86static const struct pci_device_id smsc9420_id_table[] = {
87 { PCI_VENDOR_ID_9420, PCI_DEVICE_ID_9420, PCI_ANY_ID, PCI_ANY_ID, }, 87 { PCI_VENDOR_ID_9420, PCI_DEVICE_ID_9420, PCI_ANY_ID, PCI_ANY_ID, },
88 { 0, } 88 { 0, }
89}; 89};
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index 291608924849..655a23bbc451 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -170,7 +170,7 @@ static int stmmac_pci_resume(struct pci_dev *pdev)
170#define STMMAC_VENDOR_ID 0x700 170#define STMMAC_VENDOR_ID 0x700
171#define STMMAC_DEVICE_ID 0x1108 171#define STMMAC_DEVICE_ID 0x1108
172 172
173static DEFINE_PCI_DEVICE_TABLE(stmmac_id_table) = { 173static const struct pci_device_id stmmac_id_table[] = {
174 {PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID)}, 174 {PCI_DEVICE(STMMAC_VENDOR_ID, STMMAC_DEVICE_ID)},
175 {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC)}, 175 {PCI_DEVICE(PCI_VENDOR_ID_STMICRO, PCI_DEVICE_ID_STMICRO_MAC)},
176 {} 176 {}
diff --git a/drivers/net/ethernet/sun/cassini.c b/drivers/net/ethernet/sun/cassini.c
index b9ac20f42651..37f87ff28f03 100644
--- a/drivers/net/ethernet/sun/cassini.c
+++ b/drivers/net/ethernet/sun/cassini.c
@@ -229,7 +229,7 @@ static u16 link_modes[] = {
229 CAS_BMCR_SPEED1000|BMCR_FULLDPLX /* 5 : 1000bt full duplex */ 229 CAS_BMCR_SPEED1000|BMCR_FULLDPLX /* 5 : 1000bt full duplex */
230}; 230};
231 231
232static DEFINE_PCI_DEVICE_TABLE(cas_pci_tbl) = { 232static const struct pci_device_id cas_pci_tbl[] = {
233 { PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_CASSINI, 233 { PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_CASSINI,
234 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 234 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
235 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SATURN, 235 { PCI_VENDOR_ID_NS, PCI_DEVICE_ID_NS_SATURN,
diff --git a/drivers/net/ethernet/sun/niu.c b/drivers/net/ethernet/sun/niu.c
index db8ffde491b5..8216be46540f 100644
--- a/drivers/net/ethernet/sun/niu.c
+++ b/drivers/net/ethernet/sun/niu.c
@@ -59,7 +59,7 @@ static void writeq(u64 val, void __iomem *reg)
59} 59}
60#endif 60#endif
61 61
62static DEFINE_PCI_DEVICE_TABLE(niu_pci_tbl) = { 62static const struct pci_device_id niu_pci_tbl[] = {
63 {PCI_DEVICE(PCI_VENDOR_ID_SUN, 0xabcd)}, 63 {PCI_DEVICE(PCI_VENDOR_ID_SUN, 0xabcd)},
64 {} 64 {}
65}; 65};
diff --git a/drivers/net/ethernet/sun/sungem.c b/drivers/net/ethernet/sun/sungem.c
index 102a66fc54a2..f7415b6bf141 100644
--- a/drivers/net/ethernet/sun/sungem.c
+++ b/drivers/net/ethernet/sun/sungem.c
@@ -85,7 +85,7 @@ MODULE_LICENSE("GPL");
85 85
86#define GEM_MODULE_NAME "gem" 86#define GEM_MODULE_NAME "gem"
87 87
88static DEFINE_PCI_DEVICE_TABLE(gem_pci_tbl) = { 88static const struct pci_device_id gem_pci_tbl[] = {
89 { PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_GEM, 89 { PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_GEM,
90 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 90 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
91 91
diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c
index 0dbf46f08ed5..72c8525d5457 100644
--- a/drivers/net/ethernet/sun/sunhme.c
+++ b/drivers/net/ethernet/sun/sunhme.c
@@ -3172,7 +3172,7 @@ static void happy_meal_pci_remove(struct pci_dev *pdev)
3172 free_netdev(net_dev); 3172 free_netdev(net_dev);
3173} 3173}
3174 3174
3175static DEFINE_PCI_DEVICE_TABLE(happymeal_pci_ids) = { 3175static const struct pci_device_id happymeal_pci_ids[] = {
3176 { PCI_DEVICE(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_HAPPYMEAL) }, 3176 { PCI_DEVICE(PCI_VENDOR_ID_SUN, PCI_DEVICE_ID_SUN_HAPPYMEAL) },
3177 { } /* Terminating entry */ 3177 { } /* Terminating entry */
3178}; 3178};
diff --git a/drivers/net/ethernet/sun/sunvnet.c b/drivers/net/ethernet/sun/sunvnet.c
index d813bfb1a847..23c89ab5a6ad 100644
--- a/drivers/net/ethernet/sun/sunvnet.c
+++ b/drivers/net/ethernet/sun/sunvnet.c
@@ -32,6 +32,11 @@ MODULE_DESCRIPTION("Sun LDOM virtual network driver");
32MODULE_LICENSE("GPL"); 32MODULE_LICENSE("GPL");
33MODULE_VERSION(DRV_MODULE_VERSION); 33MODULE_VERSION(DRV_MODULE_VERSION);
34 34
35/* Heuristic for the number of times to exponentially backoff and
36 * retry sending an LDC trigger when EAGAIN is encountered
37 */
38#define VNET_MAX_RETRIES 10
39
35/* Ordered from largest major to lowest */ 40/* Ordered from largest major to lowest */
36static struct vio_version vnet_versions[] = { 41static struct vio_version vnet_versions[] = {
37 { .major = 1, .minor = 0 }, 42 { .major = 1, .minor = 0 },
@@ -260,6 +265,7 @@ static int vnet_send_ack(struct vnet_port *port, struct vio_dring_state *dr,
260 .state = vio_dring_state, 265 .state = vio_dring_state,
261 }; 266 };
262 int err, delay; 267 int err, delay;
268 int retries = 0;
263 269
264 hdr.seq = dr->snd_nxt; 270 hdr.seq = dr->snd_nxt;
265 delay = 1; 271 delay = 1;
@@ -272,6 +278,13 @@ static int vnet_send_ack(struct vnet_port *port, struct vio_dring_state *dr,
272 udelay(delay); 278 udelay(delay);
273 if ((delay <<= 1) > 128) 279 if ((delay <<= 1) > 128)
274 delay = 128; 280 delay = 128;
281 if (retries++ > VNET_MAX_RETRIES) {
282 pr_info("ECONNRESET %x:%x:%x:%x:%x:%x\n",
283 port->raddr[0], port->raddr[1],
284 port->raddr[2], port->raddr[3],
285 port->raddr[4], port->raddr[5]);
286 err = -ECONNRESET;
287 }
275 } while (err == -EAGAIN); 288 } while (err == -EAGAIN);
276 289
277 return err; 290 return err;
@@ -475,8 +488,9 @@ static int handle_mcast(struct vnet_port *port, void *msgbuf)
475 return 0; 488 return 0;
476} 489}
477 490
478static void maybe_tx_wakeup(struct vnet *vp) 491static void maybe_tx_wakeup(unsigned long param)
479{ 492{
493 struct vnet *vp = (struct vnet *)param;
480 struct net_device *dev = vp->dev; 494 struct net_device *dev = vp->dev;
481 495
482 netif_tx_lock(dev); 496 netif_tx_lock(dev);
@@ -573,8 +587,13 @@ static void vnet_event(void *arg, int event)
573 break; 587 break;
574 } 588 }
575 spin_unlock(&vio->lock); 589 spin_unlock(&vio->lock);
590 /* Kick off a tasklet to wake the queue. We cannot call
591 * maybe_tx_wakeup directly here because we could deadlock on
592 * netif_tx_lock() with dev_watchdog()
593 */
576 if (unlikely(tx_wakeup && err != -ECONNRESET)) 594 if (unlikely(tx_wakeup && err != -ECONNRESET))
577 maybe_tx_wakeup(port->vp); 595 tasklet_schedule(&port->vp->vnet_tx_wakeup);
596
578 local_irq_restore(flags); 597 local_irq_restore(flags);
579} 598}
580 599
@@ -593,6 +612,7 @@ static int __vnet_tx_trigger(struct vnet_port *port)
593 .end_idx = (u32) -1, 612 .end_idx = (u32) -1,
594 }; 613 };
595 int err, delay; 614 int err, delay;
615 int retries = 0;
596 616
597 hdr.seq = dr->snd_nxt; 617 hdr.seq = dr->snd_nxt;
598 delay = 1; 618 delay = 1;
@@ -605,6 +625,8 @@ static int __vnet_tx_trigger(struct vnet_port *port)
605 udelay(delay); 625 udelay(delay);
606 if ((delay <<= 1) > 128) 626 if ((delay <<= 1) > 128)
607 delay = 128; 627 delay = 128;
628 if (retries++ > VNET_MAX_RETRIES)
629 break;
608 } while (err == -EAGAIN); 630 } while (err == -EAGAIN);
609 631
610 return err; 632 return err;
@@ -691,7 +713,15 @@ static int vnet_start_xmit(struct sk_buff *skb, struct net_device *dev)
691 memset(tx_buf+VNET_PACKET_SKIP+skb->len, 0, len - skb->len); 713 memset(tx_buf+VNET_PACKET_SKIP+skb->len, 0, len - skb->len);
692 } 714 }
693 715
694 d->hdr.ack = VIO_ACK_ENABLE; 716 /* We don't rely on the ACKs to free the skb in vnet_start_xmit(),
717 * thus it is safe to not set VIO_ACK_ENABLE for each transmission:
718 * the protocol itself does not require it as long as the peer
719 * sends a VIO_SUBTYPE_ACK for VIO_DRING_STOPPED.
720 *
721 * An ACK for every packet in the ring is expensive as the
722 * sending of LDC messages is slow and affects performance.
723 */
724 d->hdr.ack = VIO_ACK_DISABLE;
695 d->size = len; 725 d->size = len;
696 d->ncookies = port->tx_bufs[dr->prod].ncookies; 726 d->ncookies = port->tx_bufs[dr->prod].ncookies;
697 for (i = 0; i < d->ncookies; i++) 727 for (i = 0; i < d->ncookies; i++)
@@ -1046,6 +1076,7 @@ static struct vnet *vnet_new(const u64 *local_mac)
1046 vp = netdev_priv(dev); 1076 vp = netdev_priv(dev);
1047 1077
1048 spin_lock_init(&vp->lock); 1078 spin_lock_init(&vp->lock);
1079 tasklet_init(&vp->vnet_tx_wakeup, maybe_tx_wakeup, (unsigned long)vp);
1049 vp->dev = dev; 1080 vp->dev = dev;
1050 1081
1051 INIT_LIST_HEAD(&vp->port_list); 1082 INIT_LIST_HEAD(&vp->port_list);
@@ -1105,6 +1136,7 @@ static void vnet_cleanup(void)
1105 vp = list_first_entry(&vnet_list, struct vnet, list); 1136 vp = list_first_entry(&vnet_list, struct vnet, list);
1106 list_del(&vp->list); 1137 list_del(&vp->list);
1107 dev = vp->dev; 1138 dev = vp->dev;
1139 tasklet_kill(&vp->vnet_tx_wakeup);
1108 /* vio_unregister_driver() should have cleaned up port_list */ 1140 /* vio_unregister_driver() should have cleaned up port_list */
1109 BUG_ON(!list_empty(&vp->port_list)); 1141 BUG_ON(!list_empty(&vp->port_list));
1110 unregister_netdev(dev); 1142 unregister_netdev(dev);
diff --git a/drivers/net/ethernet/sun/sunvnet.h b/drivers/net/ethernet/sun/sunvnet.h
index d347a5bf24b0..de5c2c64996f 100644
--- a/drivers/net/ethernet/sun/sunvnet.h
+++ b/drivers/net/ethernet/sun/sunvnet.h
@@ -1,6 +1,8 @@
1#ifndef _SUNVNET_H 1#ifndef _SUNVNET_H
2#define _SUNVNET_H 2#define _SUNVNET_H
3 3
4#include <linux/interrupt.h>
5
4#define DESC_NCOOKIES(entry_size) \ 6#define DESC_NCOOKIES(entry_size) \
5 ((entry_size) - sizeof(struct vio_net_desc)) 7 ((entry_size) - sizeof(struct vio_net_desc))
6 8
@@ -78,6 +80,8 @@ struct vnet {
78 80
79 struct list_head list; 81 struct list_head list;
80 u64 local_mac; 82 u64 local_mac;
83
84 struct tasklet_struct vnet_tx_wakeup;
81}; 85};
82 86
83#endif /* _SUNVNET_H */ 87#endif /* _SUNVNET_H */
diff --git a/drivers/net/ethernet/tehuti/tehuti.c b/drivers/net/ethernet/tehuti/tehuti.c
index 38da73a2a886..6ab36d9ff2ab 100644
--- a/drivers/net/ethernet/tehuti/tehuti.c
+++ b/drivers/net/ethernet/tehuti/tehuti.c
@@ -66,7 +66,7 @@
66 66
67#include "tehuti.h" 67#include "tehuti.h"
68 68
69static DEFINE_PCI_DEVICE_TABLE(bdx_pci_tbl) = { 69static const struct pci_device_id bdx_pci_tbl[] = {
70 { PCI_VDEVICE(TEHUTI, 0x3009), }, 70 { PCI_VDEVICE(TEHUTI, 0x3009), },
71 { PCI_VDEVICE(TEHUTI, 0x3010), }, 71 { PCI_VDEVICE(TEHUTI, 0x3010), },
72 { PCI_VDEVICE(TEHUTI, 0x3014), }, 72 { PCI_VDEVICE(TEHUTI, 0x3014), },
diff --git a/drivers/net/ethernet/ti/cpmac.c b/drivers/net/ethernet/ti/cpmac.c
index 3809f4ec2820..f9bcf7aa88ca 100644
--- a/drivers/net/ethernet/ti/cpmac.c
+++ b/drivers/net/ethernet/ti/cpmac.c
@@ -1130,6 +1130,7 @@ static int cpmac_probe(struct platform_device *pdev)
1130 strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */ 1130 strncpy(mdio_bus_id, "fixed-0", MII_BUS_ID_SIZE); /* fixed phys bus */
1131 phy_id = pdev->id; 1131 phy_id = pdev->id;
1132 } 1132 }
1133 mdio_bus_id[sizeof(mdio_bus_id) - 1] = '\0';
1133 1134
1134 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES); 1135 dev = alloc_etherdev_mq(sizeof(*priv), CPMAC_QUEUES);
1135 if (!dev) 1136 if (!dev)
diff --git a/drivers/net/ethernet/ti/tlan.c b/drivers/net/ethernet/ti/tlan.c
index 6078342fe3f2..f2ff0074aac9 100644
--- a/drivers/net/ethernet/ti/tlan.c
+++ b/drivers/net/ethernet/ti/tlan.c
@@ -116,7 +116,7 @@ static struct board {
116 TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, /* EISA card */ 116 TLAN_ADAPTER_ACTIVITY_LED, 0x83 }, /* EISA card */
117}; 117};
118 118
119static DEFINE_PCI_DEVICE_TABLE(tlan_pci_tbl) = { 119static const struct pci_device_id tlan_pci_tbl[] = {
120 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL10, 120 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL10,
121 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 }, 121 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0 },
122 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100, 122 { PCI_VENDOR_ID_COMPAQ, PCI_DEVICE_ID_COMPAQ_NETEL100,
diff --git a/drivers/net/ethernet/toshiba/spider_net.c b/drivers/net/ethernet/toshiba/spider_net.c
index 0282d0161859..3e38f67c6011 100644
--- a/drivers/net/ethernet/toshiba/spider_net.c
+++ b/drivers/net/ethernet/toshiba/spider_net.c
@@ -73,7 +73,7 @@ MODULE_PARM_DESC(tx_descriptors, "number of descriptors used " \
73 73
74char spider_net_driver_name[] = "spidernet"; 74char spider_net_driver_name[] = "spidernet";
75 75
76static DEFINE_PCI_DEVICE_TABLE(spider_net_pci_tbl) = { 76static const struct pci_device_id spider_net_pci_tbl[] = {
77 { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_SPIDER_NET, 77 { PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_SPIDER_NET,
78 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL }, 78 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 0UL },
79 { 0, } 79 { 0, }
diff --git a/drivers/net/ethernet/toshiba/tc35815.c b/drivers/net/ethernet/toshiba/tc35815.c
index fef5573dbfca..45ac38d29ed8 100644
--- a/drivers/net/ethernet/toshiba/tc35815.c
+++ b/drivers/net/ethernet/toshiba/tc35815.c
@@ -65,7 +65,7 @@ static const struct {
65 { "TOSHIBA TC35815/TX4939" }, 65 { "TOSHIBA TC35815/TX4939" },
66}; 66};
67 67
68static DEFINE_PCI_DEVICE_TABLE(tc35815_pci_tbl) = { 68static const struct pci_device_id tc35815_pci_tbl[] = {
69 {PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC35815CF), .driver_data = TC35815CF }, 69 {PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC35815CF), .driver_data = TC35815CF },
70 {PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC35815_NWU), .driver_data = TC35815_NWU }, 70 {PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC35815_NWU), .driver_data = TC35815_NWU },
71 {PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC35815_TX4939), .driver_data = TC35815_TX4939 }, 71 {PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA_2, PCI_DEVICE_ID_TOSHIBA_TC35815_TX4939), .driver_data = TC35815_TX4939 },
diff --git a/drivers/net/ethernet/via/via-rhine.c b/drivers/net/ethernet/via/via-rhine.c
index 2d72f96a9e2c..68c5260cc322 100644
--- a/drivers/net/ethernet/via/via-rhine.c
+++ b/drivers/net/ethernet/via/via-rhine.c
@@ -273,7 +273,7 @@ enum rhine_quirks {
273/* Beware of PCI posted writes */ 273/* Beware of PCI posted writes */
274#define IOSYNC do { ioread8(ioaddr + StationAddr); } while (0) 274#define IOSYNC do { ioread8(ioaddr + StationAddr); } while (0)
275 275
276static DEFINE_PCI_DEVICE_TABLE(rhine_pci_tbl) = { 276static const struct pci_device_id rhine_pci_tbl[] = {
277 { 0x1106, 0x3043, PCI_ANY_ID, PCI_ANY_ID, }, /* VT86C100A */ 277 { 0x1106, 0x3043, PCI_ANY_ID, PCI_ANY_ID, }, /* VT86C100A */
278 { 0x1106, 0x3065, PCI_ANY_ID, PCI_ANY_ID, }, /* VT6102 */ 278 { 0x1106, 0x3065, PCI_ANY_ID, PCI_ANY_ID, }, /* VT6102 */
279 { 0x1106, 0x3106, PCI_ANY_ID, PCI_ANY_ID, }, /* 6105{,L,LOM} */ 279 { 0x1106, 0x3106, PCI_ANY_ID, PCI_ANY_ID, }, /* 6105{,L,LOM} */
diff --git a/drivers/net/ethernet/via/via-velocity.c b/drivers/net/ethernet/via/via-velocity.c
index de08e86db209..f5fbc12d3e10 100644
--- a/drivers/net/ethernet/via/via-velocity.c
+++ b/drivers/net/ethernet/via/via-velocity.c
@@ -381,7 +381,7 @@ static struct velocity_info_tbl chip_info_table[] = {
381 * device driver. Used for hotplug autoloading. 381 * device driver. Used for hotplug autoloading.
382 */ 382 */
383 383
384static DEFINE_PCI_DEVICE_TABLE(velocity_pci_id_table) = { 384static const struct pci_device_id velocity_pci_id_table[] = {
385 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) }, 385 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_612X) },
386 { } 386 { }
387}; 387};
diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
index 8a6e5c2d6f95..fda5891835d4 100644
--- a/drivers/net/ethernet/xilinx/ll_temac_main.c
+++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
@@ -1148,8 +1148,7 @@ static int temac_of_remove(struct platform_device *op)
1148 temac_mdio_teardown(lp); 1148 temac_mdio_teardown(lp);
1149 unregister_netdev(ndev); 1149 unregister_netdev(ndev);
1150 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group); 1150 sysfs_remove_group(&lp->dev->kobj, &temac_attr_group);
1151 if (lp->phy_node) 1151 of_node_put(lp->phy_node);
1152 of_node_put(lp->phy_node);
1153 lp->phy_node = NULL; 1152 lp->phy_node = NULL;
1154 iounmap(lp->regs); 1153 iounmap(lp->regs);
1155 if (lp->sdma_regs) 1154 if (lp->sdma_regs)
@@ -1171,7 +1170,6 @@ static struct platform_driver temac_of_driver = {
1171 .probe = temac_of_probe, 1170 .probe = temac_of_probe,
1172 .remove = temac_of_remove, 1171 .remove = temac_of_remove,
1173 .driver = { 1172 .driver = {
1174 .owner = THIS_MODULE,
1175 .name = "xilinx_temac", 1173 .name = "xilinx_temac",
1176 .of_match_table = temac_of_match, 1174 .of_match_table = temac_of_match,
1177 }, 1175 },
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
index 7b0a73556264..c8fd94133ecd 100644
--- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
+++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c
@@ -1630,8 +1630,7 @@ static int axienet_of_remove(struct platform_device *op)
1630 axienet_mdio_teardown(lp); 1630 axienet_mdio_teardown(lp);
1631 unregister_netdev(ndev); 1631 unregister_netdev(ndev);
1632 1632
1633 if (lp->phy_node) 1633 of_node_put(lp->phy_node);
1634 of_node_put(lp->phy_node);
1635 lp->phy_node = NULL; 1634 lp->phy_node = NULL;
1636 1635
1637 iounmap(lp->regs); 1636 iounmap(lp->regs);
@@ -1646,7 +1645,6 @@ static struct platform_driver axienet_of_driver = {
1646 .probe = axienet_of_probe, 1645 .probe = axienet_of_probe,
1647 .remove = axienet_of_remove, 1646 .remove = axienet_of_remove,
1648 .driver = { 1647 .driver = {
1649 .owner = THIS_MODULE,
1650 .name = "xilinx_axienet", 1648 .name = "xilinx_axienet",
1651 .of_match_table = axienet_of_match, 1649 .of_match_table = axienet_of_match,
1652 }, 1650 },
diff --git a/drivers/net/ethernet/xilinx/xilinx_emaclite.c b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
index 782bb9373cd8..28dbbdc393eb 100644
--- a/drivers/net/ethernet/xilinx/xilinx_emaclite.c
+++ b/drivers/net/ethernet/xilinx/xilinx_emaclite.c
@@ -1245,7 +1245,6 @@ MODULE_DEVICE_TABLE(of, xemaclite_of_match);
1245static struct platform_driver xemaclite_of_driver = { 1245static struct platform_driver xemaclite_of_driver = {
1246 .driver = { 1246 .driver = {
1247 .name = DRIVER_NAME, 1247 .name = DRIVER_NAME,
1248 .owner = THIS_MODULE,
1249 .of_match_table = xemaclite_of_match, 1248 .of_match_table = xemaclite_of_match,
1250 }, 1249 },
1251 .probe = xemaclite_of_probe, 1250 .probe = xemaclite_of_probe,
diff --git a/drivers/net/ethernet/xircom/xirc2ps_cs.c b/drivers/net/ethernet/xircom/xirc2ps_cs.c
index 7c81ffb861e8..d56f8693202b 100644
--- a/drivers/net/ethernet/xircom/xirc2ps_cs.c
+++ b/drivers/net/ethernet/xircom/xirc2ps_cs.c
@@ -266,7 +266,7 @@ static void xirc2ps_detach(struct pcmcia_device *p_dev);
266 266
267static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id); 267static irqreturn_t xirc2ps_interrupt(int irq, void *dev_id);
268 268
269typedef struct local_info_t { 269struct local_info {
270 struct net_device *dev; 270 struct net_device *dev;
271 struct pcmcia_device *p_dev; 271 struct pcmcia_device *p_dev;
272 272
@@ -281,7 +281,7 @@ typedef struct local_info_t {
281 unsigned last_ptr_value; /* last packets transmitted value */ 281 unsigned last_ptr_value; /* last packets transmitted value */
282 const char *manf_str; 282 const char *manf_str;
283 struct work_struct tx_timeout_task; 283 struct work_struct tx_timeout_task;
284} local_info_t; 284};
285 285
286/**************** 286/****************
287 * Some more prototypes 287 * Some more prototypes
@@ -475,12 +475,12 @@ static int
475xirc2ps_probe(struct pcmcia_device *link) 475xirc2ps_probe(struct pcmcia_device *link)
476{ 476{
477 struct net_device *dev; 477 struct net_device *dev;
478 local_info_t *local; 478 struct local_info *local;
479 479
480 dev_dbg(&link->dev, "attach()\n"); 480 dev_dbg(&link->dev, "attach()\n");
481 481
482 /* Allocate the device structure */ 482 /* Allocate the device structure */
483 dev = alloc_etherdev(sizeof(local_info_t)); 483 dev = alloc_etherdev(sizeof(struct local_info));
484 if (!dev) 484 if (!dev)
485 return -ENOMEM; 485 return -ENOMEM;
486 local = netdev_priv(dev); 486 local = netdev_priv(dev);
@@ -536,7 +536,7 @@ static int
536set_card_type(struct pcmcia_device *link) 536set_card_type(struct pcmcia_device *link)
537{ 537{
538 struct net_device *dev = link->priv; 538 struct net_device *dev = link->priv;
539 local_info_t *local = netdev_priv(dev); 539 struct local_info *local = netdev_priv(dev);
540 u8 *buf; 540 u8 *buf;
541 unsigned int cisrev, mediaid, prodid; 541 unsigned int cisrev, mediaid, prodid;
542 size_t len; 542 size_t len;
@@ -690,7 +690,7 @@ static int
690xirc2ps_config(struct pcmcia_device * link) 690xirc2ps_config(struct pcmcia_device * link)
691{ 691{
692 struct net_device *dev = link->priv; 692 struct net_device *dev = link->priv;
693 local_info_t *local = netdev_priv(dev); 693 struct local_info *local = netdev_priv(dev);
694 unsigned int ioaddr; 694 unsigned int ioaddr;
695 int err; 695 int err;
696 u8 *buf; 696 u8 *buf;
@@ -931,7 +931,7 @@ xirc2ps_release(struct pcmcia_device *link)
931 931
932 if (link->resource[2]->end) { 932 if (link->resource[2]->end) {
933 struct net_device *dev = link->priv; 933 struct net_device *dev = link->priv;
934 local_info_t *local = netdev_priv(dev); 934 struct local_info *local = netdev_priv(dev);
935 if (local->dingo) 935 if (local->dingo)
936 iounmap(local->dingo_ccr - 0x0800); 936 iounmap(local->dingo_ccr - 0x0800);
937 } 937 }
@@ -975,7 +975,7 @@ static irqreturn_t
975xirc2ps_interrupt(int irq, void *dev_id) 975xirc2ps_interrupt(int irq, void *dev_id)
976{ 976{
977 struct net_device *dev = (struct net_device *)dev_id; 977 struct net_device *dev = (struct net_device *)dev_id;
978 local_info_t *lp = netdev_priv(dev); 978 struct local_info *lp = netdev_priv(dev);
979 unsigned int ioaddr; 979 unsigned int ioaddr;
980 u_char saved_page; 980 u_char saved_page;
981 unsigned bytes_rcvd; 981 unsigned bytes_rcvd;
@@ -1194,8 +1194,8 @@ xirc2ps_interrupt(int irq, void *dev_id)
1194static void 1194static void
1195xirc2ps_tx_timeout_task(struct work_struct *work) 1195xirc2ps_tx_timeout_task(struct work_struct *work)
1196{ 1196{
1197 local_info_t *local = 1197 struct local_info *local =
1198 container_of(work, local_info_t, tx_timeout_task); 1198 container_of(work, struct local_info, tx_timeout_task);
1199 struct net_device *dev = local->dev; 1199 struct net_device *dev = local->dev;
1200 /* reset the card */ 1200 /* reset the card */
1201 do_reset(dev,1); 1201 do_reset(dev,1);
@@ -1206,7 +1206,7 @@ xirc2ps_tx_timeout_task(struct work_struct *work)
1206static void 1206static void
1207xirc_tx_timeout(struct net_device *dev) 1207xirc_tx_timeout(struct net_device *dev)
1208{ 1208{
1209 local_info_t *lp = netdev_priv(dev); 1209 struct local_info *lp = netdev_priv(dev);
1210 dev->stats.tx_errors++; 1210 dev->stats.tx_errors++;
1211 netdev_notice(dev, "transmit timed out\n"); 1211 netdev_notice(dev, "transmit timed out\n");
1212 schedule_work(&lp->tx_timeout_task); 1212 schedule_work(&lp->tx_timeout_task);
@@ -1215,7 +1215,7 @@ xirc_tx_timeout(struct net_device *dev)
1215static netdev_tx_t 1215static netdev_tx_t
1216do_start_xmit(struct sk_buff *skb, struct net_device *dev) 1216do_start_xmit(struct sk_buff *skb, struct net_device *dev)
1217{ 1217{
1218 local_info_t *lp = netdev_priv(dev); 1218 struct local_info *lp = netdev_priv(dev);
1219 unsigned int ioaddr = dev->base_addr; 1219 unsigned int ioaddr = dev->base_addr;
1220 int okay; 1220 int okay;
1221 unsigned freespace; 1221 unsigned freespace;
@@ -1300,7 +1300,7 @@ static void set_address(struct set_address_info *sa_info, char *addr)
1300static void set_addresses(struct net_device *dev) 1300static void set_addresses(struct net_device *dev)
1301{ 1301{
1302 unsigned int ioaddr = dev->base_addr; 1302 unsigned int ioaddr = dev->base_addr;
1303 local_info_t *lp = netdev_priv(dev); 1303 struct local_info *lp = netdev_priv(dev);
1304 struct netdev_hw_addr *ha; 1304 struct netdev_hw_addr *ha;
1305 struct set_address_info sa_info; 1305 struct set_address_info sa_info;
1306 int i; 1306 int i;
@@ -1362,7 +1362,7 @@ set_multicast_list(struct net_device *dev)
1362static int 1362static int
1363do_config(struct net_device *dev, struct ifmap *map) 1363do_config(struct net_device *dev, struct ifmap *map)
1364{ 1364{
1365 local_info_t *local = netdev_priv(dev); 1365 struct local_info *local = netdev_priv(dev);
1366 1366
1367 pr_debug("do_config(%p)\n", dev); 1367 pr_debug("do_config(%p)\n", dev);
1368 if (map->port != 255 && map->port != dev->if_port) { 1368 if (map->port != 255 && map->port != dev->if_port) {
@@ -1387,7 +1387,7 @@ do_config(struct net_device *dev, struct ifmap *map)
1387static int 1387static int
1388do_open(struct net_device *dev) 1388do_open(struct net_device *dev)
1389{ 1389{
1390 local_info_t *lp = netdev_priv(dev); 1390 struct local_info *lp = netdev_priv(dev);
1391 struct pcmcia_device *link = lp->p_dev; 1391 struct pcmcia_device *link = lp->p_dev;
1392 1392
1393 dev_dbg(&link->dev, "do_open(%p)\n", dev); 1393 dev_dbg(&link->dev, "do_open(%p)\n", dev);
@@ -1421,7 +1421,7 @@ static const struct ethtool_ops netdev_ethtool_ops = {
1421static int 1421static int
1422do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) 1422do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1423{ 1423{
1424 local_info_t *local = netdev_priv(dev); 1424 struct local_info *local = netdev_priv(dev);
1425 unsigned int ioaddr = dev->base_addr; 1425 unsigned int ioaddr = dev->base_addr;
1426 struct mii_ioctl_data *data = if_mii(rq); 1426 struct mii_ioctl_data *data = if_mii(rq);
1427 1427
@@ -1453,7 +1453,7 @@ do_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1453static void 1453static void
1454hardreset(struct net_device *dev) 1454hardreset(struct net_device *dev)
1455{ 1455{
1456 local_info_t *local = netdev_priv(dev); 1456 struct local_info *local = netdev_priv(dev);
1457 unsigned int ioaddr = dev->base_addr; 1457 unsigned int ioaddr = dev->base_addr;
1458 1458
1459 SelectPage(4); 1459 SelectPage(4);
@@ -1470,7 +1470,7 @@ hardreset(struct net_device *dev)
1470static void 1470static void
1471do_reset(struct net_device *dev, int full) 1471do_reset(struct net_device *dev, int full)
1472{ 1472{
1473 local_info_t *local = netdev_priv(dev); 1473 struct local_info *local = netdev_priv(dev);
1474 unsigned int ioaddr = dev->base_addr; 1474 unsigned int ioaddr = dev->base_addr;
1475 unsigned value; 1475 unsigned value;
1476 1476
@@ -1631,7 +1631,7 @@ do_reset(struct net_device *dev, int full)
1631static int 1631static int
1632init_mii(struct net_device *dev) 1632init_mii(struct net_device *dev)
1633{ 1633{
1634 local_info_t *local = netdev_priv(dev); 1634 struct local_info *local = netdev_priv(dev);
1635 unsigned int ioaddr = dev->base_addr; 1635 unsigned int ioaddr = dev->base_addr;
1636 unsigned control, status, linkpartner; 1636 unsigned control, status, linkpartner;
1637 int i; 1637 int i;
@@ -1715,7 +1715,7 @@ static int
1715do_stop(struct net_device *dev) 1715do_stop(struct net_device *dev)
1716{ 1716{
1717 unsigned int ioaddr = dev->base_addr; 1717 unsigned int ioaddr = dev->base_addr;
1718 local_info_t *lp = netdev_priv(dev); 1718 struct local_info *lp = netdev_priv(dev);
1719 struct pcmcia_device *link = lp->p_dev; 1719 struct pcmcia_device *link = lp->p_dev;
1720 1720
1721 dev_dbg(&link->dev, "do_stop(%p)\n", dev); 1721 dev_dbg(&link->dev, "do_stop(%p)\n", dev);
diff --git a/drivers/net/fddi/defxx.c b/drivers/net/fddi/defxx.c
index 6eb849a56da5..c44eaf019dea 100644
--- a/drivers/net/fddi/defxx.c
+++ b/drivers/net/fddi/defxx.c
@@ -3664,7 +3664,7 @@ static int __maybe_unused dfx_dev_unregister(struct device *);
3664static int dfx_pci_register(struct pci_dev *, const struct pci_device_id *); 3664static int dfx_pci_register(struct pci_dev *, const struct pci_device_id *);
3665static void dfx_pci_unregister(struct pci_dev *); 3665static void dfx_pci_unregister(struct pci_dev *);
3666 3666
3667static DEFINE_PCI_DEVICE_TABLE(dfx_pci_table) = { 3667static const struct pci_device_id dfx_pci_table[] = {
3668 { PCI_DEVICE(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI) }, 3668 { PCI_DEVICE(PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_FDDI) },
3669 { } 3669 { }
3670}; 3670};
diff --git a/drivers/net/fddi/skfp/skfddi.c b/drivers/net/fddi/skfp/skfddi.c
index d5f58121b2e2..51acc6d86e91 100644
--- a/drivers/net/fddi/skfp/skfddi.c
+++ b/drivers/net/fddi/skfp/skfddi.c
@@ -149,7 +149,7 @@ extern void mac_drv_rx_mode(struct s_smc *smc, int mode);
149extern void mac_drv_clear_rx_queue(struct s_smc *smc); 149extern void mac_drv_clear_rx_queue(struct s_smc *smc);
150extern void enable_tx_irq(struct s_smc *smc, u_short queue); 150extern void enable_tx_irq(struct s_smc *smc, u_short queue);
151 151
152static DEFINE_PCI_DEVICE_TABLE(skfddi_pci_tbl) = { 152static const struct pci_device_id skfddi_pci_tbl[] = {
153 { PCI_VENDOR_ID_SK, PCI_DEVICE_ID_SK_FP, PCI_ANY_ID, PCI_ANY_ID, }, 153 { PCI_VENDOR_ID_SK, PCI_DEVICE_ID_SK_FP, PCI_ANY_ID, PCI_ANY_ID, },
154 { } /* Terminating entry */ 154 { } /* Terminating entry */
155}; 155};
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c
index e580583f196d..95c0b45a68fb 100644
--- a/drivers/net/hippi/rrunner.c
+++ b/drivers/net/hippi/rrunner.c
@@ -1668,7 +1668,7 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
1668 } 1668 }
1669} 1669}
1670 1670
1671static DEFINE_PCI_DEVICE_TABLE(rr_pci_tbl) = { 1671static const struct pci_device_id rr_pci_tbl[] = {
1672 { PCI_VENDOR_ID_ESSENTIAL, PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER, 1672 { PCI_VENDOR_ID_ESSENTIAL, PCI_DEVICE_ID_ESSENTIAL_ROADRUNNER,
1673 PCI_ANY_ID, PCI_ANY_ID, }, 1673 PCI_ANY_ID, PCI_ANY_ID, },
1674 { 0,} 1674 { 0,}
diff --git a/drivers/net/hyperv/hyperv_net.h b/drivers/net/hyperv/hyperv_net.h
index 02a3ee282eee..d5e07def6a59 100644
--- a/drivers/net/hyperv/hyperv_net.h
+++ b/drivers/net/hyperv/hyperv_net.h
@@ -585,7 +585,7 @@ struct nvsp_message {
585 585
586#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */ 586#define NETVSC_RECEIVE_BUFFER_SIZE (1024*1024*16) /* 16MB */
587#define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15) /* 15MB */ 587#define NETVSC_RECEIVE_BUFFER_SIZE_LEGACY (1024*1024*15) /* 15MB */
588#define NETVSC_SEND_BUFFER_SIZE (1024 * 1024 * 16) /* 16MB */ 588#define NETVSC_SEND_BUFFER_SIZE (1024 * 1024 * 15) /* 15MB */
589#define NETVSC_INVALID_INDEX -1 589#define NETVSC_INVALID_INDEX -1
590 590
591 591
diff --git a/drivers/net/irda/au1k_ir.c b/drivers/net/irda/au1k_ir.c
index 5f91e3e01c04..aab2cf72d025 100644
--- a/drivers/net/irda/au1k_ir.c
+++ b/drivers/net/irda/au1k_ir.c
@@ -18,6 +18,7 @@
18 * with this program; if not, see <http://www.gnu.org/licenses/>. 18 * with this program; if not, see <http://www.gnu.org/licenses/>.
19 */ 19 */
20 20
21#include <linux/clk.h>
21#include <linux/module.h> 22#include <linux/module.h>
22#include <linux/netdevice.h> 23#include <linux/netdevice.h>
23#include <linux/interrupt.h> 24#include <linux/interrupt.h>
@@ -175,6 +176,7 @@ struct au1k_private {
175 176
176 struct resource *ioarea; 177 struct resource *ioarea;
177 struct au1k_irda_platform_data *platdata; 178 struct au1k_irda_platform_data *platdata;
179 struct clk *irda_clk;
178}; 180};
179 181
180static int qos_mtt_bits = 0x07; /* 1 ms or more */ 182static int qos_mtt_bits = 0x07; /* 1 ms or more */
@@ -514,9 +516,39 @@ static irqreturn_t au1k_irda_interrupt(int dummy, void *dev_id)
514static int au1k_init(struct net_device *dev) 516static int au1k_init(struct net_device *dev)
515{ 517{
516 struct au1k_private *aup = netdev_priv(dev); 518 struct au1k_private *aup = netdev_priv(dev);
517 u32 enable, ring_address; 519 u32 enable, ring_address, phyck;
520 struct clk *c;
518 int i; 521 int i;
519 522
523 c = clk_get(NULL, "irda_clk");
524 if (IS_ERR(c))
525 return PTR_ERR(c);
526 i = clk_prepare_enable(c);
527 if (i) {
528 clk_put(c);
529 return i;
530 }
531
532 switch (clk_get_rate(c)) {
533 case 40000000:
534 phyck = IR_PHYCLK_40MHZ;
535 break;
536 case 48000000:
537 phyck = IR_PHYCLK_48MHZ;
538 break;
539 case 56000000:
540 phyck = IR_PHYCLK_56MHZ;
541 break;
542 case 64000000:
543 phyck = IR_PHYCLK_64MHZ;
544 break;
545 default:
546 clk_disable_unprepare(c);
547 clk_put(c);
548 return -EINVAL;
549 }
550 aup->irda_clk = c;
551
520 enable = IR_HC | IR_CE | IR_C; 552 enable = IR_HC | IR_CE | IR_C;
521#ifndef CONFIG_CPU_LITTLE_ENDIAN 553#ifndef CONFIG_CPU_LITTLE_ENDIAN
522 enable |= IR_BE; 554 enable |= IR_BE;
@@ -545,7 +577,7 @@ static int au1k_init(struct net_device *dev)
545 irda_write(aup, IR_RING_SIZE, 577 irda_write(aup, IR_RING_SIZE,
546 (RING_SIZE_64 << 8) | (RING_SIZE_64 << 12)); 578 (RING_SIZE_64 << 8) | (RING_SIZE_64 << 12));
547 579
548 irda_write(aup, IR_CONFIG_2, IR_PHYCLK_48MHZ | IR_ONE_PIN); 580 irda_write(aup, IR_CONFIG_2, phyck | IR_ONE_PIN);
549 irda_write(aup, IR_RING_ADDR_CMPR, 0); 581 irda_write(aup, IR_RING_ADDR_CMPR, 0);
550 582
551 au1k_irda_set_speed(dev, 9600); 583 au1k_irda_set_speed(dev, 9600);
@@ -619,6 +651,9 @@ static int au1k_irda_stop(struct net_device *dev)
619 free_irq(aup->irq_tx, dev); 651 free_irq(aup->irq_tx, dev);
620 free_irq(aup->irq_rx, dev); 652 free_irq(aup->irq_rx, dev);
621 653
654 clk_disable_unprepare(aup->irda_clk);
655 clk_put(aup->irda_clk);
656
622 return 0; 657 return 0;
623} 658}
624 659
@@ -853,6 +888,7 @@ static int au1k_irda_probe(struct platform_device *pdev)
853 struct au1k_private *aup; 888 struct au1k_private *aup;
854 struct net_device *dev; 889 struct net_device *dev;
855 struct resource *r; 890 struct resource *r;
891 struct clk *c;
856 int err; 892 int err;
857 893
858 dev = alloc_irdadev(sizeof(struct au1k_private)); 894 dev = alloc_irdadev(sizeof(struct au1k_private));
@@ -886,6 +922,14 @@ static int au1k_irda_probe(struct platform_device *pdev)
886 if (!aup->ioarea) 922 if (!aup->ioarea)
887 goto out; 923 goto out;
888 924
925 /* bail out early if clock doesn't exist */
926 c = clk_get(NULL, "irda_clk");
927 if (IS_ERR(c)) {
928 err = PTR_ERR(c);
929 goto out;
930 }
931 clk_put(c);
932
889 aup->iobase = ioremap_nocache(r->start, resource_size(r)); 933 aup->iobase = ioremap_nocache(r->start, resource_size(r));
890 if (!aup->iobase) 934 if (!aup->iobase)
891 goto out2; 935 goto out2;
diff --git a/drivers/net/irda/donauboe.c b/drivers/net/irda/donauboe.c
index 768dfe9a9315..a87a82ca111f 100644
--- a/drivers/net/irda/donauboe.c
+++ b/drivers/net/irda/donauboe.c
@@ -184,7 +184,7 @@
184#define CONFIG0H_DMA_ON_NORX CONFIG0H_DMA_OFF| OBOE_CONFIG0H_ENDMAC 184#define CONFIG0H_DMA_ON_NORX CONFIG0H_DMA_OFF| OBOE_CONFIG0H_ENDMAC
185#define CONFIG0H_DMA_ON CONFIG0H_DMA_ON_NORX | OBOE_CONFIG0H_ENRX 185#define CONFIG0H_DMA_ON CONFIG0H_DMA_ON_NORX | OBOE_CONFIG0H_ENRX
186 186
187static DEFINE_PCI_DEVICE_TABLE(toshoboe_pci_tbl) = { 187static const struct pci_device_id toshoboe_pci_tbl[] = {
188 { PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_FIR701, PCI_ANY_ID, PCI_ANY_ID, }, 188 { PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_FIR701, PCI_ANY_ID, PCI_ANY_ID, },
189 { PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_FIRD01, PCI_ANY_ID, PCI_ANY_ID, }, 189 { PCI_VENDOR_ID_TOSHIBA, PCI_DEVICE_ID_FIRD01, PCI_ANY_ID, PCI_ANY_ID, },
190 { } /* Terminating entry */ 190 { } /* Terminating entry */
@@ -1755,17 +1755,4 @@ static struct pci_driver donauboe_pci_driver = {
1755 .resume = toshoboe_wakeup 1755 .resume = toshoboe_wakeup
1756}; 1756};
1757 1757
1758static int __init 1758module_pci_driver(donauboe_pci_driver);
1759donauboe_init (void)
1760{
1761 return pci_register_driver(&donauboe_pci_driver);
1762}
1763
1764static void __exit
1765donauboe_cleanup (void)
1766{
1767 pci_unregister_driver(&donauboe_pci_driver);
1768}
1769
1770module_init(donauboe_init);
1771module_exit(donauboe_cleanup);
diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
index 998bb89ede71..36e004288ea7 100644
--- a/drivers/net/irda/via-ircc.c
+++ b/drivers/net/irda/via-ircc.c
@@ -115,7 +115,7 @@ static void iodelay(int udelay)
115 } 115 }
116} 116}
117 117
118static DEFINE_PCI_DEVICE_TABLE(via_pci_tbl) = { 118static const struct pci_device_id via_pci_tbl[] = {
119 { PCI_VENDOR_ID_VIA, 0x8231, PCI_ANY_ID, PCI_ANY_ID,0,0,0 }, 119 { PCI_VENDOR_ID_VIA, 0x8231, PCI_ANY_ID, PCI_ANY_ID,0,0,0 },
120 { PCI_VENDOR_ID_VIA, 0x3109, PCI_ANY_ID, PCI_ANY_ID,0,0,1 }, 120 { PCI_VENDOR_ID_VIA, 0x3109, PCI_ANY_ID, PCI_ANY_ID,0,0,1 },
121 { PCI_VENDOR_ID_VIA, 0x3074, PCI_ANY_ID, PCI_ANY_ID,0,0,2 }, 121 { PCI_VENDOR_ID_VIA, 0x3074, PCI_ANY_ID, PCI_ANY_ID,0,0,2 },
diff --git a/drivers/net/irda/vlsi_ir.c b/drivers/net/irda/vlsi_ir.c
index 485006604bbc..a04af9d0f8f9 100644
--- a/drivers/net/irda/vlsi_ir.c
+++ b/drivers/net/irda/vlsi_ir.c
@@ -58,7 +58,7 @@ MODULE_LICENSE("GPL");
58 58
59static /* const */ char drivername[] = DRIVER_NAME; 59static /* const */ char drivername[] = DRIVER_NAME;
60 60
61static DEFINE_PCI_DEVICE_TABLE(vlsi_irda_table) = { 61static const struct pci_device_id vlsi_irda_table[] = {
62 { 62 {
63 .class = PCI_CLASS_WIRELESS_IRDA << 8, 63 .class = PCI_CLASS_WIRELESS_IRDA << 8,
64 .class_mask = PCI_CLASS_SUBCLASS_MASK << 8, 64 .class_mask = PCI_CLASS_SUBCLASS_MASK << 8,
@@ -485,13 +485,13 @@ static int vlsi_create_hwif(vlsi_irda_dev_t *idev)
485 idev->virtaddr = NULL; 485 idev->virtaddr = NULL;
486 idev->busaddr = 0; 486 idev->busaddr = 0;
487 487
488 ringarea = pci_alloc_consistent(idev->pdev, HW_RING_AREA_SIZE, &idev->busaddr); 488 ringarea = pci_zalloc_consistent(idev->pdev, HW_RING_AREA_SIZE,
489 &idev->busaddr);
489 if (!ringarea) { 490 if (!ringarea) {
490 IRDA_ERROR("%s: insufficient memory for descriptor rings\n", 491 IRDA_ERROR("%s: insufficient memory for descriptor rings\n",
491 __func__); 492 __func__);
492 goto out; 493 goto out;
493 } 494 }
494 memset(ringarea, 0, HW_RING_AREA_SIZE);
495 495
496 hwmap = (struct ring_descr_hw *)ringarea; 496 hwmap = (struct ring_descr_hw *)ringarea;
497 idev->rx_ring = vlsi_alloc_ring(idev->pdev, hwmap, ringsize[1], 497 idev->rx_ring = vlsi_alloc_ring(idev->pdev, hwmap, ringsize[1],
diff --git a/drivers/net/macvlan.c b/drivers/net/macvlan.c
index ef8a5c20236a..60e4ca01ccbb 100644
--- a/drivers/net/macvlan.c
+++ b/drivers/net/macvlan.c
@@ -45,10 +45,9 @@ struct macvlan_port {
45 struct sk_buff_head bc_queue; 45 struct sk_buff_head bc_queue;
46 struct work_struct bc_work; 46 struct work_struct bc_work;
47 bool passthru; 47 bool passthru;
48 int count;
48}; 49};
49 50
50#define MACVLAN_PORT_IS_EMPTY(port) list_empty(&port->vlans)
51
52struct macvlan_skb_cb { 51struct macvlan_skb_cb {
53 const struct macvlan_dev *src; 52 const struct macvlan_dev *src;
54}; 53};
@@ -667,7 +666,8 @@ static void macvlan_uninit(struct net_device *dev)
667 666
668 free_percpu(vlan->pcpu_stats); 667 free_percpu(vlan->pcpu_stats);
669 668
670 if (MACVLAN_PORT_IS_EMPTY(port)) 669 port->count -= 1;
670 if (!port->count)
671 macvlan_port_destroy(port->dev); 671 macvlan_port_destroy(port->dev);
672} 672}
673 673
@@ -1020,12 +1020,13 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
1020 vlan->flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]); 1020 vlan->flags = nla_get_u16(data[IFLA_MACVLAN_FLAGS]);
1021 1021
1022 if (vlan->mode == MACVLAN_MODE_PASSTHRU) { 1022 if (vlan->mode == MACVLAN_MODE_PASSTHRU) {
1023 if (!MACVLAN_PORT_IS_EMPTY(port)) 1023 if (port->count)
1024 return -EINVAL; 1024 return -EINVAL;
1025 port->passthru = true; 1025 port->passthru = true;
1026 eth_hw_addr_inherit(dev, lowerdev); 1026 eth_hw_addr_inherit(dev, lowerdev);
1027 } 1027 }
1028 1028
1029 port->count += 1;
1029 err = register_netdevice(dev); 1030 err = register_netdevice(dev);
1030 if (err < 0) 1031 if (err < 0)
1031 goto destroy_port; 1032 goto destroy_port;
@@ -1043,7 +1044,8 @@ int macvlan_common_newlink(struct net *src_net, struct net_device *dev,
1043unregister_netdev: 1044unregister_netdev:
1044 unregister_netdevice(dev); 1045 unregister_netdevice(dev);
1045destroy_port: 1046destroy_port:
1046 if (MACVLAN_PORT_IS_EMPTY(port)) 1047 port->count -= 1;
1048 if (!port->count)
1047 macvlan_port_destroy(lowerdev); 1049 macvlan_port_destroy(lowerdev);
1048 1050
1049 return err; 1051 return err;
diff --git a/drivers/net/usb/Kconfig b/drivers/net/usb/Kconfig
index 9f194a0bef7c..37eed4d84e9c 100644
--- a/drivers/net/usb/Kconfig
+++ b/drivers/net/usb/Kconfig
@@ -5,8 +5,8 @@ comment "Host-side USB support is needed for USB Network Adapter support"
5 depends on !USB && NET 5 depends on !USB && NET
6 6
7menuconfig USB_NET_DRIVERS 7menuconfig USB_NET_DRIVERS
8 bool "USB Network Adapters" 8 tristate "USB Network Adapters"
9 default y 9 default USB if USB
10 depends on USB && NET 10 depends on USB && NET
11 11
12if USB_NET_DRIVERS 12if USB_NET_DRIVERS
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index b76f7dcde0db..d6e90c72c257 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -36,7 +36,7 @@ char vmxnet3_driver_name[] = "vmxnet3";
36 * PCI Device ID Table 36 * PCI Device ID Table
37 * Last entry must be all 0s 37 * Last entry must be all 0s
38 */ 38 */
39static DEFINE_PCI_DEVICE_TABLE(vmxnet3_pciid_table) = { 39static const struct pci_device_id vmxnet3_pciid_table[] = {
40 {PCI_VDEVICE(VMWARE, PCI_DEVICE_ID_VMWARE_VMXNET3)}, 40 {PCI_VDEVICE(VMWARE, PCI_DEVICE_ID_VMWARE_VMXNET3)},
41 {0} 41 {0}
42}; 42};
@@ -766,7 +766,7 @@ vmxnet3_map_pkt(struct sk_buff *skb, struct vmxnet3_tx_ctx *ctx,
766 gdesc->dword[3] = 0; 766 gdesc->dword[3] = 0;
767 767
768 netdev_dbg(adapter->netdev, 768 netdev_dbg(adapter->netdev,
769 "txd[%u]: 0x%llu %u %u\n", 769 "txd[%u]: 0x%llx %u %u\n",
770 tq->tx_ring.next2fill, le64_to_cpu(gdesc->txd.addr), 770 tq->tx_ring.next2fill, le64_to_cpu(gdesc->txd.addr),
771 le32_to_cpu(gdesc->dword[2]), gdesc->dword[3]); 771 le32_to_cpu(gdesc->dword[2]), gdesc->dword[3]);
772 vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring); 772 vmxnet3_cmd_ring_adv_next2fill(&tq->tx_ring);
diff --git a/drivers/net/wan/dscc4.c b/drivers/net/wan/dscc4.c
index 288610df205c..08223569cebd 100644
--- a/drivers/net/wan/dscc4.c
+++ b/drivers/net/wan/dscc4.c
@@ -2039,7 +2039,7 @@ static int __init dscc4_setup(char *str)
2039__setup("dscc4.setup=", dscc4_setup); 2039__setup("dscc4.setup=", dscc4_setup);
2040#endif 2040#endif
2041 2041
2042static DEFINE_PCI_DEVICE_TABLE(dscc4_pci_tbl) = { 2042static const struct pci_device_id dscc4_pci_tbl[] = {
2043 { PCI_VENDOR_ID_SIEMENS, PCI_DEVICE_ID_SIEMENS_DSCC4, 2043 { PCI_VENDOR_ID_SIEMENS, PCI_DEVICE_ID_SIEMENS_DSCC4,
2044 PCI_ANY_ID, PCI_ANY_ID, }, 2044 PCI_ANY_ID, PCI_ANY_ID, },
2045 { 0,} 2045 { 0,}
diff --git a/drivers/net/wan/farsync.c b/drivers/net/wan/farsync.c
index 1f041271f7fe..44541dbc5c28 100644
--- a/drivers/net/wan/farsync.c
+++ b/drivers/net/wan/farsync.c
@@ -531,7 +531,7 @@ do { \
531/* 531/*
532 * PCI ID lookup table 532 * PCI ID lookup table
533 */ 533 */
534static DEFINE_PCI_DEVICE_TABLE(fst_pci_dev_id) = { 534static const struct pci_device_id fst_pci_dev_id[] = {
535 {PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T2P, PCI_ANY_ID, 535 {PCI_VENDOR_ID_FARSITE, PCI_DEVICE_ID_FARSITE_T2P, PCI_ANY_ID,
536 PCI_ANY_ID, 0, 0, FST_TYPE_T2P}, 536 PCI_ANY_ID, 0, 0, FST_TYPE_T2P},
537 537
diff --git a/drivers/net/wan/hdlc_fr.c b/drivers/net/wan/hdlc_fr.c
index 7cc64eac0fa3..e5c7e6165a4b 100644
--- a/drivers/net/wan/hdlc_fr.c
+++ b/drivers/net/wan/hdlc_fr.c
@@ -90,7 +90,7 @@
90#define LMI_ANSI_LENGTH 14 90#define LMI_ANSI_LENGTH 14
91 91
92 92
93typedef struct { 93struct fr_hdr {
94#if defined(__LITTLE_ENDIAN_BITFIELD) 94#if defined(__LITTLE_ENDIAN_BITFIELD)
95 unsigned ea1: 1; 95 unsigned ea1: 1;
96 unsigned cr: 1; 96 unsigned cr: 1;
@@ -112,14 +112,14 @@ typedef struct {
112 unsigned de: 1; 112 unsigned de: 1;
113 unsigned ea2: 1; 113 unsigned ea2: 1;
114#endif 114#endif
115}__packed fr_hdr; 115} __packed;
116 116
117 117
118typedef struct pvc_device_struct { 118struct pvc_device {
119 struct net_device *frad; 119 struct net_device *frad;
120 struct net_device *main; 120 struct net_device *main;
121 struct net_device *ether; /* bridged Ethernet interface */ 121 struct net_device *ether; /* bridged Ethernet interface */
122 struct pvc_device_struct *next; /* Sorted in ascending DLCI order */ 122 struct pvc_device *next; /* Sorted in ascending DLCI order */
123 int dlci; 123 int dlci;
124 int open_count; 124 int open_count;
125 125
@@ -132,11 +132,11 @@ typedef struct pvc_device_struct {
132 unsigned int becn: 1; 132 unsigned int becn: 1;
133 unsigned int bandwidth; /* Cisco LMI reporting only */ 133 unsigned int bandwidth; /* Cisco LMI reporting only */
134 }state; 134 }state;
135}pvc_device; 135};
136 136
137struct frad_state { 137struct frad_state {
138 fr_proto settings; 138 fr_proto settings;
139 pvc_device *first_pvc; 139 struct pvc_device *first_pvc;
140 int dce_pvc_count; 140 int dce_pvc_count;
141 141
142 struct timer_list timer; 142 struct timer_list timer;
@@ -174,9 +174,9 @@ static inline struct frad_state* state(hdlc_device *hdlc)
174} 174}
175 175
176 176
177static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci) 177static inline struct pvc_device *find_pvc(hdlc_device *hdlc, u16 dlci)
178{ 178{
179 pvc_device *pvc = state(hdlc)->first_pvc; 179 struct pvc_device *pvc = state(hdlc)->first_pvc;
180 180
181 while (pvc) { 181 while (pvc) {
182 if (pvc->dlci == dlci) 182 if (pvc->dlci == dlci)
@@ -190,10 +190,10 @@ static inline pvc_device* find_pvc(hdlc_device *hdlc, u16 dlci)
190} 190}
191 191
192 192
193static pvc_device* add_pvc(struct net_device *dev, u16 dlci) 193static struct pvc_device *add_pvc(struct net_device *dev, u16 dlci)
194{ 194{
195 hdlc_device *hdlc = dev_to_hdlc(dev); 195 hdlc_device *hdlc = dev_to_hdlc(dev);
196 pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc; 196 struct pvc_device *pvc, **pvc_p = &state(hdlc)->first_pvc;
197 197
198 while (*pvc_p) { 198 while (*pvc_p) {
199 if ((*pvc_p)->dlci == dlci) 199 if ((*pvc_p)->dlci == dlci)
@@ -203,7 +203,7 @@ static pvc_device* add_pvc(struct net_device *dev, u16 dlci)
203 pvc_p = &(*pvc_p)->next; 203 pvc_p = &(*pvc_p)->next;
204 } 204 }
205 205
206 pvc = kzalloc(sizeof(pvc_device), GFP_ATOMIC); 206 pvc = kzalloc(sizeof(*pvc), GFP_ATOMIC);
207#ifdef DEBUG_PVC 207#ifdef DEBUG_PVC
208 printk(KERN_DEBUG "add_pvc: allocated pvc %p, frad %p\n", pvc, dev); 208 printk(KERN_DEBUG "add_pvc: allocated pvc %p, frad %p\n", pvc, dev);
209#endif 209#endif
@@ -218,13 +218,13 @@ static pvc_device* add_pvc(struct net_device *dev, u16 dlci)
218} 218}
219 219
220 220
221static inline int pvc_is_used(pvc_device *pvc) 221static inline int pvc_is_used(struct pvc_device *pvc)
222{ 222{
223 return pvc->main || pvc->ether; 223 return pvc->main || pvc->ether;
224} 224}
225 225
226 226
227static inline void pvc_carrier(int on, pvc_device *pvc) 227static inline void pvc_carrier(int on, struct pvc_device *pvc)
228{ 228{
229 if (on) { 229 if (on) {
230 if (pvc->main) 230 if (pvc->main)
@@ -246,11 +246,11 @@ static inline void pvc_carrier(int on, pvc_device *pvc)
246 246
247static inline void delete_unused_pvcs(hdlc_device *hdlc) 247static inline void delete_unused_pvcs(hdlc_device *hdlc)
248{ 248{
249 pvc_device **pvc_p = &state(hdlc)->first_pvc; 249 struct pvc_device **pvc_p = &state(hdlc)->first_pvc;
250 250
251 while (*pvc_p) { 251 while (*pvc_p) {
252 if (!pvc_is_used(*pvc_p)) { 252 if (!pvc_is_used(*pvc_p)) {
253 pvc_device *pvc = *pvc_p; 253 struct pvc_device *pvc = *pvc_p;
254#ifdef DEBUG_PVC 254#ifdef DEBUG_PVC
255 printk(KERN_DEBUG "freeing unused pvc: %p\n", pvc); 255 printk(KERN_DEBUG "freeing unused pvc: %p\n", pvc);
256#endif 256#endif
@@ -263,7 +263,8 @@ static inline void delete_unused_pvcs(hdlc_device *hdlc)
263} 263}
264 264
265 265
266static inline struct net_device** get_dev_p(pvc_device *pvc, int type) 266static inline struct net_device **get_dev_p(struct pvc_device *pvc,
267 int type)
267{ 268{
268 if (type == ARPHRD_ETHER) 269 if (type == ARPHRD_ETHER)
269 return &pvc->ether; 270 return &pvc->ether;
@@ -342,7 +343,7 @@ static int fr_hard_header(struct sk_buff **skb_p, u16 dlci)
342 343
343static int pvc_open(struct net_device *dev) 344static int pvc_open(struct net_device *dev)
344{ 345{
345 pvc_device *pvc = dev->ml_priv; 346 struct pvc_device *pvc = dev->ml_priv;
346 347
347 if ((pvc->frad->flags & IFF_UP) == 0) 348 if ((pvc->frad->flags & IFF_UP) == 0)
348 return -EIO; /* Frad must be UP in order to activate PVC */ 349 return -EIO; /* Frad must be UP in order to activate PVC */
@@ -362,7 +363,7 @@ static int pvc_open(struct net_device *dev)
362 363
363static int pvc_close(struct net_device *dev) 364static int pvc_close(struct net_device *dev)
364{ 365{
365 pvc_device *pvc = dev->ml_priv; 366 struct pvc_device *pvc = dev->ml_priv;
366 367
367 if (--pvc->open_count == 0) { 368 if (--pvc->open_count == 0) {
368 hdlc_device *hdlc = dev_to_hdlc(pvc->frad); 369 hdlc_device *hdlc = dev_to_hdlc(pvc->frad);
@@ -381,7 +382,7 @@ static int pvc_close(struct net_device *dev)
381 382
382static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd) 383static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
383{ 384{
384 pvc_device *pvc = dev->ml_priv; 385 struct pvc_device *pvc = dev->ml_priv;
385 fr_proto_pvc_info info; 386 fr_proto_pvc_info info;
386 387
387 if (ifr->ifr_settings.type == IF_GET_PROTO) { 388 if (ifr->ifr_settings.type == IF_GET_PROTO) {
@@ -409,7 +410,7 @@ static int pvc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
409 410
410static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev) 411static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
411{ 412{
412 pvc_device *pvc = dev->ml_priv; 413 struct pvc_device *pvc = dev->ml_priv;
413 414
414 if (pvc->state.active) { 415 if (pvc->state.active) {
415 if (dev->type == ARPHRD_ETHER) { 416 if (dev->type == ARPHRD_ETHER) {
@@ -444,7 +445,7 @@ static netdev_tx_t pvc_xmit(struct sk_buff *skb, struct net_device *dev)
444 return NETDEV_TX_OK; 445 return NETDEV_TX_OK;
445} 446}
446 447
447static inline void fr_log_dlci_active(pvc_device *pvc) 448static inline void fr_log_dlci_active(struct pvc_device *pvc)
448{ 449{
449 netdev_info(pvc->frad, "DLCI %d [%s%s%s]%s %s\n", 450 netdev_info(pvc->frad, "DLCI %d [%s%s%s]%s %s\n",
450 pvc->dlci, 451 pvc->dlci,
@@ -469,7 +470,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)
469{ 470{
470 hdlc_device *hdlc = dev_to_hdlc(dev); 471 hdlc_device *hdlc = dev_to_hdlc(dev);
471 struct sk_buff *skb; 472 struct sk_buff *skb;
472 pvc_device *pvc = state(hdlc)->first_pvc; 473 struct pvc_device *pvc = state(hdlc)->first_pvc;
473 int lmi = state(hdlc)->settings.lmi; 474 int lmi = state(hdlc)->settings.lmi;
474 int dce = state(hdlc)->settings.dce; 475 int dce = state(hdlc)->settings.dce;
475 int len = lmi == LMI_ANSI ? LMI_ANSI_LENGTH : LMI_CCITT_CISCO_LENGTH; 476 int len = lmi == LMI_ANSI ? LMI_ANSI_LENGTH : LMI_CCITT_CISCO_LENGTH;
@@ -566,7 +567,7 @@ static void fr_lmi_send(struct net_device *dev, int fullrep)
566static void fr_set_link_state(int reliable, struct net_device *dev) 567static void fr_set_link_state(int reliable, struct net_device *dev)
567{ 568{
568 hdlc_device *hdlc = dev_to_hdlc(dev); 569 hdlc_device *hdlc = dev_to_hdlc(dev);
569 pvc_device *pvc = state(hdlc)->first_pvc; 570 struct pvc_device *pvc = state(hdlc)->first_pvc;
570 571
571 state(hdlc)->reliable = reliable; 572 state(hdlc)->reliable = reliable;
572 if (reliable) { 573 if (reliable) {
@@ -652,7 +653,7 @@ static void fr_timer(unsigned long arg)
652static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb) 653static int fr_lmi_recv(struct net_device *dev, struct sk_buff *skb)
653{ 654{
654 hdlc_device *hdlc = dev_to_hdlc(dev); 655 hdlc_device *hdlc = dev_to_hdlc(dev);
655 pvc_device *pvc; 656 struct pvc_device *pvc;
656 u8 rxseq, txseq; 657 u8 rxseq, txseq;
657 int lmi = state(hdlc)->settings.lmi; 658 int lmi = state(hdlc)->settings.lmi;
658 int dce = state(hdlc)->settings.dce; 659 int dce = state(hdlc)->settings.dce;
@@ -869,10 +870,10 @@ static int fr_rx(struct sk_buff *skb)
869{ 870{
870 struct net_device *frad = skb->dev; 871 struct net_device *frad = skb->dev;
871 hdlc_device *hdlc = dev_to_hdlc(frad); 872 hdlc_device *hdlc = dev_to_hdlc(frad);
872 fr_hdr *fh = (fr_hdr*)skb->data; 873 struct fr_hdr *fh = (struct fr_hdr *)skb->data;
873 u8 *data = skb->data; 874 u8 *data = skb->data;
874 u16 dlci; 875 u16 dlci;
875 pvc_device *pvc; 876 struct pvc_device *pvc;
876 struct net_device *dev = NULL; 877 struct net_device *dev = NULL;
877 878
878 if (skb->len <= 4 || fh->ea1 || data[2] != FR_UI) 879 if (skb->len <= 4 || fh->ea1 || data[2] != FR_UI)
@@ -1028,7 +1029,7 @@ static void fr_stop(struct net_device *dev)
1028static void fr_close(struct net_device *dev) 1029static void fr_close(struct net_device *dev)
1029{ 1030{
1030 hdlc_device *hdlc = dev_to_hdlc(dev); 1031 hdlc_device *hdlc = dev_to_hdlc(dev);
1031 pvc_device *pvc = state(hdlc)->first_pvc; 1032 struct pvc_device *pvc = state(hdlc)->first_pvc;
1032 1033
1033 while (pvc) { /* Shutdown all PVCs for this FRAD */ 1034 while (pvc) { /* Shutdown all PVCs for this FRAD */
1034 if (pvc->main) 1035 if (pvc->main)
@@ -1060,7 +1061,7 @@ static const struct net_device_ops pvc_ops = {
1060static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type) 1061static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
1061{ 1062{
1062 hdlc_device *hdlc = dev_to_hdlc(frad); 1063 hdlc_device *hdlc = dev_to_hdlc(frad);
1063 pvc_device *pvc; 1064 struct pvc_device *pvc;
1064 struct net_device *dev; 1065 struct net_device *dev;
1065 int used; 1066 int used;
1066 1067
@@ -1117,7 +1118,7 @@ static int fr_add_pvc(struct net_device *frad, unsigned int dlci, int type)
1117 1118
1118static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type) 1119static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
1119{ 1120{
1120 pvc_device *pvc; 1121 struct pvc_device *pvc;
1121 struct net_device *dev; 1122 struct net_device *dev;
1122 1123
1123 if ((pvc = find_pvc(hdlc, dlci)) == NULL) 1124 if ((pvc = find_pvc(hdlc, dlci)) == NULL)
@@ -1145,13 +1146,13 @@ static int fr_del_pvc(hdlc_device *hdlc, unsigned int dlci, int type)
1145static void fr_destroy(struct net_device *frad) 1146static void fr_destroy(struct net_device *frad)
1146{ 1147{
1147 hdlc_device *hdlc = dev_to_hdlc(frad); 1148 hdlc_device *hdlc = dev_to_hdlc(frad);
1148 pvc_device *pvc = state(hdlc)->first_pvc; 1149 struct pvc_device *pvc = state(hdlc)->first_pvc;
1149 state(hdlc)->first_pvc = NULL; /* All PVCs destroyed */ 1150 state(hdlc)->first_pvc = NULL; /* All PVCs destroyed */
1150 state(hdlc)->dce_pvc_count = 0; 1151 state(hdlc)->dce_pvc_count = 0;
1151 state(hdlc)->dce_changed = 1; 1152 state(hdlc)->dce_changed = 1;
1152 1153
1153 while (pvc) { 1154 while (pvc) {
1154 pvc_device *next = pvc->next; 1155 struct pvc_device *next = pvc->next;
1155 /* destructors will free_netdev() main and ether */ 1156 /* destructors will free_netdev() main and ether */
1156 if (pvc->main) 1157 if (pvc->main)
1157 unregister_netdevice(pvc->main); 1158 unregister_netdevice(pvc->main);
diff --git a/drivers/net/wan/lmc/lmc_main.c b/drivers/net/wan/lmc/lmc_main.c
index b2fe9bb89633..bea0f313a7a8 100644
--- a/drivers/net/wan/lmc/lmc_main.c
+++ b/drivers/net/wan/lmc/lmc_main.c
@@ -76,7 +76,7 @@
76 76
77static int LMC_PKT_BUF_SZ = 1542; 77static int LMC_PKT_BUF_SZ = 1542;
78 78
79static DEFINE_PCI_DEVICE_TABLE(lmc_pci_tbl) = { 79static const struct pci_device_id lmc_pci_tbl[] = {
80 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST, 80 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
81 PCI_VENDOR_ID_LMC, PCI_ANY_ID }, 81 PCI_VENDOR_ID_LMC, PCI_ANY_ID },
82 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST, 82 { PCI_VENDOR_ID_DEC, PCI_DEVICE_ID_DEC_TULIP_FAST,
diff --git a/drivers/net/wan/pc300too.c b/drivers/net/wan/pc300too.c
index 5b72f7f8c516..db363856e0b5 100644
--- a/drivers/net/wan/pc300too.c
+++ b/drivers/net/wan/pc300too.c
@@ -477,7 +477,7 @@ static int pc300_pci_init_one(struct pci_dev *pdev,
477 477
478 478
479 479
480static DEFINE_PCI_DEVICE_TABLE(pc300_pci_tbl) = { 480static const struct pci_device_id pc300_pci_tbl[] = {
481 { PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_PC300_RX_1, PCI_ANY_ID, 481 { PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_PC300_RX_1, PCI_ANY_ID,
482 PCI_ANY_ID, 0, 0, 0 }, 482 PCI_ANY_ID, 0, 0, 0 },
483 { PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_PC300_RX_2, PCI_ANY_ID, 483 { PCI_VENDOR_ID_CYCLADES, PCI_DEVICE_ID_PC300_RX_2, PCI_ANY_ID,
diff --git a/drivers/net/wan/pci200syn.c b/drivers/net/wan/pci200syn.c
index fe4e3ece3c42..e8455621390e 100644
--- a/drivers/net/wan/pci200syn.c
+++ b/drivers/net/wan/pci200syn.c
@@ -414,7 +414,7 @@ static int pci200_pci_init_one(struct pci_dev *pdev,
414 414
415 415
416 416
417static DEFINE_PCI_DEVICE_TABLE(pci200_pci_tbl) = { 417static const struct pci_device_id pci200_pci_tbl[] = {
418 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_VENDOR_ID_PLX, 418 { PCI_VENDOR_ID_PLX, PCI_DEVICE_ID_PLX_9050, PCI_VENDOR_ID_PLX,
419 PCI_DEVICE_ID_PLX_PCI200SYN, 0, 0, 0 }, 419 PCI_DEVICE_ID_PLX_PCI200SYN, 0, 0, 0 },
420 { 0, } 420 { 0, }
diff --git a/drivers/net/wan/wanxl.c b/drivers/net/wan/wanxl.c
index f76aa9081585..e73f13857846 100644
--- a/drivers/net/wan/wanxl.c
+++ b/drivers/net/wan/wanxl.c
@@ -54,24 +54,24 @@ static const char* version = "wanXL serial card driver version: 0.48";
54#define MBX2_MEMSZ_MASK 0xFFFF0000 /* PUTS Memory Size Register mask */ 54#define MBX2_MEMSZ_MASK 0xFFFF0000 /* PUTS Memory Size Register mask */
55 55
56 56
57typedef struct { 57struct port {
58 struct net_device *dev; 58 struct net_device *dev;
59 struct card_t *card; 59 struct card *card;
60 spinlock_t lock; /* for wanxl_xmit */ 60 spinlock_t lock; /* for wanxl_xmit */
61 int node; /* physical port #0 - 3 */ 61 int node; /* physical port #0 - 3 */
62 unsigned int clock_type; 62 unsigned int clock_type;
63 int tx_in, tx_out; 63 int tx_in, tx_out;
64 struct sk_buff *tx_skbs[TX_BUFFERS]; 64 struct sk_buff *tx_skbs[TX_BUFFERS];
65}port_t; 65};
66 66
67 67
68typedef struct { 68struct card_status {
69 desc_t rx_descs[RX_QUEUE_LENGTH]; 69 desc_t rx_descs[RX_QUEUE_LENGTH];
70 port_status_t port_status[4]; 70 port_status_t port_status[4];
71}card_status_t; 71};
72 72
73 73
74typedef struct card_t { 74struct card {
75 int n_ports; /* 1, 2 or 4 ports */ 75 int n_ports; /* 1, 2 or 4 ports */
76 u8 irq; 76 u8 irq;
77 77
@@ -79,20 +79,20 @@ typedef struct card_t {
79 struct pci_dev *pdev; /* for pci_name(pdev) */ 79 struct pci_dev *pdev; /* for pci_name(pdev) */
80 int rx_in; 80 int rx_in;
81 struct sk_buff *rx_skbs[RX_QUEUE_LENGTH]; 81 struct sk_buff *rx_skbs[RX_QUEUE_LENGTH];
82 card_status_t *status; /* shared between host and card */ 82 struct card_status *status; /* shared between host and card */
83 dma_addr_t status_address; 83 dma_addr_t status_address;
84 port_t ports[0]; /* 1 - 4 port_t structures follow */ 84 struct port ports[0]; /* 1 - 4 port structures follow */
85}card_t; 85};
86 86
87 87
88 88
89static inline port_t* dev_to_port(struct net_device *dev) 89static inline struct port *dev_to_port(struct net_device *dev)
90{ 90{
91 return (port_t *)dev_to_hdlc(dev)->priv; 91 return (struct port *)dev_to_hdlc(dev)->priv;
92} 92}
93 93
94 94
95static inline port_status_t* get_status(port_t *port) 95static inline port_status_t *get_status(struct port *port)
96{ 96{
97 return &port->card->status->port_status[port->node]; 97 return &port->card->status->port_status[port->node];
98} 98}
@@ -115,7 +115,7 @@ static inline dma_addr_t pci_map_single_debug(struct pci_dev *pdev, void *ptr,
115 115
116 116
117/* Cable and/or personality module change interrupt service */ 117/* Cable and/or personality module change interrupt service */
118static inline void wanxl_cable_intr(port_t *port) 118static inline void wanxl_cable_intr(struct port *port)
119{ 119{
120 u32 value = get_status(port)->cable; 120 u32 value = get_status(port)->cable;
121 int valid = 1; 121 int valid = 1;
@@ -160,7 +160,7 @@ static inline void wanxl_cable_intr(port_t *port)
160 160
161 161
162/* Transmit complete interrupt service */ 162/* Transmit complete interrupt service */
163static inline void wanxl_tx_intr(port_t *port) 163static inline void wanxl_tx_intr(struct port *port)
164{ 164{
165 struct net_device *dev = port->dev; 165 struct net_device *dev = port->dev;
166 while (1) { 166 while (1) {
@@ -193,7 +193,7 @@ static inline void wanxl_tx_intr(port_t *port)
193 193
194 194
195/* Receive complete interrupt service */ 195/* Receive complete interrupt service */
196static inline void wanxl_rx_intr(card_t *card) 196static inline void wanxl_rx_intr(struct card *card)
197{ 197{
198 desc_t *desc; 198 desc_t *desc;
199 while (desc = &card->status->rx_descs[card->rx_in], 199 while (desc = &card->status->rx_descs[card->rx_in],
@@ -203,7 +203,7 @@ static inline void wanxl_rx_intr(card_t *card)
203 pci_name(card->pdev)); 203 pci_name(card->pdev));
204 else { 204 else {
205 struct sk_buff *skb = card->rx_skbs[card->rx_in]; 205 struct sk_buff *skb = card->rx_skbs[card->rx_in];
206 port_t *port = &card->ports[desc->stat & 206 struct port *port = &card->ports[desc->stat &
207 PACKET_PORT_MASK]; 207 PACKET_PORT_MASK];
208 struct net_device *dev = port->dev; 208 struct net_device *dev = port->dev;
209 209
@@ -245,7 +245,7 @@ static inline void wanxl_rx_intr(card_t *card)
245 245
246static irqreturn_t wanxl_intr(int irq, void* dev_id) 246static irqreturn_t wanxl_intr(int irq, void* dev_id)
247{ 247{
248 card_t *card = dev_id; 248 struct card *card = dev_id;
249 int i; 249 int i;
250 u32 stat; 250 u32 stat;
251 int handled = 0; 251 int handled = 0;
@@ -272,7 +272,7 @@ static irqreturn_t wanxl_intr(int irq, void* dev_id)
272 272
273static netdev_tx_t wanxl_xmit(struct sk_buff *skb, struct net_device *dev) 273static netdev_tx_t wanxl_xmit(struct sk_buff *skb, struct net_device *dev)
274{ 274{
275 port_t *port = dev_to_port(dev); 275 struct port *port = dev_to_port(dev);
276 desc_t *desc; 276 desc_t *desc;
277 277
278 spin_lock(&port->lock); 278 spin_lock(&port->lock);
@@ -319,7 +319,7 @@ static netdev_tx_t wanxl_xmit(struct sk_buff *skb, struct net_device *dev)
319static int wanxl_attach(struct net_device *dev, unsigned short encoding, 319static int wanxl_attach(struct net_device *dev, unsigned short encoding,
320 unsigned short parity) 320 unsigned short parity)
321{ 321{
322 port_t *port = dev_to_port(dev); 322 struct port *port = dev_to_port(dev);
323 323
324 if (encoding != ENCODING_NRZ && 324 if (encoding != ENCODING_NRZ &&
325 encoding != ENCODING_NRZI) 325 encoding != ENCODING_NRZI)
@@ -343,7 +343,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
343{ 343{
344 const size_t size = sizeof(sync_serial_settings); 344 const size_t size = sizeof(sync_serial_settings);
345 sync_serial_settings line; 345 sync_serial_settings line;
346 port_t *port = dev_to_port(dev); 346 struct port *port = dev_to_port(dev);
347 347
348 if (cmd != SIOCWANDEV) 348 if (cmd != SIOCWANDEV)
349 return hdlc_ioctl(dev, ifr, cmd); 349 return hdlc_ioctl(dev, ifr, cmd);
@@ -393,7 +393,7 @@ static int wanxl_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
393 393
394static int wanxl_open(struct net_device *dev) 394static int wanxl_open(struct net_device *dev)
395{ 395{
396 port_t *port = dev_to_port(dev); 396 struct port *port = dev_to_port(dev);
397 u8 __iomem *dbr = port->card->plx + PLX_DOORBELL_TO_CARD; 397 u8 __iomem *dbr = port->card->plx + PLX_DOORBELL_TO_CARD;
398 unsigned long timeout; 398 unsigned long timeout;
399 int i; 399 int i;
@@ -429,7 +429,7 @@ static int wanxl_open(struct net_device *dev)
429 429
430static int wanxl_close(struct net_device *dev) 430static int wanxl_close(struct net_device *dev)
431{ 431{
432 port_t *port = dev_to_port(dev); 432 struct port *port = dev_to_port(dev);
433 unsigned long timeout; 433 unsigned long timeout;
434 int i; 434 int i;
435 435
@@ -467,7 +467,7 @@ static int wanxl_close(struct net_device *dev)
467 467
468static struct net_device_stats *wanxl_get_stats(struct net_device *dev) 468static struct net_device_stats *wanxl_get_stats(struct net_device *dev)
469{ 469{
470 port_t *port = dev_to_port(dev); 470 struct port *port = dev_to_port(dev);
471 471
472 dev->stats.rx_over_errors = get_status(port)->rx_overruns; 472 dev->stats.rx_over_errors = get_status(port)->rx_overruns;
473 dev->stats.rx_frame_errors = get_status(port)->rx_frame_errors; 473 dev->stats.rx_frame_errors = get_status(port)->rx_frame_errors;
@@ -478,7 +478,7 @@ static struct net_device_stats *wanxl_get_stats(struct net_device *dev)
478 478
479 479
480 480
481static int wanxl_puts_command(card_t *card, u32 cmd) 481static int wanxl_puts_command(struct card *card, u32 cmd)
482{ 482{
483 unsigned long timeout = jiffies + 5 * HZ; 483 unsigned long timeout = jiffies + 5 * HZ;
484 484
@@ -495,7 +495,7 @@ static int wanxl_puts_command(card_t *card, u32 cmd)
495 495
496 496
497 497
498static void wanxl_reset(card_t *card) 498static void wanxl_reset(struct card *card)
499{ 499{
500 u32 old_value = readl(card->plx + PLX_CONTROL) & ~PLX_CTL_RESET; 500 u32 old_value = readl(card->plx + PLX_CONTROL) & ~PLX_CTL_RESET;
501 501
@@ -511,7 +511,7 @@ static void wanxl_reset(card_t *card)
511 511
512static void wanxl_pci_remove_one(struct pci_dev *pdev) 512static void wanxl_pci_remove_one(struct pci_dev *pdev)
513{ 513{
514 card_t *card = pci_get_drvdata(pdev); 514 struct card *card = pci_get_drvdata(pdev);
515 int i; 515 int i;
516 516
517 for (i = 0; i < card->n_ports; i++) { 517 for (i = 0; i < card->n_ports; i++) {
@@ -537,7 +537,7 @@ static void wanxl_pci_remove_one(struct pci_dev *pdev)
537 iounmap(card->plx); 537 iounmap(card->plx);
538 538
539 if (card->status) 539 if (card->status)
540 pci_free_consistent(pdev, sizeof(card_status_t), 540 pci_free_consistent(pdev, sizeof(struct card_status),
541 card->status, card->status_address); 541 card->status, card->status_address);
542 542
543 pci_release_regions(pdev); 543 pci_release_regions(pdev);
@@ -560,7 +560,7 @@ static const struct net_device_ops wanxl_ops = {
560static int wanxl_pci_init_one(struct pci_dev *pdev, 560static int wanxl_pci_init_one(struct pci_dev *pdev,
561 const struct pci_device_id *ent) 561 const struct pci_device_id *ent)
562{ 562{
563 card_t *card; 563 struct card *card;
564 u32 ramsize, stat; 564 u32 ramsize, stat;
565 unsigned long timeout; 565 unsigned long timeout;
566 u32 plx_phy; /* PLX PCI base address */ 566 u32 plx_phy; /* PLX PCI base address */
@@ -601,7 +601,7 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
601 default: ports = 4; 601 default: ports = 4;
602 } 602 }
603 603
604 alloc_size = sizeof(card_t) + ports * sizeof(port_t); 604 alloc_size = sizeof(struct card) + ports * sizeof(struct port);
605 card = kzalloc(alloc_size, GFP_KERNEL); 605 card = kzalloc(alloc_size, GFP_KERNEL);
606 if (card == NULL) { 606 if (card == NULL) {
607 pci_release_regions(pdev); 607 pci_release_regions(pdev);
@@ -612,7 +612,8 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
612 pci_set_drvdata(pdev, card); 612 pci_set_drvdata(pdev, card);
613 card->pdev = pdev; 613 card->pdev = pdev;
614 614
615 card->status = pci_alloc_consistent(pdev, sizeof(card_status_t), 615 card->status = pci_alloc_consistent(pdev,
616 sizeof(struct card_status),
616 &card->status_address); 617 &card->status_address);
617 if (card->status == NULL) { 618 if (card->status == NULL) {
618 wanxl_pci_remove_one(pdev); 619 wanxl_pci_remove_one(pdev);
@@ -766,7 +767,7 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
766 767
767 for (i = 0; i < ports; i++) { 768 for (i = 0; i < ports; i++) {
768 hdlc_device *hdlc; 769 hdlc_device *hdlc;
769 port_t *port = &card->ports[i]; 770 struct port *port = &card->ports[i];
770 struct net_device *dev = alloc_hdlcdev(port); 771 struct net_device *dev = alloc_hdlcdev(port);
771 if (!dev) { 772 if (!dev) {
772 pr_err("%s: unable to allocate memory\n", 773 pr_err("%s: unable to allocate memory\n",
@@ -807,7 +808,7 @@ static int wanxl_pci_init_one(struct pci_dev *pdev,
807 return 0; 808 return 0;
808} 809}
809 810
810static DEFINE_PCI_DEVICE_TABLE(wanxl_pci_tbl) = { 811static const struct pci_device_id wanxl_pci_tbl[] = {
811 { PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_SBE_WANXL100, PCI_ANY_ID, 812 { PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_SBE_WANXL100, PCI_ANY_ID,
812 PCI_ANY_ID, 0, 0, 0 }, 813 PCI_ANY_ID, 0, 0, 0 },
813 { PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_SBE_WANXL200, PCI_ANY_ID, 814 { PCI_VENDOR_ID_SBE, PCI_DEVICE_ID_SBE_WANXL200, PCI_ANY_ID,
diff --git a/drivers/net/wireless/Kconfig b/drivers/net/wireless/Kconfig
index b2137e8f7ca6..16604bdf5197 100644
--- a/drivers/net/wireless/Kconfig
+++ b/drivers/net/wireless/Kconfig
@@ -189,6 +189,7 @@ config USB_NET_RNDIS_WLAN
189 tristate "Wireless RNDIS USB support" 189 tristate "Wireless RNDIS USB support"
190 depends on USB 190 depends on USB
191 depends on CFG80211 191 depends on CFG80211
192 select USB_NET_DRIVERS
192 select USB_USBNET 193 select USB_USBNET
193 select USB_NET_CDCETHER 194 select USB_NET_CDCETHER
194 select USB_NET_RNDIS_HOST 195 select USB_NET_RNDIS_HOST
diff --git a/drivers/net/wireless/adm8211.c b/drivers/net/wireless/adm8211.c
index f35f93c31b09..17fcaabb2687 100644
--- a/drivers/net/wireless/adm8211.c
+++ b/drivers/net/wireless/adm8211.c
@@ -41,7 +41,7 @@ static unsigned int rx_ring_size __read_mostly = 16;
41module_param(tx_ring_size, uint, 0); 41module_param(tx_ring_size, uint, 0);
42module_param(rx_ring_size, uint, 0); 42module_param(rx_ring_size, uint, 0);
43 43
44static DEFINE_PCI_DEVICE_TABLE(adm8211_pci_id_table) = { 44static const struct pci_device_id adm8211_pci_id_table[] = {
45 /* ADMtek ADM8211 */ 45 /* ADMtek ADM8211 */
46 { PCI_DEVICE(0x10B7, 0x6000) }, /* 3Com 3CRSHPW796 */ 46 { PCI_DEVICE(0x10B7, 0x6000) }, /* 3Com 3CRSHPW796 */
47 { PCI_DEVICE(0x1200, 0x8201) }, /* ? */ 47 { PCI_DEVICE(0x1200, 0x8201) }, /* ? */
diff --git a/drivers/net/wireless/airo.c b/drivers/net/wireless/airo.c
index b39807579a8a..e71a2ce7a448 100644
--- a/drivers/net/wireless/airo.c
+++ b/drivers/net/wireless/airo.c
@@ -57,7 +57,7 @@
57#define DRV_NAME "airo" 57#define DRV_NAME "airo"
58 58
59#ifdef CONFIG_PCI 59#ifdef CONFIG_PCI
60static DEFINE_PCI_DEVICE_TABLE(card_ids) = { 60static const struct pci_device_id card_ids[] = {
61 { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, }, 61 { 0x14b9, 1, PCI_ANY_ID, PCI_ANY_ID, },
62 { 0x14b9, 0x4500, PCI_ANY_ID, PCI_ANY_ID }, 62 { 0x14b9, 0x4500, PCI_ANY_ID, PCI_ANY_ID },
63 { 0x14b9, 0x4800, PCI_ANY_ID, PCI_ANY_ID, }, 63 { 0x14b9, 0x4800, PCI_ANY_ID, PCI_ANY_ID, },
diff --git a/drivers/net/wireless/airo_cs.c b/drivers/net/wireless/airo_cs.c
index 7e9ede6c5798..d9ed22b4cc6b 100644
--- a/drivers/net/wireless/airo_cs.c
+++ b/drivers/net/wireless/airo_cs.c
@@ -56,18 +56,18 @@ static void airo_release(struct pcmcia_device *link);
56 56
57static void airo_detach(struct pcmcia_device *p_dev); 57static void airo_detach(struct pcmcia_device *p_dev);
58 58
59typedef struct local_info_t { 59struct local_info {
60 struct net_device *eth_dev; 60 struct net_device *eth_dev;
61} local_info_t; 61};
62 62
63static int airo_probe(struct pcmcia_device *p_dev) 63static int airo_probe(struct pcmcia_device *p_dev)
64{ 64{
65 local_info_t *local; 65 struct local_info *local;
66 66
67 dev_dbg(&p_dev->dev, "airo_attach()\n"); 67 dev_dbg(&p_dev->dev, "airo_attach()\n");
68 68
69 /* Allocate space for private device-specific data */ 69 /* Allocate space for private device-specific data */
70 local = kzalloc(sizeof(local_info_t), GFP_KERNEL); 70 local = kzalloc(sizeof(*local), GFP_KERNEL);
71 if (!local) 71 if (!local)
72 return -ENOMEM; 72 return -ENOMEM;
73 73
@@ -82,10 +82,11 @@ static void airo_detach(struct pcmcia_device *link)
82 82
83 airo_release(link); 83 airo_release(link);
84 84
85 if (((local_info_t *)link->priv)->eth_dev) { 85 if (((struct local_info *)link->priv)->eth_dev) {
86 stop_airo_card(((local_info_t *)link->priv)->eth_dev, 0); 86 stop_airo_card(((struct local_info *)link->priv)->eth_dev,
87 0);
87 } 88 }
88 ((local_info_t *)link->priv)->eth_dev = NULL; 89 ((struct local_info *)link->priv)->eth_dev = NULL;
89 90
90 kfree(link->priv); 91 kfree(link->priv);
91} /* airo_detach */ 92} /* airo_detach */
@@ -101,7 +102,7 @@ static int airo_cs_config_check(struct pcmcia_device *p_dev, void *priv_data)
101 102
102static int airo_config(struct pcmcia_device *link) 103static int airo_config(struct pcmcia_device *link)
103{ 104{
104 local_info_t *dev; 105 struct local_info *dev;
105 int ret; 106 int ret;
106 107
107 dev = link->priv; 108 dev = link->priv;
@@ -121,10 +122,10 @@ static int airo_config(struct pcmcia_device *link)
121 ret = pcmcia_enable_device(link); 122 ret = pcmcia_enable_device(link);
122 if (ret) 123 if (ret)
123 goto failed; 124 goto failed;
124 ((local_info_t *)link->priv)->eth_dev = 125 ((struct local_info *)link->priv)->eth_dev =
125 init_airo_card(link->irq, 126 init_airo_card(link->irq,
126 link->resource[0]->start, 1, &link->dev); 127 link->resource[0]->start, 1, &link->dev);
127 if (!((local_info_t *)link->priv)->eth_dev) 128 if (!((struct local_info *)link->priv)->eth_dev)
128 goto failed; 129 goto failed;
129 130
130 return 0; 131 return 0;
@@ -142,7 +143,7 @@ static void airo_release(struct pcmcia_device *link)
142 143
143static int airo_suspend(struct pcmcia_device *link) 144static int airo_suspend(struct pcmcia_device *link)
144{ 145{
145 local_info_t *local = link->priv; 146 struct local_info *local = link->priv;
146 147
147 netif_device_detach(local->eth_dev); 148 netif_device_detach(local->eth_dev);
148 149
@@ -151,7 +152,7 @@ static int airo_suspend(struct pcmcia_device *link)
151 152
152static int airo_resume(struct pcmcia_device *link) 153static int airo_resume(struct pcmcia_device *link)
153{ 154{
154 local_info_t *local = link->priv; 155 struct local_info *local = link->priv;
155 156
156 if (link->open) { 157 if (link->open) {
157 reset_airo_card(local->eth_dev); 158 reset_airo_card(local->eth_dev);
diff --git a/drivers/net/wireless/ath/ath10k/pci.c b/drivers/net/wireless/ath/ath10k/pci.c
index 0ffff205478d..3376963a4862 100644
--- a/drivers/net/wireless/ath/ath10k/pci.c
+++ b/drivers/net/wireless/ath/ath10k/pci.c
@@ -63,7 +63,7 @@ MODULE_PARM_DESC(reset_mode, "0: auto, 1: warm only (default: 0)");
63 63
64#define QCA988X_2_0_DEVICE_ID (0x003c) 64#define QCA988X_2_0_DEVICE_ID (0x003c)
65 65
66static DEFINE_PCI_DEVICE_TABLE(ath10k_pci_id_table) = { 66static const struct pci_device_id ath10k_pci_id_table[] = {
67 { PCI_VDEVICE(ATHEROS, QCA988X_2_0_DEVICE_ID) }, /* PCI-E QCA988X V2 */ 67 { PCI_VDEVICE(ATHEROS, QCA988X_2_0_DEVICE_ID) }, /* PCI-E QCA988X V2 */
68 {0} 68 {0}
69}; 69};
diff --git a/drivers/net/wireless/ath/ath5k/led.c b/drivers/net/wireless/ath/ath5k/led.c
index f77ef36acf87..48a6a69b57bc 100644
--- a/drivers/net/wireless/ath/ath5k/led.c
+++ b/drivers/net/wireless/ath/ath5k/led.c
@@ -53,7 +53,7 @@
53#define ATH_POLARITY(data) ((data) & 0xff) 53#define ATH_POLARITY(data) ((data) & 0xff)
54 54
55/* Devices we match on for LED config info (typically laptops) */ 55/* Devices we match on for LED config info (typically laptops) */
56static DEFINE_PCI_DEVICE_TABLE(ath5k_led_devices) = { 56static const struct pci_device_id ath5k_led_devices[] = {
57 /* AR5211 */ 57 /* AR5211 */
58 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5211), ATH_LED(0, 0) }, 58 { PCI_VDEVICE(ATHEROS, PCI_DEVICE_ID_ATHEROS_AR5211), ATH_LED(0, 0) },
59 /* HP Compaq nc6xx, nc4000, nx6000 */ 59 /* HP Compaq nc6xx, nc4000, nx6000 */
diff --git a/drivers/net/wireless/ath/ath5k/pci.c b/drivers/net/wireless/ath/ath5k/pci.c
index 859db7c34f87..c6156cc38940 100644
--- a/drivers/net/wireless/ath/ath5k/pci.c
+++ b/drivers/net/wireless/ath/ath5k/pci.c
@@ -28,7 +28,7 @@
28#include "reg.h" 28#include "reg.h"
29 29
30/* Known PCI ids */ 30/* Known PCI ids */
31static DEFINE_PCI_DEVICE_TABLE(ath5k_pci_id_table) = { 31static const struct pci_device_id ath5k_pci_id_table[] = {
32 { PCI_VDEVICE(ATHEROS, 0x0207) }, /* 5210 early */ 32 { PCI_VDEVICE(ATHEROS, 0x0207) }, /* 5210 early */
33 { PCI_VDEVICE(ATHEROS, 0x0007) }, /* 5210 */ 33 { PCI_VDEVICE(ATHEROS, 0x0007) }, /* 5210 */
34 { PCI_VDEVICE(ATHEROS, 0x0011) }, /* 5311 - this is on AHB bus !*/ 34 { PCI_VDEVICE(ATHEROS, 0x0011) }, /* 5311 - this is on AHB bus !*/
diff --git a/drivers/net/wireless/ath/ath9k/pci.c b/drivers/net/wireless/ath/ath9k/pci.c
index 7a2b2c5caced..c018dea0b2e8 100644
--- a/drivers/net/wireless/ath/ath9k/pci.c
+++ b/drivers/net/wireless/ath/ath9k/pci.c
@@ -23,7 +23,7 @@
23#include <linux/module.h> 23#include <linux/module.h>
24#include "ath9k.h" 24#include "ath9k.h"
25 25
26static DEFINE_PCI_DEVICE_TABLE(ath_pci_id_table) = { 26static const struct pci_device_id ath_pci_id_table[] = {
27 { PCI_VDEVICE(ATHEROS, 0x0023) }, /* PCI */ 27 { PCI_VDEVICE(ATHEROS, 0x0023) }, /* PCI */
28 { PCI_VDEVICE(ATHEROS, 0x0024) }, /* PCI-E */ 28 { PCI_VDEVICE(ATHEROS, 0x0024) }, /* PCI-E */
29 { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */ 29 { PCI_VDEVICE(ATHEROS, 0x0027) }, /* PCI */
diff --git a/drivers/net/wireless/ath/carl9170/carl9170.h b/drivers/net/wireless/ath/carl9170/carl9170.h
index 8596aba34f96..237d0cda1bcb 100644
--- a/drivers/net/wireless/ath/carl9170/carl9170.h
+++ b/drivers/net/wireless/ath/carl9170/carl9170.h
@@ -256,6 +256,7 @@ struct ar9170 {
256 atomic_t rx_work_urbs; 256 atomic_t rx_work_urbs;
257 atomic_t rx_pool_urbs; 257 atomic_t rx_pool_urbs;
258 kernel_ulong_t features; 258 kernel_ulong_t features;
259 bool usb_ep_cmd_is_bulk;
259 260
260 /* firmware settings */ 261 /* firmware settings */
261 struct completion fw_load_wait; 262 struct completion fw_load_wait;
diff --git a/drivers/net/wireless/ath/carl9170/usb.c b/drivers/net/wireless/ath/carl9170/usb.c
index f35c7f30f9a6..c9f93310c0d6 100644
--- a/drivers/net/wireless/ath/carl9170/usb.c
+++ b/drivers/net/wireless/ath/carl9170/usb.c
@@ -621,9 +621,16 @@ int __carl9170_exec_cmd(struct ar9170 *ar, struct carl9170_cmd *cmd,
621 goto err_free; 621 goto err_free;
622 } 622 }
623 623
624 usb_fill_int_urb(urb, ar->udev, usb_sndintpipe(ar->udev, 624 if (ar->usb_ep_cmd_is_bulk)
625 AR9170_USB_EP_CMD), cmd, cmd->hdr.len + 4, 625 usb_fill_bulk_urb(urb, ar->udev,
626 carl9170_usb_cmd_complete, ar, 1); 626 usb_sndbulkpipe(ar->udev, AR9170_USB_EP_CMD),
627 cmd, cmd->hdr.len + 4,
628 carl9170_usb_cmd_complete, ar);
629 else
630 usb_fill_int_urb(urb, ar->udev,
631 usb_sndintpipe(ar->udev, AR9170_USB_EP_CMD),
632 cmd, cmd->hdr.len + 4,
633 carl9170_usb_cmd_complete, ar, 1);
627 634
628 if (free_buf) 635 if (free_buf)
629 urb->transfer_flags |= URB_FREE_BUFFER; 636 urb->transfer_flags |= URB_FREE_BUFFER;
@@ -1032,9 +1039,10 @@ static void carl9170_usb_firmware_step2(const struct firmware *fw,
1032static int carl9170_usb_probe(struct usb_interface *intf, 1039static int carl9170_usb_probe(struct usb_interface *intf,
1033 const struct usb_device_id *id) 1040 const struct usb_device_id *id)
1034{ 1041{
1042 struct usb_endpoint_descriptor *ep;
1035 struct ar9170 *ar; 1043 struct ar9170 *ar;
1036 struct usb_device *udev; 1044 struct usb_device *udev;
1037 int err; 1045 int i, err;
1038 1046
1039 err = usb_reset_device(interface_to_usbdev(intf)); 1047 err = usb_reset_device(interface_to_usbdev(intf));
1040 if (err) 1048 if (err)
@@ -1050,6 +1058,21 @@ static int carl9170_usb_probe(struct usb_interface *intf,
1050 ar->intf = intf; 1058 ar->intf = intf;
1051 ar->features = id->driver_info; 1059 ar->features = id->driver_info;
1052 1060
1061 /* We need to remember the type of endpoint 4 because it differs
1062 * between high- and full-speed configuration. The high-speed
1063 * configuration specifies it as interrupt and the full-speed
1064 * configuration as bulk endpoint. This information is required
1065 * later when sending urbs to that endpoint.
1066 */
1067 for (i = 0; i < intf->cur_altsetting->desc.bNumEndpoints; ++i) {
1068 ep = &intf->cur_altsetting->endpoint[i].desc;
1069
1070 if (usb_endpoint_num(ep) == AR9170_USB_EP_CMD &&
1071 usb_endpoint_dir_out(ep) &&
1072 usb_endpoint_type(ep) == USB_ENDPOINT_XFER_BULK)
1073 ar->usb_ep_cmd_is_bulk = true;
1074 }
1075
1053 usb_set_intfdata(intf, ar); 1076 usb_set_intfdata(intf, ar);
1054 SET_IEEE80211_DEV(ar->hw, &intf->dev); 1077 SET_IEEE80211_DEV(ar->hw, &intf->dev);
1055 1078
diff --git a/drivers/net/wireless/atmel.c b/drivers/net/wireless/atmel.c
index 1fe41af81a59..9183f1cf89a7 100644
--- a/drivers/net/wireless/atmel.c
+++ b/drivers/net/wireless/atmel.c
@@ -2598,11 +2598,11 @@ static const iw_handler atmel_private_handler[] =
2598 NULL, /* SIOCIWFIRSTPRIV */ 2598 NULL, /* SIOCIWFIRSTPRIV */
2599}; 2599};
2600 2600
2601typedef struct atmel_priv_ioctl { 2601struct atmel_priv_ioctl {
2602 char id[32]; 2602 char id[32];
2603 unsigned char __user *data; 2603 unsigned char __user *data;
2604 unsigned short len; 2604 unsigned short len;
2605} atmel_priv_ioctl; 2605};
2606 2606
2607#define ATMELFWL SIOCIWFIRSTPRIV 2607#define ATMELFWL SIOCIWFIRSTPRIV
2608#define ATMELIDIFC ATMELFWL + 1 2608#define ATMELIDIFC ATMELFWL + 1
@@ -2615,7 +2615,7 @@ static const struct iw_priv_args atmel_private_args[] = {
2615 .cmd = ATMELFWL, 2615 .cmd = ATMELFWL,
2616 .set_args = IW_PRIV_TYPE_BYTE 2616 .set_args = IW_PRIV_TYPE_BYTE
2617 | IW_PRIV_SIZE_FIXED 2617 | IW_PRIV_SIZE_FIXED
2618 | sizeof (atmel_priv_ioctl), 2618 | sizeof(struct atmel_priv_ioctl),
2619 .get_args = IW_PRIV_TYPE_NONE, 2619 .get_args = IW_PRIV_TYPE_NONE,
2620 .name = "atmelfwl" 2620 .name = "atmelfwl"
2621 }, { 2621 }, {
@@ -2645,7 +2645,7 @@ static int atmel_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
2645{ 2645{
2646 int i, rc = 0; 2646 int i, rc = 0;
2647 struct atmel_private *priv = netdev_priv(dev); 2647 struct atmel_private *priv = netdev_priv(dev);
2648 atmel_priv_ioctl com; 2648 struct atmel_priv_ioctl com;
2649 struct iwreq *wrq = (struct iwreq *) rq; 2649 struct iwreq *wrq = (struct iwreq *) rq;
2650 unsigned char *new_firmware; 2650 unsigned char *new_firmware;
2651 char domain[REGDOMAINSZ + 1]; 2651 char domain[REGDOMAINSZ + 1];
diff --git a/drivers/net/wireless/atmel_pci.c b/drivers/net/wireless/atmel_pci.c
index 5cd97e3cbee3..bcf1f274a251 100644
--- a/drivers/net/wireless/atmel_pci.c
+++ b/drivers/net/wireless/atmel_pci.c
@@ -30,7 +30,7 @@ MODULE_DESCRIPTION("Support for Atmel at76c50x 802.11 wireless ethernet cards.")
30MODULE_LICENSE("GPL"); 30MODULE_LICENSE("GPL");
31MODULE_SUPPORTED_DEVICE("Atmel at76c506 PCI wireless cards"); 31MODULE_SUPPORTED_DEVICE("Atmel at76c506 PCI wireless cards");
32 32
33static DEFINE_PCI_DEVICE_TABLE(card_ids) = { 33static const struct pci_device_id card_ids[] = {
34 { 0x1114, 0x0506, PCI_ANY_ID, PCI_ANY_ID }, 34 { 0x1114, 0x0506, PCI_ANY_ID, PCI_ANY_ID },
35 { 0, } 35 { 0, }
36}; 36};
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
index 535c7eb01b3a..8f8b9373de95 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/msgbuf.c
@@ -1318,6 +1318,8 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr)
1318 msgbuf->nrof_flowrings = if_msgbuf->nrof_flowrings; 1318 msgbuf->nrof_flowrings = if_msgbuf->nrof_flowrings;
1319 msgbuf->flowring_dma_handle = kzalloc(msgbuf->nrof_flowrings * 1319 msgbuf->flowring_dma_handle = kzalloc(msgbuf->nrof_flowrings *
1320 sizeof(*msgbuf->flowring_dma_handle), GFP_ATOMIC); 1320 sizeof(*msgbuf->flowring_dma_handle), GFP_ATOMIC);
1321 if (!msgbuf->flowring_dma_handle)
1322 goto fail;
1321 1323
1322 msgbuf->rx_dataoffset = if_msgbuf->rx_dataoffset; 1324 msgbuf->rx_dataoffset = if_msgbuf->rx_dataoffset;
1323 msgbuf->max_rxbufpost = if_msgbuf->max_rxbufpost; 1325 msgbuf->max_rxbufpost = if_msgbuf->max_rxbufpost;
@@ -1362,6 +1364,7 @@ fail:
1362 kfree(msgbuf->flow_map); 1364 kfree(msgbuf->flow_map);
1363 kfree(msgbuf->txstatus_done_map); 1365 kfree(msgbuf->txstatus_done_map);
1364 brcmf_msgbuf_release_pktids(msgbuf); 1366 brcmf_msgbuf_release_pktids(msgbuf);
1367 kfree(msgbuf->flowring_dma_handle);
1365 if (msgbuf->ioctbuf) 1368 if (msgbuf->ioctbuf)
1366 dma_free_coherent(drvr->bus_if->dev, 1369 dma_free_coherent(drvr->bus_if->dev,
1367 BRCMF_TX_IOCTL_MAX_MSG_SIZE, 1370 BRCMF_TX_IOCTL_MAX_MSG_SIZE,
@@ -1391,6 +1394,7 @@ void brcmf_proto_msgbuf_detach(struct brcmf_pub *drvr)
1391 BRCMF_TX_IOCTL_MAX_MSG_SIZE, 1394 BRCMF_TX_IOCTL_MAX_MSG_SIZE,
1392 msgbuf->ioctbuf, msgbuf->ioctbuf_handle); 1395 msgbuf->ioctbuf, msgbuf->ioctbuf_handle);
1393 brcmf_msgbuf_release_pktids(msgbuf); 1396 brcmf_msgbuf_release_pktids(msgbuf);
1397 kfree(msgbuf->flowring_dma_handle);
1394 kfree(msgbuf); 1398 kfree(msgbuf);
1395 drvr->proto->pd = NULL; 1399 drvr->proto->pd = NULL;
1396 } 1400 }
diff --git a/drivers/net/wireless/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
index bc972c0ba5f8..e5101b287e4e 100644
--- a/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
+++ b/drivers/net/wireless/brcm80211/brcmfmac/pcie.c
@@ -591,12 +591,13 @@ static void brcmf_pcie_handle_mb_data(struct brcmf_pciedev_info *devinfo)
591 } 591 }
592 if (dtoh_mb_data & BRCMF_D2H_DEV_DS_EXIT_NOTE) 592 if (dtoh_mb_data & BRCMF_D2H_DEV_DS_EXIT_NOTE)
593 brcmf_dbg(PCIE, "D2H_MB_DATA: DEEP SLEEP EXIT\n"); 593 brcmf_dbg(PCIE, "D2H_MB_DATA: DEEP SLEEP EXIT\n");
594 if (dtoh_mb_data & BRCMF_D2H_DEV_D3_ACK) 594 if (dtoh_mb_data & BRCMF_D2H_DEV_D3_ACK) {
595 brcmf_dbg(PCIE, "D2H_MB_DATA: D3 ACK\n"); 595 brcmf_dbg(PCIE, "D2H_MB_DATA: D3 ACK\n");
596 if (waitqueue_active(&devinfo->mbdata_resp_wait)) { 596 if (waitqueue_active(&devinfo->mbdata_resp_wait)) {
597 devinfo->mbdata_completed = true; 597 devinfo->mbdata_completed = true;
598 wake_up(&devinfo->mbdata_resp_wait); 598 wake_up(&devinfo->mbdata_resp_wait);
599 } 599 }
600 }
600} 601}
601 602
602 603
diff --git a/drivers/net/wireless/hostap/hostap_pci.c b/drivers/net/wireless/hostap/hostap_pci.c
index 91158e2e961c..c864ef4b0015 100644
--- a/drivers/net/wireless/hostap/hostap_pci.c
+++ b/drivers/net/wireless/hostap/hostap_pci.c
@@ -39,7 +39,7 @@ struct hostap_pci_priv {
39/* FIX: do we need mb/wmb/rmb with memory operations? */ 39/* FIX: do we need mb/wmb/rmb with memory operations? */
40 40
41 41
42static DEFINE_PCI_DEVICE_TABLE(prism2_pci_id_table) = { 42static const struct pci_device_id prism2_pci_id_table[] = {
43 /* Intersil Prism3 ISL3872 11Mb/s WLAN Controller */ 43 /* Intersil Prism3 ISL3872 11Mb/s WLAN Controller */
44 { 0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID }, 44 { 0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID },
45 /* Intersil Prism2.5 ISL3874 11Mb/s WLAN Controller */ 45 /* Intersil Prism2.5 ISL3874 11Mb/s WLAN Controller */
diff --git a/drivers/net/wireless/hostap/hostap_plx.c b/drivers/net/wireless/hostap/hostap_plx.c
index 3bf530d9a40f..4901a99c6c59 100644
--- a/drivers/net/wireless/hostap/hostap_plx.c
+++ b/drivers/net/wireless/hostap/hostap_plx.c
@@ -60,7 +60,7 @@ struct hostap_plx_priv {
60 60
61#define PLXDEV(vendor,dev,str) { vendor, dev, PCI_ANY_ID, PCI_ANY_ID } 61#define PLXDEV(vendor,dev,str) { vendor, dev, PCI_ANY_ID, PCI_ANY_ID }
62 62
63static DEFINE_PCI_DEVICE_TABLE(prism2_plx_id_table) = { 63static const struct pci_device_id prism2_plx_id_table[] = {
64 PLXDEV(0x10b7, 0x7770, "3Com AirConnect PCI 777A"), 64 PLXDEV(0x10b7, 0x7770, "3Com AirConnect PCI 777A"),
65 PLXDEV(0x111a, 0x1023, "Siemens SpeedStream SS1023"), 65 PLXDEV(0x111a, 0x1023, "Siemens SpeedStream SS1023"),
66 PLXDEV(0x126c, 0x8030, "Nortel emobility"), 66 PLXDEV(0x126c, 0x8030, "Nortel emobility"),
diff --git a/drivers/net/wireless/ipw2x00/ipw2100.c b/drivers/net/wireless/ipw2x00/ipw2100.c
index dfc6dfc56d52..c3d726f334e3 100644
--- a/drivers/net/wireless/ipw2x00/ipw2100.c
+++ b/drivers/net/wireless/ipw2x00/ipw2100.c
@@ -3449,8 +3449,9 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
3449 return -ENOMEM; 3449 return -ENOMEM;
3450 3450
3451 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) { 3451 for (i = 0; i < IPW_COMMAND_POOL_SIZE; i++) {
3452 v = pci_alloc_consistent(priv->pci_dev, 3452 v = pci_zalloc_consistent(priv->pci_dev,
3453 sizeof(struct ipw2100_cmd_header), &p); 3453 sizeof(struct ipw2100_cmd_header),
3454 &p);
3454 if (!v) { 3455 if (!v) {
3455 printk(KERN_ERR DRV_NAME ": " 3456 printk(KERN_ERR DRV_NAME ": "
3456 "%s: PCI alloc failed for msg " 3457 "%s: PCI alloc failed for msg "
@@ -3459,8 +3460,6 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv)
3459 break; 3460 break;
3460 } 3461 }
3461 3462
3462 memset(v, 0, sizeof(struct ipw2100_cmd_header));
3463
3464 priv->msg_buffers[i].type = COMMAND; 3463 priv->msg_buffers[i].type = COMMAND;
3465 priv->msg_buffers[i].info.c_struct.cmd = 3464 priv->msg_buffers[i].info.c_struct.cmd =
3466 (struct ipw2100_cmd_header *)v; 3465 (struct ipw2100_cmd_header *)v;
@@ -4336,16 +4335,12 @@ static int status_queue_allocate(struct ipw2100_priv *priv, int entries)
4336 IPW_DEBUG_INFO("enter\n"); 4335 IPW_DEBUG_INFO("enter\n");
4337 4336
4338 q->size = entries * sizeof(struct ipw2100_status); 4337 q->size = entries * sizeof(struct ipw2100_status);
4339 q->drv = 4338 q->drv = pci_zalloc_consistent(priv->pci_dev, q->size, &q->nic);
4340 (struct ipw2100_status *)pci_alloc_consistent(priv->pci_dev,
4341 q->size, &q->nic);
4342 if (!q->drv) { 4339 if (!q->drv) {
4343 IPW_DEBUG_WARNING("Can not allocate status queue.\n"); 4340 IPW_DEBUG_WARNING("Can not allocate status queue.\n");
4344 return -ENOMEM; 4341 return -ENOMEM;
4345 } 4342 }
4346 4343
4347 memset(q->drv, 0, q->size);
4348
4349 IPW_DEBUG_INFO("exit\n"); 4344 IPW_DEBUG_INFO("exit\n");
4350 4345
4351 return 0; 4346 return 0;
@@ -4374,13 +4369,12 @@ static int bd_queue_allocate(struct ipw2100_priv *priv,
4374 4369
4375 q->entries = entries; 4370 q->entries = entries;
4376 q->size = entries * sizeof(struct ipw2100_bd); 4371 q->size = entries * sizeof(struct ipw2100_bd);
4377 q->drv = pci_alloc_consistent(priv->pci_dev, q->size, &q->nic); 4372 q->drv = pci_zalloc_consistent(priv->pci_dev, q->size, &q->nic);
4378 if (!q->drv) { 4373 if (!q->drv) {
4379 IPW_DEBUG_INFO 4374 IPW_DEBUG_INFO
4380 ("can't allocate shared memory for buffer descriptors\n"); 4375 ("can't allocate shared memory for buffer descriptors\n");
4381 return -ENOMEM; 4376 return -ENOMEM;
4382 } 4377 }
4383 memset(q->drv, 0, q->size);
4384 4378
4385 IPW_DEBUG_INFO("exit\n"); 4379 IPW_DEBUG_INFO("exit\n");
4386 4380
@@ -6511,7 +6505,7 @@ static void ipw2100_shutdown(struct pci_dev *pci_dev)
6511 6505
6512#define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x } 6506#define IPW2100_DEV_ID(x) { PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, x }
6513 6507
6514static DEFINE_PCI_DEVICE_TABLE(ipw2100_pci_id_table) = { 6508static const struct pci_device_id ipw2100_pci_id_table[] = {
6515 IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */ 6509 IPW2100_DEV_ID(0x2520), /* IN 2100A mPCI 3A */
6516 IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */ 6510 IPW2100_DEV_ID(0x2521), /* IN 2100A mPCI 3B */
6517 IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */ 6511 IPW2100_DEV_ID(0x2524), /* IN 2100A mPCI 3B */
diff --git a/drivers/net/wireless/ipw2x00/ipw2200.c b/drivers/net/wireless/ipw2x00/ipw2200.c
index c5aa404069f3..a42f9c335090 100644
--- a/drivers/net/wireless/ipw2x00/ipw2200.c
+++ b/drivers/net/wireless/ipw2x00/ipw2200.c
@@ -9853,6 +9853,7 @@ static int ipw_wx_get_wireless_mode(struct net_device *dev,
9853 strncpy(extra, "unknown", MAX_WX_STRING); 9853 strncpy(extra, "unknown", MAX_WX_STRING);
9854 break; 9854 break;
9855 } 9855 }
9856 extra[MAX_WX_STRING - 1] = '\0';
9856 9857
9857 IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra); 9858 IPW_DEBUG_WX("PRIV GET MODE: %s\n", extra);
9858 9859
@@ -11542,7 +11543,7 @@ out:
11542} 11543}
11543 11544
11544/* PCI driver stuff */ 11545/* PCI driver stuff */
11545static DEFINE_PCI_DEVICE_TABLE(card_ids) = { 11546static const struct pci_device_id card_ids[] = {
11546 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2701, 0, 0, 0}, 11547 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2701, 0, 0, 0},
11547 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2702, 0, 0, 0}, 11548 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2702, 0, 0, 0},
11548 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2711, 0, 0, 0}, 11549 {PCI_VENDOR_ID_INTEL, 0x1043, 0x8086, 0x2711, 0, 0, 0},
diff --git a/drivers/net/wireless/iwlegacy/3945.c b/drivers/net/wireless/iwlegacy/3945.c
index b598e2803500..93bdf684babe 100644
--- a/drivers/net/wireless/iwlegacy/3945.c
+++ b/drivers/net/wireless/iwlegacy/3945.c
@@ -2728,7 +2728,7 @@ static struct il_cfg il3945_abg_cfg = {
2728 }, 2728 },
2729}; 2729};
2730 2730
2731DEFINE_PCI_DEVICE_TABLE(il3945_hw_card_ids) = { 2731const struct pci_device_id il3945_hw_card_ids[] = {
2732 {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)}, 2732 {IL_PCI_DEVICE(0x4222, 0x1005, il3945_bg_cfg)},
2733 {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)}, 2733 {IL_PCI_DEVICE(0x4222, 0x1034, il3945_bg_cfg)},
2734 {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)}, 2734 {IL_PCI_DEVICE(0x4222, 0x1044, il3945_bg_cfg)},
diff --git a/drivers/net/wireless/iwlegacy/4965-mac.c b/drivers/net/wireless/iwlegacy/4965-mac.c
index c159c05db6ef..3dcbe2cd2b28 100644
--- a/drivers/net/wireless/iwlegacy/4965-mac.c
+++ b/drivers/net/wireless/iwlegacy/4965-mac.c
@@ -6800,7 +6800,7 @@ il4965_txq_set_sched(struct il_priv *il, u32 mask)
6800 *****************************************************************************/ 6800 *****************************************************************************/
6801 6801
6802/* Hardware specific file defines the PCI IDs table for that hardware module */ 6802/* Hardware specific file defines the PCI IDs table for that hardware module */
6803static DEFINE_PCI_DEVICE_TABLE(il4965_hw_card_ids) = { 6803static const struct pci_device_id il4965_hw_card_ids[] = {
6804 {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)}, 6804 {IL_PCI_DEVICE(0x4229, PCI_ANY_ID, il4965_cfg)},
6805 {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)}, 6805 {IL_PCI_DEVICE(0x4230, PCI_ANY_ID, il4965_cfg)},
6806 {0} 6806 {0}
diff --git a/drivers/net/wireless/iwlwifi/mvm/mac80211.c b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
index 0d6a8b768a68..7c8796584c25 100644
--- a/drivers/net/wireless/iwlwifi/mvm/mac80211.c
+++ b/drivers/net/wireless/iwlwifi/mvm/mac80211.c
@@ -396,7 +396,8 @@ int iwl_mvm_mac_setup_register(struct iwl_mvm *mvm)
396 else 396 else
397 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT; 397 hw->wiphy->flags &= ~WIPHY_FLAG_PS_ON_BY_DEFAULT;
398 398
399 hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; 399 /* TODO: enable that only for firmwares that don't crash */
400 /* hw->wiphy->flags |= WIPHY_FLAG_SUPPORTS_SCHED_SCAN; */
400 hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX; 401 hw->wiphy->max_sched_scan_ssids = PROBE_OPTION_MAX;
401 hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES; 402 hw->wiphy->max_match_sets = IWL_SCAN_MAX_PROFILES;
402 /* we create the 802.11 header and zero length SSID IE. */ 403 /* we create the 802.11 header and zero length SSID IE. */
diff --git a/drivers/net/wireless/iwlwifi/pcie/drv.c b/drivers/net/wireless/iwlwifi/pcie/drv.c
index 98950e45c7b0..f0e722ced080 100644
--- a/drivers/net/wireless/iwlwifi/pcie/drv.c
+++ b/drivers/net/wireless/iwlwifi/pcie/drv.c
@@ -78,7 +78,7 @@
78 .driver_data = (kernel_ulong_t)&(cfg) 78 .driver_data = (kernel_ulong_t)&(cfg)
79 79
80/* Hardware specific file defines the PCI IDs table for that hardware module */ 80/* Hardware specific file defines the PCI IDs table for that hardware module */
81static DEFINE_PCI_DEVICE_TABLE(iwl_hw_card_ids) = { 81static const struct pci_device_id iwl_hw_card_ids[] = {
82#if IS_ENABLED(CONFIG_IWLDVM) 82#if IS_ENABLED(CONFIG_IWLDVM)
83 {IWL_PCI_DEVICE(0x4232, 0x1201, iwl5100_agn_cfg)}, /* Mini Card */ 83 {IWL_PCI_DEVICE(0x4232, 0x1201, iwl5100_agn_cfg)}, /* Mini Card */
84 {IWL_PCI_DEVICE(0x4232, 0x1301, iwl5100_agn_cfg)}, /* Half Mini Card */ 84 {IWL_PCI_DEVICE(0x4232, 0x1301, iwl5100_agn_cfg)}, /* Half Mini Card */
diff --git a/drivers/net/wireless/mwifiex/pcie.c b/drivers/net/wireless/mwifiex/pcie.c
index c16dd2cc8198..ff0545888dd0 100644
--- a/drivers/net/wireless/mwifiex/pcie.c
+++ b/drivers/net/wireless/mwifiex/pcie.c
@@ -257,7 +257,7 @@ static void mwifiex_pcie_shutdown(struct pci_dev *pdev)
257 return; 257 return;
258} 258}
259 259
260static DEFINE_PCI_DEVICE_TABLE(mwifiex_ids) = { 260static const struct pci_device_id mwifiex_ids[] = {
261 { 261 {
262 PCIE_VENDOR_ID_MARVELL, PCIE_DEVICE_ID_MARVELL_88W8766P, 262 PCIE_VENDOR_ID_MARVELL, PCIE_DEVICE_ID_MARVELL_88W8766P,
263 PCI_ANY_ID, PCI_ANY_ID, 0, 0, 263 PCI_ANY_ID, PCI_ANY_ID, 0, 0,
diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index 9a3d4d6724f7..ef1104476bd8 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -1159,12 +1159,11 @@ static int mwl8k_rxq_init(struct ieee80211_hw *hw, int index)
1159 1159
1160 size = MWL8K_RX_DESCS * priv->rxd_ops->rxd_size; 1160 size = MWL8K_RX_DESCS * priv->rxd_ops->rxd_size;
1161 1161
1162 rxq->rxd = pci_alloc_consistent(priv->pdev, size, &rxq->rxd_dma); 1162 rxq->rxd = pci_zalloc_consistent(priv->pdev, size, &rxq->rxd_dma);
1163 if (rxq->rxd == NULL) { 1163 if (rxq->rxd == NULL) {
1164 wiphy_err(hw->wiphy, "failed to alloc RX descriptors\n"); 1164 wiphy_err(hw->wiphy, "failed to alloc RX descriptors\n");
1165 return -ENOMEM; 1165 return -ENOMEM;
1166 } 1166 }
1167 memset(rxq->rxd, 0, size);
1168 1167
1169 rxq->buf = kcalloc(MWL8K_RX_DESCS, sizeof(*rxq->buf), GFP_KERNEL); 1168 rxq->buf = kcalloc(MWL8K_RX_DESCS, sizeof(*rxq->buf), GFP_KERNEL);
1170 if (rxq->buf == NULL) { 1169 if (rxq->buf == NULL) {
@@ -1451,12 +1450,11 @@ static int mwl8k_txq_init(struct ieee80211_hw *hw, int index)
1451 1450
1452 size = MWL8K_TX_DESCS * sizeof(struct mwl8k_tx_desc); 1451 size = MWL8K_TX_DESCS * sizeof(struct mwl8k_tx_desc);
1453 1452
1454 txq->txd = pci_alloc_consistent(priv->pdev, size, &txq->txd_dma); 1453 txq->txd = pci_zalloc_consistent(priv->pdev, size, &txq->txd_dma);
1455 if (txq->txd == NULL) { 1454 if (txq->txd == NULL) {
1456 wiphy_err(hw->wiphy, "failed to alloc TX descriptors\n"); 1455 wiphy_err(hw->wiphy, "failed to alloc TX descriptors\n");
1457 return -ENOMEM; 1456 return -ENOMEM;
1458 } 1457 }
1459 memset(txq->txd, 0, size);
1460 1458
1461 txq->skb = kcalloc(MWL8K_TX_DESCS, sizeof(*txq->skb), GFP_KERNEL); 1459 txq->skb = kcalloc(MWL8K_TX_DESCS, sizeof(*txq->skb), GFP_KERNEL);
1462 if (txq->skb == NULL) { 1460 if (txq->skb == NULL) {
@@ -5676,7 +5674,7 @@ MODULE_FIRMWARE("mwl8k/helper_8366.fw");
5676MODULE_FIRMWARE("mwl8k/fmimage_8366.fw"); 5674MODULE_FIRMWARE("mwl8k/fmimage_8366.fw");
5677MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API)); 5675MODULE_FIRMWARE(MWL8K_8366_AP_FW(MWL8K_8366_AP_FW_API));
5678 5676
5679static DEFINE_PCI_DEVICE_TABLE(mwl8k_pci_id_table) = { 5677static const struct pci_device_id mwl8k_pci_id_table[] = {
5680 { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, }, 5678 { PCI_VDEVICE(MARVELL, 0x2a0a), .driver_data = MWL8363, },
5681 { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, }, 5679 { PCI_VDEVICE(MARVELL, 0x2a0c), .driver_data = MWL8363, },
5682 { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, }, 5680 { PCI_VDEVICE(MARVELL, 0x2a24), .driver_data = MWL8363, },
diff --git a/drivers/net/wireless/orinoco/orinoco_nortel.c b/drivers/net/wireless/orinoco/orinoco_nortel.c
index ffb2469eb679..1b543e30eff7 100644
--- a/drivers/net/wireless/orinoco/orinoco_nortel.c
+++ b/drivers/net/wireless/orinoco/orinoco_nortel.c
@@ -272,7 +272,7 @@ static void orinoco_nortel_remove_one(struct pci_dev *pdev)
272 pci_disable_device(pdev); 272 pci_disable_device(pdev);
273} 273}
274 274
275static DEFINE_PCI_DEVICE_TABLE(orinoco_nortel_id_table) = { 275static const struct pci_device_id orinoco_nortel_id_table[] = {
276 /* Nortel emobility PCI */ 276 /* Nortel emobility PCI */
277 {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,}, 277 {0x126c, 0x8030, PCI_ANY_ID, PCI_ANY_ID,},
278 /* Symbol LA-4123 PCI */ 278 /* Symbol LA-4123 PCI */
diff --git a/drivers/net/wireless/orinoco/orinoco_pci.c b/drivers/net/wireless/orinoco/orinoco_pci.c
index 5ae1191d2532..b6bdad632842 100644
--- a/drivers/net/wireless/orinoco/orinoco_pci.c
+++ b/drivers/net/wireless/orinoco/orinoco_pci.c
@@ -210,7 +210,7 @@ static void orinoco_pci_remove_one(struct pci_dev *pdev)
210 pci_disable_device(pdev); 210 pci_disable_device(pdev);
211} 211}
212 212
213static DEFINE_PCI_DEVICE_TABLE(orinoco_pci_id_table) = { 213static const struct pci_device_id orinoco_pci_id_table[] = {
214 /* Intersil Prism 3 */ 214 /* Intersil Prism 3 */
215 {0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID,}, 215 {0x1260, 0x3872, PCI_ANY_ID, PCI_ANY_ID,},
216 /* Intersil Prism 2.5 */ 216 /* Intersil Prism 2.5 */
diff --git a/drivers/net/wireless/orinoco/orinoco_plx.c b/drivers/net/wireless/orinoco/orinoco_plx.c
index bbd36d1676ff..b8f6e5c431ae 100644
--- a/drivers/net/wireless/orinoco/orinoco_plx.c
+++ b/drivers/net/wireless/orinoco/orinoco_plx.c
@@ -308,7 +308,7 @@ static void orinoco_plx_remove_one(struct pci_dev *pdev)
308 pci_disable_device(pdev); 308 pci_disable_device(pdev);
309} 309}
310 310
311static DEFINE_PCI_DEVICE_TABLE(orinoco_plx_id_table) = { 311static const struct pci_device_id orinoco_plx_id_table[] = {
312 {0x111a, 0x1023, PCI_ANY_ID, PCI_ANY_ID,}, /* Siemens SpeedStream SS1023 */ 312 {0x111a, 0x1023, PCI_ANY_ID, PCI_ANY_ID,}, /* Siemens SpeedStream SS1023 */
313 {0x1385, 0x4100, PCI_ANY_ID, PCI_ANY_ID,}, /* Netgear MA301 */ 313 {0x1385, 0x4100, PCI_ANY_ID, PCI_ANY_ID,}, /* Netgear MA301 */
314 {0x15e8, 0x0130, PCI_ANY_ID, PCI_ANY_ID,}, /* Correga - does this work? */ 314 {0x15e8, 0x0130, PCI_ANY_ID, PCI_ANY_ID,}, /* Correga - does this work? */
diff --git a/drivers/net/wireless/orinoco/orinoco_tmd.c b/drivers/net/wireless/orinoco/orinoco_tmd.c
index 04b08de5fd5d..79d0e33b625e 100644
--- a/drivers/net/wireless/orinoco/orinoco_tmd.c
+++ b/drivers/net/wireless/orinoco/orinoco_tmd.c
@@ -201,7 +201,7 @@ static void orinoco_tmd_remove_one(struct pci_dev *pdev)
201 pci_disable_device(pdev); 201 pci_disable_device(pdev);
202} 202}
203 203
204static DEFINE_PCI_DEVICE_TABLE(orinoco_tmd_id_table) = { 204static const struct pci_device_id orinoco_tmd_id_table[] = {
205 {0x15e8, 0x0131, PCI_ANY_ID, PCI_ANY_ID,}, /* NDC and OEMs, e.g. pheecom */ 205 {0x15e8, 0x0131, PCI_ANY_ID, PCI_ANY_ID,}, /* NDC and OEMs, e.g. pheecom */
206 {0,}, 206 {0,},
207}; 207};
diff --git a/drivers/net/wireless/p54/p54pci.c b/drivers/net/wireless/p54/p54pci.c
index d411de409050..d4aee64fb5ea 100644
--- a/drivers/net/wireless/p54/p54pci.c
+++ b/drivers/net/wireless/p54/p54pci.c
@@ -32,7 +32,7 @@ MODULE_LICENSE("GPL");
32MODULE_ALIAS("prism54pci"); 32MODULE_ALIAS("prism54pci");
33MODULE_FIRMWARE("isl3886pci"); 33MODULE_FIRMWARE("isl3886pci");
34 34
35static DEFINE_PCI_DEVICE_TABLE(p54p_table) = { 35static const struct pci_device_id p54p_table[] = {
36 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */ 36 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
37 { PCI_DEVICE(0x1260, 0x3890) }, 37 { PCI_DEVICE(0x1260, 0x3890) },
38 /* 3COM 3CRWE154G72 Wireless LAN adapter */ 38 /* 3COM 3CRWE154G72 Wireless LAN adapter */
diff --git a/drivers/net/wireless/prism54/islpci_hotplug.c b/drivers/net/wireless/prism54/islpci_hotplug.c
index 1105a12dbde8..300c846ea087 100644
--- a/drivers/net/wireless/prism54/islpci_hotplug.c
+++ b/drivers/net/wireless/prism54/islpci_hotplug.c
@@ -39,7 +39,7 @@ module_param(init_pcitm, int, 0);
39 * driver_data 39 * driver_data
40 * If you have an update for this please contact prism54-devel@prism54.org 40 * If you have an update for this please contact prism54-devel@prism54.org
41 * The latest list can be found at http://wireless.kernel.org/en/users/Drivers/p54 */ 41 * The latest list can be found at http://wireless.kernel.org/en/users/Drivers/p54 */
42static DEFINE_PCI_DEVICE_TABLE(prism54_id_tbl) = { 42static const struct pci_device_id prism54_id_tbl[] = {
43 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */ 43 /* Intersil PRISM Duette/Prism GT Wireless LAN adapter */
44 { 44 {
45 0x1260, 0x3890, 45 0x1260, 0x3890,
diff --git a/drivers/net/wireless/rt2x00/rt2400pci.c b/drivers/net/wireless/rt2x00/rt2400pci.c
index 4ccfef5094e0..bdf5590ba304 100644
--- a/drivers/net/wireless/rt2x00/rt2400pci.c
+++ b/drivers/net/wireless/rt2x00/rt2400pci.c
@@ -1821,7 +1821,7 @@ static const struct rt2x00_ops rt2400pci_ops = {
1821/* 1821/*
1822 * RT2400pci module information. 1822 * RT2400pci module information.
1823 */ 1823 */
1824static DEFINE_PCI_DEVICE_TABLE(rt2400pci_device_table) = { 1824static const struct pci_device_id rt2400pci_device_table[] = {
1825 { PCI_DEVICE(0x1814, 0x0101) }, 1825 { PCI_DEVICE(0x1814, 0x0101) },
1826 { 0, } 1826 { 0, }
1827}; 1827};
diff --git a/drivers/net/wireless/rt2x00/rt2500pci.c b/drivers/net/wireless/rt2x00/rt2500pci.c
index a511cccc9f01..79f4fe65a119 100644
--- a/drivers/net/wireless/rt2x00/rt2500pci.c
+++ b/drivers/net/wireless/rt2x00/rt2500pci.c
@@ -2120,7 +2120,7 @@ static const struct rt2x00_ops rt2500pci_ops = {
2120/* 2120/*
2121 * RT2500pci module information. 2121 * RT2500pci module information.
2122 */ 2122 */
2123static DEFINE_PCI_DEVICE_TABLE(rt2500pci_device_table) = { 2123static const struct pci_device_id rt2500pci_device_table[] = {
2124 { PCI_DEVICE(0x1814, 0x0201) }, 2124 { PCI_DEVICE(0x1814, 0x0201) },
2125 { 0, } 2125 { 0, }
2126}; 2126};
diff --git a/drivers/net/wireless/rt2x00/rt2800pci.c b/drivers/net/wireless/rt2x00/rt2800pci.c
index a5b32ca2cf0f..cc1b3cc73c5a 100644
--- a/drivers/net/wireless/rt2x00/rt2800pci.c
+++ b/drivers/net/wireless/rt2x00/rt2800pci.c
@@ -400,7 +400,7 @@ static const struct rt2x00_ops rt2800pci_ops = {
400/* 400/*
401 * RT2800pci module information. 401 * RT2800pci module information.
402 */ 402 */
403static DEFINE_PCI_DEVICE_TABLE(rt2800pci_device_table) = { 403static const struct pci_device_id rt2800pci_device_table[] = {
404 { PCI_DEVICE(0x1814, 0x0601) }, 404 { PCI_DEVICE(0x1814, 0x0601) },
405 { PCI_DEVICE(0x1814, 0x0681) }, 405 { PCI_DEVICE(0x1814, 0x0681) },
406 { PCI_DEVICE(0x1814, 0x0701) }, 406 { PCI_DEVICE(0x1814, 0x0701) },
diff --git a/drivers/net/wireless/rt2x00/rt61pci.c b/drivers/net/wireless/rt2x00/rt61pci.c
index 9048a9cbe52c..819455009fe4 100644
--- a/drivers/net/wireless/rt2x00/rt61pci.c
+++ b/drivers/net/wireless/rt2x00/rt61pci.c
@@ -3075,7 +3075,7 @@ static const struct rt2x00_ops rt61pci_ops = {
3075/* 3075/*
3076 * RT61pci module information. 3076 * RT61pci module information.
3077 */ 3077 */
3078static DEFINE_PCI_DEVICE_TABLE(rt61pci_device_table) = { 3078static const struct pci_device_id rt61pci_device_table[] = {
3079 /* RT2561s */ 3079 /* RT2561s */
3080 { PCI_DEVICE(0x1814, 0x0301) }, 3080 { PCI_DEVICE(0x1814, 0x0301) },
3081 /* RT2561 v2 */ 3081 /* RT2561 v2 */
diff --git a/drivers/net/wireless/rtl818x/rtl8180/dev.c b/drivers/net/wireless/rtl818x/rtl8180/dev.c
index 4b904f708184..026d912f516b 100644
--- a/drivers/net/wireless/rtl818x/rtl8180/dev.c
+++ b/drivers/net/wireless/rtl818x/rtl8180/dev.c
@@ -64,7 +64,7 @@ MODULE_AUTHOR("Andrea Merello <andrea.merello@gmail.com>");
64MODULE_DESCRIPTION("RTL8180 / RTL8185 / RTL8187SE PCI wireless driver"); 64MODULE_DESCRIPTION("RTL8180 / RTL8185 / RTL8187SE PCI wireless driver");
65MODULE_LICENSE("GPL"); 65MODULE_LICENSE("GPL");
66 66
67static DEFINE_PCI_DEVICE_TABLE(rtl8180_table) = { 67static const struct pci_device_id rtl8180_table[] = {
68 68
69 /* rtl8187se */ 69 /* rtl8187se */
70 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8199) }, 70 { PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8199) },
@@ -972,16 +972,13 @@ static int rtl8180_init_rx_ring(struct ieee80211_hw *dev)
972 else 972 else
973 priv->rx_ring_sz = sizeof(struct rtl8180_rx_desc); 973 priv->rx_ring_sz = sizeof(struct rtl8180_rx_desc);
974 974
975 priv->rx_ring = pci_alloc_consistent(priv->pdev, 975 priv->rx_ring = pci_zalloc_consistent(priv->pdev, priv->rx_ring_sz * 32,
976 priv->rx_ring_sz * 32, 976 &priv->rx_ring_dma);
977 &priv->rx_ring_dma);
978
979 if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) { 977 if (!priv->rx_ring || (unsigned long)priv->rx_ring & 0xFF) {
980 wiphy_err(dev->wiphy, "Cannot allocate RX ring\n"); 978 wiphy_err(dev->wiphy, "Cannot allocate RX ring\n");
981 return -ENOMEM; 979 return -ENOMEM;
982 } 980 }
983 981
984 memset(priv->rx_ring, 0, priv->rx_ring_sz * 32);
985 priv->rx_idx = 0; 982 priv->rx_idx = 0;
986 983
987 for (i = 0; i < 32; i++) { 984 for (i = 0; i < 32; i++) {
@@ -1040,14 +1037,14 @@ static int rtl8180_init_tx_ring(struct ieee80211_hw *dev,
1040 dma_addr_t dma; 1037 dma_addr_t dma;
1041 int i; 1038 int i;
1042 1039
1043 ring = pci_alloc_consistent(priv->pdev, sizeof(*ring) * entries, &dma); 1040 ring = pci_zalloc_consistent(priv->pdev, sizeof(*ring) * entries,
1041 &dma);
1044 if (!ring || (unsigned long)ring & 0xFF) { 1042 if (!ring || (unsigned long)ring & 0xFF) {
1045 wiphy_err(dev->wiphy, "Cannot allocate TX ring (prio = %d)\n", 1043 wiphy_err(dev->wiphy, "Cannot allocate TX ring (prio = %d)\n",
1046 prio); 1044 prio);
1047 return -ENOMEM; 1045 return -ENOMEM;
1048 } 1046 }
1049 1047
1050 memset(ring, 0, sizeof(*ring)*entries);
1051 priv->tx_ring[prio].desc = ring; 1048 priv->tx_ring[prio].desc = ring;
1052 priv->tx_ring[prio].dma = dma; 1049 priv->tx_ring[prio].dma = dma;
1053 priv->tx_ring[prio].idx = 0; 1050 priv->tx_ring[prio].idx = 0;
diff --git a/drivers/net/wireless/rtlwifi/pci.c b/drivers/net/wireless/rtlwifi/pci.c
index dae55257f0e8..67d1ee6edcad 100644
--- a/drivers/net/wireless/rtlwifi/pci.c
+++ b/drivers/net/wireless/rtlwifi/pci.c
@@ -1092,16 +1092,14 @@ static int _rtl_pci_init_tx_ring(struct ieee80211_hw *hw,
1092 u32 nextdescaddress; 1092 u32 nextdescaddress;
1093 int i; 1093 int i;
1094 1094
1095 ring = pci_alloc_consistent(rtlpci->pdev, 1095 ring = pci_zalloc_consistent(rtlpci->pdev, sizeof(*ring) * entries,
1096 sizeof(*ring) * entries, &dma); 1096 &dma);
1097
1098 if (!ring || (unsigned long)ring & 0xFF) { 1097 if (!ring || (unsigned long)ring & 0xFF) {
1099 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG, 1098 RT_TRACE(rtlpriv, COMP_ERR, DBG_EMERG,
1100 "Cannot allocate TX ring (prio = %d)\n", prio); 1099 "Cannot allocate TX ring (prio = %d)\n", prio);
1101 return -ENOMEM; 1100 return -ENOMEM;
1102 } 1101 }
1103 1102
1104 memset(ring, 0, sizeof(*ring) * entries);
1105 rtlpci->tx_ring[prio].desc = ring; 1103 rtlpci->tx_ring[prio].desc = ring;
1106 rtlpci->tx_ring[prio].dma = dma; 1104 rtlpci->tx_ring[prio].dma = dma;
1107 rtlpci->tx_ring[prio].idx = 0; 1105 rtlpci->tx_ring[prio].idx = 0;
@@ -1139,10 +1137,9 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw)
1139 for (rx_queue_idx = 0; rx_queue_idx < RTL_PCI_MAX_RX_QUEUE; 1137 for (rx_queue_idx = 0; rx_queue_idx < RTL_PCI_MAX_RX_QUEUE;
1140 rx_queue_idx++) { 1138 rx_queue_idx++) {
1141 rtlpci->rx_ring[rx_queue_idx].desc = 1139 rtlpci->rx_ring[rx_queue_idx].desc =
1142 pci_alloc_consistent(rtlpci->pdev, 1140 pci_zalloc_consistent(rtlpci->pdev,
1143 sizeof(*rtlpci->rx_ring[rx_queue_idx]. 1141 sizeof(*rtlpci->rx_ring[rx_queue_idx].desc) * rtlpci->rxringcount,
1144 desc) * rtlpci->rxringcount, 1142 &rtlpci->rx_ring[rx_queue_idx].dma);
1145 &rtlpci->rx_ring[rx_queue_idx].dma);
1146 1143
1147 if (!rtlpci->rx_ring[rx_queue_idx].desc || 1144 if (!rtlpci->rx_ring[rx_queue_idx].desc ||
1148 (unsigned long)rtlpci->rx_ring[rx_queue_idx].desc & 0xFF) { 1145 (unsigned long)rtlpci->rx_ring[rx_queue_idx].desc & 0xFF) {
@@ -1151,10 +1148,6 @@ static int _rtl_pci_init_rx_ring(struct ieee80211_hw *hw)
1151 return -ENOMEM; 1148 return -ENOMEM;
1152 } 1149 }
1153 1150
1154 memset(rtlpci->rx_ring[rx_queue_idx].desc, 0,
1155 sizeof(*rtlpci->rx_ring[rx_queue_idx].desc) *
1156 rtlpci->rxringcount);
1157
1158 rtlpci->rx_ring[rx_queue_idx].idx = 0; 1151 rtlpci->rx_ring[rx_queue_idx].idx = 0;
1159 1152
1160 /* If amsdu_8k is disabled, set buffersize to 4096. This 1153 /* If amsdu_8k is disabled, set buffersize to 4096. This
diff --git a/drivers/net/wireless/rtlwifi/rtl8188ee/sw.c b/drivers/net/wireless/rtlwifi/rtl8188ee/sw.c
index 842d69349a37..631b6907c17d 100644
--- a/drivers/net/wireless/rtlwifi/rtl8188ee/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8188ee/sw.c
@@ -364,7 +364,7 @@ static struct rtl_hal_cfg rtl88ee_hal_cfg = {
364 .maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15, 364 .maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15,
365}; 365};
366 366
367static DEFINE_PCI_DEVICE_TABLE(rtl88ee_pci_ids) = { 367static const struct pci_device_id rtl88ee_pci_ids[] = {
368 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8179, rtl88ee_hal_cfg)}, 368 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8179, rtl88ee_hal_cfg)},
369 {}, 369 {},
370}; 370};
diff --git a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
index 12f21f4073e8..4bbdfb2df363 100644
--- a/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8192ce/sw.c
@@ -344,7 +344,7 @@ static struct rtl_hal_cfg rtl92ce_hal_cfg = {
344 .maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15, 344 .maps[RTL_RC_HT_RATEMCS15] = DESC92_RATEMCS15,
345}; 345};
346 346
347static DEFINE_PCI_DEVICE_TABLE(rtl92ce_pci_ids) = { 347static const struct pci_device_id rtl92ce_pci_ids[] = {
348 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8191, rtl92ce_hal_cfg)}, 348 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8191, rtl92ce_hal_cfg)},
349 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8178, rtl92ce_hal_cfg)}, 349 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8178, rtl92ce_hal_cfg)},
350 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8177, rtl92ce_hal_cfg)}, 350 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0x8177, rtl92ce_hal_cfg)},
diff --git a/drivers/net/wireless/rtlwifi/rtl8723be/sw.c b/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
index ff12bf41644b..532913c6622a 100644
--- a/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
+++ b/drivers/net/wireless/rtlwifi/rtl8723be/sw.c
@@ -348,7 +348,7 @@ static struct rtl_hal_cfg rtl8723be_hal_cfg = {
348 .maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15, 348 .maps[RTL_RC_HT_RATEMCS15] = DESC92C_RATEMCS15,
349}; 349};
350 350
351static DEFINE_PCI_DEVICE_TABLE(rtl8723be_pci_id) = { 351static const struct pci_device_id rtl8723be_pci_id[] = {
352 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xb723, rtl8723be_hal_cfg)}, 352 {RTL_PCI_DEVICE(PCI_VENDOR_ID_REALTEK, 0xb723, rtl8723be_hal_cfg)},
353 {}, 353 {},
354}; 354};
diff --git a/drivers/net/xen-netback/common.h b/drivers/net/xen-netback/common.h
index ef3026f46a37..d4eb8d2e9cb7 100644
--- a/drivers/net/xen-netback/common.h
+++ b/drivers/net/xen-netback/common.h
@@ -165,6 +165,7 @@ struct xenvif_queue { /* Per-queue data for xenvif */
165 u16 dealloc_ring[MAX_PENDING_REQS]; 165 u16 dealloc_ring[MAX_PENDING_REQS];
166 struct task_struct *dealloc_task; 166 struct task_struct *dealloc_task;
167 wait_queue_head_t dealloc_wq; 167 wait_queue_head_t dealloc_wq;
168 atomic_t inflight_packets;
168 169
169 /* Use kthread for guest RX */ 170 /* Use kthread for guest RX */
170 struct task_struct *task; 171 struct task_struct *task;
@@ -329,4 +330,8 @@ extern unsigned int xenvif_max_queues;
329extern struct dentry *xen_netback_dbg_root; 330extern struct dentry *xen_netback_dbg_root;
330#endif 331#endif
331 332
333void xenvif_skb_zerocopy_prepare(struct xenvif_queue *queue,
334 struct sk_buff *skb);
335void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue);
336
332#endif /* __XEN_NETBACK__COMMON_H__ */ 337#endif /* __XEN_NETBACK__COMMON_H__ */
diff --git a/drivers/net/xen-netback/interface.c b/drivers/net/xen-netback/interface.c
index 48a55cda979b..e29e15dca86e 100644
--- a/drivers/net/xen-netback/interface.c
+++ b/drivers/net/xen-netback/interface.c
@@ -43,6 +43,23 @@
43#define XENVIF_QUEUE_LENGTH 32 43#define XENVIF_QUEUE_LENGTH 32
44#define XENVIF_NAPI_WEIGHT 64 44#define XENVIF_NAPI_WEIGHT 64
45 45
46/* This function is used to set SKBTX_DEV_ZEROCOPY as well as
47 * increasing the inflight counter. We need to increase the inflight
48 * counter because core driver calls into xenvif_zerocopy_callback
49 * which calls xenvif_skb_zerocopy_complete.
50 */
51void xenvif_skb_zerocopy_prepare(struct xenvif_queue *queue,
52 struct sk_buff *skb)
53{
54 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY;
55 atomic_inc(&queue->inflight_packets);
56}
57
58void xenvif_skb_zerocopy_complete(struct xenvif_queue *queue)
59{
60 atomic_dec(&queue->inflight_packets);
61}
62
46static inline void xenvif_stop_queue(struct xenvif_queue *queue) 63static inline void xenvif_stop_queue(struct xenvif_queue *queue)
47{ 64{
48 struct net_device *dev = queue->vif->dev; 65 struct net_device *dev = queue->vif->dev;
@@ -78,12 +95,8 @@ int xenvif_poll(struct napi_struct *napi, int budget)
78 /* This vif is rogue, we pretend we've there is nothing to do 95 /* This vif is rogue, we pretend we've there is nothing to do
79 * for this vif to deschedule it from NAPI. But this interface 96 * for this vif to deschedule it from NAPI. But this interface
80 * will be turned off in thread context later. 97 * will be turned off in thread context later.
81 * Also, if a guest doesn't post enough slots to receive data on one of
82 * its queues, the carrier goes down and NAPI is descheduled here so
83 * the guest can't send more packets until it's ready to receive.
84 */ 98 */
85 if (unlikely(queue->vif->disabled || 99 if (unlikely(queue->vif->disabled)) {
86 !netif_carrier_ok(queue->vif->dev))) {
87 napi_complete(napi); 100 napi_complete(napi);
88 return 0; 101 return 0;
89 } 102 }
@@ -528,9 +541,6 @@ int xenvif_init_queue(struct xenvif_queue *queue)
528 541
529 init_timer(&queue->rx_stalled); 542 init_timer(&queue->rx_stalled);
530 543
531 netif_napi_add(queue->vif->dev, &queue->napi, xenvif_poll,
532 XENVIF_NAPI_WEIGHT);
533
534 return 0; 544 return 0;
535} 545}
536 546
@@ -564,6 +574,7 @@ int xenvif_connect(struct xenvif_queue *queue, unsigned long tx_ring_ref,
564 574
565 init_waitqueue_head(&queue->wq); 575 init_waitqueue_head(&queue->wq);
566 init_waitqueue_head(&queue->dealloc_wq); 576 init_waitqueue_head(&queue->dealloc_wq);
577 atomic_set(&queue->inflight_packets, 0);
567 578
568 if (tx_evtchn == rx_evtchn) { 579 if (tx_evtchn == rx_evtchn) {
569 /* feature-split-event-channels == 0 */ 580 /* feature-split-event-channels == 0 */
@@ -618,6 +629,9 @@ int xenvif_connect(struct xenvif_queue *queue, unsigned long tx_ring_ref,
618 wake_up_process(queue->task); 629 wake_up_process(queue->task);
619 wake_up_process(queue->dealloc_task); 630 wake_up_process(queue->dealloc_task);
620 631
632 netif_napi_add(queue->vif->dev, &queue->napi, xenvif_poll,
633 XENVIF_NAPI_WEIGHT);
634
621 return 0; 635 return 0;
622 636
623err_rx_unbind: 637err_rx_unbind:
@@ -646,25 +660,6 @@ void xenvif_carrier_off(struct xenvif *vif)
646 rtnl_unlock(); 660 rtnl_unlock();
647} 661}
648 662
649static void xenvif_wait_unmap_timeout(struct xenvif_queue *queue,
650 unsigned int worst_case_skb_lifetime)
651{
652 int i, unmap_timeout = 0;
653
654 for (i = 0; i < MAX_PENDING_REQS; ++i) {
655 if (queue->grant_tx_handle[i] != NETBACK_INVALID_HANDLE) {
656 unmap_timeout++;
657 schedule_timeout(msecs_to_jiffies(1000));
658 if (unmap_timeout > worst_case_skb_lifetime &&
659 net_ratelimit())
660 netdev_err(queue->vif->dev,
661 "Page still granted! Index: %x\n",
662 i);
663 i = -1;
664 }
665 }
666}
667
668void xenvif_disconnect(struct xenvif *vif) 663void xenvif_disconnect(struct xenvif *vif)
669{ 664{
670 struct xenvif_queue *queue = NULL; 665 struct xenvif_queue *queue = NULL;
@@ -676,6 +671,8 @@ void xenvif_disconnect(struct xenvif *vif)
676 for (queue_index = 0; queue_index < num_queues; ++queue_index) { 671 for (queue_index = 0; queue_index < num_queues; ++queue_index) {
677 queue = &vif->queues[queue_index]; 672 queue = &vif->queues[queue_index];
678 673
674 netif_napi_del(&queue->napi);
675
679 if (queue->task) { 676 if (queue->task) {
680 del_timer_sync(&queue->rx_stalled); 677 del_timer_sync(&queue->rx_stalled);
681 kthread_stop(queue->task); 678 kthread_stop(queue->task);
@@ -708,7 +705,6 @@ void xenvif_disconnect(struct xenvif *vif)
708void xenvif_deinit_queue(struct xenvif_queue *queue) 705void xenvif_deinit_queue(struct xenvif_queue *queue)
709{ 706{
710 free_xenballooned_pages(MAX_PENDING_REQS, queue->mmap_pages); 707 free_xenballooned_pages(MAX_PENDING_REQS, queue->mmap_pages);
711 netif_napi_del(&queue->napi);
712} 708}
713 709
714void xenvif_free(struct xenvif *vif) 710void xenvif_free(struct xenvif *vif)
@@ -716,21 +712,11 @@ void xenvif_free(struct xenvif *vif)
716 struct xenvif_queue *queue = NULL; 712 struct xenvif_queue *queue = NULL;
717 unsigned int num_queues = vif->num_queues; 713 unsigned int num_queues = vif->num_queues;
718 unsigned int queue_index; 714 unsigned int queue_index;
719 /* Here we want to avoid timeout messages if an skb can be legitimately
720 * stuck somewhere else. Realistically this could be an another vif's
721 * internal or QDisc queue. That another vif also has this
722 * rx_drain_timeout_msecs timeout, so give it time to drain out.
723 * Although if that other guest wakes up just before its timeout happens
724 * and takes only one skb from QDisc, it can hold onto other skbs for a
725 * longer period.
726 */
727 unsigned int worst_case_skb_lifetime = (rx_drain_timeout_msecs/1000);
728 715
729 unregister_netdev(vif->dev); 716 unregister_netdev(vif->dev);
730 717
731 for (queue_index = 0; queue_index < num_queues; ++queue_index) { 718 for (queue_index = 0; queue_index < num_queues; ++queue_index) {
732 queue = &vif->queues[queue_index]; 719 queue = &vif->queues[queue_index];
733 xenvif_wait_unmap_timeout(queue, worst_case_skb_lifetime);
734 xenvif_deinit_queue(queue); 720 xenvif_deinit_queue(queue);
735 } 721 }
736 722
diff --git a/drivers/net/xen-netback/netback.c b/drivers/net/xen-netback/netback.c
index aa2093325be1..08f65996534c 100644
--- a/drivers/net/xen-netback/netback.c
+++ b/drivers/net/xen-netback/netback.c
@@ -1525,10 +1525,12 @@ static int xenvif_handle_frag_list(struct xenvif_queue *queue, struct sk_buff *s
1525 /* remove traces of mapped pages and frag_list */ 1525 /* remove traces of mapped pages and frag_list */
1526 skb_frag_list_init(skb); 1526 skb_frag_list_init(skb);
1527 uarg = skb_shinfo(skb)->destructor_arg; 1527 uarg = skb_shinfo(skb)->destructor_arg;
1528 /* increase inflight counter to offset decrement in callback */
1529 atomic_inc(&queue->inflight_packets);
1528 uarg->callback(uarg, true); 1530 uarg->callback(uarg, true);
1529 skb_shinfo(skb)->destructor_arg = NULL; 1531 skb_shinfo(skb)->destructor_arg = NULL;
1530 1532
1531 skb_shinfo(nskb)->tx_flags |= SKBTX_DEV_ZEROCOPY; 1533 xenvif_skb_zerocopy_prepare(queue, nskb);
1532 kfree_skb(nskb); 1534 kfree_skb(nskb);
1533 1535
1534 return 0; 1536 return 0;
@@ -1589,7 +1591,7 @@ static int xenvif_tx_submit(struct xenvif_queue *queue)
1589 if (net_ratelimit()) 1591 if (net_ratelimit())
1590 netdev_err(queue->vif->dev, 1592 netdev_err(queue->vif->dev,
1591 "Not enough memory to consolidate frag_list!\n"); 1593 "Not enough memory to consolidate frag_list!\n");
1592 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; 1594 xenvif_skb_zerocopy_prepare(queue, skb);
1593 kfree_skb(skb); 1595 kfree_skb(skb);
1594 continue; 1596 continue;
1595 } 1597 }
@@ -1609,7 +1611,7 @@ static int xenvif_tx_submit(struct xenvif_queue *queue)
1609 "Can't setup checksum in net_tx_action\n"); 1611 "Can't setup checksum in net_tx_action\n");
1610 /* We have to set this flag to trigger the callback */ 1612 /* We have to set this flag to trigger the callback */
1611 if (skb_shinfo(skb)->destructor_arg) 1613 if (skb_shinfo(skb)->destructor_arg)
1612 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; 1614 xenvif_skb_zerocopy_prepare(queue, skb);
1613 kfree_skb(skb); 1615 kfree_skb(skb);
1614 continue; 1616 continue;
1615 } 1617 }
@@ -1641,7 +1643,7 @@ static int xenvif_tx_submit(struct xenvif_queue *queue)
1641 * skb. E.g. the __pskb_pull_tail earlier can do such thing. 1643 * skb. E.g. the __pskb_pull_tail earlier can do such thing.
1642 */ 1644 */
1643 if (skb_shinfo(skb)->destructor_arg) { 1645 if (skb_shinfo(skb)->destructor_arg) {
1644 skb_shinfo(skb)->tx_flags |= SKBTX_DEV_ZEROCOPY; 1646 xenvif_skb_zerocopy_prepare(queue, skb);
1645 queue->stats.tx_zerocopy_sent++; 1647 queue->stats.tx_zerocopy_sent++;
1646 } 1648 }
1647 1649
@@ -1681,6 +1683,7 @@ void xenvif_zerocopy_callback(struct ubuf_info *ubuf, bool zerocopy_success)
1681 queue->stats.tx_zerocopy_success++; 1683 queue->stats.tx_zerocopy_success++;
1682 else 1684 else
1683 queue->stats.tx_zerocopy_fail++; 1685 queue->stats.tx_zerocopy_fail++;
1686 xenvif_skb_zerocopy_complete(queue);
1684} 1687}
1685 1688
1686static inline void xenvif_tx_dealloc_action(struct xenvif_queue *queue) 1689static inline void xenvif_tx_dealloc_action(struct xenvif_queue *queue)
@@ -2025,9 +2028,15 @@ int xenvif_kthread_guest_rx(void *data)
2025 * context so we defer it here, if this thread is 2028 * context so we defer it here, if this thread is
2026 * associated with queue 0. 2029 * associated with queue 0.
2027 */ 2030 */
2028 if (unlikely(queue->vif->disabled && queue->id == 0)) 2031 if (unlikely(queue->vif->disabled && queue->id == 0)) {
2029 xenvif_carrier_off(queue->vif); 2032 xenvif_carrier_off(queue->vif);
2030 else if (unlikely(test_and_clear_bit(QUEUE_STATUS_RX_PURGE_EVENT, 2033 } else if (unlikely(queue->vif->disabled)) {
2034 /* kthread_stop() would be called upon this thread soon,
2035 * be a bit proactive
2036 */
2037 skb_queue_purge(&queue->rx_queue);
2038 queue->rx_last_skb_slots = 0;
2039 } else if (unlikely(test_and_clear_bit(QUEUE_STATUS_RX_PURGE_EVENT,
2031 &queue->status))) { 2040 &queue->status))) {
2032 xenvif_rx_purge_event(queue); 2041 xenvif_rx_purge_event(queue);
2033 } else if (!netif_carrier_ok(queue->vif->dev)) { 2042 } else if (!netif_carrier_ok(queue->vif->dev)) {
@@ -2052,15 +2061,24 @@ int xenvif_kthread_guest_rx(void *data)
2052 return 0; 2061 return 0;
2053} 2062}
2054 2063
2064static bool xenvif_dealloc_kthread_should_stop(struct xenvif_queue *queue)
2065{
2066 /* Dealloc thread must remain running until all inflight
2067 * packets complete.
2068 */
2069 return kthread_should_stop() &&
2070 !atomic_read(&queue->inflight_packets);
2071}
2072
2055int xenvif_dealloc_kthread(void *data) 2073int xenvif_dealloc_kthread(void *data)
2056{ 2074{
2057 struct xenvif_queue *queue = data; 2075 struct xenvif_queue *queue = data;
2058 2076
2059 while (!kthread_should_stop()) { 2077 for (;;) {
2060 wait_event_interruptible(queue->dealloc_wq, 2078 wait_event_interruptible(queue->dealloc_wq,
2061 tx_dealloc_work_todo(queue) || 2079 tx_dealloc_work_todo(queue) ||
2062 kthread_should_stop()); 2080 xenvif_dealloc_kthread_should_stop(queue));
2063 if (kthread_should_stop()) 2081 if (xenvif_dealloc_kthread_should_stop(queue))
2064 break; 2082 break;
2065 2083
2066 xenvif_tx_dealloc_action(queue); 2084 xenvif_tx_dealloc_action(queue);
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c
index 580517d857bf..9c47b897b6d2 100644
--- a/drivers/net/xen-netback/xenbus.c
+++ b/drivers/net/xen-netback/xenbus.c
@@ -116,6 +116,7 @@ static int xenvif_read_io_ring(struct seq_file *m, void *v)
116} 116}
117 117
118#define XENVIF_KICK_STR "kick" 118#define XENVIF_KICK_STR "kick"
119#define BUFFER_SIZE 32
119 120
120static ssize_t 121static ssize_t
121xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count, 122xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count,
@@ -124,22 +125,24 @@ xenvif_write_io_ring(struct file *filp, const char __user *buf, size_t count,
124 struct xenvif_queue *queue = 125 struct xenvif_queue *queue =
125 ((struct seq_file *)filp->private_data)->private; 126 ((struct seq_file *)filp->private_data)->private;
126 int len; 127 int len;
127 char write[sizeof(XENVIF_KICK_STR)]; 128 char write[BUFFER_SIZE];
128 129
129 /* don't allow partial writes and check the length */ 130 /* don't allow partial writes and check the length */
130 if (*ppos != 0) 131 if (*ppos != 0)
131 return 0; 132 return 0;
132 if (count < sizeof(XENVIF_KICK_STR) - 1) 133 if (count >= sizeof(write))
133 return -ENOSPC; 134 return -ENOSPC;
134 135
135 len = simple_write_to_buffer(write, 136 len = simple_write_to_buffer(write,
136 sizeof(write), 137 sizeof(write) - 1,
137 ppos, 138 ppos,
138 buf, 139 buf,
139 count); 140 count);
140 if (len < 0) 141 if (len < 0)
141 return len; 142 return len;
142 143
144 write[len] = '\0';
145
143 if (!strncmp(write, XENVIF_KICK_STR, sizeof(XENVIF_KICK_STR) - 1)) 146 if (!strncmp(write, XENVIF_KICK_STR, sizeof(XENVIF_KICK_STR) - 1))
144 xenvif_interrupt(0, (void *)queue); 147 xenvif_interrupt(0, (void *)queue);
145 else { 148 else {
@@ -171,10 +174,9 @@ static const struct file_operations xenvif_dbg_io_ring_ops_fops = {
171 .write = xenvif_write_io_ring, 174 .write = xenvif_write_io_ring,
172}; 175};
173 176
174static void xenvif_debugfs_addif(struct xenvif_queue *queue) 177static void xenvif_debugfs_addif(struct xenvif *vif)
175{ 178{
176 struct dentry *pfile; 179 struct dentry *pfile;
177 struct xenvif *vif = queue->vif;
178 int i; 180 int i;
179 181
180 if (IS_ERR_OR_NULL(xen_netback_dbg_root)) 182 if (IS_ERR_OR_NULL(xen_netback_dbg_root))
@@ -733,10 +735,11 @@ static void connect(struct backend_info *be)
733 be->vif->num_queues = queue_index; 735 be->vif->num_queues = queue_index;
734 goto err; 736 goto err;
735 } 737 }
738 }
739
736#ifdef CONFIG_DEBUG_FS 740#ifdef CONFIG_DEBUG_FS
737 xenvif_debugfs_addif(queue); 741 xenvif_debugfs_addif(be->vif);
738#endif /* CONFIG_DEBUG_FS */ 742#endif /* CONFIG_DEBUG_FS */
739 }
740 743
741 /* Initialisation completed, tell core driver the number of 744 /* Initialisation completed, tell core driver the number of
742 * active queues. 745 * active queues.
diff --git a/drivers/net/xen-netfront.c b/drivers/net/xen-netfront.c
index 28204bc4f369..ca82f545ec2c 100644
--- a/drivers/net/xen-netfront.c
+++ b/drivers/net/xen-netfront.c
@@ -628,9 +628,10 @@ static int xennet_start_xmit(struct sk_buff *skb, struct net_device *dev)
628 slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) + 628 slots = DIV_ROUND_UP(offset + len, PAGE_SIZE) +
629 xennet_count_skb_frag_slots(skb); 629 xennet_count_skb_frag_slots(skb);
630 if (unlikely(slots > MAX_SKB_FRAGS + 1)) { 630 if (unlikely(slots > MAX_SKB_FRAGS + 1)) {
631 net_alert_ratelimited( 631 net_dbg_ratelimited("xennet: skb rides the rocket: %d slots, %d bytes\n",
632 "xennet: skb rides the rocket: %d slots\n", slots); 632 slots, skb->len);
633 goto drop; 633 if (skb_linearize(skb))
634 goto drop;
634 } 635 }
635 636
636 spin_lock_irqsave(&queue->tx_lock, flags); 637 spin_lock_irqsave(&queue->tx_lock, flags);