
This allows incrementing the correct timeout statistic without any mess. Down the road, devices can learn to reset just the specific queue. The patch was generated with the following script: use strict; use warnings; our $^I = '.bak'; my @work = ( ["arch/m68k/emu/nfeth.c", "nfeth_tx_timeout"], ["arch/um/drivers/net_kern.c", "uml_net_tx_timeout"], ["arch/um/drivers/vector_kern.c", "vector_net_tx_timeout"], ["arch/xtensa/platforms/iss/network.c", "iss_net_tx_timeout"], ["drivers/char/pcmcia/synclink_cs.c", "hdlcdev_tx_timeout"], ["drivers/infiniband/ulp/ipoib/ipoib_main.c", "ipoib_timeout"], ["drivers/infiniband/ulp/ipoib/ipoib_main.c", "ipoib_timeout"], ["drivers/message/fusion/mptlan.c", "mpt_lan_tx_timeout"], ["drivers/misc/sgi-xp/xpnet.c", "xpnet_dev_tx_timeout"], ["drivers/net/appletalk/cops.c", "cops_timeout"], ["drivers/net/arcnet/arcdevice.h", "arcnet_timeout"], ["drivers/net/arcnet/arcnet.c", "arcnet_timeout"], ["drivers/net/arcnet/com20020.c", "arcnet_timeout"], ["drivers/net/ethernet/3com/3c509.c", "el3_tx_timeout"], ["drivers/net/ethernet/3com/3c515.c", "corkscrew_timeout"], ["drivers/net/ethernet/3com/3c574_cs.c", "el3_tx_timeout"], ["drivers/net/ethernet/3com/3c589_cs.c", "el3_tx_timeout"], ["drivers/net/ethernet/3com/3c59x.c", "vortex_tx_timeout"], ["drivers/net/ethernet/3com/3c59x.c", "vortex_tx_timeout"], ["drivers/net/ethernet/3com/typhoon.c", "typhoon_tx_timeout"], ["drivers/net/ethernet/8390/8390.h", "ei_tx_timeout"], ["drivers/net/ethernet/8390/8390.h", "eip_tx_timeout"], ["drivers/net/ethernet/8390/8390.c", "ei_tx_timeout"], ["drivers/net/ethernet/8390/8390p.c", "eip_tx_timeout"], ["drivers/net/ethernet/8390/ax88796.c", "ax_ei_tx_timeout"], ["drivers/net/ethernet/8390/axnet_cs.c", "axnet_tx_timeout"], ["drivers/net/ethernet/8390/etherh.c", "__ei_tx_timeout"], ["drivers/net/ethernet/8390/hydra.c", "__ei_tx_timeout"], ["drivers/net/ethernet/8390/mac8390.c", "__ei_tx_timeout"], ["drivers/net/ethernet/8390/mcf8390.c", "__ei_tx_timeout"], ["drivers/net/ethernet/8390/lib8390.c", "__ei_tx_timeout"], ["drivers/net/ethernet/8390/ne2k-pci.c", "ei_tx_timeout"], ["drivers/net/ethernet/8390/pcnet_cs.c", "ei_tx_timeout"], ["drivers/net/ethernet/8390/smc-ultra.c", "ei_tx_timeout"], ["drivers/net/ethernet/8390/wd.c", "ei_tx_timeout"], ["drivers/net/ethernet/8390/zorro8390.c", "__ei_tx_timeout"], ["drivers/net/ethernet/adaptec/starfire.c", "tx_timeout"], ["drivers/net/ethernet/agere/et131x.c", "et131x_tx_timeout"], ["drivers/net/ethernet/allwinner/sun4i-emac.c", "emac_timeout"], ["drivers/net/ethernet/alteon/acenic.c", "ace_watchdog"], ["drivers/net/ethernet/amazon/ena/ena_netdev.c", "ena_tx_timeout"], ["drivers/net/ethernet/amd/7990.h", "lance_tx_timeout"], ["drivers/net/ethernet/amd/7990.c", "lance_tx_timeout"], ["drivers/net/ethernet/amd/a2065.c", "lance_tx_timeout"], ["drivers/net/ethernet/amd/am79c961a.c", "am79c961_timeout"], ["drivers/net/ethernet/amd/amd8111e.c", "amd8111e_tx_timeout"], ["drivers/net/ethernet/amd/ariadne.c", "ariadne_tx_timeout"], ["drivers/net/ethernet/amd/atarilance.c", "lance_tx_timeout"], ["drivers/net/ethernet/amd/au1000_eth.c", "au1000_tx_timeout"], ["drivers/net/ethernet/amd/declance.c", "lance_tx_timeout"], ["drivers/net/ethernet/amd/lance.c", "lance_tx_timeout"], ["drivers/net/ethernet/amd/mvme147.c", "lance_tx_timeout"], ["drivers/net/ethernet/amd/ni65.c", "ni65_timeout"], ["drivers/net/ethernet/amd/nmclan_cs.c", "mace_tx_timeout"], ["drivers/net/ethernet/amd/pcnet32.c", "pcnet32_tx_timeout"], ["drivers/net/ethernet/amd/sunlance.c", "lance_tx_timeout"], ["drivers/net/ethernet/amd/xgbe/xgbe-drv.c", "xgbe_tx_timeout"], ["drivers/net/ethernet/apm/xgene-v2/main.c", "xge_timeout"], ["drivers/net/ethernet/apm/xgene/xgene_enet_main.c", "xgene_enet_timeout"], ["drivers/net/ethernet/apple/macmace.c", "mace_tx_timeout"], ["drivers/net/ethernet/atheros/ag71xx.c", "ag71xx_tx_timeout"], ["drivers/net/ethernet/atheros/alx/main.c", "alx_tx_timeout"], ["drivers/net/ethernet/atheros/atl1c/atl1c_main.c", "atl1c_tx_timeout"], ["drivers/net/ethernet/atheros/atl1e/atl1e_main.c", "atl1e_tx_timeout"], ["drivers/net/ethernet/atheros/atlx/atl.c", "atlx_tx_timeout"], ["drivers/net/ethernet/atheros/atlx/atl1.c", "atlx_tx_timeout"], ["drivers/net/ethernet/atheros/atlx/atl2.c", "atl2_tx_timeout"], ["drivers/net/ethernet/broadcom/b44.c", "b44_tx_timeout"], ["drivers/net/ethernet/broadcom/bcmsysport.c", "bcm_sysport_tx_timeout"], ["drivers/net/ethernet/broadcom/bnx2.c", "bnx2_tx_timeout"], ["drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.h", "bnx2x_tx_timeout"], ["drivers/net/ethernet/broadcom/bnx2x/bnx2x_cmn.c", "bnx2x_tx_timeout"], ["drivers/net/ethernet/broadcom/bnx2x/bnx2x_main.c", "bnx2x_tx_timeout"], ["drivers/net/ethernet/broadcom/bnxt/bnxt.c", "bnxt_tx_timeout"], ["drivers/net/ethernet/broadcom/genet/bcmgenet.c", "bcmgenet_timeout"], ["drivers/net/ethernet/broadcom/sb1250-mac.c", "sbmac_tx_timeout"], ["drivers/net/ethernet/broadcom/tg3.c", "tg3_tx_timeout"], ["drivers/net/ethernet/calxeda/xgmac.c", "xgmac_tx_timeout"], ["drivers/net/ethernet/cavium/liquidio/lio_main.c", "liquidio_tx_timeout"], ["drivers/net/ethernet/cavium/liquidio/lio_vf_main.c", "liquidio_tx_timeout"], ["drivers/net/ethernet/cavium/liquidio/lio_vf_rep.c", "lio_vf_rep_tx_timeout"], ["drivers/net/ethernet/cavium/thunder/nicvf_main.c", "nicvf_tx_timeout"], ["drivers/net/ethernet/cirrus/cs89x0.c", "net_timeout"], ["drivers/net/ethernet/cisco/enic/enic_main.c", "enic_tx_timeout"], ["drivers/net/ethernet/cisco/enic/enic_main.c", "enic_tx_timeout"], ["drivers/net/ethernet/cortina/gemini.c", "gmac_tx_timeout"], ["drivers/net/ethernet/davicom/dm9000.c", "dm9000_timeout"], ["drivers/net/ethernet/dec/tulip/de2104x.c", "de_tx_timeout"], ["drivers/net/ethernet/dec/tulip/tulip_core.c", "tulip_tx_timeout"], ["drivers/net/ethernet/dec/tulip/winbond-840.c", "tx_timeout"], ["drivers/net/ethernet/dlink/dl2k.c", "rio_tx_timeout"], ["drivers/net/ethernet/dlink/sundance.c", "tx_timeout"], ["drivers/net/ethernet/emulex/benet/be_main.c", "be_tx_timeout"], ["drivers/net/ethernet/ethoc.c", "ethoc_tx_timeout"], ["drivers/net/ethernet/faraday/ftgmac100.c", "ftgmac100_tx_timeout"], ["drivers/net/ethernet/fealnx.c", "fealnx_tx_timeout"], ["drivers/net/ethernet/freescale/dpaa/dpaa_eth.c", "dpaa_tx_timeout"], ["drivers/net/ethernet/freescale/fec_main.c", "fec_timeout"], ["drivers/net/ethernet/freescale/fec_mpc52xx.c", "mpc52xx_fec_tx_timeout"], ["drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c", "fs_timeout"], ["drivers/net/ethernet/freescale/gianfar.c", "gfar_timeout"], ["drivers/net/ethernet/freescale/ucc_geth.c", "ucc_geth_timeout"], ["drivers/net/ethernet/fujitsu/fmvj18x_cs.c", "fjn_tx_timeout"], ["drivers/net/ethernet/google/gve/gve_main.c", "gve_tx_timeout"], ["drivers/net/ethernet/hisilicon/hip04_eth.c", "hip04_timeout"], ["drivers/net/ethernet/hisilicon/hix5hd2_gmac.c", "hix5hd2_net_timeout"], ["drivers/net/ethernet/hisilicon/hns/hns_enet.c", "hns_nic_net_timeout"], ["drivers/net/ethernet/hisilicon/hns3/hns3_enet.c", "hns3_nic_net_timeout"], ["drivers/net/ethernet/huawei/hinic/hinic_main.c", "hinic_tx_timeout"], ["drivers/net/ethernet/i825xx/82596.c", "i596_tx_timeout"], ["drivers/net/ethernet/i825xx/ether1.c", "ether1_timeout"], ["drivers/net/ethernet/i825xx/lib82596.c", "i596_tx_timeout"], ["drivers/net/ethernet/i825xx/sun3_82586.c", "sun3_82586_timeout"], ["drivers/net/ethernet/ibm/ehea/ehea_main.c", "ehea_tx_watchdog"], ["drivers/net/ethernet/ibm/emac/core.c", "emac_tx_timeout"], ["drivers/net/ethernet/ibm/emac/core.c", "emac_tx_timeout"], ["drivers/net/ethernet/ibm/ibmvnic.c", "ibmvnic_tx_timeout"], ["drivers/net/ethernet/intel/e100.c", "e100_tx_timeout"], ["drivers/net/ethernet/intel/e1000/e1000_main.c", "e1000_tx_timeout"], ["drivers/net/ethernet/intel/e1000e/netdev.c", "e1000_tx_timeout"], ["drivers/net/ethernet/intel/fm10k/fm10k_netdev.c", "fm10k_tx_timeout"], ["drivers/net/ethernet/intel/i40e/i40e_main.c", "i40e_tx_timeout"], ["drivers/net/ethernet/intel/iavf/iavf_main.c", "iavf_tx_timeout"], ["drivers/net/ethernet/intel/ice/ice_main.c", "ice_tx_timeout"], ["drivers/net/ethernet/intel/ice/ice_main.c", "ice_tx_timeout"], ["drivers/net/ethernet/intel/igb/igb_main.c", "igb_tx_timeout"], ["drivers/net/ethernet/intel/igbvf/netdev.c", "igbvf_tx_timeout"], ["drivers/net/ethernet/intel/ixgb/ixgb_main.c", "ixgb_tx_timeout"], ["drivers/net/ethernet/intel/ixgbe/ixgbe_debugfs.c", "adapter->netdev->netdev_ops->ndo_tx_timeout(adapter->netdev);"], ["drivers/net/ethernet/intel/ixgbe/ixgbe_main.c", "ixgbe_tx_timeout"], ["drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c", "ixgbevf_tx_timeout"], ["drivers/net/ethernet/jme.c", "jme_tx_timeout"], ["drivers/net/ethernet/korina.c", "korina_tx_timeout"], ["drivers/net/ethernet/lantiq_etop.c", "ltq_etop_tx_timeout"], ["drivers/net/ethernet/marvell/mv643xx_eth.c", "mv643xx_eth_tx_timeout"], ["drivers/net/ethernet/marvell/pxa168_eth.c", "pxa168_eth_tx_timeout"], ["drivers/net/ethernet/marvell/skge.c", "skge_tx_timeout"], ["drivers/net/ethernet/marvell/sky2.c", "sky2_tx_timeout"], ["drivers/net/ethernet/marvell/sky2.c", "sky2_tx_timeout"], ["drivers/net/ethernet/mediatek/mtk_eth_soc.c", "mtk_tx_timeout"], ["drivers/net/ethernet/mellanox/mlx4/en_netdev.c", "mlx4_en_tx_timeout"], ["drivers/net/ethernet/mellanox/mlx4/en_netdev.c", "mlx4_en_tx_timeout"], ["drivers/net/ethernet/mellanox/mlx5/core/en_main.c", "mlx5e_tx_timeout"], ["drivers/net/ethernet/micrel/ks8842.c", "ks8842_tx_timeout"], ["drivers/net/ethernet/micrel/ksz884x.c", "netdev_tx_timeout"], ["drivers/net/ethernet/microchip/enc28j60.c", "enc28j60_tx_timeout"], ["drivers/net/ethernet/microchip/encx24j600.c", "encx24j600_tx_timeout"], ["drivers/net/ethernet/natsemi/sonic.h", "sonic_tx_timeout"], ["drivers/net/ethernet/natsemi/sonic.c", "sonic_tx_timeout"], ["drivers/net/ethernet/natsemi/jazzsonic.c", "sonic_tx_timeout"], ["drivers/net/ethernet/natsemi/macsonic.c", "sonic_tx_timeout"], ["drivers/net/ethernet/natsemi/natsemi.c", "ns_tx_timeout"], ["drivers/net/ethernet/natsemi/ns83820.c", "ns83820_tx_timeout"], ["drivers/net/ethernet/natsemi/xtsonic.c", "sonic_tx_timeout"], ["drivers/net/ethernet/neterion/s2io.h", "s2io_tx_watchdog"], ["drivers/net/ethernet/neterion/s2io.c", "s2io_tx_watchdog"], ["drivers/net/ethernet/neterion/vxge/vxge-main.c", "vxge_tx_watchdog"], ["drivers/net/ethernet/netronome/nfp/nfp_net_common.c", "nfp_net_tx_timeout"], ["drivers/net/ethernet/nvidia/forcedeth.c", "nv_tx_timeout"], ["drivers/net/ethernet/nvidia/forcedeth.c", "nv_tx_timeout"], ["drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c", "pch_gbe_tx_timeout"], ["drivers/net/ethernet/packetengines/hamachi.c", "hamachi_tx_timeout"], ["drivers/net/ethernet/packetengines/yellowfin.c", "yellowfin_tx_timeout"], ["drivers/net/ethernet/pensando/ionic/ionic_lif.c", "ionic_tx_timeout"], ["drivers/net/ethernet/qlogic/netxen/netxen_nic_main.c", "netxen_tx_timeout"], ["drivers/net/ethernet/qlogic/qla3xxx.c", "ql3xxx_tx_timeout"], ["drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c", "qlcnic_tx_timeout"], ["drivers/net/ethernet/qualcomm/emac/emac.c", "emac_tx_timeout"], ["drivers/net/ethernet/qualcomm/qca_spi.c", "qcaspi_netdev_tx_timeout"], ["drivers/net/ethernet/qualcomm/qca_uart.c", "qcauart_netdev_tx_timeout"], ["drivers/net/ethernet/rdc/r6040.c", "r6040_tx_timeout"], ["drivers/net/ethernet/realtek/8139cp.c", "cp_tx_timeout"], ["drivers/net/ethernet/realtek/8139too.c", "rtl8139_tx_timeout"], ["drivers/net/ethernet/realtek/atp.c", "tx_timeout"], ["drivers/net/ethernet/realtek/r8169_main.c", "rtl8169_tx_timeout"], ["drivers/net/ethernet/renesas/ravb_main.c", "ravb_tx_timeout"], ["drivers/net/ethernet/renesas/sh_eth.c", "sh_eth_tx_timeout"], ["drivers/net/ethernet/renesas/sh_eth.c", "sh_eth_tx_timeout"], ["drivers/net/ethernet/samsung/sxgbe/sxgbe_main.c", "sxgbe_tx_timeout"], ["drivers/net/ethernet/seeq/ether3.c", "ether3_timeout"], ["drivers/net/ethernet/seeq/sgiseeq.c", "timeout"], ["drivers/net/ethernet/sfc/efx.c", "efx_watchdog"], ["drivers/net/ethernet/sfc/falcon/efx.c", "ef4_watchdog"], ["drivers/net/ethernet/sgi/ioc3-eth.c", "ioc3_timeout"], ["drivers/net/ethernet/sgi/meth.c", "meth_tx_timeout"], ["drivers/net/ethernet/silan/sc92031.c", "sc92031_tx_timeout"], ["drivers/net/ethernet/sis/sis190.c", "sis190_tx_timeout"], ["drivers/net/ethernet/sis/sis900.c", "sis900_tx_timeout"], ["drivers/net/ethernet/smsc/epic100.c", "epic_tx_timeout"], ["drivers/net/ethernet/smsc/smc911x.c", "smc911x_timeout"], ["drivers/net/ethernet/smsc/smc9194.c", "smc_timeout"], ["drivers/net/ethernet/smsc/smc91c92_cs.c", "smc_tx_timeout"], ["drivers/net/ethernet/smsc/smc91x.c", "smc_timeout"], ["drivers/net/ethernet/stmicro/stmmac/stmmac_main.c", "stmmac_tx_timeout"], ["drivers/net/ethernet/sun/cassini.c", "cas_tx_timeout"], ["drivers/net/ethernet/sun/ldmvsw.c", "sunvnet_tx_timeout_common"], ["drivers/net/ethernet/sun/niu.c", "niu_tx_timeout"], ["drivers/net/ethernet/sun/sunbmac.c", "bigmac_tx_timeout"], ["drivers/net/ethernet/sun/sungem.c", "gem_tx_timeout"], ["drivers/net/ethernet/sun/sunhme.c", "happy_meal_tx_timeout"], ["drivers/net/ethernet/sun/sunqe.c", "qe_tx_timeout"], ["drivers/net/ethernet/sun/sunvnet.c", "sunvnet_tx_timeout_common"], ["drivers/net/ethernet/sun/sunvnet_common.c", "sunvnet_tx_timeout_common"], ["drivers/net/ethernet/sun/sunvnet_common.h", "sunvnet_tx_timeout_common"], ["drivers/net/ethernet/synopsys/dwc-xlgmac-net.c", "xlgmac_tx_timeout"], ["drivers/net/ethernet/ti/cpmac.c", "cpmac_tx_timeout"], ["drivers/net/ethernet/ti/cpsw.c", "cpsw_ndo_tx_timeout"], ["drivers/net/ethernet/ti/cpsw_priv.c", "cpsw_ndo_tx_timeout"], ["drivers/net/ethernet/ti/cpsw_priv.h", "cpsw_ndo_tx_timeout"], ["drivers/net/ethernet/ti/davinci_emac.c", "emac_dev_tx_timeout"], ["drivers/net/ethernet/ti/netcp_core.c", "netcp_ndo_tx_timeout"], ["drivers/net/ethernet/ti/tlan.c", "tlan_tx_timeout"], ["drivers/net/ethernet/toshiba/ps3_gelic_net.h", "gelic_net_tx_timeout"], ["drivers/net/ethernet/toshiba/ps3_gelic_net.c", "gelic_net_tx_timeout"], ["drivers/net/ethernet/toshiba/ps3_gelic_wireless.c", "gelic_net_tx_timeout"], ["drivers/net/ethernet/toshiba/spider_net.c", "spider_net_tx_timeout"], ["drivers/net/ethernet/toshiba/tc35815.c", "tc35815_tx_timeout"], ["drivers/net/ethernet/via/via-rhine.c", "rhine_tx_timeout"], ["drivers/net/ethernet/wiznet/w5100.c", "w5100_tx_timeout"], ["drivers/net/ethernet/wiznet/w5300.c", "w5300_tx_timeout"], ["drivers/net/ethernet/xilinx/xilinx_emaclite.c", "xemaclite_tx_timeout"], ["drivers/net/ethernet/xircom/xirc2ps_cs.c", "xirc_tx_timeout"], ["drivers/net/fjes/fjes_main.c", "fjes_tx_retry"], ["drivers/net/slip/slip.c", "sl_tx_timeout"], ["include/linux/usb/usbnet.h", "usbnet_tx_timeout"], ["drivers/net/usb/aqc111.c", "usbnet_tx_timeout"], ["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"], ["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"], ["drivers/net/usb/asix_devices.c", "usbnet_tx_timeout"], ["drivers/net/usb/ax88172a.c", "usbnet_tx_timeout"], ["drivers/net/usb/ax88179_178a.c", "usbnet_tx_timeout"], ["drivers/net/usb/catc.c", "catc_tx_timeout"], ["drivers/net/usb/cdc_mbim.c", "usbnet_tx_timeout"], ["drivers/net/usb/cdc_ncm.c", "usbnet_tx_timeout"], ["drivers/net/usb/dm9601.c", "usbnet_tx_timeout"], ["drivers/net/usb/hso.c", "hso_net_tx_timeout"], ["drivers/net/usb/int51x1.c", "usbnet_tx_timeout"], ["drivers/net/usb/ipheth.c", "ipheth_tx_timeout"], ["drivers/net/usb/kaweth.c", "kaweth_tx_timeout"], ["drivers/net/usb/lan78xx.c", "lan78xx_tx_timeout"], ["drivers/net/usb/mcs7830.c", "usbnet_tx_timeout"], ["drivers/net/usb/pegasus.c", "pegasus_tx_timeout"], ["drivers/net/usb/qmi_wwan.c", "usbnet_tx_timeout"], ["drivers/net/usb/r8152.c", "rtl8152_tx_timeout"], ["drivers/net/usb/rndis_host.c", "usbnet_tx_timeout"], ["drivers/net/usb/rtl8150.c", "rtl8150_tx_timeout"], ["drivers/net/usb/sierra_net.c", "usbnet_tx_timeout"], ["drivers/net/usb/smsc75xx.c", "usbnet_tx_timeout"], ["drivers/net/usb/smsc95xx.c", "usbnet_tx_timeout"], ["drivers/net/usb/sr9700.c", "usbnet_tx_timeout"], ["drivers/net/usb/sr9800.c", "usbnet_tx_timeout"], ["drivers/net/usb/usbnet.c", "usbnet_tx_timeout"], ["drivers/net/vmxnet3/vmxnet3_drv.c", "vmxnet3_tx_timeout"], ["drivers/net/wan/cosa.c", "cosa_net_timeout"], ["drivers/net/wan/farsync.c", "fst_tx_timeout"], ["drivers/net/wan/fsl_ucc_hdlc.c", "uhdlc_tx_timeout"], ["drivers/net/wan/lmc/lmc_main.c", "lmc_driver_timeout"], ["drivers/net/wan/x25_asy.c", "x25_asy_timeout"], ["drivers/net/wimax/i2400m/netdev.c", "i2400m_tx_timeout"], ["drivers/net/wireless/intel/ipw2x00/ipw2100.c", "ipw2100_tx_timeout"], ["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"], ["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"], ["drivers/net/wireless/intersil/hostap/hostap_main.c", "prism2_tx_timeout"], ["drivers/net/wireless/intersil/orinoco/main.c", "orinoco_tx_timeout"], ["drivers/net/wireless/intersil/orinoco/orinoco_usb.c", "orinoco_tx_timeout"], ["drivers/net/wireless/intersil/orinoco/orinoco.h", "orinoco_tx_timeout"], ["drivers/net/wireless/intersil/prism54/islpci_dev.c", "islpci_eth_tx_timeout"], ["drivers/net/wireless/intersil/prism54/islpci_eth.c", "islpci_eth_tx_timeout"], ["drivers/net/wireless/intersil/prism54/islpci_eth.h", "islpci_eth_tx_timeout"], ["drivers/net/wireless/marvell/mwifiex/main.c", "mwifiex_tx_timeout"], ["drivers/net/wireless/quantenna/qtnfmac/core.c", "qtnf_netdev_tx_timeout"], ["drivers/net/wireless/quantenna/qtnfmac/core.h", "qtnf_netdev_tx_timeout"], ["drivers/net/wireless/rndis_wlan.c", "usbnet_tx_timeout"], ["drivers/net/wireless/wl3501_cs.c", "wl3501_tx_timeout"], ["drivers/net/wireless/zydas/zd1201.c", "zd1201_tx_timeout"], ["drivers/s390/net/qeth_core.h", "qeth_tx_timeout"], ["drivers/s390/net/qeth_core_main.c", "qeth_tx_timeout"], ["drivers/s390/net/qeth_l2_main.c", "qeth_tx_timeout"], ["drivers/s390/net/qeth_l2_main.c", "qeth_tx_timeout"], ["drivers/s390/net/qeth_l3_main.c", "qeth_tx_timeout"], ["drivers/s390/net/qeth_l3_main.c", "qeth_tx_timeout"], ["drivers/staging/ks7010/ks_wlan_net.c", "ks_wlan_tx_timeout"], ["drivers/staging/qlge/qlge_main.c", "qlge_tx_timeout"], ["drivers/staging/rtl8192e/rtl8192e/rtl_core.c", "_rtl92e_tx_timeout"], ["drivers/staging/rtl8192u/r8192U_core.c", "tx_timeout"], ["drivers/staging/unisys/visornic/visornic_main.c", "visornic_xmit_timeout"], ["drivers/staging/wlan-ng/p80211netdev.c", "p80211knetdev_tx_timeout"], ["drivers/tty/n_gsm.c", "gsm_mux_net_tx_timeout"], ["drivers/tty/synclink.c", "hdlcdev_tx_timeout"], ["drivers/tty/synclink_gt.c", "hdlcdev_tx_timeout"], ["drivers/tty/synclinkmp.c", "hdlcdev_tx_timeout"], ["net/atm/lec.c", "lec_tx_timeout"], ["net/bluetooth/bnep/netdev.c", "bnep_net_timeout"] ); for my $p (@work) { my @pair = @$p; my $file = $pair[0]; my $func = $pair[1]; print STDERR $file , ": ", $func,"\n"; our @ARGV = ($file); while (<ARGV>) { if (m/($func\s*\(struct\s+net_device\s+\*[A-Za-z_]?[A-Za-z-0-9_]*)(\))/) { print STDERR "found $1+$2 in $file\n"; } if (s/($func\s*\(struct\s+net_device\s+\*[A-Za-z_]?[A-Za-z-0-9_]*)(\))/$1, unsigned int txqueue$2/) { print STDERR "$func found in $file\n"; } print; } } where the list of files and functions is simply from: git grep ndo_tx_timeout, with manual addition of headers in the rare cases where the function is from a header, then manually changing the few places which actually call ndo_tx_timeout. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Acked-by: Heiner Kallweit <hkallweit1@gmail.com> Acked-by: Jakub Kicinski <jakub.kicinski@netronome.com> Acked-by: Shannon Nelson <snelson@pensando.io> Reviewed-by: Martin Habets <mhabets@solarflare.com> changes from v9: fixup a forward declaration changes from v9: more leftovers from v3 change changes from v8: fix up a missing direct call to timeout rebased on net-next changes from v7: fixup leftovers from v3 change changes from v6: fix typo in rtl driver changes from v5: add missing files (allow any net device argument name) changes from v4: add a missing driver header changes from v3: change queue # to unsigned Changes from v2: added headers Changes from v1: Fix errors found by kbuild: generalize the pattern a bit, to pick up a couple of instances missed by the previous version. Signed-off-by: David S. Miller <davem@davemloft.net>
968 lines
25 KiB
C
968 lines
25 KiB
C
/* ======================================================================
|
|
*
|
|
* A PCMCIA ethernet driver for the 3com 3c589 card.
|
|
*
|
|
* Copyright (C) 1999 David A. Hinds -- dahinds@users.sourceforge.net
|
|
*
|
|
* 3c589_cs.c 1.162 2001/10/13 00:08:50
|
|
*
|
|
* The network driver code is based on Donald Becker's 3c589 code:
|
|
*
|
|
* Written 1994 by Donald Becker.
|
|
* Copyright 1993 United States Government as represented by the
|
|
* Director, National Security Agency. This software may be used and
|
|
* distributed according to the terms of the GNU General Public License,
|
|
* incorporated herein by reference.
|
|
* Donald Becker may be reached at becker@scyld.com
|
|
*
|
|
* Updated for 2.5.x by Alan Cox <alan@lxorguk.ukuu.org.uk>
|
|
*
|
|
* ======================================================================
|
|
*/
|
|
|
|
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
|
|
|
#define DRV_NAME "3c589_cs"
|
|
#define DRV_VERSION "1.162-ac"
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/ptrace.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/string.h>
|
|
#include <linux/timer.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/in.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/ethtool.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/etherdevice.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/if_arp.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/jiffies.h>
|
|
#include <linux/uaccess.h>
|
|
#include <linux/io.h>
|
|
|
|
#include <pcmcia/cistpl.h>
|
|
#include <pcmcia/cisreg.h>
|
|
#include <pcmcia/ciscode.h>
|
|
#include <pcmcia/ds.h>
|
|
|
|
|
|
/* To minimize the size of the driver source I only define operating
|
|
* constants if they are used several times. You'll need the manual
|
|
* if you want to understand driver details.
|
|
*/
|
|
|
|
/* Offsets from base I/O address. */
|
|
#define EL3_DATA 0x00
|
|
#define EL3_TIMER 0x0a
|
|
#define EL3_CMD 0x0e
|
|
#define EL3_STATUS 0x0e
|
|
|
|
#define EEPROM_READ 0x0080
|
|
#define EEPROM_BUSY 0x8000
|
|
|
|
#define EL3WINDOW(win_num) outw(SelectWindow + (win_num), ioaddr + EL3_CMD)
|
|
|
|
/* The top five bits written to EL3_CMD are a command, the lower
|
|
* 11 bits are the parameter, if applicable.
|
|
*/
|
|
|
|
enum c509cmd {
|
|
TotalReset = 0<<11,
|
|
SelectWindow = 1<<11,
|
|
StartCoax = 2<<11,
|
|
RxDisable = 3<<11,
|
|
RxEnable = 4<<11,
|
|
RxReset = 5<<11,
|
|
RxDiscard = 8<<11,
|
|
TxEnable = 9<<11,
|
|
TxDisable = 10<<11,
|
|
TxReset = 11<<11,
|
|
FakeIntr = 12<<11,
|
|
AckIntr = 13<<11,
|
|
SetIntrEnb = 14<<11,
|
|
SetStatusEnb = 15<<11,
|
|
SetRxFilter = 16<<11,
|
|
SetRxThreshold = 17<<11,
|
|
SetTxThreshold = 18<<11,
|
|
SetTxStart = 19<<11,
|
|
StatsEnable = 21<<11,
|
|
StatsDisable = 22<<11,
|
|
StopCoax = 23<<11
|
|
};
|
|
|
|
enum c509status {
|
|
IntLatch = 0x0001,
|
|
AdapterFailure = 0x0002,
|
|
TxComplete = 0x0004,
|
|
TxAvailable = 0x0008,
|
|
RxComplete = 0x0010,
|
|
RxEarly = 0x0020,
|
|
IntReq = 0x0040,
|
|
StatsFull = 0x0080,
|
|
CmdBusy = 0x1000
|
|
};
|
|
|
|
/* The SetRxFilter command accepts the following classes: */
|
|
enum RxFilter {
|
|
RxStation = 1,
|
|
RxMulticast = 2,
|
|
RxBroadcast = 4,
|
|
RxProm = 8
|
|
};
|
|
|
|
/* Register window 1 offsets, the window used in normal operation. */
|
|
#define TX_FIFO 0x00
|
|
#define RX_FIFO 0x00
|
|
#define RX_STATUS 0x08
|
|
#define TX_STATUS 0x0B
|
|
#define TX_FREE 0x0C /* Remaining free bytes in Tx buffer. */
|
|
|
|
#define WN0_IRQ 0x08 /* Window 0: Set IRQ line in bits 12-15. */
|
|
#define WN4_MEDIA 0x0A /* Window 4: Various transcvr/media bits. */
|
|
#define MEDIA_TP 0x00C0 /* Enable link beat and jabber for 10baseT. */
|
|
#define MEDIA_LED 0x0001 /* Enable link light on 3C589E cards. */
|
|
|
|
/* Time in jiffies before concluding Tx hung */
|
|
#define TX_TIMEOUT ((400*HZ)/1000)
|
|
|
|
struct el3_private {
|
|
struct pcmcia_device *p_dev;
|
|
/* For transceiver monitoring */
|
|
struct timer_list media;
|
|
u16 media_status;
|
|
u16 fast_poll;
|
|
unsigned long last_irq;
|
|
spinlock_t lock;
|
|
};
|
|
|
|
static const char *if_names[] = { "auto", "10baseT", "10base2", "AUI" };
|
|
|
|
/*====================================================================*/
|
|
|
|
/* Module parameters */
|
|
|
|
MODULE_AUTHOR("David Hinds <dahinds@users.sourceforge.net>");
|
|
MODULE_DESCRIPTION("3Com 3c589 series PCMCIA ethernet driver");
|
|
MODULE_LICENSE("GPL");
|
|
|
|
#define INT_MODULE_PARM(n, v) static int n = v; module_param(n, int, 0)
|
|
|
|
/* Special hook for setting if_port when module is loaded */
|
|
INT_MODULE_PARM(if_port, 0);
|
|
|
|
|
|
/*====================================================================*/
|
|
|
|
static int tc589_config(struct pcmcia_device *link);
|
|
static void tc589_release(struct pcmcia_device *link);
|
|
|
|
static u16 read_eeprom(unsigned int ioaddr, int index);
|
|
static void tc589_reset(struct net_device *dev);
|
|
static void media_check(struct timer_list *t);
|
|
static int el3_config(struct net_device *dev, struct ifmap *map);
|
|
static int el3_open(struct net_device *dev);
|
|
static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
|
|
struct net_device *dev);
|
|
static irqreturn_t el3_interrupt(int irq, void *dev_id);
|
|
static void update_stats(struct net_device *dev);
|
|
static struct net_device_stats *el3_get_stats(struct net_device *dev);
|
|
static int el3_rx(struct net_device *dev);
|
|
static int el3_close(struct net_device *dev);
|
|
static void el3_tx_timeout(struct net_device *dev, unsigned int txqueue);
|
|
static void set_rx_mode(struct net_device *dev);
|
|
static void set_multicast_list(struct net_device *dev);
|
|
static const struct ethtool_ops netdev_ethtool_ops;
|
|
|
|
static void tc589_detach(struct pcmcia_device *p_dev);
|
|
|
|
static const struct net_device_ops el3_netdev_ops = {
|
|
.ndo_open = el3_open,
|
|
.ndo_stop = el3_close,
|
|
.ndo_start_xmit = el3_start_xmit,
|
|
.ndo_tx_timeout = el3_tx_timeout,
|
|
.ndo_set_config = el3_config,
|
|
.ndo_get_stats = el3_get_stats,
|
|
.ndo_set_rx_mode = set_multicast_list,
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
};
|
|
|
|
static int tc589_probe(struct pcmcia_device *link)
|
|
{
|
|
struct el3_private *lp;
|
|
struct net_device *dev;
|
|
|
|
dev_dbg(&link->dev, "3c589_attach()\n");
|
|
|
|
/* Create new ethernet device */
|
|
dev = alloc_etherdev(sizeof(struct el3_private));
|
|
if (!dev)
|
|
return -ENOMEM;
|
|
lp = netdev_priv(dev);
|
|
link->priv = dev;
|
|
lp->p_dev = link;
|
|
|
|
spin_lock_init(&lp->lock);
|
|
link->resource[0]->end = 16;
|
|
link->resource[0]->flags |= IO_DATA_PATH_WIDTH_16;
|
|
|
|
link->config_flags |= CONF_ENABLE_IRQ;
|
|
link->config_index = 1;
|
|
|
|
dev->netdev_ops = &el3_netdev_ops;
|
|
dev->watchdog_timeo = TX_TIMEOUT;
|
|
|
|
dev->ethtool_ops = &netdev_ethtool_ops;
|
|
|
|
return tc589_config(link);
|
|
}
|
|
|
|
static void tc589_detach(struct pcmcia_device *link)
|
|
{
|
|
struct net_device *dev = link->priv;
|
|
|
|
dev_dbg(&link->dev, "3c589_detach\n");
|
|
|
|
unregister_netdev(dev);
|
|
|
|
tc589_release(link);
|
|
|
|
free_netdev(dev);
|
|
} /* tc589_detach */
|
|
|
|
static int tc589_config(struct pcmcia_device *link)
|
|
{
|
|
struct net_device *dev = link->priv;
|
|
__be16 *phys_addr;
|
|
int ret, i, j, multi = 0, fifo;
|
|
unsigned int ioaddr;
|
|
static const char * const ram_split[] = {"5:3", "3:1", "1:1", "3:5"};
|
|
u8 *buf;
|
|
size_t len;
|
|
|
|
dev_dbg(&link->dev, "3c589_config\n");
|
|
|
|
phys_addr = (__be16 *)dev->dev_addr;
|
|
/* Is this a 3c562? */
|
|
if (link->manf_id != MANFID_3COM)
|
|
dev_info(&link->dev, "hmmm, is this really a 3Com card??\n");
|
|
multi = (link->card_id == PRODID_3COM_3C562);
|
|
|
|
link->io_lines = 16;
|
|
|
|
/* For the 3c562, the base address must be xx00-xx7f */
|
|
for (i = j = 0; j < 0x400; j += 0x10) {
|
|
if (multi && (j & 0x80))
|
|
continue;
|
|
link->resource[0]->start = j ^ 0x300;
|
|
i = pcmcia_request_io(link);
|
|
if (i == 0)
|
|
break;
|
|
}
|
|
if (i != 0)
|
|
goto failed;
|
|
|
|
ret = pcmcia_request_irq(link, el3_interrupt);
|
|
if (ret)
|
|
goto failed;
|
|
|
|
ret = pcmcia_enable_device(link);
|
|
if (ret)
|
|
goto failed;
|
|
|
|
dev->irq = link->irq;
|
|
dev->base_addr = link->resource[0]->start;
|
|
ioaddr = dev->base_addr;
|
|
EL3WINDOW(0);
|
|
|
|
/* The 3c589 has an extra EEPROM for configuration info, including
|
|
* the hardware address. The 3c562 puts the address in the CIS.
|
|
*/
|
|
len = pcmcia_get_tuple(link, 0x88, &buf);
|
|
if (buf && len >= 6) {
|
|
for (i = 0; i < 3; i++)
|
|
phys_addr[i] = htons(le16_to_cpu(buf[i*2]));
|
|
kfree(buf);
|
|
} else {
|
|
kfree(buf); /* 0 < len < 6 */
|
|
for (i = 0; i < 3; i++)
|
|
phys_addr[i] = htons(read_eeprom(ioaddr, i));
|
|
if (phys_addr[0] == htons(0x6060)) {
|
|
dev_err(&link->dev, "IO port conflict at 0x%03lx-0x%03lx\n",
|
|
dev->base_addr, dev->base_addr+15);
|
|
goto failed;
|
|
}
|
|
}
|
|
|
|
/* The address and resource configuration register aren't loaded from
|
|
* the EEPROM and *must* be set to 0 and IRQ3 for the PCMCIA version.
|
|
*/
|
|
|
|
outw(0x3f00, ioaddr + 8);
|
|
fifo = inl(ioaddr);
|
|
|
|
/* The if_port symbol can be set when the module is loaded */
|
|
if ((if_port >= 0) && (if_port <= 3))
|
|
dev->if_port = if_port;
|
|
else
|
|
dev_err(&link->dev, "invalid if_port requested\n");
|
|
|
|
SET_NETDEV_DEV(dev, &link->dev);
|
|
|
|
if (register_netdev(dev) != 0) {
|
|
dev_err(&link->dev, "register_netdev() failed\n");
|
|
goto failed;
|
|
}
|
|
|
|
netdev_info(dev, "3Com 3c%s, io %#3lx, irq %d, hw_addr %pM\n",
|
|
(multi ? "562" : "589"), dev->base_addr, dev->irq,
|
|
dev->dev_addr);
|
|
netdev_info(dev, " %dK FIFO split %s Rx:Tx, %s xcvr\n",
|
|
(fifo & 7) ? 32 : 8, ram_split[(fifo >> 16) & 3],
|
|
if_names[dev->if_port]);
|
|
return 0;
|
|
|
|
failed:
|
|
tc589_release(link);
|
|
return -ENODEV;
|
|
} /* tc589_config */
|
|
|
|
static void tc589_release(struct pcmcia_device *link)
|
|
{
|
|
pcmcia_disable_device(link);
|
|
}
|
|
|
|
static int tc589_suspend(struct pcmcia_device *link)
|
|
{
|
|
struct net_device *dev = link->priv;
|
|
|
|
if (link->open)
|
|
netif_device_detach(dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int tc589_resume(struct pcmcia_device *link)
|
|
{
|
|
struct net_device *dev = link->priv;
|
|
|
|
if (link->open) {
|
|
tc589_reset(dev);
|
|
netif_device_attach(dev);
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/*====================================================================*/
|
|
|
|
/* Use this for commands that may take time to finish */
|
|
|
|
static void tc589_wait_for_completion(struct net_device *dev, int cmd)
|
|
{
|
|
int i = 100;
|
|
outw(cmd, dev->base_addr + EL3_CMD);
|
|
while (--i > 0)
|
|
if (!(inw(dev->base_addr + EL3_STATUS) & 0x1000))
|
|
break;
|
|
if (i == 0)
|
|
netdev_warn(dev, "command 0x%04x did not complete!\n", cmd);
|
|
}
|
|
|
|
/* Read a word from the EEPROM using the regular EEPROM access register.
|
|
* Assume that we are in register window zero.
|
|
*/
|
|
|
|
static u16 read_eeprom(unsigned int ioaddr, int index)
|
|
{
|
|
int i;
|
|
outw(EEPROM_READ + index, ioaddr + 10);
|
|
/* Reading the eeprom takes 162 us */
|
|
for (i = 1620; i >= 0; i--)
|
|
if ((inw(ioaddr + 10) & EEPROM_BUSY) == 0)
|
|
break;
|
|
return inw(ioaddr + 12);
|
|
}
|
|
|
|
/* Set transceiver type, perhaps to something other than what the user
|
|
* specified in dev->if_port.
|
|
*/
|
|
|
|
static void tc589_set_xcvr(struct net_device *dev, int if_port)
|
|
{
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
unsigned int ioaddr = dev->base_addr;
|
|
|
|
EL3WINDOW(0);
|
|
switch (if_port) {
|
|
case 0:
|
|
case 1:
|
|
outw(0, ioaddr + 6);
|
|
break;
|
|
case 2:
|
|
outw(3<<14, ioaddr + 6);
|
|
break;
|
|
case 3:
|
|
outw(1<<14, ioaddr + 6);
|
|
break;
|
|
}
|
|
/* On PCMCIA, this just turns on the LED */
|
|
outw((if_port == 2) ? StartCoax : StopCoax, ioaddr + EL3_CMD);
|
|
/* 10baseT interface, enable link beat and jabber check. */
|
|
EL3WINDOW(4);
|
|
outw(MEDIA_LED | ((if_port < 2) ? MEDIA_TP : 0), ioaddr + WN4_MEDIA);
|
|
EL3WINDOW(1);
|
|
if (if_port == 2)
|
|
lp->media_status = ((dev->if_port == 0) ? 0x8000 : 0x4000);
|
|
else
|
|
lp->media_status = ((dev->if_port == 0) ? 0x4010 : 0x8800);
|
|
}
|
|
|
|
static void dump_status(struct net_device *dev)
|
|
{
|
|
unsigned int ioaddr = dev->base_addr;
|
|
EL3WINDOW(1);
|
|
netdev_info(dev, " irq status %04x, rx status %04x, tx status %02x tx free %04x\n",
|
|
inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS),
|
|
inb(ioaddr+TX_STATUS), inw(ioaddr+TX_FREE));
|
|
EL3WINDOW(4);
|
|
netdev_info(dev, " diagnostics: fifo %04x net %04x ethernet %04x media %04x\n",
|
|
inw(ioaddr+0x04), inw(ioaddr+0x06), inw(ioaddr+0x08),
|
|
inw(ioaddr+0x0a));
|
|
EL3WINDOW(1);
|
|
}
|
|
|
|
/* Reset and restore all of the 3c589 registers. */
|
|
static void tc589_reset(struct net_device *dev)
|
|
{
|
|
unsigned int ioaddr = dev->base_addr;
|
|
int i;
|
|
|
|
EL3WINDOW(0);
|
|
outw(0x0001, ioaddr + 4); /* Activate board. */
|
|
outw(0x3f00, ioaddr + 8); /* Set the IRQ line. */
|
|
|
|
/* Set the station address in window 2. */
|
|
EL3WINDOW(2);
|
|
for (i = 0; i < 6; i++)
|
|
outb(dev->dev_addr[i], ioaddr + i);
|
|
|
|
tc589_set_xcvr(dev, dev->if_port);
|
|
|
|
/* Switch to the stats window, and clear all stats by reading. */
|
|
outw(StatsDisable, ioaddr + EL3_CMD);
|
|
EL3WINDOW(6);
|
|
for (i = 0; i < 9; i++)
|
|
inb(ioaddr+i);
|
|
inw(ioaddr + 10);
|
|
inw(ioaddr + 12);
|
|
|
|
/* Switch to register set 1 for normal use. */
|
|
EL3WINDOW(1);
|
|
|
|
set_rx_mode(dev);
|
|
outw(StatsEnable, ioaddr + EL3_CMD); /* Turn on statistics. */
|
|
outw(RxEnable, ioaddr + EL3_CMD); /* Enable the receiver. */
|
|
outw(TxEnable, ioaddr + EL3_CMD); /* Enable transmitter. */
|
|
/* Allow status bits to be seen. */
|
|
outw(SetStatusEnb | 0xff, ioaddr + EL3_CMD);
|
|
/* Ack all pending events, and set active indicator mask. */
|
|
outw(AckIntr | IntLatch | TxAvailable | RxEarly | IntReq,
|
|
ioaddr + EL3_CMD);
|
|
outw(SetIntrEnb | IntLatch | TxAvailable | RxComplete | StatsFull
|
|
| AdapterFailure, ioaddr + EL3_CMD);
|
|
}
|
|
|
|
static void netdev_get_drvinfo(struct net_device *dev,
|
|
struct ethtool_drvinfo *info)
|
|
{
|
|
strlcpy(info->driver, DRV_NAME, sizeof(info->driver));
|
|
strlcpy(info->version, DRV_VERSION, sizeof(info->version));
|
|
snprintf(info->bus_info, sizeof(info->bus_info),
|
|
"PCMCIA 0x%lx", dev->base_addr);
|
|
}
|
|
|
|
static const struct ethtool_ops netdev_ethtool_ops = {
|
|
.get_drvinfo = netdev_get_drvinfo,
|
|
};
|
|
|
|
static int el3_config(struct net_device *dev, struct ifmap *map)
|
|
{
|
|
if ((map->port != (u_char)(-1)) && (map->port != dev->if_port)) {
|
|
if (map->port <= 3) {
|
|
dev->if_port = map->port;
|
|
netdev_info(dev, "switched to %s port\n", if_names[dev->if_port]);
|
|
tc589_set_xcvr(dev, dev->if_port);
|
|
} else {
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
static int el3_open(struct net_device *dev)
|
|
{
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
struct pcmcia_device *link = lp->p_dev;
|
|
|
|
if (!pcmcia_dev_present(link))
|
|
return -ENODEV;
|
|
|
|
link->open++;
|
|
netif_start_queue(dev);
|
|
|
|
tc589_reset(dev);
|
|
timer_setup(&lp->media, media_check, 0);
|
|
mod_timer(&lp->media, jiffies + HZ);
|
|
|
|
dev_dbg(&link->dev, "%s: opened, status %4.4x.\n",
|
|
dev->name, inw(dev->base_addr + EL3_STATUS));
|
|
|
|
return 0;
|
|
}
|
|
|
|
static void el3_tx_timeout(struct net_device *dev, unsigned int txqueue)
|
|
{
|
|
unsigned int ioaddr = dev->base_addr;
|
|
|
|
netdev_warn(dev, "Transmit timed out!\n");
|
|
dump_status(dev);
|
|
dev->stats.tx_errors++;
|
|
netif_trans_update(dev); /* prevent tx timeout */
|
|
/* Issue TX_RESET and TX_START commands. */
|
|
tc589_wait_for_completion(dev, TxReset);
|
|
outw(TxEnable, ioaddr + EL3_CMD);
|
|
netif_wake_queue(dev);
|
|
}
|
|
|
|
static void pop_tx_status(struct net_device *dev)
|
|
{
|
|
unsigned int ioaddr = dev->base_addr;
|
|
int i;
|
|
|
|
/* Clear the Tx status stack. */
|
|
for (i = 32; i > 0; i--) {
|
|
u_char tx_status = inb(ioaddr + TX_STATUS);
|
|
if (!(tx_status & 0x84))
|
|
break;
|
|
/* reset transmitter on jabber error or underrun */
|
|
if (tx_status & 0x30)
|
|
tc589_wait_for_completion(dev, TxReset);
|
|
if (tx_status & 0x38) {
|
|
netdev_dbg(dev, "transmit error: status 0x%02x\n", tx_status);
|
|
outw(TxEnable, ioaddr + EL3_CMD);
|
|
dev->stats.tx_aborted_errors++;
|
|
}
|
|
outb(0x00, ioaddr + TX_STATUS); /* Pop the status stack. */
|
|
}
|
|
}
|
|
|
|
static netdev_tx_t el3_start_xmit(struct sk_buff *skb,
|
|
struct net_device *dev)
|
|
{
|
|
unsigned int ioaddr = dev->base_addr;
|
|
struct el3_private *priv = netdev_priv(dev);
|
|
unsigned long flags;
|
|
|
|
netdev_dbg(dev, "el3_start_xmit(length = %ld) called, status %4.4x.\n",
|
|
(long)skb->len, inw(ioaddr + EL3_STATUS));
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
|
|
dev->stats.tx_bytes += skb->len;
|
|
|
|
/* Put out the doubleword header... */
|
|
outw(skb->len, ioaddr + TX_FIFO);
|
|
outw(0x00, ioaddr + TX_FIFO);
|
|
/* ... and the packet rounded to a doubleword. */
|
|
outsl(ioaddr + TX_FIFO, skb->data, (skb->len + 3) >> 2);
|
|
|
|
if (inw(ioaddr + TX_FREE) <= 1536) {
|
|
netif_stop_queue(dev);
|
|
/* Interrupt us when the FIFO has room for max-sized packet. */
|
|
outw(SetTxThreshold + 1536, ioaddr + EL3_CMD);
|
|
}
|
|
|
|
pop_tx_status(dev);
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
dev_kfree_skb(skb);
|
|
|
|
return NETDEV_TX_OK;
|
|
}
|
|
|
|
/* The EL3 interrupt handler. */
|
|
static irqreturn_t el3_interrupt(int irq, void *dev_id)
|
|
{
|
|
struct net_device *dev = (struct net_device *) dev_id;
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
unsigned int ioaddr;
|
|
__u16 status;
|
|
int i = 0, handled = 1;
|
|
|
|
if (!netif_device_present(dev))
|
|
return IRQ_NONE;
|
|
|
|
ioaddr = dev->base_addr;
|
|
|
|
netdev_dbg(dev, "interrupt, status %4.4x.\n", inw(ioaddr + EL3_STATUS));
|
|
|
|
spin_lock(&lp->lock);
|
|
while ((status = inw(ioaddr + EL3_STATUS)) &
|
|
(IntLatch | RxComplete | StatsFull)) {
|
|
if ((status & 0xe000) != 0x2000) {
|
|
netdev_dbg(dev, "interrupt from dead card\n");
|
|
handled = 0;
|
|
break;
|
|
}
|
|
if (status & RxComplete)
|
|
el3_rx(dev);
|
|
if (status & TxAvailable) {
|
|
netdev_dbg(dev, " TX room bit was handled.\n");
|
|
/* There's room in the FIFO for a full-sized packet. */
|
|
outw(AckIntr | TxAvailable, ioaddr + EL3_CMD);
|
|
netif_wake_queue(dev);
|
|
}
|
|
if (status & TxComplete)
|
|
pop_tx_status(dev);
|
|
if (status & (AdapterFailure | RxEarly | StatsFull)) {
|
|
/* Handle all uncommon interrupts. */
|
|
if (status & StatsFull) /* Empty statistics. */
|
|
update_stats(dev);
|
|
if (status & RxEarly) {
|
|
/* Rx early is unused. */
|
|
el3_rx(dev);
|
|
outw(AckIntr | RxEarly, ioaddr + EL3_CMD);
|
|
}
|
|
if (status & AdapterFailure) {
|
|
u16 fifo_diag;
|
|
EL3WINDOW(4);
|
|
fifo_diag = inw(ioaddr + 4);
|
|
EL3WINDOW(1);
|
|
netdev_warn(dev, "adapter failure, FIFO diagnostic register %04x.\n",
|
|
fifo_diag);
|
|
if (fifo_diag & 0x0400) {
|
|
/* Tx overrun */
|
|
tc589_wait_for_completion(dev, TxReset);
|
|
outw(TxEnable, ioaddr + EL3_CMD);
|
|
}
|
|
if (fifo_diag & 0x2000) {
|
|
/* Rx underrun */
|
|
tc589_wait_for_completion(dev, RxReset);
|
|
set_rx_mode(dev);
|
|
outw(RxEnable, ioaddr + EL3_CMD);
|
|
}
|
|
outw(AckIntr | AdapterFailure, ioaddr + EL3_CMD);
|
|
}
|
|
}
|
|
if (++i > 10) {
|
|
netdev_err(dev, "infinite loop in interrupt, status %4.4x.\n",
|
|
status);
|
|
/* Clear all interrupts */
|
|
outw(AckIntr | 0xFF, ioaddr + EL3_CMD);
|
|
break;
|
|
}
|
|
/* Acknowledge the IRQ. */
|
|
outw(AckIntr | IntReq | IntLatch, ioaddr + EL3_CMD);
|
|
}
|
|
lp->last_irq = jiffies;
|
|
spin_unlock(&lp->lock);
|
|
netdev_dbg(dev, "exiting interrupt, status %4.4x.\n",
|
|
inw(ioaddr + EL3_STATUS));
|
|
return IRQ_RETVAL(handled);
|
|
}
|
|
|
|
static void media_check(struct timer_list *t)
|
|
{
|
|
struct el3_private *lp = from_timer(lp, t, media);
|
|
struct net_device *dev = lp->p_dev->priv;
|
|
unsigned int ioaddr = dev->base_addr;
|
|
u16 media, errs;
|
|
unsigned long flags;
|
|
|
|
if (!netif_device_present(dev))
|
|
goto reschedule;
|
|
|
|
/* Check for pending interrupt with expired latency timer: with
|
|
* this, we can limp along even if the interrupt is blocked
|
|
*/
|
|
if ((inw(ioaddr + EL3_STATUS) & IntLatch) &&
|
|
(inb(ioaddr + EL3_TIMER) == 0xff)) {
|
|
if (!lp->fast_poll)
|
|
netdev_warn(dev, "interrupt(s) dropped!\n");
|
|
|
|
local_irq_save(flags);
|
|
el3_interrupt(dev->irq, dev);
|
|
local_irq_restore(flags);
|
|
|
|
lp->fast_poll = HZ;
|
|
}
|
|
if (lp->fast_poll) {
|
|
lp->fast_poll--;
|
|
lp->media.expires = jiffies + HZ/100;
|
|
add_timer(&lp->media);
|
|
return;
|
|
}
|
|
|
|
/* lp->lock guards the EL3 window. Window should always be 1 except
|
|
* when the lock is held
|
|
*/
|
|
|
|
spin_lock_irqsave(&lp->lock, flags);
|
|
EL3WINDOW(4);
|
|
media = inw(ioaddr+WN4_MEDIA) & 0xc810;
|
|
|
|
/* Ignore collisions unless we've had no irq's recently */
|
|
if (time_before(jiffies, lp->last_irq + HZ)) {
|
|
media &= ~0x0010;
|
|
} else {
|
|
/* Try harder to detect carrier errors */
|
|
EL3WINDOW(6);
|
|
outw(StatsDisable, ioaddr + EL3_CMD);
|
|
errs = inb(ioaddr + 0);
|
|
outw(StatsEnable, ioaddr + EL3_CMD);
|
|
dev->stats.tx_carrier_errors += errs;
|
|
if (errs || (lp->media_status & 0x0010))
|
|
media |= 0x0010;
|
|
}
|
|
|
|
if (media != lp->media_status) {
|
|
if ((media & lp->media_status & 0x8000) &&
|
|
((lp->media_status ^ media) & 0x0800))
|
|
netdev_info(dev, "%s link beat\n",
|
|
(lp->media_status & 0x0800 ? "lost" : "found"));
|
|
else if ((media & lp->media_status & 0x4000) &&
|
|
((lp->media_status ^ media) & 0x0010))
|
|
netdev_info(dev, "coax cable %s\n",
|
|
(lp->media_status & 0x0010 ? "ok" : "problem"));
|
|
if (dev->if_port == 0) {
|
|
if (media & 0x8000) {
|
|
if (media & 0x0800)
|
|
netdev_info(dev, "flipped to 10baseT\n");
|
|
else
|
|
tc589_set_xcvr(dev, 2);
|
|
} else if (media & 0x4000) {
|
|
if (media & 0x0010)
|
|
tc589_set_xcvr(dev, 1);
|
|
else
|
|
netdev_info(dev, "flipped to 10base2\n");
|
|
}
|
|
}
|
|
lp->media_status = media;
|
|
}
|
|
|
|
EL3WINDOW(1);
|
|
spin_unlock_irqrestore(&lp->lock, flags);
|
|
|
|
reschedule:
|
|
lp->media.expires = jiffies + HZ;
|
|
add_timer(&lp->media);
|
|
}
|
|
|
|
static struct net_device_stats *el3_get_stats(struct net_device *dev)
|
|
{
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
unsigned long flags;
|
|
struct pcmcia_device *link = lp->p_dev;
|
|
|
|
if (pcmcia_dev_present(link)) {
|
|
spin_lock_irqsave(&lp->lock, flags);
|
|
update_stats(dev);
|
|
spin_unlock_irqrestore(&lp->lock, flags);
|
|
}
|
|
return &dev->stats;
|
|
}
|
|
|
|
/* Update statistics. We change to register window 6, so this should be run
|
|
* single-threaded if the device is active. This is expected to be a rare
|
|
* operation, and it's simpler for the rest of the driver to assume that
|
|
* window 1 is always valid rather than use a special window-state variable.
|
|
*
|
|
* Caller must hold the lock for this
|
|
*/
|
|
|
|
static void update_stats(struct net_device *dev)
|
|
{
|
|
unsigned int ioaddr = dev->base_addr;
|
|
|
|
netdev_dbg(dev, "updating the statistics.\n");
|
|
/* Turn off statistics updates while reading. */
|
|
outw(StatsDisable, ioaddr + EL3_CMD);
|
|
/* Switch to the stats window, and read everything. */
|
|
EL3WINDOW(6);
|
|
dev->stats.tx_carrier_errors += inb(ioaddr + 0);
|
|
dev->stats.tx_heartbeat_errors += inb(ioaddr + 1);
|
|
/* Multiple collisions. */
|
|
inb(ioaddr + 2);
|
|
dev->stats.collisions += inb(ioaddr + 3);
|
|
dev->stats.tx_window_errors += inb(ioaddr + 4);
|
|
dev->stats.rx_fifo_errors += inb(ioaddr + 5);
|
|
dev->stats.tx_packets += inb(ioaddr + 6);
|
|
/* Rx packets */
|
|
inb(ioaddr + 7);
|
|
/* Tx deferrals */
|
|
inb(ioaddr + 8);
|
|
/* Rx octets */
|
|
inw(ioaddr + 10);
|
|
/* Tx octets */
|
|
inw(ioaddr + 12);
|
|
|
|
/* Back to window 1, and turn statistics back on. */
|
|
EL3WINDOW(1);
|
|
outw(StatsEnable, ioaddr + EL3_CMD);
|
|
}
|
|
|
|
static int el3_rx(struct net_device *dev)
|
|
{
|
|
unsigned int ioaddr = dev->base_addr;
|
|
int worklimit = 32;
|
|
short rx_status;
|
|
|
|
netdev_dbg(dev, "in rx_packet(), status %4.4x, rx_status %4.4x.\n",
|
|
inw(ioaddr+EL3_STATUS), inw(ioaddr+RX_STATUS));
|
|
while (!((rx_status = inw(ioaddr + RX_STATUS)) & 0x8000) &&
|
|
worklimit > 0) {
|
|
worklimit--;
|
|
if (rx_status & 0x4000) { /* Error, update stats. */
|
|
short error = rx_status & 0x3800;
|
|
dev->stats.rx_errors++;
|
|
switch (error) {
|
|
case 0x0000:
|
|
dev->stats.rx_over_errors++;
|
|
break;
|
|
case 0x0800:
|
|
dev->stats.rx_length_errors++;
|
|
break;
|
|
case 0x1000:
|
|
dev->stats.rx_frame_errors++;
|
|
break;
|
|
case 0x1800:
|
|
dev->stats.rx_length_errors++;
|
|
break;
|
|
case 0x2000:
|
|
dev->stats.rx_frame_errors++;
|
|
break;
|
|
case 0x2800:
|
|
dev->stats.rx_crc_errors++;
|
|
break;
|
|
}
|
|
} else {
|
|
short pkt_len = rx_status & 0x7ff;
|
|
struct sk_buff *skb;
|
|
|
|
skb = netdev_alloc_skb(dev, pkt_len + 5);
|
|
|
|
netdev_dbg(dev, " Receiving packet size %d status %4.4x.\n",
|
|
pkt_len, rx_status);
|
|
if (skb != NULL) {
|
|
skb_reserve(skb, 2);
|
|
insl(ioaddr+RX_FIFO, skb_put(skb, pkt_len),
|
|
(pkt_len+3)>>2);
|
|
skb->protocol = eth_type_trans(skb, dev);
|
|
netif_rx(skb);
|
|
dev->stats.rx_packets++;
|
|
dev->stats.rx_bytes += pkt_len;
|
|
} else {
|
|
netdev_dbg(dev, "couldn't allocate a sk_buff of size %d.\n",
|
|
pkt_len);
|
|
dev->stats.rx_dropped++;
|
|
}
|
|
}
|
|
/* Pop the top of the Rx FIFO */
|
|
tc589_wait_for_completion(dev, RxDiscard);
|
|
}
|
|
if (worklimit == 0)
|
|
netdev_warn(dev, "too much work in el3_rx!\n");
|
|
return 0;
|
|
}
|
|
|
|
static void set_rx_mode(struct net_device *dev)
|
|
{
|
|
unsigned int ioaddr = dev->base_addr;
|
|
u16 opts = SetRxFilter | RxStation | RxBroadcast;
|
|
|
|
if (dev->flags & IFF_PROMISC)
|
|
opts |= RxMulticast | RxProm;
|
|
else if (!netdev_mc_empty(dev) || (dev->flags & IFF_ALLMULTI))
|
|
opts |= RxMulticast;
|
|
outw(opts, ioaddr + EL3_CMD);
|
|
}
|
|
|
|
static void set_multicast_list(struct net_device *dev)
|
|
{
|
|
struct el3_private *priv = netdev_priv(dev);
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&priv->lock, flags);
|
|
set_rx_mode(dev);
|
|
spin_unlock_irqrestore(&priv->lock, flags);
|
|
}
|
|
|
|
static int el3_close(struct net_device *dev)
|
|
{
|
|
struct el3_private *lp = netdev_priv(dev);
|
|
struct pcmcia_device *link = lp->p_dev;
|
|
unsigned int ioaddr = dev->base_addr;
|
|
|
|
dev_dbg(&link->dev, "%s: shutting down ethercard.\n", dev->name);
|
|
|
|
if (pcmcia_dev_present(link)) {
|
|
/* Turn off statistics ASAP. We update dev->stats below. */
|
|
outw(StatsDisable, ioaddr + EL3_CMD);
|
|
|
|
/* Disable the receiver and transmitter. */
|
|
outw(RxDisable, ioaddr + EL3_CMD);
|
|
outw(TxDisable, ioaddr + EL3_CMD);
|
|
|
|
if (dev->if_port == 2)
|
|
/* Turn off thinnet power. Green! */
|
|
outw(StopCoax, ioaddr + EL3_CMD);
|
|
else if (dev->if_port == 1) {
|
|
/* Disable link beat and jabber */
|
|
EL3WINDOW(4);
|
|
outw(0, ioaddr + WN4_MEDIA);
|
|
}
|
|
|
|
/* Switching back to window 0 disables the IRQ. */
|
|
EL3WINDOW(0);
|
|
/* But we explicitly zero the IRQ line select anyway. */
|
|
outw(0x0f00, ioaddr + WN0_IRQ);
|
|
|
|
/* Check if the card still exists */
|
|
if ((inw(ioaddr+EL3_STATUS) & 0xe000) == 0x2000)
|
|
update_stats(dev);
|
|
}
|
|
|
|
link->open--;
|
|
netif_stop_queue(dev);
|
|
del_timer_sync(&lp->media);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct pcmcia_device_id tc589_ids[] = {
|
|
PCMCIA_MFC_DEVICE_MANF_CARD(0, 0x0101, 0x0562),
|
|
PCMCIA_MFC_DEVICE_PROD_ID1(0, "Motorola MARQUIS", 0xf03e4e77),
|
|
PCMCIA_DEVICE_MANF_CARD(0x0101, 0x0589),
|
|
PCMCIA_DEVICE_PROD_ID12("Farallon", "ENet", 0x58d93fc4, 0x992c2202),
|
|
PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x0035, "cis/3CXEM556.cis"),
|
|
PCMCIA_MFC_DEVICE_CIS_MANF_CARD(0, 0x0101, 0x003d, "cis/3CXEM556.cis"),
|
|
PCMCIA_DEVICE_NULL,
|
|
};
|
|
MODULE_DEVICE_TABLE(pcmcia, tc589_ids);
|
|
|
|
static struct pcmcia_driver tc589_driver = {
|
|
.owner = THIS_MODULE,
|
|
.name = "3c589_cs",
|
|
.probe = tc589_probe,
|
|
.remove = tc589_detach,
|
|
.id_table = tc589_ids,
|
|
.suspend = tc589_suspend,
|
|
.resume = tc589_resume,
|
|
};
|
|
module_pcmcia_driver(tc589_driver);
|