#define pr_fmt(fmt) …
#include <linux/hardirq.h>
#include <linux/interrupt.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/types.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/delay.h>
#include <linux/init.h>
#include <linux/pci.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/mii.h>
#include <linux/if_vlan.h>
#include <linux/skbuff.h>
#include <linux/ethtool.h>
#include <linux/string.h>
#include <linux/firmware.h>
#include <linux/rtnetlink.h>
#include <linux/unaligned.h>
#define DRV_NAME …
#define DRV_DESCRIPTION …
#define DRV_COPYRIGHT …
#define E100_WATCHDOG_PERIOD …
#define E100_NAPI_WEIGHT …
#define FIRMWARE_D101M …
#define FIRMWARE_D101S …
#define FIRMWARE_D102E …
MODULE_DESCRIPTION(…);
MODULE_LICENSE(…) …;
MODULE_FIRMWARE(…);
MODULE_FIRMWARE(…);
MODULE_FIRMWARE(…);
static int debug = …;
static int eeprom_bad_csum_allow = …;
static int use_io = …;
module_param(debug, int, 0);
module_param(eeprom_bad_csum_allow, int, 0444);
module_param(use_io, int, 0444);
MODULE_PARM_DESC(…) …;
MODULE_PARM_DESC(…) …;
MODULE_PARM_DESC(…) …;
#define INTEL_8255X_ETHERNET_DEVICE(device_id, ich) …
static const struct pci_device_id e100_id_table[] = …;
MODULE_DEVICE_TABLE(pci, e100_id_table);
enum mac { … };
enum phy { … };
struct csr { … };
enum scb_status { … };
enum ru_state { … };
enum scb_stat_ack { … };
enum scb_cmd_hi { … };
enum scb_cmd_lo { … };
enum cuc_dump { … };
enum port { … };
enum eeprom_ctrl_lo { … };
enum mdi_ctrl { … };
enum eeprom_op { … };
enum eeprom_offsets { … };
enum eeprom_cnfg_mdix { … };
enum eeprom_phy_iface { … };
enum eeprom_id { … };
enum eeprom_config_asf { … };
enum cb_status { … };
enum cb_command { … };
struct rfd { … };
struct rx { … };
#if defined(__BIG_ENDIAN_BITFIELD)
#define X …
#else
#define X(a,b) …
#endif
struct config { … };
#define E100_MAX_MULTICAST_ADDRS …
struct multi { … };
#define UCODE_SIZE …
struct cb { … };
enum loopback { … };
struct stats { … };
struct mem { … };
struct param_range { … };
struct params { … };
struct nic { … };
static inline void e100_write_flush(struct nic *nic)
{ … }
static void e100_enable_irq(struct nic *nic)
{ … }
static void e100_disable_irq(struct nic *nic)
{ … }
static void e100_hw_reset(struct nic *nic)
{ … }
static int e100_self_test(struct nic *nic)
{ … }
static void e100_eeprom_write(struct nic *nic, u16 addr_len, u16 addr, __le16 data)
{
u32 cmd_addr_data[3];
u8 ctrl;
int i, j;
cmd_addr_data[0] = op_ewen << (addr_len - 2);
cmd_addr_data[1] = (((op_write << addr_len) | addr) << 16) |
le16_to_cpu(data);
cmd_addr_data[2] = op_ewds << (addr_len - 2);
for (j = 0; j < 3; j++) {
iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
for (i = 31; i >= 0; i--) {
ctrl = (cmd_addr_data[j] & (1 << i)) ?
eecs | eedi : eecs;
iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
iowrite8(ctrl | eesk, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
}
msleep(10);
iowrite8(0, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
}
};
static __le16 e100_eeprom_read(struct nic *nic, u16 *addr_len, u16 addr)
{
u32 cmd_addr_data;
u16 data = 0;
u8 ctrl;
int i;
cmd_addr_data = ((op_read << *addr_len) | addr) << 16;
iowrite8(eecs | eesk, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
for (i = 31; i >= 0; i--) {
ctrl = (cmd_addr_data & (1 << i)) ? eecs | eedi : eecs;
iowrite8(ctrl, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
iowrite8(ctrl | eesk, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
ctrl = ioread8(&nic->csr->eeprom_ctrl_lo);
if (!(ctrl & eedo) && i > 16) {
*addr_len -= (i - 16);
i = 17;
}
data = (data << 1) | (ctrl & eedo ? 1 : 0);
}
iowrite8(0, &nic->csr->eeprom_ctrl_lo);
e100_write_flush(nic); udelay(4);
return cpu_to_le16(data);
};
static int e100_eeprom_load(struct nic *nic)
{ … }
static int e100_eeprom_save(struct nic *nic, u16 start, u16 count)
{ … }
#define E100_WAIT_SCB_TIMEOUT …
#define E100_WAIT_SCB_FAST …
static int e100_exec_cmd(struct nic *nic, u8 cmd, dma_addr_t dma_addr)
{ … }
static int e100_exec_cb(struct nic *nic, struct sk_buff *skb,
int (*cb_prepare)(struct nic *, struct cb *, struct sk_buff *))
{ … }
static int mdio_read(struct net_device *netdev, int addr, int reg)
{ … }
static void mdio_write(struct net_device *netdev, int addr, int reg, int data)
{ … }
static u16 mdio_ctrl_hw(struct nic *nic, u32 addr, u32 dir, u32 reg, u16 data)
{ … }
static u16 mdio_ctrl_phy_82552_v(struct nic *nic,
u32 addr,
u32 dir,
u32 reg,
u16 data)
{ … }
static u16 mdio_ctrl_phy_mii_emulated(struct nic *nic,
u32 addr,
u32 dir,
u32 reg,
u16 data)
{ … }
static inline int e100_phy_supports_mii(struct nic *nic)
{ … }
static void e100_get_defaults(struct nic *nic)
{ … }
static int e100_configure(struct nic *nic, struct cb *cb, struct sk_buff *skb)
{ … }
#define BUNDLESMALL …
#define BUNDLEMAX …
#define INTDELAY …
static const struct firmware *e100_request_firmware(struct nic *nic)
{ … }
static int e100_setup_ucode(struct nic *nic, struct cb *cb,
struct sk_buff *skb)
{ … }
static inline int e100_load_ucode_wait(struct nic *nic)
{ … }
static int e100_setup_iaaddr(struct nic *nic, struct cb *cb,
struct sk_buff *skb)
{ … }
static int e100_dump(struct nic *nic, struct cb *cb, struct sk_buff *skb)
{ … }
static int e100_phy_check_without_mii(struct nic *nic)
{ … }
#define NCONFIG_AUTO_SWITCH …
#define MII_NSC_CONG …
#define NSC_CONG_ENABLE …
#define NSC_CONG_TXREADY …
static int e100_phy_init(struct nic *nic)
{ … }
static int e100_hw_init(struct nic *nic)
{ … }
static int e100_multi(struct nic *nic, struct cb *cb, struct sk_buff *skb)
{ … }
static void e100_set_multicast_list(struct net_device *netdev)
{ … }
static void e100_update_stats(struct nic *nic)
{ … }
static void e100_adjust_adaptive_ifs(struct nic *nic, int speed, int duplex)
{ … }
static void e100_watchdog(struct timer_list *t)
{ … }
static int e100_xmit_prepare(struct nic *nic, struct cb *cb,
struct sk_buff *skb)
{ … }
static netdev_tx_t e100_xmit_frame(struct sk_buff *skb,
struct net_device *netdev)
{ … }
static int e100_tx_clean(struct nic *nic)
{ … }
static void e100_clean_cbs(struct nic *nic)
{ … }
static int e100_alloc_cbs(struct nic *nic)
{ … }
static inline void e100_start_receiver(struct nic *nic, struct rx *rx)
{ … }
#define RFD_BUF_LEN …
static int e100_rx_alloc_skb(struct nic *nic, struct rx *rx)
{ … }
static int e100_rx_indicate(struct nic *nic, struct rx *rx,
unsigned int *work_done, unsigned int work_to_do)
{ … }
static void e100_rx_clean(struct nic *nic, unsigned int *work_done,
unsigned int work_to_do)
{ … }
static void e100_rx_clean_list(struct nic *nic)
{ … }
static int e100_rx_alloc_list(struct nic *nic)
{ … }
static irqreturn_t e100_intr(int irq, void *dev_id)
{ … }
static int e100_poll(struct napi_struct *napi, int budget)
{ … }
#ifdef CONFIG_NET_POLL_CONTROLLER
static void e100_netpoll(struct net_device *netdev)
{ … }
#endif
static int e100_set_mac_address(struct net_device *netdev, void *p)
{ … }
static int e100_asf(struct nic *nic)
{ … }
static int e100_up(struct nic *nic)
{ … }
static void e100_down(struct nic *nic)
{ … }
static void e100_tx_timeout(struct net_device *netdev, unsigned int txqueue)
{ … }
static void e100_tx_timeout_task(struct work_struct *work)
{ … }
static int e100_loopback_test(struct nic *nic, enum loopback loopback_mode)
{ … }
#define MII_LED_CONTROL …
#define E100_82552_LED_OVERRIDE …
#define E100_82552_LED_ON …
#define E100_82552_LED_OFF …
static int e100_get_link_ksettings(struct net_device *netdev,
struct ethtool_link_ksettings *cmd)
{ … }
static int e100_set_link_ksettings(struct net_device *netdev,
const struct ethtool_link_ksettings *cmd)
{ … }
static void e100_get_drvinfo(struct net_device *netdev,
struct ethtool_drvinfo *info)
{ … }
#define E100_PHY_REGS …
static int e100_get_regs_len(struct net_device *netdev)
{ … }
static void e100_get_regs(struct net_device *netdev,
struct ethtool_regs *regs, void *p)
{ … }
static void e100_get_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
{ … }
static int e100_set_wol(struct net_device *netdev, struct ethtool_wolinfo *wol)
{ … }
static u32 e100_get_msglevel(struct net_device *netdev)
{ … }
static void e100_set_msglevel(struct net_device *netdev, u32 value)
{ … }
static int e100_nway_reset(struct net_device *netdev)
{ … }
static u32 e100_get_link(struct net_device *netdev)
{ … }
static int e100_get_eeprom_len(struct net_device *netdev)
{ … }
#define E100_EEPROM_MAGIC …
static int e100_get_eeprom(struct net_device *netdev,
struct ethtool_eeprom *eeprom, u8 *bytes)
{ … }
static int e100_set_eeprom(struct net_device *netdev,
struct ethtool_eeprom *eeprom, u8 *bytes)
{ … }
static void e100_get_ringparam(struct net_device *netdev,
struct ethtool_ringparam *ring,
struct kernel_ethtool_ringparam *kernel_ring,
struct netlink_ext_ack *extack)
{ … }
static int e100_set_ringparam(struct net_device *netdev,
struct ethtool_ringparam *ring,
struct kernel_ethtool_ringparam *kernel_ring,
struct netlink_ext_ack *extack)
{ … }
static const char e100_gstrings_test[][ETH_GSTRING_LEN] = …;
#define E100_TEST_LEN …
static void e100_diag_test(struct net_device *netdev,
struct ethtool_test *test, u64 *data)
{ … }
static int e100_set_phys_id(struct net_device *netdev,
enum ethtool_phys_id_state state)
{ … }
static const char e100_gstrings_stats[][ETH_GSTRING_LEN] = …;
#define E100_NET_STATS_LEN …
#define E100_STATS_LEN …
static int e100_get_sset_count(struct net_device *netdev, int sset)
{ … }
static void e100_get_ethtool_stats(struct net_device *netdev,
struct ethtool_stats *stats, u64 *data)
{ … }
static void e100_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
{ … }
static const struct ethtool_ops e100_ethtool_ops = …;
static int e100_do_ioctl(struct net_device *netdev, struct ifreq *ifr, int cmd)
{ … }
static int e100_alloc(struct nic *nic)
{ … }
static void e100_free(struct nic *nic)
{ … }
static int e100_open(struct net_device *netdev)
{ … }
static int e100_close(struct net_device *netdev)
{ … }
static int e100_set_features(struct net_device *netdev,
netdev_features_t features)
{ … }
static const struct net_device_ops e100_netdev_ops = …;
static int e100_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
{ … }
static void e100_remove(struct pci_dev *pdev)
{ … }
#define E100_82552_SMARTSPEED …
#define E100_82552_REV_ANEG …
#define E100_82552_ANEG_NOW …
static void __e100_shutdown(struct pci_dev *pdev, bool *enable_wake)
{ … }
static int __e100_power_off(struct pci_dev *pdev, bool wake)
{ … }
static int e100_suspend(struct device *dev_d)
{ … }
static int e100_resume(struct device *dev_d)
{ … }
static void e100_shutdown(struct pci_dev *pdev)
{ … }
static pci_ers_result_t e100_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
{ … }
static pci_ers_result_t e100_io_slot_reset(struct pci_dev *pdev)
{ … }
static void e100_io_resume(struct pci_dev *pdev)
{ … }
static const struct pci_error_handlers e100_err_handler = …;
static DEFINE_SIMPLE_DEV_PM_OPS(e100_pm_ops, e100_suspend, e100_resume);
static struct pci_driver e100_driver = …;
static int __init e100_init_module(void)
{ … }
static void __exit e100_cleanup_module(void)
{ … }
module_init(…) …;
module_exit(e100_cleanup_module);