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>
1190 lines
32 KiB
C
1190 lines
32 KiB
C
/*
|
|
* Sun3 i82586 Ethernet driver
|
|
*
|
|
* Cloned from ni52.c for the Sun3 by Sam Creasey (sammy@sammy.net)
|
|
*
|
|
* Original copyright follows:
|
|
* --------------------------
|
|
*
|
|
* net-3-driver for the NI5210 card (i82586 Ethernet chip)
|
|
*
|
|
* This is an extension to the Linux operating system, and is covered by the
|
|
* same Gnu Public License that covers that work.
|
|
*
|
|
* Alphacode 0.82 (96/09/29) for Linux 2.0.0 (or later)
|
|
* Copyrights (c) 1994,1995,1996 by M.Hipp (hippm@informatik.uni-tuebingen.de)
|
|
* --------------------------
|
|
*
|
|
* Consult ni52.c for further notes from the original driver.
|
|
*
|
|
* This incarnation currently supports the OBIO version of the i82586 chip
|
|
* used in certain sun3 models. It should be fairly doable to expand this
|
|
* to support VME if I should every acquire such a board.
|
|
*
|
|
*/
|
|
|
|
static int debuglevel = 0; /* debug-printk 0: off 1: a few 2: more */
|
|
static int automatic_resume = 0; /* experimental .. better should be zero */
|
|
static int rfdadd = 0; /* rfdadd=1 may be better for 8K MEM cards */
|
|
static int fifo=0x8; /* don't change */
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/string.h>
|
|
#include <linux/errno.h>
|
|
#include <linux/ioport.h>
|
|
#include <linux/interrupt.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/init.h>
|
|
#include <linux/bitops.h>
|
|
#include <asm/io.h>
|
|
#include <asm/idprom.h>
|
|
#include <asm/machines.h>
|
|
#include <asm/sun3mmu.h>
|
|
#include <asm/dvma.h>
|
|
#include <asm/byteorder.h>
|
|
|
|
#include <linux/netdevice.h>
|
|
#include <linux/etherdevice.h>
|
|
#include <linux/skbuff.h>
|
|
|
|
#include "sun3_82586.h"
|
|
|
|
#define DRV_NAME "sun3_82586"
|
|
|
|
#define DEBUG /* debug on */
|
|
#define SYSBUSVAL 0 /* 16 Bit */
|
|
#define SUN3_82586_TOTAL_SIZE PAGE_SIZE
|
|
|
|
#define sun3_attn586() {*(volatile unsigned char *)(dev->base_addr) |= IEOB_ATTEN; *(volatile unsigned char *)(dev->base_addr) &= ~IEOB_ATTEN;}
|
|
#define sun3_reset586() {*(volatile unsigned char *)(dev->base_addr) = 0; udelay(100); *(volatile unsigned char *)(dev->base_addr) = IEOB_NORSET;}
|
|
#define sun3_disint() {*(volatile unsigned char *)(dev->base_addr) &= ~IEOB_IENAB;}
|
|
#define sun3_enaint() {*(volatile unsigned char *)(dev->base_addr) |= IEOB_IENAB;}
|
|
#define sun3_active() {*(volatile unsigned char *)(dev->base_addr) |= (IEOB_IENAB|IEOB_ONAIR|IEOB_NORSET);}
|
|
|
|
#define make32(ptr16) (p->memtop + (swab16((unsigned short) (ptr16))) )
|
|
#define make24(ptr32) (char *)swab32(( ((unsigned long) (ptr32)) - p->base))
|
|
#define make16(ptr32) (swab16((unsigned short) ((unsigned long)(ptr32) - (unsigned long) p->memtop )))
|
|
|
|
/******************* how to calculate the buffers *****************************
|
|
|
|
* IMPORTANT NOTE: if you configure only one NUM_XMIT_BUFFS, the driver works
|
|
* --------------- in a different (more stable?) mode. Only in this mode it's
|
|
* possible to configure the driver with 'NO_NOPCOMMANDS'
|
|
|
|
sizeof(scp)=12; sizeof(scb)=16; sizeof(iscp)=8;
|
|
sizeof(scp)+sizeof(iscp)+sizeof(scb) = 36 = INIT
|
|
sizeof(rfd) = 24; sizeof(rbd) = 12;
|
|
sizeof(tbd) = 8; sizeof(transmit_cmd) = 16;
|
|
sizeof(nop_cmd) = 8;
|
|
|
|
* if you don't know the driver, better do not change these values: */
|
|
|
|
#define RECV_BUFF_SIZE 1536 /* slightly oversized */
|
|
#define XMIT_BUFF_SIZE 1536 /* slightly oversized */
|
|
#define NUM_XMIT_BUFFS 1 /* config for 32K shmem */
|
|
#define NUM_RECV_BUFFS_8 4 /* config for 32K shared mem */
|
|
#define NUM_RECV_BUFFS_16 9 /* config for 32K shared mem */
|
|
#define NUM_RECV_BUFFS_32 16 /* config for 32K shared mem */
|
|
#define NO_NOPCOMMANDS /* only possible with NUM_XMIT_BUFFS=1 */
|
|
|
|
/**************************************************************************/
|
|
|
|
/* different DELAYs */
|
|
#define DELAY(x) mdelay(32 * x);
|
|
#define DELAY_16(); { udelay(16); }
|
|
#define DELAY_18(); { udelay(4); }
|
|
|
|
/* wait for command with timeout: */
|
|
#define WAIT_4_SCB_CMD() \
|
|
{ int i; \
|
|
for(i=0;i<16384;i++) { \
|
|
if(!p->scb->cmd_cuc) break; \
|
|
DELAY_18(); \
|
|
if(i == 16383) { \
|
|
printk("%s: scb_cmd timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_cuc,p->scb->cus); \
|
|
if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
|
|
|
|
#define WAIT_4_SCB_CMD_RUC() { int i; \
|
|
for(i=0;i<16384;i++) { \
|
|
if(!p->scb->cmd_ruc) break; \
|
|
DELAY_18(); \
|
|
if(i == 16383) { \
|
|
printk("%s: scb_cmd (ruc) timed out: %04x,%04x .. disabling i82586!!\n",dev->name,p->scb->cmd_ruc,p->scb->rus); \
|
|
if(!p->reseted) { p->reseted = 1; sun3_reset586(); } } } }
|
|
|
|
#define WAIT_4_STAT_COMPL(addr) { int i; \
|
|
for(i=0;i<32767;i++) { \
|
|
if(swab16((addr)->cmd_status) & STAT_COMPL) break; \
|
|
DELAY_16(); DELAY_16(); } }
|
|
|
|
static int sun3_82586_probe1(struct net_device *dev,int ioaddr);
|
|
static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id);
|
|
static int sun3_82586_open(struct net_device *dev);
|
|
static int sun3_82586_close(struct net_device *dev);
|
|
static netdev_tx_t sun3_82586_send_packet(struct sk_buff *,
|
|
struct net_device *);
|
|
static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev);
|
|
static void set_multicast_list(struct net_device *dev);
|
|
static void sun3_82586_timeout(struct net_device *dev, unsigned int txqueue);
|
|
#if 0
|
|
static void sun3_82586_dump(struct net_device *,void *);
|
|
#endif
|
|
|
|
/* helper-functions */
|
|
static int init586(struct net_device *dev);
|
|
static int check586(struct net_device *dev,char *where,unsigned size);
|
|
static void alloc586(struct net_device *dev);
|
|
static void startrecv586(struct net_device *dev);
|
|
static void *alloc_rfa(struct net_device *dev,void *ptr);
|
|
static void sun3_82586_rcv_int(struct net_device *dev);
|
|
static void sun3_82586_xmt_int(struct net_device *dev);
|
|
static void sun3_82586_rnr_int(struct net_device *dev);
|
|
|
|
struct priv
|
|
{
|
|
unsigned long base;
|
|
char *memtop;
|
|
long int lock;
|
|
int reseted;
|
|
volatile struct rfd_struct *rfd_last,*rfd_top,*rfd_first;
|
|
volatile struct scp_struct *scp; /* volatile is important */
|
|
volatile struct iscp_struct *iscp; /* volatile is important */
|
|
volatile struct scb_struct *scb; /* volatile is important */
|
|
volatile struct tbd_struct *xmit_buffs[NUM_XMIT_BUFFS];
|
|
volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];
|
|
#if (NUM_XMIT_BUFFS == 1)
|
|
volatile struct nop_cmd_struct *nop_cmds[2];
|
|
#else
|
|
volatile struct nop_cmd_struct *nop_cmds[NUM_XMIT_BUFFS];
|
|
#endif
|
|
volatile int nop_point,num_recv_buffs;
|
|
volatile char *xmit_cbuffs[NUM_XMIT_BUFFS];
|
|
volatile int xmit_count,xmit_last;
|
|
};
|
|
|
|
/**********************************************
|
|
* close device
|
|
*/
|
|
static int sun3_82586_close(struct net_device *dev)
|
|
{
|
|
free_irq(dev->irq, dev);
|
|
|
|
sun3_reset586(); /* the hard way to stop the receiver */
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**********************************************
|
|
* open device
|
|
*/
|
|
static int sun3_82586_open(struct net_device *dev)
|
|
{
|
|
int ret;
|
|
|
|
sun3_disint();
|
|
alloc586(dev);
|
|
init586(dev);
|
|
startrecv586(dev);
|
|
sun3_enaint();
|
|
|
|
ret = request_irq(dev->irq, sun3_82586_interrupt,0,dev->name,dev);
|
|
if (ret)
|
|
{
|
|
sun3_reset586();
|
|
return ret;
|
|
}
|
|
|
|
netif_start_queue(dev);
|
|
|
|
return 0; /* most done by init */
|
|
}
|
|
|
|
/**********************************************
|
|
* Check to see if there's an 82586 out there.
|
|
*/
|
|
static int check586(struct net_device *dev,char *where,unsigned size)
|
|
{
|
|
struct priv pb;
|
|
struct priv *p = &pb;
|
|
char *iscp_addr;
|
|
int i;
|
|
|
|
p->base = (unsigned long) dvma_btov(0);
|
|
p->memtop = (char *)dvma_btov((unsigned long)where);
|
|
p->scp = (struct scp_struct *)(p->base + SCP_DEFAULT_ADDRESS);
|
|
memset((char *)p->scp,0, sizeof(struct scp_struct));
|
|
for(i=0;i<sizeof(struct scp_struct);i++) /* memory was writeable? */
|
|
if(((char *)p->scp)[i])
|
|
return 0;
|
|
p->scp->sysbus = SYSBUSVAL; /* 1 = 8Bit-Bus, 0 = 16 Bit */
|
|
if(p->scp->sysbus != SYSBUSVAL)
|
|
return 0;
|
|
|
|
iscp_addr = (char *)dvma_btov((unsigned long)where);
|
|
|
|
p->iscp = (struct iscp_struct *) iscp_addr;
|
|
memset((char *)p->iscp,0, sizeof(struct iscp_struct));
|
|
|
|
p->scp->iscp = make24(p->iscp);
|
|
p->iscp->busy = 1;
|
|
|
|
sun3_reset586();
|
|
sun3_attn586();
|
|
DELAY(1); /* wait a while... */
|
|
|
|
if(p->iscp->busy) /* i82586 clears 'busy' after successful init */
|
|
return 0;
|
|
|
|
return 1;
|
|
}
|
|
|
|
/******************************************************************
|
|
* set iscp at the right place, called by sun3_82586_probe1 and open586.
|
|
*/
|
|
static void alloc586(struct net_device *dev)
|
|
{
|
|
struct priv *p = netdev_priv(dev);
|
|
|
|
sun3_reset586();
|
|
DELAY(1);
|
|
|
|
p->scp = (struct scp_struct *) (p->base + SCP_DEFAULT_ADDRESS);
|
|
p->iscp = (struct iscp_struct *) dvma_btov(dev->mem_start);
|
|
p->scb = (struct scb_struct *) ((char *)p->iscp + sizeof(struct iscp_struct));
|
|
|
|
memset((char *) p->iscp,0,sizeof(struct iscp_struct));
|
|
memset((char *) p->scp ,0,sizeof(struct scp_struct));
|
|
|
|
p->scp->iscp = make24(p->iscp);
|
|
p->scp->sysbus = SYSBUSVAL;
|
|
p->iscp->scb_offset = make16(p->scb);
|
|
p->iscp->scb_base = make24(dvma_btov(dev->mem_start));
|
|
|
|
p->iscp->busy = 1;
|
|
sun3_reset586();
|
|
sun3_attn586();
|
|
|
|
DELAY(1);
|
|
|
|
if(p->iscp->busy)
|
|
printk("%s: Init-Problems (alloc).\n",dev->name);
|
|
|
|
p->reseted = 0;
|
|
|
|
memset((char *)p->scb,0,sizeof(struct scb_struct));
|
|
}
|
|
|
|
struct net_device * __init sun3_82586_probe(int unit)
|
|
{
|
|
struct net_device *dev;
|
|
unsigned long ioaddr;
|
|
static int found = 0;
|
|
int err = -ENOMEM;
|
|
|
|
/* check that this machine has an onboard 82586 */
|
|
switch(idprom->id_machtype) {
|
|
case SM_SUN3|SM_3_160:
|
|
case SM_SUN3|SM_3_260:
|
|
/* these machines have 82586 */
|
|
break;
|
|
|
|
default:
|
|
return ERR_PTR(-ENODEV);
|
|
}
|
|
|
|
if (found)
|
|
return ERR_PTR(-ENODEV);
|
|
|
|
ioaddr = (unsigned long)ioremap(IE_OBIO, SUN3_82586_TOTAL_SIZE);
|
|
if (!ioaddr)
|
|
return ERR_PTR(-ENOMEM);
|
|
found = 1;
|
|
|
|
dev = alloc_etherdev(sizeof(struct priv));
|
|
if (!dev)
|
|
goto out;
|
|
if (unit >= 0) {
|
|
sprintf(dev->name, "eth%d", unit);
|
|
netdev_boot_setup_check(dev);
|
|
}
|
|
|
|
dev->irq = IE_IRQ;
|
|
dev->base_addr = ioaddr;
|
|
err = sun3_82586_probe1(dev, ioaddr);
|
|
if (err)
|
|
goto out1;
|
|
err = register_netdev(dev);
|
|
if (err)
|
|
goto out2;
|
|
return dev;
|
|
|
|
out2:
|
|
release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
|
|
out1:
|
|
free_netdev(dev);
|
|
out:
|
|
iounmap((void __iomem *)ioaddr);
|
|
return ERR_PTR(err);
|
|
}
|
|
|
|
static const struct net_device_ops sun3_82586_netdev_ops = {
|
|
.ndo_open = sun3_82586_open,
|
|
.ndo_stop = sun3_82586_close,
|
|
.ndo_start_xmit = sun3_82586_send_packet,
|
|
.ndo_set_rx_mode = set_multicast_list,
|
|
.ndo_tx_timeout = sun3_82586_timeout,
|
|
.ndo_get_stats = sun3_82586_get_stats,
|
|
.ndo_validate_addr = eth_validate_addr,
|
|
.ndo_set_mac_address = eth_mac_addr,
|
|
};
|
|
|
|
static int __init sun3_82586_probe1(struct net_device *dev,int ioaddr)
|
|
{
|
|
int i, size, retval;
|
|
|
|
if (!request_region(ioaddr, SUN3_82586_TOTAL_SIZE, DRV_NAME))
|
|
return -EBUSY;
|
|
|
|
/* copy in the ethernet address from the prom */
|
|
for(i = 0; i < 6 ; i++)
|
|
dev->dev_addr[i] = idprom->id_ethaddr[i];
|
|
|
|
printk("%s: SUN3 Intel 82586 found at %lx, ",dev->name,dev->base_addr);
|
|
|
|
/*
|
|
* check (or search) IO-Memory, 32K
|
|
*/
|
|
size = 0x8000;
|
|
|
|
dev->mem_start = (unsigned long)dvma_malloc_align(0x8000, 0x1000);
|
|
dev->mem_end = dev->mem_start + size;
|
|
|
|
if(size != 0x2000 && size != 0x4000 && size != 0x8000) {
|
|
printk("\n%s: Illegal memory size %d. Allowed is 0x2000 or 0x4000 or 0x8000 bytes.\n",dev->name,size);
|
|
retval = -ENODEV;
|
|
goto out;
|
|
}
|
|
if(!check586(dev,(char *) dev->mem_start,size)) {
|
|
printk("?memcheck, Can't find memory at 0x%lx with size %d!\n",dev->mem_start,size);
|
|
retval = -ENODEV;
|
|
goto out;
|
|
}
|
|
|
|
((struct priv *)netdev_priv(dev))->memtop =
|
|
(char *)dvma_btov(dev->mem_start);
|
|
((struct priv *)netdev_priv(dev))->base = (unsigned long) dvma_btov(0);
|
|
alloc586(dev);
|
|
|
|
/* set number of receive-buffs according to memsize */
|
|
if(size == 0x2000)
|
|
((struct priv *)netdev_priv(dev))->num_recv_buffs =
|
|
NUM_RECV_BUFFS_8;
|
|
else if(size == 0x4000)
|
|
((struct priv *)netdev_priv(dev))->num_recv_buffs =
|
|
NUM_RECV_BUFFS_16;
|
|
else
|
|
((struct priv *)netdev_priv(dev))->num_recv_buffs =
|
|
NUM_RECV_BUFFS_32;
|
|
|
|
printk("Memaddr: 0x%lx, Memsize: %d, IRQ %d\n",dev->mem_start,size, dev->irq);
|
|
|
|
dev->netdev_ops = &sun3_82586_netdev_ops;
|
|
dev->watchdog_timeo = HZ/20;
|
|
|
|
dev->if_port = 0;
|
|
return 0;
|
|
out:
|
|
release_region(ioaddr, SUN3_82586_TOTAL_SIZE);
|
|
return retval;
|
|
}
|
|
|
|
|
|
static int init586(struct net_device *dev)
|
|
{
|
|
void *ptr;
|
|
int i,result=0;
|
|
struct priv *p = netdev_priv(dev);
|
|
volatile struct configure_cmd_struct *cfg_cmd;
|
|
volatile struct iasetup_cmd_struct *ias_cmd;
|
|
volatile struct tdr_cmd_struct *tdr_cmd;
|
|
volatile struct mcsetup_cmd_struct *mc_cmd;
|
|
struct netdev_hw_addr *ha;
|
|
int num_addrs=netdev_mc_count(dev);
|
|
|
|
ptr = (void *) ((char *)p->scb + sizeof(struct scb_struct));
|
|
|
|
cfg_cmd = (struct configure_cmd_struct *)ptr; /* configure-command */
|
|
cfg_cmd->cmd_status = 0;
|
|
cfg_cmd->cmd_cmd = swab16(CMD_CONFIGURE | CMD_LAST);
|
|
cfg_cmd->cmd_link = 0xffff;
|
|
|
|
cfg_cmd->byte_cnt = 0x0a; /* number of cfg bytes */
|
|
cfg_cmd->fifo = fifo; /* fifo-limit (8=tx:32/rx:64) */
|
|
cfg_cmd->sav_bf = 0x40; /* hold or discard bad recv frames (bit 7) */
|
|
cfg_cmd->adr_len = 0x2e; /* addr_len |!src_insert |pre-len |loopback */
|
|
cfg_cmd->priority = 0x00;
|
|
cfg_cmd->ifs = 0x60;
|
|
cfg_cmd->time_low = 0x00;
|
|
cfg_cmd->time_high = 0xf2;
|
|
cfg_cmd->promisc = 0;
|
|
if(dev->flags & IFF_ALLMULTI) {
|
|
int len = ((char *) p->iscp - (char *) ptr - 8) / 6;
|
|
if(num_addrs > len) {
|
|
printk("%s: switching to promisc. mode\n",dev->name);
|
|
cfg_cmd->promisc = 1;
|
|
}
|
|
}
|
|
if(dev->flags&IFF_PROMISC)
|
|
cfg_cmd->promisc = 1;
|
|
cfg_cmd->carr_coll = 0x00;
|
|
|
|
p->scb->cbl_offset = make16(cfg_cmd);
|
|
p->scb->cmd_ruc = 0;
|
|
|
|
p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
|
|
sun3_attn586();
|
|
|
|
WAIT_4_STAT_COMPL(cfg_cmd);
|
|
|
|
if((swab16(cfg_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_COMPL|STAT_OK))
|
|
{
|
|
printk("%s: configure command failed: %x\n",dev->name,swab16(cfg_cmd->cmd_status));
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* individual address setup
|
|
*/
|
|
|
|
ias_cmd = (struct iasetup_cmd_struct *)ptr;
|
|
|
|
ias_cmd->cmd_status = 0;
|
|
ias_cmd->cmd_cmd = swab16(CMD_IASETUP | CMD_LAST);
|
|
ias_cmd->cmd_link = 0xffff;
|
|
|
|
memcpy((char *)&ias_cmd->iaddr,(char *) dev->dev_addr,ETH_ALEN);
|
|
|
|
p->scb->cbl_offset = make16(ias_cmd);
|
|
|
|
p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
|
|
sun3_attn586();
|
|
|
|
WAIT_4_STAT_COMPL(ias_cmd);
|
|
|
|
if((swab16(ias_cmd->cmd_status) & (STAT_OK|STAT_COMPL)) != (STAT_OK|STAT_COMPL)) {
|
|
printk("%s (82586): individual address setup command failed: %04x\n",dev->name,swab16(ias_cmd->cmd_status));
|
|
return 1;
|
|
}
|
|
|
|
/*
|
|
* TDR, wire check .. e.g. no resistor e.t.c
|
|
*/
|
|
|
|
tdr_cmd = (struct tdr_cmd_struct *)ptr;
|
|
|
|
tdr_cmd->cmd_status = 0;
|
|
tdr_cmd->cmd_cmd = swab16(CMD_TDR | CMD_LAST);
|
|
tdr_cmd->cmd_link = 0xffff;
|
|
tdr_cmd->status = 0;
|
|
|
|
p->scb->cbl_offset = make16(tdr_cmd);
|
|
p->scb->cmd_cuc = CUC_START; /* cmd.-unit start */
|
|
sun3_attn586();
|
|
|
|
WAIT_4_STAT_COMPL(tdr_cmd);
|
|
|
|
if(!(swab16(tdr_cmd->cmd_status) & STAT_COMPL))
|
|
{
|
|
printk("%s: Problems while running the TDR.\n",dev->name);
|
|
}
|
|
else
|
|
{
|
|
DELAY_16(); /* wait for result */
|
|
result = swab16(tdr_cmd->status);
|
|
|
|
p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
|
|
sun3_attn586(); /* ack the interrupts */
|
|
|
|
if(result & TDR_LNK_OK)
|
|
;
|
|
else if(result & TDR_XCVR_PRB)
|
|
printk("%s: TDR: Transceiver problem. Check the cable(s)!\n",dev->name);
|
|
else if(result & TDR_ET_OPN)
|
|
printk("%s: TDR: No correct termination %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
|
|
else if(result & TDR_ET_SRT)
|
|
{
|
|
if (result & TDR_TIMEMASK) /* time == 0 -> strange :-) */
|
|
printk("%s: TDR: Detected a short circuit %d clocks away.\n",dev->name,result & TDR_TIMEMASK);
|
|
}
|
|
else
|
|
printk("%s: TDR: Unknown status %04x\n",dev->name,result);
|
|
}
|
|
|
|
/*
|
|
* Multicast setup
|
|
*/
|
|
if(num_addrs && !(dev->flags & IFF_PROMISC) )
|
|
{
|
|
mc_cmd = (struct mcsetup_cmd_struct *) ptr;
|
|
mc_cmd->cmd_status = 0;
|
|
mc_cmd->cmd_cmd = swab16(CMD_MCSETUP | CMD_LAST);
|
|
mc_cmd->cmd_link = 0xffff;
|
|
mc_cmd->mc_cnt = swab16(num_addrs * 6);
|
|
|
|
i = 0;
|
|
netdev_for_each_mc_addr(ha, dev)
|
|
memcpy((char *) mc_cmd->mc_list[i++],
|
|
ha->addr, ETH_ALEN);
|
|
|
|
p->scb->cbl_offset = make16(mc_cmd);
|
|
p->scb->cmd_cuc = CUC_START;
|
|
sun3_attn586();
|
|
|
|
WAIT_4_STAT_COMPL(mc_cmd);
|
|
|
|
if( (swab16(mc_cmd->cmd_status) & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
|
|
printk("%s: Can't apply multicast-address-list.\n",dev->name);
|
|
}
|
|
|
|
/*
|
|
* alloc nop/xmit-cmds
|
|
*/
|
|
#if (NUM_XMIT_BUFFS == 1)
|
|
for(i=0;i<2;i++)
|
|
{
|
|
p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
|
|
p->nop_cmds[i]->cmd_cmd = swab16(CMD_NOP);
|
|
p->nop_cmds[i]->cmd_status = 0;
|
|
p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
|
|
ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
|
|
}
|
|
#else
|
|
for(i=0;i<NUM_XMIT_BUFFS;i++)
|
|
{
|
|
p->nop_cmds[i] = (struct nop_cmd_struct *)ptr;
|
|
p->nop_cmds[i]->cmd_cmd = swab16(CMD_NOP);
|
|
p->nop_cmds[i]->cmd_status = 0;
|
|
p->nop_cmds[i]->cmd_link = make16((p->nop_cmds[i]));
|
|
ptr = (char *) ptr + sizeof(struct nop_cmd_struct);
|
|
}
|
|
#endif
|
|
|
|
ptr = alloc_rfa(dev,ptr); /* init receive-frame-area */
|
|
|
|
/*
|
|
* alloc xmit-buffs / init xmit_cmds
|
|
*/
|
|
for(i=0;i<NUM_XMIT_BUFFS;i++)
|
|
{
|
|
p->xmit_cmds[i] = (struct transmit_cmd_struct *)ptr; /*transmit cmd/buff 0*/
|
|
ptr = (char *) ptr + sizeof(struct transmit_cmd_struct);
|
|
p->xmit_cbuffs[i] = (char *)ptr; /* char-buffs */
|
|
ptr = (char *) ptr + XMIT_BUFF_SIZE;
|
|
p->xmit_buffs[i] = (struct tbd_struct *)ptr; /* TBD */
|
|
ptr = (char *) ptr + sizeof(struct tbd_struct);
|
|
if(ptr > (void *)dev->mem_end)
|
|
{
|
|
printk("%s: not enough shared-mem for your configuration!\n",dev->name);
|
|
return 1;
|
|
}
|
|
memset((char *)(p->xmit_cmds[i]) ,0, sizeof(struct transmit_cmd_struct));
|
|
memset((char *)(p->xmit_buffs[i]),0, sizeof(struct tbd_struct));
|
|
p->xmit_cmds[i]->cmd_link = make16(p->nop_cmds[(i+1)%NUM_XMIT_BUFFS]);
|
|
p->xmit_cmds[i]->cmd_status = swab16(STAT_COMPL);
|
|
p->xmit_cmds[i]->cmd_cmd = swab16(CMD_XMIT | CMD_INT);
|
|
p->xmit_cmds[i]->tbd_offset = make16((p->xmit_buffs[i]));
|
|
p->xmit_buffs[i]->next = 0xffff;
|
|
p->xmit_buffs[i]->buffer = make24((p->xmit_cbuffs[i]));
|
|
}
|
|
|
|
p->xmit_count = 0;
|
|
p->xmit_last = 0;
|
|
#ifndef NO_NOPCOMMANDS
|
|
p->nop_point = 0;
|
|
#endif
|
|
|
|
/*
|
|
* 'start transmitter'
|
|
*/
|
|
#ifndef NO_NOPCOMMANDS
|
|
p->scb->cbl_offset = make16(p->nop_cmds[0]);
|
|
p->scb->cmd_cuc = CUC_START;
|
|
sun3_attn586();
|
|
WAIT_4_SCB_CMD();
|
|
#else
|
|
p->xmit_cmds[0]->cmd_link = make16(p->xmit_cmds[0]);
|
|
p->xmit_cmds[0]->cmd_cmd = swab16(CMD_XMIT | CMD_SUSPEND | CMD_INT);
|
|
#endif
|
|
|
|
/*
|
|
* ack. interrupts
|
|
*/
|
|
p->scb->cmd_cuc = p->scb->cus & STAT_MASK;
|
|
sun3_attn586();
|
|
DELAY_16();
|
|
|
|
sun3_enaint();
|
|
sun3_active();
|
|
|
|
return 0;
|
|
}
|
|
|
|
/******************************************************
|
|
* This is a helper routine for sun3_82586_rnr_int() and init586().
|
|
* It sets up the Receive Frame Area (RFA).
|
|
*/
|
|
|
|
static void *alloc_rfa(struct net_device *dev,void *ptr)
|
|
{
|
|
volatile struct rfd_struct *rfd = (struct rfd_struct *)ptr;
|
|
volatile struct rbd_struct *rbd;
|
|
int i;
|
|
struct priv *p = netdev_priv(dev);
|
|
|
|
memset((char *) rfd,0,sizeof(struct rfd_struct)*(p->num_recv_buffs+rfdadd));
|
|
p->rfd_first = rfd;
|
|
|
|
for(i = 0; i < (p->num_recv_buffs+rfdadd); i++) {
|
|
rfd[i].next = make16(rfd + (i+1) % (p->num_recv_buffs+rfdadd) );
|
|
rfd[i].rbd_offset = 0xffff;
|
|
}
|
|
rfd[p->num_recv_buffs-1+rfdadd].last = RFD_SUSP; /* RU suspend */
|
|
|
|
ptr = (void *) (rfd + (p->num_recv_buffs + rfdadd) );
|
|
|
|
rbd = (struct rbd_struct *) ptr;
|
|
ptr = (void *) (rbd + p->num_recv_buffs);
|
|
|
|
/* clr descriptors */
|
|
memset((char *) rbd,0,sizeof(struct rbd_struct)*(p->num_recv_buffs));
|
|
|
|
for(i=0;i<p->num_recv_buffs;i++)
|
|
{
|
|
rbd[i].next = make16((rbd + (i+1) % p->num_recv_buffs));
|
|
rbd[i].size = swab16(RECV_BUFF_SIZE);
|
|
rbd[i].buffer = make24(ptr);
|
|
ptr = (char *) ptr + RECV_BUFF_SIZE;
|
|
}
|
|
|
|
p->rfd_top = p->rfd_first;
|
|
p->rfd_last = p->rfd_first + (p->num_recv_buffs - 1 + rfdadd);
|
|
|
|
p->scb->rfa_offset = make16(p->rfd_first);
|
|
p->rfd_first->rbd_offset = make16(rbd);
|
|
|
|
return ptr;
|
|
}
|
|
|
|
|
|
/**************************************************
|
|
* Interrupt Handler ...
|
|
*/
|
|
|
|
static irqreturn_t sun3_82586_interrupt(int irq,void *dev_id)
|
|
{
|
|
struct net_device *dev = dev_id;
|
|
unsigned short stat;
|
|
int cnt=0;
|
|
struct priv *p;
|
|
|
|
if (!dev) {
|
|
printk ("sun3_82586-interrupt: irq %d for unknown device.\n",irq);
|
|
return IRQ_NONE;
|
|
}
|
|
p = netdev_priv(dev);
|
|
|
|
if(debuglevel > 1)
|
|
printk("I");
|
|
|
|
WAIT_4_SCB_CMD(); /* wait for last command */
|
|
|
|
while((stat=p->scb->cus & STAT_MASK))
|
|
{
|
|
p->scb->cmd_cuc = stat;
|
|
sun3_attn586();
|
|
|
|
if(stat & STAT_FR) /* received a frame */
|
|
sun3_82586_rcv_int(dev);
|
|
|
|
if(stat & STAT_RNR) /* RU went 'not ready' */
|
|
{
|
|
printk("(R)");
|
|
if(p->scb->rus & RU_SUSPEND) /* special case: RU_SUSPEND */
|
|
{
|
|
WAIT_4_SCB_CMD();
|
|
p->scb->cmd_ruc = RUC_RESUME;
|
|
sun3_attn586();
|
|
WAIT_4_SCB_CMD_RUC();
|
|
}
|
|
else
|
|
{
|
|
printk("%s: Receiver-Unit went 'NOT READY': %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->rus);
|
|
sun3_82586_rnr_int(dev);
|
|
}
|
|
}
|
|
|
|
if(stat & STAT_CX) /* command with I-bit set complete */
|
|
sun3_82586_xmt_int(dev);
|
|
|
|
#ifndef NO_NOPCOMMANDS
|
|
if(stat & STAT_CNA) /* CU went 'not ready' */
|
|
{
|
|
if(netif_running(dev))
|
|
printk("%s: oops! CU has left active state. stat: %04x/%02x.\n",dev->name,(int) stat,(int) p->scb->cus);
|
|
}
|
|
#endif
|
|
|
|
if(debuglevel > 1)
|
|
printk("%d",cnt++);
|
|
|
|
WAIT_4_SCB_CMD(); /* wait for ack. (sun3_82586_xmt_int can be faster than ack!!) */
|
|
if(p->scb->cmd_cuc) /* timed out? */
|
|
{
|
|
printk("%s: Acknowledge timed out.\n",dev->name);
|
|
sun3_disint();
|
|
break;
|
|
}
|
|
}
|
|
|
|
if(debuglevel > 1)
|
|
printk("i");
|
|
return IRQ_HANDLED;
|
|
}
|
|
|
|
/*******************************************************
|
|
* receive-interrupt
|
|
*/
|
|
|
|
static void sun3_82586_rcv_int(struct net_device *dev)
|
|
{
|
|
int status,cnt=0;
|
|
unsigned short totlen;
|
|
struct sk_buff *skb;
|
|
struct rbd_struct *rbd;
|
|
struct priv *p = netdev_priv(dev);
|
|
|
|
if(debuglevel > 0)
|
|
printk("R");
|
|
|
|
for(;(status = p->rfd_top->stat_high) & RFD_COMPL;)
|
|
{
|
|
rbd = (struct rbd_struct *) make32(p->rfd_top->rbd_offset);
|
|
|
|
if(status & RFD_OK) /* frame received without error? */
|
|
{
|
|
if( (totlen = swab16(rbd->status)) & RBD_LAST) /* the first and the last buffer? */
|
|
{
|
|
totlen &= RBD_MASK; /* length of this frame */
|
|
rbd->status = 0;
|
|
skb = netdev_alloc_skb(dev, totlen + 2);
|
|
if(skb != NULL)
|
|
{
|
|
skb_reserve(skb,2);
|
|
skb_put(skb,totlen);
|
|
skb_copy_to_linear_data(skb,(char *) p->base+swab32((unsigned long) rbd->buffer),totlen);
|
|
skb->protocol=eth_type_trans(skb,dev);
|
|
netif_rx(skb);
|
|
dev->stats.rx_packets++;
|
|
}
|
|
else
|
|
dev->stats.rx_dropped++;
|
|
}
|
|
else
|
|
{
|
|
int rstat;
|
|
/* free all RBD's until RBD_LAST is set */
|
|
totlen = 0;
|
|
while(!((rstat=swab16(rbd->status)) & RBD_LAST))
|
|
{
|
|
totlen += rstat & RBD_MASK;
|
|
if(!rstat)
|
|
{
|
|
printk("%s: Whoops .. no end mark in RBD list\n",dev->name);
|
|
break;
|
|
}
|
|
rbd->status = 0;
|
|
rbd = (struct rbd_struct *) make32(rbd->next);
|
|
}
|
|
totlen += rstat & RBD_MASK;
|
|
rbd->status = 0;
|
|
printk("%s: received oversized frame! length: %d\n",dev->name,totlen);
|
|
dev->stats.rx_dropped++;
|
|
}
|
|
}
|
|
else /* frame !(ok), only with 'save-bad-frames' */
|
|
{
|
|
printk("%s: oops! rfd-error-status: %04x\n",dev->name,status);
|
|
dev->stats.rx_errors++;
|
|
}
|
|
p->rfd_top->stat_high = 0;
|
|
p->rfd_top->last = RFD_SUSP; /* maybe exchange by RFD_LAST */
|
|
p->rfd_top->rbd_offset = 0xffff;
|
|
p->rfd_last->last = 0; /* delete RFD_SUSP */
|
|
p->rfd_last = p->rfd_top;
|
|
p->rfd_top = (struct rfd_struct *) make32(p->rfd_top->next); /* step to next RFD */
|
|
p->scb->rfa_offset = make16(p->rfd_top);
|
|
|
|
if(debuglevel > 0)
|
|
printk("%d",cnt++);
|
|
}
|
|
|
|
if(automatic_resume)
|
|
{
|
|
WAIT_4_SCB_CMD();
|
|
p->scb->cmd_ruc = RUC_RESUME;
|
|
sun3_attn586();
|
|
WAIT_4_SCB_CMD_RUC();
|
|
}
|
|
|
|
#ifdef WAIT_4_BUSY
|
|
{
|
|
int i;
|
|
for(i=0;i<1024;i++)
|
|
{
|
|
if(p->rfd_top->status)
|
|
break;
|
|
DELAY_16();
|
|
if(i == 1023)
|
|
printk("%s: RU hasn't fetched next RFD (not busy/complete)\n",dev->name);
|
|
}
|
|
}
|
|
#endif
|
|
|
|
#if 0
|
|
if(!at_least_one)
|
|
{
|
|
int i;
|
|
volatile struct rfd_struct *rfds=p->rfd_top;
|
|
volatile struct rbd_struct *rbds;
|
|
printk("%s: received a FC intr. without having a frame: %04x %d\n",dev->name,status,old_at_least);
|
|
for(i=0;i< (p->num_recv_buffs+4);i++)
|
|
{
|
|
rbds = (struct rbd_struct *) make32(rfds->rbd_offset);
|
|
printk("%04x:%04x ",rfds->status,rbds->status);
|
|
rfds = (struct rfd_struct *) make32(rfds->next);
|
|
}
|
|
printk("\nerrs: %04x %04x stat: %04x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->status);
|
|
printk("\nerrs: %04x %04x rus: %02x, cus: %02x\n",(int)p->scb->rsc_errs,(int)p->scb->ovrn_errs,(int)p->scb->rus,(int)p->scb->cus);
|
|
}
|
|
old_at_least = at_least_one;
|
|
#endif
|
|
|
|
if(debuglevel > 0)
|
|
printk("r");
|
|
}
|
|
|
|
/**********************************************************
|
|
* handle 'Receiver went not ready'.
|
|
*/
|
|
|
|
static void sun3_82586_rnr_int(struct net_device *dev)
|
|
{
|
|
struct priv *p = netdev_priv(dev);
|
|
|
|
dev->stats.rx_errors++;
|
|
|
|
WAIT_4_SCB_CMD(); /* wait for the last cmd, WAIT_4_FULLSTAT?? */
|
|
p->scb->cmd_ruc = RUC_ABORT; /* usually the RU is in the 'no resource'-state .. abort it now. */
|
|
sun3_attn586();
|
|
WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. */
|
|
|
|
alloc_rfa(dev,(char *)p->rfd_first);
|
|
/* maybe add a check here, before restarting the RU */
|
|
startrecv586(dev); /* restart RU */
|
|
|
|
printk("%s: Receive-Unit restarted. Status: %04x\n",dev->name,p->scb->rus);
|
|
|
|
}
|
|
|
|
/**********************************************************
|
|
* handle xmit - interrupt
|
|
*/
|
|
|
|
static void sun3_82586_xmt_int(struct net_device *dev)
|
|
{
|
|
int status;
|
|
struct priv *p = netdev_priv(dev);
|
|
|
|
if(debuglevel > 0)
|
|
printk("X");
|
|
|
|
status = swab16(p->xmit_cmds[p->xmit_last]->cmd_status);
|
|
if(!(status & STAT_COMPL))
|
|
printk("%s: strange .. xmit-int without a 'COMPLETE'\n",dev->name);
|
|
|
|
if(status & STAT_OK)
|
|
{
|
|
dev->stats.tx_packets++;
|
|
dev->stats.collisions += (status & TCMD_MAXCOLLMASK);
|
|
}
|
|
else
|
|
{
|
|
dev->stats.tx_errors++;
|
|
if(status & TCMD_LATECOLL) {
|
|
printk("%s: late collision detected.\n",dev->name);
|
|
dev->stats.collisions++;
|
|
}
|
|
else if(status & TCMD_NOCARRIER) {
|
|
dev->stats.tx_carrier_errors++;
|
|
printk("%s: no carrier detected.\n",dev->name);
|
|
}
|
|
else if(status & TCMD_LOSTCTS)
|
|
printk("%s: loss of CTS detected.\n",dev->name);
|
|
else if(status & TCMD_UNDERRUN) {
|
|
dev->stats.tx_fifo_errors++;
|
|
printk("%s: DMA underrun detected.\n",dev->name);
|
|
}
|
|
else if(status & TCMD_MAXCOLL) {
|
|
printk("%s: Max. collisions exceeded.\n",dev->name);
|
|
dev->stats.collisions += 16;
|
|
}
|
|
}
|
|
|
|
#if (NUM_XMIT_BUFFS > 1)
|
|
if( (++p->xmit_last) == NUM_XMIT_BUFFS)
|
|
p->xmit_last = 0;
|
|
#endif
|
|
netif_wake_queue(dev);
|
|
}
|
|
|
|
/***********************************************************
|
|
* (re)start the receiver
|
|
*/
|
|
|
|
static void startrecv586(struct net_device *dev)
|
|
{
|
|
struct priv *p = netdev_priv(dev);
|
|
|
|
WAIT_4_SCB_CMD();
|
|
WAIT_4_SCB_CMD_RUC();
|
|
p->scb->rfa_offset = make16(p->rfd_first);
|
|
p->scb->cmd_ruc = RUC_START;
|
|
sun3_attn586(); /* start cmd. */
|
|
WAIT_4_SCB_CMD_RUC(); /* wait for accept cmd. (no timeout!!) */
|
|
}
|
|
|
|
static void sun3_82586_timeout(struct net_device *dev, unsigned int txqueue)
|
|
{
|
|
struct priv *p = netdev_priv(dev);
|
|
#ifndef NO_NOPCOMMANDS
|
|
if(p->scb->cus & CU_ACTIVE) /* COMMAND-UNIT active? */
|
|
{
|
|
netif_wake_queue(dev);
|
|
#ifdef DEBUG
|
|
printk("%s: strange ... timeout with CU active?!?\n",dev->name);
|
|
printk("%s: X0: %04x N0: %04x N1: %04x %d\n",dev->name,(int)swab16(p->xmit_cmds[0]->cmd_status),(int)swab16(p->nop_cmds[0]->cmd_status),(int)swab16(p->nop_cmds[1]->cmd_status),(int)p->nop_point);
|
|
#endif
|
|
p->scb->cmd_cuc = CUC_ABORT;
|
|
sun3_attn586();
|
|
WAIT_4_SCB_CMD();
|
|
p->scb->cbl_offset = make16(p->nop_cmds[p->nop_point]);
|
|
p->scb->cmd_cuc = CUC_START;
|
|
sun3_attn586();
|
|
WAIT_4_SCB_CMD();
|
|
netif_trans_update(dev); /* prevent tx timeout */
|
|
return 0;
|
|
}
|
|
#endif
|
|
{
|
|
#ifdef DEBUG
|
|
printk("%s: xmitter timed out, try to restart! stat: %02x\n",dev->name,p->scb->cus);
|
|
printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
|
|
printk("%s: check, whether you set the right interrupt number!\n",dev->name);
|
|
#endif
|
|
sun3_82586_close(dev);
|
|
sun3_82586_open(dev);
|
|
}
|
|
netif_trans_update(dev); /* prevent tx timeout */
|
|
}
|
|
|
|
/******************************************************
|
|
* send frame
|
|
*/
|
|
|
|
static netdev_tx_t
|
|
sun3_82586_send_packet(struct sk_buff *skb, struct net_device *dev)
|
|
{
|
|
int len,i;
|
|
#ifndef NO_NOPCOMMANDS
|
|
int next_nop;
|
|
#endif
|
|
struct priv *p = netdev_priv(dev);
|
|
|
|
if(skb->len > XMIT_BUFF_SIZE)
|
|
{
|
|
printk("%s: Sorry, max. framelength is %d bytes. The length of your frame is %d bytes.\n",dev->name,XMIT_BUFF_SIZE,skb->len);
|
|
return NETDEV_TX_OK;
|
|
}
|
|
|
|
netif_stop_queue(dev);
|
|
|
|
#if(NUM_XMIT_BUFFS > 1)
|
|
if(test_and_set_bit(0,(void *) &p->lock)) {
|
|
printk("%s: Queue was locked\n",dev->name);
|
|
return NETDEV_TX_BUSY;
|
|
}
|
|
else
|
|
#endif
|
|
{
|
|
len = skb->len;
|
|
if (len < ETH_ZLEN) {
|
|
memset((void *)p->xmit_cbuffs[p->xmit_count], 0,
|
|
ETH_ZLEN);
|
|
len = ETH_ZLEN;
|
|
}
|
|
skb_copy_from_linear_data(skb, (void *)p->xmit_cbuffs[p->xmit_count], skb->len);
|
|
|
|
#if (NUM_XMIT_BUFFS == 1)
|
|
# ifdef NO_NOPCOMMANDS
|
|
|
|
#ifdef DEBUG
|
|
if(p->scb->cus & CU_ACTIVE)
|
|
{
|
|
printk("%s: Hmmm .. CU is still running and we wanna send a new packet.\n",dev->name);
|
|
printk("%s: stat: %04x %04x\n",dev->name,p->scb->cus,swab16(p->xmit_cmds[0]->cmd_status));
|
|
}
|
|
#endif
|
|
|
|
p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
|
|
for(i=0;i<16;i++)
|
|
{
|
|
p->xmit_cmds[0]->cmd_status = 0;
|
|
WAIT_4_SCB_CMD();
|
|
if( (p->scb->cus & CU_STATUS) == CU_SUSPEND)
|
|
p->scb->cmd_cuc = CUC_RESUME;
|
|
else
|
|
{
|
|
p->scb->cbl_offset = make16(p->xmit_cmds[0]);
|
|
p->scb->cmd_cuc = CUC_START;
|
|
}
|
|
|
|
sun3_attn586();
|
|
if(!i)
|
|
dev_kfree_skb(skb);
|
|
WAIT_4_SCB_CMD();
|
|
if( (p->scb->cus & CU_ACTIVE)) /* test it, because CU sometimes doesn't start immediately */
|
|
break;
|
|
if(p->xmit_cmds[0]->cmd_status)
|
|
break;
|
|
if(i==15)
|
|
printk("%s: Can't start transmit-command.\n",dev->name);
|
|
}
|
|
# else
|
|
next_nop = (p->nop_point + 1) & 0x1;
|
|
p->xmit_buffs[0]->size = swab16(TBD_LAST | len);
|
|
|
|
p->xmit_cmds[0]->cmd_link = p->nop_cmds[next_nop]->cmd_link
|
|
= make16((p->nop_cmds[next_nop]));
|
|
p->xmit_cmds[0]->cmd_status = p->nop_cmds[next_nop]->cmd_status = 0;
|
|
|
|
p->nop_cmds[p->nop_point]->cmd_link = make16((p->xmit_cmds[0]));
|
|
p->nop_point = next_nop;
|
|
dev_kfree_skb(skb);
|
|
# endif
|
|
#else
|
|
p->xmit_buffs[p->xmit_count]->size = swab16(TBD_LAST | len);
|
|
if( (next_nop = p->xmit_count + 1) == NUM_XMIT_BUFFS )
|
|
next_nop = 0;
|
|
|
|
p->xmit_cmds[p->xmit_count]->cmd_status = 0;
|
|
/* linkpointer of xmit-command already points to next nop cmd */
|
|
p->nop_cmds[next_nop]->cmd_link = make16((p->nop_cmds[next_nop]));
|
|
p->nop_cmds[next_nop]->cmd_status = 0;
|
|
|
|
p->nop_cmds[p->xmit_count]->cmd_link = make16((p->xmit_cmds[p->xmit_count]));
|
|
p->xmit_count = next_nop;
|
|
|
|
{
|
|
unsigned long flags;
|
|
local_irq_save(flags);
|
|
if(p->xmit_count != p->xmit_last)
|
|
netif_wake_queue(dev);
|
|
p->lock = 0;
|
|
local_irq_restore(flags);
|
|
}
|
|
dev_kfree_skb(skb);
|
|
#endif
|
|
}
|
|
return NETDEV_TX_OK;
|
|
}
|
|
|
|
/*******************************************
|
|
* Someone wanna have the statistics
|
|
*/
|
|
|
|
static struct net_device_stats *sun3_82586_get_stats(struct net_device *dev)
|
|
{
|
|
struct priv *p = netdev_priv(dev);
|
|
unsigned short crc,aln,rsc,ovrn;
|
|
|
|
crc = swab16(p->scb->crc_errs); /* get error-statistic from the ni82586 */
|
|
p->scb->crc_errs = 0;
|
|
aln = swab16(p->scb->aln_errs);
|
|
p->scb->aln_errs = 0;
|
|
rsc = swab16(p->scb->rsc_errs);
|
|
p->scb->rsc_errs = 0;
|
|
ovrn = swab16(p->scb->ovrn_errs);
|
|
p->scb->ovrn_errs = 0;
|
|
|
|
dev->stats.rx_crc_errors += crc;
|
|
dev->stats.rx_fifo_errors += ovrn;
|
|
dev->stats.rx_frame_errors += aln;
|
|
dev->stats.rx_dropped += rsc;
|
|
|
|
return &dev->stats;
|
|
}
|
|
|
|
/********************************************************
|
|
* Set MC list ..
|
|
*/
|
|
|
|
static void set_multicast_list(struct net_device *dev)
|
|
{
|
|
netif_stop_queue(dev);
|
|
sun3_disint();
|
|
alloc586(dev);
|
|
init586(dev);
|
|
startrecv586(dev);
|
|
sun3_enaint();
|
|
netif_wake_queue(dev);
|
|
}
|
|
|
|
#if 0
|
|
/*
|
|
* DUMP .. we expect a not running CMD unit and enough space
|
|
*/
|
|
void sun3_82586_dump(struct net_device *dev,void *ptr)
|
|
{
|
|
struct priv *p = netdev_priv(dev);
|
|
struct dump_cmd_struct *dump_cmd = (struct dump_cmd_struct *) ptr;
|
|
int i;
|
|
|
|
p->scb->cmd_cuc = CUC_ABORT;
|
|
sun3_attn586();
|
|
WAIT_4_SCB_CMD();
|
|
WAIT_4_SCB_CMD_RUC();
|
|
|
|
dump_cmd->cmd_status = 0;
|
|
dump_cmd->cmd_cmd = CMD_DUMP | CMD_LAST;
|
|
dump_cmd->dump_offset = make16((dump_cmd + 1));
|
|
dump_cmd->cmd_link = 0xffff;
|
|
|
|
p->scb->cbl_offset = make16(dump_cmd);
|
|
p->scb->cmd_cuc = CUC_START;
|
|
sun3_attn586();
|
|
WAIT_4_STAT_COMPL(dump_cmd);
|
|
|
|
if( (dump_cmd->cmd_status & (STAT_COMPL|STAT_OK)) != (STAT_COMPL|STAT_OK) )
|
|
printk("%s: Can't get dump information.\n",dev->name);
|
|
|
|
for(i=0;i<170;i++) {
|
|
printk("%02x ",(int) ((unsigned char *) (dump_cmd + 1))[i]);
|
|
if(i % 24 == 23)
|
|
printk("\n");
|
|
}
|
|
printk("\n");
|
|
}
|
|
#endif
|