forked from Minki/linux
0290bd291c
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>
970 lines
23 KiB
C
970 lines
23 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* Copyright (c) 2001 Vojtech Pavlik
|
|
*
|
|
* CATC EL1210A NetMate USB Ethernet driver
|
|
*
|
|
* Sponsored by SuSE
|
|
*
|
|
* Based on the work of
|
|
* Donald Becker
|
|
*
|
|
* Old chipset support added by Simon Evans <spse@secret.org.uk> 2002
|
|
* - adds support for Belkin F5U011
|
|
*/
|
|
|
|
/*
|
|
*
|
|
* Should you need to contact me, the author, you can do so either by
|
|
* e-mail - mail your message to <vojtech@suse.cz>, or by paper mail:
|
|
* Vojtech Pavlik, Simunkova 1594, Prague 8, 182 00 Czech Republic
|
|
*/
|
|
|
|
#include <linux/module.h>
|
|
#include <linux/kernel.h>
|
|
#include <linux/string.h>
|
|
#include <linux/netdevice.h>
|
|
#include <linux/etherdevice.h>
|
|
#include <linux/skbuff.h>
|
|
#include <linux/spinlock.h>
|
|
#include <linux/ethtool.h>
|
|
#include <linux/crc32.h>
|
|
#include <linux/bitops.h>
|
|
#include <linux/gfp.h>
|
|
#include <linux/uaccess.h>
|
|
|
|
#undef DEBUG
|
|
|
|
#include <linux/usb.h>
|
|
|
|
/*
|
|
* Version information.
|
|
*/
|
|
|
|
#define DRIVER_VERSION "v2.8"
|
|
#define DRIVER_AUTHOR "Vojtech Pavlik <vojtech@suse.cz>"
|
|
#define DRIVER_DESC "CATC EL1210A NetMate USB Ethernet driver"
|
|
#define SHORT_DRIVER_DESC "EL1210A NetMate USB Ethernet"
|
|
|
|
MODULE_AUTHOR(DRIVER_AUTHOR);
|
|
MODULE_DESCRIPTION(DRIVER_DESC);
|
|
MODULE_LICENSE("GPL");
|
|
|
|
static const char driver_name[] = "catc";
|
|
|
|
/*
|
|
* Some defines.
|
|
*/
|
|
|
|
#define STATS_UPDATE (HZ) /* Time between stats updates */
|
|
#define TX_TIMEOUT (5*HZ) /* Max time the queue can be stopped */
|
|
#define PKT_SZ 1536 /* Max Ethernet packet size */
|
|
#define RX_MAX_BURST 15 /* Max packets per rx buffer (> 0, < 16) */
|
|
#define TX_MAX_BURST 15 /* Max full sized packets per tx buffer (> 0) */
|
|
#define CTRL_QUEUE 16 /* Max control requests in flight (power of two) */
|
|
#define RX_PKT_SZ 1600 /* Max size of receive packet for F5U011 */
|
|
|
|
/*
|
|
* Control requests.
|
|
*/
|
|
|
|
enum control_requests {
|
|
ReadMem = 0xf1,
|
|
GetMac = 0xf2,
|
|
Reset = 0xf4,
|
|
SetMac = 0xf5,
|
|
SetRxMode = 0xf5, /* F5U011 only */
|
|
WriteROM = 0xf8,
|
|
SetReg = 0xfa,
|
|
GetReg = 0xfb,
|
|
WriteMem = 0xfc,
|
|
ReadROM = 0xfd,
|
|
};
|
|
|
|
/*
|
|
* Registers.
|
|
*/
|
|
|
|
enum register_offsets {
|
|
TxBufCount = 0x20,
|
|
RxBufCount = 0x21,
|
|
OpModes = 0x22,
|
|
TxQed = 0x23,
|
|
RxQed = 0x24,
|
|
MaxBurst = 0x25,
|
|
RxUnit = 0x60,
|
|
EthStatus = 0x61,
|
|
StationAddr0 = 0x67,
|
|
EthStats = 0x69,
|
|
LEDCtrl = 0x81,
|
|
};
|
|
|
|
enum eth_stats {
|
|
TxSingleColl = 0x00,
|
|
TxMultiColl = 0x02,
|
|
TxExcessColl = 0x04,
|
|
RxFramErr = 0x06,
|
|
};
|
|
|
|
enum op_mode_bits {
|
|
Op3MemWaits = 0x03,
|
|
OpLenInclude = 0x08,
|
|
OpRxMerge = 0x10,
|
|
OpTxMerge = 0x20,
|
|
OpWin95bugfix = 0x40,
|
|
OpLoopback = 0x80,
|
|
};
|
|
|
|
enum rx_filter_bits {
|
|
RxEnable = 0x01,
|
|
RxPolarity = 0x02,
|
|
RxForceOK = 0x04,
|
|
RxMultiCast = 0x08,
|
|
RxPromisc = 0x10,
|
|
AltRxPromisc = 0x20, /* F5U011 uses different bit */
|
|
};
|
|
|
|
enum led_values {
|
|
LEDFast = 0x01,
|
|
LEDSlow = 0x02,
|
|
LEDFlash = 0x03,
|
|
LEDPulse = 0x04,
|
|
LEDLink = 0x08,
|
|
};
|
|
|
|
enum link_status {
|
|
LinkNoChange = 0,
|
|
LinkGood = 1,
|
|
LinkBad = 2
|
|
};
|
|
|
|
/*
|
|
* The catc struct.
|
|
*/
|
|
|
|
#define CTRL_RUNNING 0
|
|
#define RX_RUNNING 1
|
|
#define TX_RUNNING 2
|
|
|
|
struct catc {
|
|
struct net_device *netdev;
|
|
struct usb_device *usbdev;
|
|
|
|
unsigned long flags;
|
|
|
|
unsigned int tx_ptr, tx_idx;
|
|
unsigned int ctrl_head, ctrl_tail;
|
|
spinlock_t tx_lock, ctrl_lock;
|
|
|
|
u8 tx_buf[2][TX_MAX_BURST * (PKT_SZ + 2)];
|
|
u8 rx_buf[RX_MAX_BURST * (PKT_SZ + 2)];
|
|
u8 irq_buf[2];
|
|
u8 ctrl_buf[64];
|
|
struct usb_ctrlrequest ctrl_dr;
|
|
|
|
struct timer_list timer;
|
|
u8 stats_buf[8];
|
|
u16 stats_vals[4];
|
|
unsigned long last_stats;
|
|
|
|
u8 multicast[64];
|
|
|
|
struct ctrl_queue {
|
|
u8 dir;
|
|
u8 request;
|
|
u16 value;
|
|
u16 index;
|
|
void *buf;
|
|
int len;
|
|
void (*callback)(struct catc *catc, struct ctrl_queue *q);
|
|
} ctrl_queue[CTRL_QUEUE];
|
|
|
|
struct urb *tx_urb, *rx_urb, *irq_urb, *ctrl_urb;
|
|
|
|
u8 is_f5u011; /* Set if device is an F5U011 */
|
|
u8 rxmode[2]; /* Used for F5U011 */
|
|
atomic_t recq_sz; /* Used for F5U011 - counter of waiting rx packets */
|
|
};
|
|
|
|
/*
|
|
* Useful macros.
|
|
*/
|
|
|
|
#define catc_get_mac(catc, mac) catc_ctrl_msg(catc, USB_DIR_IN, GetMac, 0, 0, mac, 6)
|
|
#define catc_reset(catc) catc_ctrl_msg(catc, USB_DIR_OUT, Reset, 0, 0, NULL, 0)
|
|
#define catc_set_reg(catc, reg, val) catc_ctrl_msg(catc, USB_DIR_OUT, SetReg, val, reg, NULL, 0)
|
|
#define catc_get_reg(catc, reg, buf) catc_ctrl_msg(catc, USB_DIR_IN, GetReg, 0, reg, buf, 1)
|
|
#define catc_write_mem(catc, addr, buf, size) catc_ctrl_msg(catc, USB_DIR_OUT, WriteMem, 0, addr, buf, size)
|
|
#define catc_read_mem(catc, addr, buf, size) catc_ctrl_msg(catc, USB_DIR_IN, ReadMem, 0, addr, buf, size)
|
|
|
|
#define f5u011_rxmode(catc, rxmode) catc_ctrl_msg(catc, USB_DIR_OUT, SetRxMode, 0, 1, rxmode, 2)
|
|
#define f5u011_rxmode_async(catc, rxmode) catc_ctrl_async(catc, USB_DIR_OUT, SetRxMode, 0, 1, &rxmode, 2, NULL)
|
|
#define f5u011_mchash_async(catc, hash) catc_ctrl_async(catc, USB_DIR_OUT, SetRxMode, 0, 2, &hash, 8, NULL)
|
|
|
|
#define catc_set_reg_async(catc, reg, val) catc_ctrl_async(catc, USB_DIR_OUT, SetReg, val, reg, NULL, 0, NULL)
|
|
#define catc_get_reg_async(catc, reg, cb) catc_ctrl_async(catc, USB_DIR_IN, GetReg, 0, reg, NULL, 1, cb)
|
|
#define catc_write_mem_async(catc, addr, buf, size) catc_ctrl_async(catc, USB_DIR_OUT, WriteMem, 0, addr, buf, size, NULL)
|
|
|
|
/*
|
|
* Receive routines.
|
|
*/
|
|
|
|
static void catc_rx_done(struct urb *urb)
|
|
{
|
|
struct catc *catc = urb->context;
|
|
u8 *pkt_start = urb->transfer_buffer;
|
|
struct sk_buff *skb;
|
|
int pkt_len, pkt_offset = 0;
|
|
int status = urb->status;
|
|
|
|
if (!catc->is_f5u011) {
|
|
clear_bit(RX_RUNNING, &catc->flags);
|
|
pkt_offset = 2;
|
|
}
|
|
|
|
if (status) {
|
|
dev_dbg(&urb->dev->dev, "rx_done, status %d, length %d\n",
|
|
status, urb->actual_length);
|
|
return;
|
|
}
|
|
|
|
do {
|
|
if(!catc->is_f5u011) {
|
|
pkt_len = le16_to_cpup((__le16*)pkt_start);
|
|
if (pkt_len > urb->actual_length) {
|
|
catc->netdev->stats.rx_length_errors++;
|
|
catc->netdev->stats.rx_errors++;
|
|
break;
|
|
}
|
|
} else {
|
|
pkt_len = urb->actual_length;
|
|
}
|
|
|
|
if (!(skb = dev_alloc_skb(pkt_len)))
|
|
return;
|
|
|
|
skb_copy_to_linear_data(skb, pkt_start + pkt_offset, pkt_len);
|
|
skb_put(skb, pkt_len);
|
|
|
|
skb->protocol = eth_type_trans(skb, catc->netdev);
|
|
netif_rx(skb);
|
|
|
|
catc->netdev->stats.rx_packets++;
|
|
catc->netdev->stats.rx_bytes += pkt_len;
|
|
|
|
/* F5U011 only does one packet per RX */
|
|
if (catc->is_f5u011)
|
|
break;
|
|
pkt_start += (((pkt_len + 1) >> 6) + 1) << 6;
|
|
|
|
} while (pkt_start - (u8 *) urb->transfer_buffer < urb->actual_length);
|
|
|
|
if (catc->is_f5u011) {
|
|
if (atomic_read(&catc->recq_sz)) {
|
|
int state;
|
|
atomic_dec(&catc->recq_sz);
|
|
netdev_dbg(catc->netdev, "getting extra packet\n");
|
|
urb->dev = catc->usbdev;
|
|
if ((state = usb_submit_urb(urb, GFP_ATOMIC)) < 0) {
|
|
netdev_dbg(catc->netdev,
|
|
"submit(rx_urb) status %d\n", state);
|
|
}
|
|
} else {
|
|
clear_bit(RX_RUNNING, &catc->flags);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void catc_irq_done(struct urb *urb)
|
|
{
|
|
struct catc *catc = urb->context;
|
|
u8 *data = urb->transfer_buffer;
|
|
int status = urb->status;
|
|
unsigned int hasdata = 0, linksts = LinkNoChange;
|
|
int res;
|
|
|
|
if (!catc->is_f5u011) {
|
|
hasdata = data[1] & 0x80;
|
|
if (data[1] & 0x40)
|
|
linksts = LinkGood;
|
|
else if (data[1] & 0x20)
|
|
linksts = LinkBad;
|
|
} else {
|
|
hasdata = (unsigned int)(be16_to_cpup((__be16*)data) & 0x0fff);
|
|
if (data[0] == 0x90)
|
|
linksts = LinkGood;
|
|
else if (data[0] == 0xA0)
|
|
linksts = LinkBad;
|
|
}
|
|
|
|
switch (status) {
|
|
case 0: /* success */
|
|
break;
|
|
case -ECONNRESET: /* unlink */
|
|
case -ENOENT:
|
|
case -ESHUTDOWN:
|
|
return;
|
|
/* -EPIPE: should clear the halt */
|
|
default: /* error */
|
|
dev_dbg(&urb->dev->dev,
|
|
"irq_done, status %d, data %02x %02x.\n",
|
|
status, data[0], data[1]);
|
|
goto resubmit;
|
|
}
|
|
|
|
if (linksts == LinkGood) {
|
|
netif_carrier_on(catc->netdev);
|
|
netdev_dbg(catc->netdev, "link ok\n");
|
|
}
|
|
|
|
if (linksts == LinkBad) {
|
|
netif_carrier_off(catc->netdev);
|
|
netdev_dbg(catc->netdev, "link bad\n");
|
|
}
|
|
|
|
if (hasdata) {
|
|
if (test_and_set_bit(RX_RUNNING, &catc->flags)) {
|
|
if (catc->is_f5u011)
|
|
atomic_inc(&catc->recq_sz);
|
|
} else {
|
|
catc->rx_urb->dev = catc->usbdev;
|
|
if ((res = usb_submit_urb(catc->rx_urb, GFP_ATOMIC)) < 0) {
|
|
dev_err(&catc->usbdev->dev,
|
|
"submit(rx_urb) status %d\n", res);
|
|
}
|
|
}
|
|
}
|
|
resubmit:
|
|
res = usb_submit_urb (urb, GFP_ATOMIC);
|
|
if (res)
|
|
dev_err(&catc->usbdev->dev,
|
|
"can't resubmit intr, %s-%s, status %d\n",
|
|
catc->usbdev->bus->bus_name,
|
|
catc->usbdev->devpath, res);
|
|
}
|
|
|
|
/*
|
|
* Transmit routines.
|
|
*/
|
|
|
|
static int catc_tx_run(struct catc *catc)
|
|
{
|
|
int status;
|
|
|
|
if (catc->is_f5u011)
|
|
catc->tx_ptr = (catc->tx_ptr + 63) & ~63;
|
|
|
|
catc->tx_urb->transfer_buffer_length = catc->tx_ptr;
|
|
catc->tx_urb->transfer_buffer = catc->tx_buf[catc->tx_idx];
|
|
catc->tx_urb->dev = catc->usbdev;
|
|
|
|
if ((status = usb_submit_urb(catc->tx_urb, GFP_ATOMIC)) < 0)
|
|
dev_err(&catc->usbdev->dev, "submit(tx_urb), status %d\n",
|
|
status);
|
|
|
|
catc->tx_idx = !catc->tx_idx;
|
|
catc->tx_ptr = 0;
|
|
|
|
netif_trans_update(catc->netdev);
|
|
return status;
|
|
}
|
|
|
|
static void catc_tx_done(struct urb *urb)
|
|
{
|
|
struct catc *catc = urb->context;
|
|
unsigned long flags;
|
|
int r, status = urb->status;
|
|
|
|
if (status == -ECONNRESET) {
|
|
dev_dbg(&urb->dev->dev, "Tx Reset.\n");
|
|
urb->status = 0;
|
|
netif_trans_update(catc->netdev);
|
|
catc->netdev->stats.tx_errors++;
|
|
clear_bit(TX_RUNNING, &catc->flags);
|
|
netif_wake_queue(catc->netdev);
|
|
return;
|
|
}
|
|
|
|
if (status) {
|
|
dev_dbg(&urb->dev->dev, "tx_done, status %d, length %d\n",
|
|
status, urb->actual_length);
|
|
return;
|
|
}
|
|
|
|
spin_lock_irqsave(&catc->tx_lock, flags);
|
|
|
|
if (catc->tx_ptr) {
|
|
r = catc_tx_run(catc);
|
|
if (unlikely(r < 0))
|
|
clear_bit(TX_RUNNING, &catc->flags);
|
|
} else {
|
|
clear_bit(TX_RUNNING, &catc->flags);
|
|
}
|
|
|
|
netif_wake_queue(catc->netdev);
|
|
|
|
spin_unlock_irqrestore(&catc->tx_lock, flags);
|
|
}
|
|
|
|
static netdev_tx_t catc_start_xmit(struct sk_buff *skb,
|
|
struct net_device *netdev)
|
|
{
|
|
struct catc *catc = netdev_priv(netdev);
|
|
unsigned long flags;
|
|
int r = 0;
|
|
char *tx_buf;
|
|
|
|
spin_lock_irqsave(&catc->tx_lock, flags);
|
|
|
|
catc->tx_ptr = (((catc->tx_ptr - 1) >> 6) + 1) << 6;
|
|
tx_buf = catc->tx_buf[catc->tx_idx] + catc->tx_ptr;
|
|
if (catc->is_f5u011)
|
|
*(__be16 *)tx_buf = cpu_to_be16(skb->len);
|
|
else
|
|
*(__le16 *)tx_buf = cpu_to_le16(skb->len);
|
|
skb_copy_from_linear_data(skb, tx_buf + 2, skb->len);
|
|
catc->tx_ptr += skb->len + 2;
|
|
|
|
if (!test_and_set_bit(TX_RUNNING, &catc->flags)) {
|
|
r = catc_tx_run(catc);
|
|
if (r < 0)
|
|
clear_bit(TX_RUNNING, &catc->flags);
|
|
}
|
|
|
|
if ((catc->is_f5u011 && catc->tx_ptr) ||
|
|
(catc->tx_ptr >= ((TX_MAX_BURST - 1) * (PKT_SZ + 2))))
|
|
netif_stop_queue(netdev);
|
|
|
|
spin_unlock_irqrestore(&catc->tx_lock, flags);
|
|
|
|
if (r >= 0) {
|
|
catc->netdev->stats.tx_bytes += skb->len;
|
|
catc->netdev->stats.tx_packets++;
|
|
}
|
|
|
|
dev_kfree_skb(skb);
|
|
|
|
return NETDEV_TX_OK;
|
|
}
|
|
|
|
static void catc_tx_timeout(struct net_device *netdev, unsigned int txqueue)
|
|
{
|
|
struct catc *catc = netdev_priv(netdev);
|
|
|
|
dev_warn(&netdev->dev, "Transmit timed out.\n");
|
|
usb_unlink_urb(catc->tx_urb);
|
|
}
|
|
|
|
/*
|
|
* Control messages.
|
|
*/
|
|
|
|
static int catc_ctrl_msg(struct catc *catc, u8 dir, u8 request, u16 value, u16 index, void *buf, int len)
|
|
{
|
|
int retval = usb_control_msg(catc->usbdev,
|
|
dir ? usb_rcvctrlpipe(catc->usbdev, 0) : usb_sndctrlpipe(catc->usbdev, 0),
|
|
request, 0x40 | dir, value, index, buf, len, 1000);
|
|
return retval < 0 ? retval : 0;
|
|
}
|
|
|
|
static void catc_ctrl_run(struct catc *catc)
|
|
{
|
|
struct ctrl_queue *q = catc->ctrl_queue + catc->ctrl_tail;
|
|
struct usb_device *usbdev = catc->usbdev;
|
|
struct urb *urb = catc->ctrl_urb;
|
|
struct usb_ctrlrequest *dr = &catc->ctrl_dr;
|
|
int status;
|
|
|
|
dr->bRequest = q->request;
|
|
dr->bRequestType = 0x40 | q->dir;
|
|
dr->wValue = cpu_to_le16(q->value);
|
|
dr->wIndex = cpu_to_le16(q->index);
|
|
dr->wLength = cpu_to_le16(q->len);
|
|
|
|
urb->pipe = q->dir ? usb_rcvctrlpipe(usbdev, 0) : usb_sndctrlpipe(usbdev, 0);
|
|
urb->transfer_buffer_length = q->len;
|
|
urb->transfer_buffer = catc->ctrl_buf;
|
|
urb->setup_packet = (void *) dr;
|
|
urb->dev = usbdev;
|
|
|
|
if (!q->dir && q->buf && q->len)
|
|
memcpy(catc->ctrl_buf, q->buf, q->len);
|
|
|
|
if ((status = usb_submit_urb(catc->ctrl_urb, GFP_ATOMIC)))
|
|
dev_err(&catc->usbdev->dev, "submit(ctrl_urb) status %d\n",
|
|
status);
|
|
}
|
|
|
|
static void catc_ctrl_done(struct urb *urb)
|
|
{
|
|
struct catc *catc = urb->context;
|
|
struct ctrl_queue *q;
|
|
unsigned long flags;
|
|
int status = urb->status;
|
|
|
|
if (status)
|
|
dev_dbg(&urb->dev->dev, "ctrl_done, status %d, len %d.\n",
|
|
status, urb->actual_length);
|
|
|
|
spin_lock_irqsave(&catc->ctrl_lock, flags);
|
|
|
|
q = catc->ctrl_queue + catc->ctrl_tail;
|
|
|
|
if (q->dir) {
|
|
if (q->buf && q->len)
|
|
memcpy(q->buf, catc->ctrl_buf, q->len);
|
|
else
|
|
q->buf = catc->ctrl_buf;
|
|
}
|
|
|
|
if (q->callback)
|
|
q->callback(catc, q);
|
|
|
|
catc->ctrl_tail = (catc->ctrl_tail + 1) & (CTRL_QUEUE - 1);
|
|
|
|
if (catc->ctrl_head != catc->ctrl_tail)
|
|
catc_ctrl_run(catc);
|
|
else
|
|
clear_bit(CTRL_RUNNING, &catc->flags);
|
|
|
|
spin_unlock_irqrestore(&catc->ctrl_lock, flags);
|
|
}
|
|
|
|
static int catc_ctrl_async(struct catc *catc, u8 dir, u8 request, u16 value,
|
|
u16 index, void *buf, int len, void (*callback)(struct catc *catc, struct ctrl_queue *q))
|
|
{
|
|
struct ctrl_queue *q;
|
|
int retval = 0;
|
|
unsigned long flags;
|
|
|
|
spin_lock_irqsave(&catc->ctrl_lock, flags);
|
|
|
|
q = catc->ctrl_queue + catc->ctrl_head;
|
|
|
|
q->dir = dir;
|
|
q->request = request;
|
|
q->value = value;
|
|
q->index = index;
|
|
q->buf = buf;
|
|
q->len = len;
|
|
q->callback = callback;
|
|
|
|
catc->ctrl_head = (catc->ctrl_head + 1) & (CTRL_QUEUE - 1);
|
|
|
|
if (catc->ctrl_head == catc->ctrl_tail) {
|
|
dev_err(&catc->usbdev->dev, "ctrl queue full\n");
|
|
catc->ctrl_tail = (catc->ctrl_tail + 1) & (CTRL_QUEUE - 1);
|
|
retval = -1;
|
|
}
|
|
|
|
if (!test_and_set_bit(CTRL_RUNNING, &catc->flags))
|
|
catc_ctrl_run(catc);
|
|
|
|
spin_unlock_irqrestore(&catc->ctrl_lock, flags);
|
|
|
|
return retval;
|
|
}
|
|
|
|
/*
|
|
* Statistics.
|
|
*/
|
|
|
|
static void catc_stats_done(struct catc *catc, struct ctrl_queue *q)
|
|
{
|
|
int index = q->index - EthStats;
|
|
u16 data, last;
|
|
|
|
catc->stats_buf[index] = *((char *)q->buf);
|
|
|
|
if (index & 1)
|
|
return;
|
|
|
|
data = ((u16)catc->stats_buf[index] << 8) | catc->stats_buf[index + 1];
|
|
last = catc->stats_vals[index >> 1];
|
|
|
|
switch (index) {
|
|
case TxSingleColl:
|
|
case TxMultiColl:
|
|
catc->netdev->stats.collisions += data - last;
|
|
break;
|
|
case TxExcessColl:
|
|
catc->netdev->stats.tx_aborted_errors += data - last;
|
|
catc->netdev->stats.tx_errors += data - last;
|
|
break;
|
|
case RxFramErr:
|
|
catc->netdev->stats.rx_frame_errors += data - last;
|
|
catc->netdev->stats.rx_errors += data - last;
|
|
break;
|
|
}
|
|
|
|
catc->stats_vals[index >> 1] = data;
|
|
}
|
|
|
|
static void catc_stats_timer(struct timer_list *t)
|
|
{
|
|
struct catc *catc = from_timer(catc, t, timer);
|
|
int i;
|
|
|
|
for (i = 0; i < 8; i++)
|
|
catc_get_reg_async(catc, EthStats + 7 - i, catc_stats_done);
|
|
|
|
mod_timer(&catc->timer, jiffies + STATS_UPDATE);
|
|
}
|
|
|
|
/*
|
|
* Receive modes. Broadcast, Multicast, Promisc.
|
|
*/
|
|
|
|
static void catc_multicast(unsigned char *addr, u8 *multicast)
|
|
{
|
|
u32 crc;
|
|
|
|
crc = ether_crc_le(6, addr);
|
|
multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7);
|
|
}
|
|
|
|
static void catc_set_multicast_list(struct net_device *netdev)
|
|
{
|
|
struct catc *catc = netdev_priv(netdev);
|
|
struct netdev_hw_addr *ha;
|
|
u8 broadcast[ETH_ALEN];
|
|
u8 rx = RxEnable | RxPolarity | RxMultiCast;
|
|
|
|
eth_broadcast_addr(broadcast);
|
|
memset(catc->multicast, 0, 64);
|
|
|
|
catc_multicast(broadcast, catc->multicast);
|
|
catc_multicast(netdev->dev_addr, catc->multicast);
|
|
|
|
if (netdev->flags & IFF_PROMISC) {
|
|
memset(catc->multicast, 0xff, 64);
|
|
rx |= (!catc->is_f5u011) ? RxPromisc : AltRxPromisc;
|
|
}
|
|
|
|
if (netdev->flags & IFF_ALLMULTI) {
|
|
memset(catc->multicast, 0xff, 64);
|
|
} else {
|
|
netdev_for_each_mc_addr(ha, netdev) {
|
|
u32 crc = ether_crc_le(6, ha->addr);
|
|
if (!catc->is_f5u011) {
|
|
catc->multicast[(crc >> 3) & 0x3f] |= 1 << (crc & 7);
|
|
} else {
|
|
catc->multicast[7-(crc >> 29)] |= 1 << ((crc >> 26) & 7);
|
|
}
|
|
}
|
|
}
|
|
if (!catc->is_f5u011) {
|
|
catc_set_reg_async(catc, RxUnit, rx);
|
|
catc_write_mem_async(catc, 0xfa80, catc->multicast, 64);
|
|
} else {
|
|
f5u011_mchash_async(catc, catc->multicast);
|
|
if (catc->rxmode[0] != rx) {
|
|
catc->rxmode[0] = rx;
|
|
netdev_dbg(catc->netdev,
|
|
"Setting RX mode to %2.2X %2.2X\n",
|
|
catc->rxmode[0], catc->rxmode[1]);
|
|
f5u011_rxmode_async(catc, catc->rxmode);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void catc_get_drvinfo(struct net_device *dev,
|
|
struct ethtool_drvinfo *info)
|
|
{
|
|
struct catc *catc = netdev_priv(dev);
|
|
strlcpy(info->driver, driver_name, sizeof(info->driver));
|
|
strlcpy(info->version, DRIVER_VERSION, sizeof(info->version));
|
|
usb_make_path(catc->usbdev, info->bus_info, sizeof(info->bus_info));
|
|
}
|
|
|
|
static int catc_get_link_ksettings(struct net_device *dev,
|
|
struct ethtool_link_ksettings *cmd)
|
|
{
|
|
struct catc *catc = netdev_priv(dev);
|
|
if (!catc->is_f5u011)
|
|
return -EOPNOTSUPP;
|
|
|
|
ethtool_link_ksettings_zero_link_mode(cmd, supported);
|
|
ethtool_link_ksettings_add_link_mode(cmd, supported, 10baseT_Half);
|
|
ethtool_link_ksettings_add_link_mode(cmd, supported, TP);
|
|
|
|
ethtool_link_ksettings_zero_link_mode(cmd, advertising);
|
|
ethtool_link_ksettings_add_link_mode(cmd, advertising, 10baseT_Half);
|
|
ethtool_link_ksettings_add_link_mode(cmd, advertising, TP);
|
|
|
|
cmd->base.speed = SPEED_10;
|
|
cmd->base.duplex = DUPLEX_HALF;
|
|
cmd->base.port = PORT_TP;
|
|
cmd->base.phy_address = 0;
|
|
cmd->base.autoneg = AUTONEG_DISABLE;
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct ethtool_ops ops = {
|
|
.get_drvinfo = catc_get_drvinfo,
|
|
.get_link = ethtool_op_get_link,
|
|
.get_link_ksettings = catc_get_link_ksettings,
|
|
};
|
|
|
|
/*
|
|
* Open, close.
|
|
*/
|
|
|
|
static int catc_open(struct net_device *netdev)
|
|
{
|
|
struct catc *catc = netdev_priv(netdev);
|
|
int status;
|
|
|
|
catc->irq_urb->dev = catc->usbdev;
|
|
if ((status = usb_submit_urb(catc->irq_urb, GFP_KERNEL)) < 0) {
|
|
dev_err(&catc->usbdev->dev, "submit(irq_urb) status %d\n",
|
|
status);
|
|
return -1;
|
|
}
|
|
|
|
netif_start_queue(netdev);
|
|
|
|
if (!catc->is_f5u011)
|
|
mod_timer(&catc->timer, jiffies + STATS_UPDATE);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static int catc_stop(struct net_device *netdev)
|
|
{
|
|
struct catc *catc = netdev_priv(netdev);
|
|
|
|
netif_stop_queue(netdev);
|
|
|
|
if (!catc->is_f5u011)
|
|
del_timer_sync(&catc->timer);
|
|
|
|
usb_kill_urb(catc->rx_urb);
|
|
usb_kill_urb(catc->tx_urb);
|
|
usb_kill_urb(catc->irq_urb);
|
|
usb_kill_urb(catc->ctrl_urb);
|
|
|
|
return 0;
|
|
}
|
|
|
|
static const struct net_device_ops catc_netdev_ops = {
|
|
.ndo_open = catc_open,
|
|
.ndo_stop = catc_stop,
|
|
.ndo_start_xmit = catc_start_xmit,
|
|
|
|
.ndo_tx_timeout = catc_tx_timeout,
|
|
.ndo_set_rx_mode = catc_set_multicast_list,
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
};
|
|
|
|
/*
|
|
* USB probe, disconnect.
|
|
*/
|
|
|
|
static int catc_probe(struct usb_interface *intf, const struct usb_device_id *id)
|
|
{
|
|
struct device *dev = &intf->dev;
|
|
struct usb_device *usbdev = interface_to_usbdev(intf);
|
|
struct net_device *netdev;
|
|
struct catc *catc;
|
|
u8 broadcast[ETH_ALEN];
|
|
int pktsz, ret;
|
|
|
|
if (usb_set_interface(usbdev,
|
|
intf->altsetting->desc.bInterfaceNumber, 1)) {
|
|
dev_err(dev, "Can't set altsetting 1.\n");
|
|
return -EIO;
|
|
}
|
|
|
|
netdev = alloc_etherdev(sizeof(struct catc));
|
|
if (!netdev)
|
|
return -ENOMEM;
|
|
|
|
catc = netdev_priv(netdev);
|
|
|
|
netdev->netdev_ops = &catc_netdev_ops;
|
|
netdev->watchdog_timeo = TX_TIMEOUT;
|
|
netdev->ethtool_ops = &ops;
|
|
|
|
catc->usbdev = usbdev;
|
|
catc->netdev = netdev;
|
|
|
|
spin_lock_init(&catc->tx_lock);
|
|
spin_lock_init(&catc->ctrl_lock);
|
|
|
|
timer_setup(&catc->timer, catc_stats_timer, 0);
|
|
|
|
catc->ctrl_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
catc->tx_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
catc->rx_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
catc->irq_urb = usb_alloc_urb(0, GFP_KERNEL);
|
|
if ((!catc->ctrl_urb) || (!catc->tx_urb) ||
|
|
(!catc->rx_urb) || (!catc->irq_urb)) {
|
|
dev_err(&intf->dev, "No free urbs available.\n");
|
|
ret = -ENOMEM;
|
|
goto fail_free;
|
|
}
|
|
|
|
/* The F5U011 has the same vendor/product as the netmate but a device version of 0x130 */
|
|
if (le16_to_cpu(usbdev->descriptor.idVendor) == 0x0423 &&
|
|
le16_to_cpu(usbdev->descriptor.idProduct) == 0xa &&
|
|
le16_to_cpu(catc->usbdev->descriptor.bcdDevice) == 0x0130) {
|
|
dev_dbg(dev, "Testing for f5u011\n");
|
|
catc->is_f5u011 = 1;
|
|
atomic_set(&catc->recq_sz, 0);
|
|
pktsz = RX_PKT_SZ;
|
|
} else {
|
|
pktsz = RX_MAX_BURST * (PKT_SZ + 2);
|
|
}
|
|
|
|
usb_fill_control_urb(catc->ctrl_urb, usbdev, usb_sndctrlpipe(usbdev, 0),
|
|
NULL, NULL, 0, catc_ctrl_done, catc);
|
|
|
|
usb_fill_bulk_urb(catc->tx_urb, usbdev, usb_sndbulkpipe(usbdev, 1),
|
|
NULL, 0, catc_tx_done, catc);
|
|
|
|
usb_fill_bulk_urb(catc->rx_urb, usbdev, usb_rcvbulkpipe(usbdev, 1),
|
|
catc->rx_buf, pktsz, catc_rx_done, catc);
|
|
|
|
usb_fill_int_urb(catc->irq_urb, usbdev, usb_rcvintpipe(usbdev, 2),
|
|
catc->irq_buf, 2, catc_irq_done, catc, 1);
|
|
|
|
if (!catc->is_f5u011) {
|
|
u32 *buf;
|
|
int i;
|
|
|
|
dev_dbg(dev, "Checking memory size\n");
|
|
|
|
buf = kmalloc(4, GFP_KERNEL);
|
|
if (!buf) {
|
|
ret = -ENOMEM;
|
|
goto fail_free;
|
|
}
|
|
|
|
*buf = 0x12345678;
|
|
catc_write_mem(catc, 0x7a80, buf, 4);
|
|
*buf = 0x87654321;
|
|
catc_write_mem(catc, 0xfa80, buf, 4);
|
|
catc_read_mem(catc, 0x7a80, buf, 4);
|
|
|
|
switch (*buf) {
|
|
case 0x12345678:
|
|
catc_set_reg(catc, TxBufCount, 8);
|
|
catc_set_reg(catc, RxBufCount, 32);
|
|
dev_dbg(dev, "64k Memory\n");
|
|
break;
|
|
default:
|
|
dev_warn(&intf->dev,
|
|
"Couldn't detect memory size, assuming 32k\n");
|
|
/* fall through */
|
|
case 0x87654321:
|
|
catc_set_reg(catc, TxBufCount, 4);
|
|
catc_set_reg(catc, RxBufCount, 16);
|
|
dev_dbg(dev, "32k Memory\n");
|
|
break;
|
|
}
|
|
|
|
kfree(buf);
|
|
|
|
dev_dbg(dev, "Getting MAC from SEEROM.\n");
|
|
|
|
catc_get_mac(catc, netdev->dev_addr);
|
|
|
|
dev_dbg(dev, "Setting MAC into registers.\n");
|
|
|
|
for (i = 0; i < 6; i++)
|
|
catc_set_reg(catc, StationAddr0 - i, netdev->dev_addr[i]);
|
|
|
|
dev_dbg(dev, "Filling the multicast list.\n");
|
|
|
|
eth_broadcast_addr(broadcast);
|
|
catc_multicast(broadcast, catc->multicast);
|
|
catc_multicast(netdev->dev_addr, catc->multicast);
|
|
catc_write_mem(catc, 0xfa80, catc->multicast, 64);
|
|
|
|
dev_dbg(dev, "Clearing error counters.\n");
|
|
|
|
for (i = 0; i < 8; i++)
|
|
catc_set_reg(catc, EthStats + i, 0);
|
|
catc->last_stats = jiffies;
|
|
|
|
dev_dbg(dev, "Enabling.\n");
|
|
|
|
catc_set_reg(catc, MaxBurst, RX_MAX_BURST);
|
|
catc_set_reg(catc, OpModes, OpTxMerge | OpRxMerge | OpLenInclude | Op3MemWaits);
|
|
catc_set_reg(catc, LEDCtrl, LEDLink);
|
|
catc_set_reg(catc, RxUnit, RxEnable | RxPolarity | RxMultiCast);
|
|
} else {
|
|
dev_dbg(dev, "Performing reset\n");
|
|
catc_reset(catc);
|
|
catc_get_mac(catc, netdev->dev_addr);
|
|
|
|
dev_dbg(dev, "Setting RX Mode\n");
|
|
catc->rxmode[0] = RxEnable | RxPolarity | RxMultiCast;
|
|
catc->rxmode[1] = 0;
|
|
f5u011_rxmode(catc, catc->rxmode);
|
|
}
|
|
dev_dbg(dev, "Init done.\n");
|
|
printk(KERN_INFO "%s: %s USB Ethernet at usb-%s-%s, %pM.\n",
|
|
netdev->name, (catc->is_f5u011) ? "Belkin F5U011" : "CATC EL1210A NetMate",
|
|
usbdev->bus->bus_name, usbdev->devpath, netdev->dev_addr);
|
|
usb_set_intfdata(intf, catc);
|
|
|
|
SET_NETDEV_DEV(netdev, &intf->dev);
|
|
ret = register_netdev(netdev);
|
|
if (ret)
|
|
goto fail_clear_intfdata;
|
|
|
|
return 0;
|
|
|
|
fail_clear_intfdata:
|
|
usb_set_intfdata(intf, NULL);
|
|
fail_free:
|
|
usb_free_urb(catc->ctrl_urb);
|
|
usb_free_urb(catc->tx_urb);
|
|
usb_free_urb(catc->rx_urb);
|
|
usb_free_urb(catc->irq_urb);
|
|
free_netdev(netdev);
|
|
return ret;
|
|
}
|
|
|
|
static void catc_disconnect(struct usb_interface *intf)
|
|
{
|
|
struct catc *catc = usb_get_intfdata(intf);
|
|
|
|
usb_set_intfdata(intf, NULL);
|
|
if (catc) {
|
|
unregister_netdev(catc->netdev);
|
|
usb_free_urb(catc->ctrl_urb);
|
|
usb_free_urb(catc->tx_urb);
|
|
usb_free_urb(catc->rx_urb);
|
|
usb_free_urb(catc->irq_urb);
|
|
free_netdev(catc->netdev);
|
|
}
|
|
}
|
|
|
|
/*
|
|
* Module functions and tables.
|
|
*/
|
|
|
|
static const struct usb_device_id catc_id_table[] = {
|
|
{ USB_DEVICE(0x0423, 0xa) }, /* CATC Netmate, Belkin F5U011 */
|
|
{ USB_DEVICE(0x0423, 0xc) }, /* CATC Netmate II, Belkin F5U111 */
|
|
{ USB_DEVICE(0x08d1, 0x1) }, /* smartBridges smartNIC */
|
|
{ }
|
|
};
|
|
|
|
MODULE_DEVICE_TABLE(usb, catc_id_table);
|
|
|
|
static struct usb_driver catc_driver = {
|
|
.name = driver_name,
|
|
.probe = catc_probe,
|
|
.disconnect = catc_disconnect,
|
|
.id_table = catc_id_table,
|
|
.disable_hub_initiated_lpm = 1,
|
|
};
|
|
|
|
module_usb_driver(catc_driver);
|