#define pr_fmt(fmt) …
#define DRV_NAME …
#include <linux/types.h>
static int debug = …;
#define RHINE_MSG_DEFAULT …
#if defined(__alpha__) || defined(__arm__) || defined(__hppa__) || \
defined(CONFIG_SPARC) || defined(__ia64__) || \
defined(__sh__) || defined(__mips__)
static int rx_copybreak = 1518;
#else
static int rx_copybreak;
#endif
static bool avoid_D3;
static const int multicast_filter_limit = …;
#define TX_RING_SIZE …
#define TX_QUEUE_LEN …
#define RX_RING_SIZE …
#define TX_TIMEOUT …
#define PKT_BUF_SZ …
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/kernel.h>
#include <linux/string.h>
#include <linux/timer.h>
#include <linux/errno.h>
#include <linux/ioport.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/of.h>
#include <linux/of_irq.h>
#include <linux/platform_device.h>
#include <linux/dma-mapping.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/mii.h>
#include <linux/ethtool.h>
#include <linux/crc32.h>
#include <linux/if_vlan.h>
#include <linux/bitops.h>
#include <linux/workqueue.h>
#include <asm/processor.h>
#include <asm/io.h>
#include <asm/irq.h>
#include <linux/uaccess.h>
#include <linux/dmi.h>
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
module_param(debug, int, 0);
module_param(rx_copybreak, int, 0);
module_param(avoid_D3, bool, 0);
MODULE_PARM_DESC(…) …;
MODULE_PARM_DESC(…) …;
MODULE_PARM_DESC(…) …;
#define MCAM_SIZE …
#define VCAM_SIZE …
enum rhine_revs { … };
enum rhine_quirks { … };
#define IOSYNC …
static const struct pci_device_id rhine_pci_tbl[] = …;
MODULE_DEVICE_TABLE(pci, rhine_pci_tbl);
static u32 vt8500_quirks = …;
static const struct of_device_id rhine_of_tbl[] = …;
MODULE_DEVICE_TABLE(of, rhine_of_tbl);
enum register_offsets { … };
enum backoff_bits { … };
enum tcr_bits { … };
enum camcon_bits { … };
enum bcr1_bits { … };
static const int mmio_verify_registers[] = …;
enum intr_status_bits { … };
enum wol_bits { … };
struct rx_desc { … };
struct tx_desc { … };
#define TXDESC …
enum rx_status_bits { … };
enum desc_status_bits { … };
enum desc_length_bits { … };
enum chip_cmd_bits { … };
struct rhine_stats { … };
struct rhine_private { … };
#define BYTE_REG_BITS_ON(x, p) …
#define WORD_REG_BITS_ON(x, p) …
#define DWORD_REG_BITS_ON(x, p) …
#define BYTE_REG_BITS_IS_ON(x, p) …
#define WORD_REG_BITS_IS_ON(x, p) …
#define DWORD_REG_BITS_IS_ON(x, p) …
#define BYTE_REG_BITS_OFF(x, p) …
#define WORD_REG_BITS_OFF(x, p) …
#define DWORD_REG_BITS_OFF(x, p) …
#define BYTE_REG_BITS_SET(x, m, p) …
#define WORD_REG_BITS_SET(x, m, p) …
#define DWORD_REG_BITS_SET(x, m, p) …
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 rhine_open(struct net_device *dev);
static void rhine_reset_task(struct work_struct *work);
static void rhine_slow_event_task(struct work_struct *work);
static void rhine_tx_timeout(struct net_device *dev, unsigned int txqueue);
static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
struct net_device *dev);
static irqreturn_t rhine_interrupt(int irq, void *dev_instance);
static void rhine_tx(struct net_device *dev);
static int rhine_rx(struct net_device *dev, int limit);
static void rhine_set_rx_mode(struct net_device *dev);
static void rhine_get_stats64(struct net_device *dev,
struct rtnl_link_stats64 *stats);
static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd);
static const struct ethtool_ops netdev_ethtool_ops;
static int rhine_close(struct net_device *dev);
static int rhine_vlan_rx_add_vid(struct net_device *dev,
__be16 proto, u16 vid);
static int rhine_vlan_rx_kill_vid(struct net_device *dev,
__be16 proto, u16 vid);
static void rhine_restart_tx(struct net_device *dev);
static void rhine_wait_bit(struct rhine_private *rp, u8 reg, u8 mask, bool low)
{ … }
static void rhine_wait_bit_high(struct rhine_private *rp, u8 reg, u8 mask)
{ … }
static void rhine_wait_bit_low(struct rhine_private *rp, u8 reg, u8 mask)
{ … }
static u32 rhine_get_events(struct rhine_private *rp)
{ … }
static void rhine_ack_events(struct rhine_private *rp, u32 mask)
{ … }
static void rhine_power_init(struct net_device *dev)
{ … }
static void rhine_chip_reset(struct net_device *dev)
{ … }
static void enable_mmio(long pioaddr, u32 quirks)
{ … }
static inline int verify_mmio(struct device *hwdev,
long pioaddr,
void __iomem *ioaddr,
u32 quirks)
{ … }
static void rhine_reload_eeprom(long pioaddr, struct net_device *dev)
{ … }
#ifdef CONFIG_NET_POLL_CONTROLLER
static void rhine_poll(struct net_device *dev)
{ … }
#endif
static void rhine_kick_tx_threshold(struct rhine_private *rp)
{ … }
static void rhine_tx_err(struct rhine_private *rp, u32 status)
{ … }
static void rhine_update_rx_crc_and_missed_errord(struct rhine_private *rp)
{ … }
#define RHINE_EVENT_NAPI_RX …
#define RHINE_EVENT_NAPI_TX_ERR …
#define RHINE_EVENT_NAPI_TX …
#define RHINE_EVENT_NAPI …
#define RHINE_EVENT_SLOW …
#define RHINE_EVENT …
static int rhine_napipoll(struct napi_struct *napi, int budget)
{ … }
static void rhine_hw_init(struct net_device *dev, long pioaddr)
{ … }
static const struct net_device_ops rhine_netdev_ops = …;
static int rhine_init_one_common(struct device *hwdev, u32 quirks,
long pioaddr, void __iomem *ioaddr, int irq)
{ … }
static int rhine_init_one_pci(struct pci_dev *pdev,
const struct pci_device_id *ent)
{ … }
static int rhine_init_one_platform(struct platform_device *pdev)
{ … }
static int alloc_ring(struct net_device* dev)
{ … }
static void free_ring(struct net_device* dev)
{ … }
struct rhine_skb_dma { … };
static inline int rhine_skb_dma_init(struct net_device *dev,
struct rhine_skb_dma *sd)
{ … }
static void rhine_reset_rbufs(struct rhine_private *rp)
{ … }
static inline void rhine_skb_dma_nic_store(struct rhine_private *rp,
struct rhine_skb_dma *sd, int entry)
{ … }
static void free_rbufs(struct net_device* dev);
static int alloc_rbufs(struct net_device *dev)
{ … }
static void free_rbufs(struct net_device* dev)
{ … }
static void alloc_tbufs(struct net_device* dev)
{ … }
static void free_tbufs(struct net_device* dev)
{ … }
static void rhine_check_media(struct net_device *dev, unsigned int init_media)
{ … }
static void rhine_set_carrier(struct mii_if_info *mii)
{ … }
static void rhine_set_cam(void __iomem *ioaddr, int idx, u8 *addr)
{ … }
static void rhine_set_vlan_cam(void __iomem *ioaddr, int idx, u8 *addr)
{ … }
static void rhine_set_cam_mask(void __iomem *ioaddr, u32 mask)
{ … }
static void rhine_set_vlan_cam_mask(void __iomem *ioaddr, u32 mask)
{ … }
static void rhine_init_cam_filter(struct net_device *dev)
{ … }
static void rhine_update_vcam(struct net_device *dev)
{ … }
static int rhine_vlan_rx_add_vid(struct net_device *dev, __be16 proto, u16 vid)
{ … }
static int rhine_vlan_rx_kill_vid(struct net_device *dev, __be16 proto, u16 vid)
{ … }
static void init_registers(struct net_device *dev)
{ … }
static void rhine_enable_linkmon(struct rhine_private *rp)
{ … }
static void rhine_disable_linkmon(struct rhine_private *rp)
{ … }
static int mdio_read(struct net_device *dev, int phy_id, int regnum)
{ … }
static void mdio_write(struct net_device *dev, int phy_id, int regnum, int value)
{ … }
static void rhine_task_disable(struct rhine_private *rp)
{ … }
static void rhine_task_enable(struct rhine_private *rp)
{ … }
static int rhine_open(struct net_device *dev)
{ … }
static void rhine_reset_task(struct work_struct *work)
{ … }
static void rhine_tx_timeout(struct net_device *dev, unsigned int txqueue)
{ … }
static inline bool rhine_tx_queue_full(struct rhine_private *rp)
{ … }
static netdev_tx_t rhine_start_tx(struct sk_buff *skb,
struct net_device *dev)
{ … }
static void rhine_irq_disable(struct rhine_private *rp)
{ … }
static irqreturn_t rhine_interrupt(int irq, void *dev_instance)
{ … }
static void rhine_tx(struct net_device *dev)
{ … }
static inline u16 rhine_get_vlan_tci(struct sk_buff *skb, int data_size)
{ … }
static inline void rhine_rx_vlan_tag(struct sk_buff *skb, struct rx_desc *desc,
int data_size)
{ … }
static int rhine_rx(struct net_device *dev, int limit)
{ … }
static void rhine_restart_tx(struct net_device *dev) { … }
static void rhine_slow_event_task(struct work_struct *work)
{ … }
static void
rhine_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{ … }
static void rhine_set_rx_mode(struct net_device *dev)
{ … }
static void netdev_get_drvinfo(struct net_device *dev, struct ethtool_drvinfo *info)
{ … }
static int netdev_get_link_ksettings(struct net_device *dev,
struct ethtool_link_ksettings *cmd)
{ … }
static int netdev_set_link_ksettings(struct net_device *dev,
const struct ethtool_link_ksettings *cmd)
{ … }
static int netdev_nway_reset(struct net_device *dev)
{ … }
static u32 netdev_get_link(struct net_device *dev)
{ … }
static u32 netdev_get_msglevel(struct net_device *dev)
{ … }
static void netdev_set_msglevel(struct net_device *dev, u32 value)
{ … }
static void rhine_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{ … }
static int rhine_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{ … }
static const struct ethtool_ops netdev_ethtool_ops = …;
static int netdev_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ … }
static int rhine_close(struct net_device *dev)
{ … }
static void rhine_remove_one_pci(struct pci_dev *pdev)
{ … }
static void rhine_remove_one_platform(struct platform_device *pdev)
{ … }
static void rhine_shutdown_pci(struct pci_dev *pdev)
{ … }
#ifdef CONFIG_PM_SLEEP
static int rhine_suspend(struct device *device)
{ … }
static int rhine_resume(struct device *device)
{ … }
static SIMPLE_DEV_PM_OPS(rhine_pm_ops, rhine_suspend, rhine_resume);
#define RHINE_PM_OPS …
#else
#define RHINE_PM_OPS …
#endif
static struct pci_driver rhine_driver_pci = …;
static struct platform_driver rhine_driver_platform = …;
static const struct dmi_system_id rhine_dmi_table[] __initconst = …;
static int __init rhine_init(void)
{ … }
static void __exit rhine_cleanup(void)
{ … }
module_init(…) …;
module_exit(rhine_cleanup);