#define pr_fmt(fmt) …
#define DRV_NAME …
#define DRV_VERSION …
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/compiler.h>
#include <linux/pci.h>
#include <linux/init.h>
#include <linux/interrupt.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/rtnetlink.h>
#include <linux/delay.h>
#include <linux/ethtool.h>
#include <linux/mii.h>
#include <linux/completion.h>
#include <linux/crc32.h>
#include <linux/io.h>
#include <linux/uaccess.h>
#include <linux/gfp.h>
#include <linux/if_vlan.h>
#include <asm/irq.h>
#define RTL8139_DRIVER_NAME …
#define RTL8139_DEF_MSG_ENABLE …
#define RTL8139_DEBUG …
#undef RTL8139_NDEBUG
#ifdef RTL8139_NDEBUG
#define assert …
#else
#define assert(expr) …
#endif
#define MAX_UNITS …
static int media[MAX_UNITS] = …;
static int full_duplex[MAX_UNITS] = …;
#ifdef CONFIG_8139TOO_PIO
static bool use_io = …;
#else
static bool use_io = false;
#endif
static int multicast_filter_limit = …;
static int debug = …;
#if defined(CONFIG_SH_DREAMCAST)
#define RX_BUF_IDX …
#else
#define RX_BUF_IDX …
#endif
#define RX_BUF_LEN …
#define RX_BUF_PAD …
#define RX_BUF_WRAP_PAD …
#if RX_BUF_LEN == 65536
#define RX_BUF_TOT_LEN …
#else
#define RX_BUF_TOT_LEN …
#endif
#define NUM_TX_DESC …
#define MAX_ETH_FRAME_SIZE …
#define MAX_ETH_DATA_SIZE …
#define TX_BUF_SIZE …
#define TX_BUF_TOT_LEN …
#define TX_FIFO_THRESH …
#define RX_FIFO_THRESH …
#define RX_DMA_BURST …
#define TX_DMA_BURST …
#define TX_RETRY …
#define TX_TIMEOUT …
enum { … };
#define RTL_NUM_STATS …
#define RTL_REGS_VER …
#define RTL_MIN_IO_SIZE …
#define RTL8139B_IO_SIZE …
#define RTL8129_CAPS …
#define RTL8139_CAPS …
board_t;
static const struct { … } board_info[] = …;
static const struct pci_device_id rtl8139_pci_tbl[] = …;
MODULE_DEVICE_TABLE (pci, rtl8139_pci_tbl);
static struct { … } ethtool_stats_keys[] = …;
enum RTL8139_registers { … };
enum ClearBitMasks { … };
enum ChipCmdBits { … };
enum IntrStatusBits { … };
enum TxStatusBits { … };
enum RxStatusBits { … };
enum rx_mode_bits { … };
enum tx_config_bits { … };
enum Config1Bits { … };
enum Config3Bits { … };
enum Config4Bits { … };
enum Config5Bits { … };
enum RxConfigBits { … };
enum CSCRBits { … };
enum Cfg9346Bits { … };
chip_t;
enum chip_flags { … };
#define HW_REVID(b30, b29, b28, b27, b26, b23, b22) …
#define HW_REVID_MASK …
static const struct { … } rtl_chip_info[] = …;
struct rtl_extra_stats { … };
struct rtl8139_stats { … };
struct rtl8139_private { … };
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
MODULE_VERSION(…);
module_param(use_io, bool, 0);
MODULE_PARM_DESC(…) …;
module_param(multicast_filter_limit, int, 0);
module_param_array(…);
module_param_array(…);
module_param(debug, int, 0);
MODULE_PARM_DESC(…) …;
MODULE_PARM_DESC(…) …;
MODULE_PARM_DESC(…) …;
MODULE_PARM_DESC(…) …;
static int read_eeprom (void __iomem *ioaddr, int location, int addr_len);
static int rtl8139_open (struct net_device *dev);
static int mdio_read (struct net_device *dev, int phy_id, int location);
static void mdio_write (struct net_device *dev, int phy_id, int location,
int val);
static void rtl8139_start_thread(struct rtl8139_private *tp);
static void rtl8139_tx_timeout (struct net_device *dev, unsigned int txqueue);
static void rtl8139_init_ring (struct net_device *dev);
static netdev_tx_t rtl8139_start_xmit (struct sk_buff *skb,
struct net_device *dev);
#ifdef CONFIG_NET_POLL_CONTROLLER
static void rtl8139_poll_controller(struct net_device *dev);
#endif
static int rtl8139_set_mac_address(struct net_device *dev, void *p);
static int rtl8139_poll(struct napi_struct *napi, int budget);
static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance);
static int rtl8139_close (struct net_device *dev);
static int netdev_ioctl (struct net_device *dev, struct ifreq *rq, int cmd);
static void rtl8139_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats);
static void rtl8139_set_rx_mode (struct net_device *dev);
static void __set_rx_mode (struct net_device *dev);
static void rtl8139_hw_start (struct net_device *dev);
static void rtl8139_thread (struct work_struct *work);
static void rtl8139_tx_timeout_task(struct work_struct *work);
static const struct ethtool_ops rtl8139_ethtool_ops;
#define RTL_W8_F(reg, val8) …
#define RTL_W16_F(reg, val16) …
#define RTL_W32_F(reg, val32) …
#define RTL_W8(reg, val8) …
#define RTL_W16(reg, val16) …
#define RTL_W32(reg, val32) …
#define RTL_R8(reg) …
#define RTL_R16(reg) …
#define RTL_R32(reg) …
static const u16 rtl8139_intr_mask = …;
static const u16 rtl8139_norx_intr_mask = … ;
#if RX_BUF_IDX == 0
static const unsigned int rtl8139_rx_config =
RxCfgRcv8K | RxNoWrap |
(RX_FIFO_THRESH << RxCfgFIFOShift) |
(RX_DMA_BURST << RxCfgDMAShift);
#elif RX_BUF_IDX == 1
static const unsigned int rtl8139_rx_config =
RxCfgRcv16K | RxNoWrap |
(RX_FIFO_THRESH << RxCfgFIFOShift) |
(RX_DMA_BURST << RxCfgDMAShift);
#elif RX_BUF_IDX == 2
static const unsigned int rtl8139_rx_config = …;
#elif RX_BUF_IDX == 3
static const unsigned int rtl8139_rx_config =
RxCfgRcv64K |
(RX_FIFO_THRESH << RxCfgFIFOShift) |
(RX_DMA_BURST << RxCfgDMAShift);
#else
#error "Invalid configuration for 8139_RXBUF_IDX"
#endif
static const unsigned int rtl8139_tx_config = …;
static void __rtl8139_cleanup_dev (struct net_device *dev)
{ … }
static void rtl8139_chip_reset (void __iomem *ioaddr)
{ … }
static struct net_device *rtl8139_init_board(struct pci_dev *pdev)
{ … }
static int rtl8139_set_features(struct net_device *dev, netdev_features_t features)
{ … }
static const struct net_device_ops rtl8139_netdev_ops = …;
static int rtl8139_init_one(struct pci_dev *pdev,
const struct pci_device_id *ent)
{ … }
static void rtl8139_remove_one(struct pci_dev *pdev)
{ … }
#define EE_SHIFT_CLK …
#define EE_CS …
#define EE_DATA_WRITE …
#define EE_WRITE_0 …
#define EE_WRITE_1 …
#define EE_DATA_READ …
#define EE_ENB …
#define eeprom_delay() …
#define EE_WRITE_CMD …
#define EE_READ_CMD …
#define EE_ERASE_CMD …
static int read_eeprom(void __iomem *ioaddr, int location, int addr_len)
{ … }
#define MDIO_DIR …
#define MDIO_DATA_OUT …
#define MDIO_DATA_IN …
#define MDIO_CLK …
#define MDIO_WRITE0 …
#define MDIO_WRITE1 …
#define mdio_delay() …
static const char mii_2_8139_map[8] = …;
#ifdef CONFIG_8139TOO_8129
static void mdio_sync (void __iomem *ioaddr)
{ … }
#endif
static int mdio_read (struct net_device *dev, int phy_id, int location)
{ … }
static void mdio_write (struct net_device *dev, int phy_id, int location,
int value)
{ … }
static int rtl8139_open (struct net_device *dev)
{ … }
static void rtl_check_media (struct net_device *dev, unsigned int init_media)
{ … }
static void rtl8139_hw_start (struct net_device *dev)
{ … }
static void rtl8139_init_ring (struct net_device *dev)
{ … }
static int next_tick = …;
#ifndef CONFIG_8139TOO_TUNE_TWISTER
static inline void rtl8139_tune_twister (struct net_device *dev,
struct rtl8139_private *tp) {}
#else
enum TwisterParamVals { … };
static const unsigned long param[4][4] = …;
static void rtl8139_tune_twister (struct net_device *dev,
struct rtl8139_private *tp)
{ … }
#endif
static inline void rtl8139_thread_iter (struct net_device *dev,
struct rtl8139_private *tp,
void __iomem *ioaddr)
{ … }
static void rtl8139_thread (struct work_struct *work)
{ … }
static void rtl8139_start_thread(struct rtl8139_private *tp)
{ … }
static inline void rtl8139_tx_clear (struct rtl8139_private *tp)
{ … }
static void rtl8139_tx_timeout_task (struct work_struct *work)
{ … }
static void rtl8139_tx_timeout(struct net_device *dev, unsigned int txqueue)
{ … }
static netdev_tx_t rtl8139_start_xmit (struct sk_buff *skb,
struct net_device *dev)
{ … }
static void rtl8139_tx_interrupt (struct net_device *dev,
struct rtl8139_private *tp,
void __iomem *ioaddr)
{ … }
static void rtl8139_rx_err (u32 rx_status, struct net_device *dev,
struct rtl8139_private *tp, void __iomem *ioaddr)
{ … }
#if RX_BUF_IDX == 3
static inline void wrap_copy(struct sk_buff *skb, const unsigned char *ring,
u32 offset, unsigned int size)
{
u32 left = RX_BUF_LEN - offset;
if (size > left) {
skb_copy_to_linear_data(skb, ring + offset, left);
skb_copy_to_linear_data_offset(skb, left, ring, size - left);
} else
skb_copy_to_linear_data(skb, ring + offset, size);
}
#endif
static void rtl8139_isr_ack(struct rtl8139_private *tp)
{ … }
static int rtl8139_rx(struct net_device *dev, struct rtl8139_private *tp,
int budget)
{ … }
static void rtl8139_weird_interrupt (struct net_device *dev,
struct rtl8139_private *tp,
void __iomem *ioaddr,
int status, int link_changed)
{ … }
static int rtl8139_poll(struct napi_struct *napi, int budget)
{ … }
static irqreturn_t rtl8139_interrupt (int irq, void *dev_instance)
{ … }
#ifdef CONFIG_NET_POLL_CONTROLLER
static void rtl8139_poll_controller(struct net_device *dev)
{ … }
#endif
static int rtl8139_set_mac_address(struct net_device *dev, void *p)
{ … }
static int rtl8139_close (struct net_device *dev)
{ … }
static void rtl8139_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{ … }
static int rtl8139_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{ … }
static void rtl8139_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{ … }
static int rtl8139_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{ … }
static int rtl8139_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{ … }
static int rtl8139_nway_reset(struct net_device *dev)
{ … }
static u32 rtl8139_get_link(struct net_device *dev)
{ … }
static u32 rtl8139_get_msglevel(struct net_device *dev)
{ … }
static void rtl8139_set_msglevel(struct net_device *dev, u32 datum)
{ … }
static int rtl8139_get_regs_len(struct net_device *dev)
{ … }
static void rtl8139_get_regs(struct net_device *dev, struct ethtool_regs *regs, void *regbuf)
{ … }
static int rtl8139_get_sset_count(struct net_device *dev, int sset)
{ … }
static void rtl8139_get_ethtool_stats(struct net_device *dev, struct ethtool_stats *stats, u64 *data)
{ … }
static void rtl8139_get_strings(struct net_device *dev, u32 stringset, u8 *data)
{ … }
static const struct ethtool_ops rtl8139_ethtool_ops = …;
static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ … }
static void
rtl8139_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{ … }
static void __set_rx_mode (struct net_device *dev)
{ … }
static void rtl8139_set_rx_mode (struct net_device *dev)
{ … }
static int __maybe_unused rtl8139_suspend(struct device *device)
{ … }
static int __maybe_unused rtl8139_resume(struct device *device)
{ … }
static SIMPLE_DEV_PM_OPS(rtl8139_pm_ops, rtl8139_suspend, rtl8139_resume);
static struct pci_driver rtl8139_pci_driver = …;
static int __init rtl8139_init_module (void)
{ … }
static void __exit rtl8139_cleanup_module (void)
{ … }
module_init(…) …;
module_exit(rtl8139_cleanup_module);