#define pr_fmt(fmt) …
#include <linux/kernel.h>
#include <linux/platform_device.h>
#include <linux/string.h>
#include <linux/errno.h>
#include <linux/unistd.h>
#include <linux/slab.h>
#include <linux/interrupt.h>
#include <linux/delay.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/if_vlan.h>
#include <linux/spinlock.h>
#include <linux/mm.h>
#include <linux/of_address.h>
#include <linux/of_irq.h>
#include <linux/of_mdio.h>
#include <linux/ip.h>
#include <linux/tcp.h>
#include <linux/udp.h>
#include <linux/in.h>
#include <linux/net_tstamp.h>
#include <asm/io.h>
#ifdef CONFIG_PPC
#include <asm/reg.h>
#include <asm/mpc85xx.h>
#endif
#include <asm/irq.h>
#include <linux/uaccess.h>
#include <linux/module.h>
#include <linux/dma-mapping.h>
#include <linux/crc32.h>
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/phy_fixed.h>
#include <linux/of.h>
#include <linux/of_net.h>
#include "gianfar.h"
#define TX_TIMEOUT …
MODULE_AUTHOR(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_LICENSE(…) …;
static void gfar_init_rxbdp(struct gfar_priv_rx_q *rx_queue, struct rxbd8 *bdp,
dma_addr_t buf)
{ … }
static void gfar_init_tx_rx_base(struct gfar_private *priv)
{ … }
static void gfar_init_rqprm(struct gfar_private *priv)
{ … }
static void gfar_rx_offload_en(struct gfar_private *priv)
{ … }
static void gfar_mac_rx_config(struct gfar_private *priv)
{ … }
static void gfar_mac_tx_config(struct gfar_private *priv)
{ … }
static void gfar_configure_coalescing(struct gfar_private *priv,
unsigned long tx_mask, unsigned long rx_mask)
{ … }
static void gfar_configure_coalescing_all(struct gfar_private *priv)
{ … }
static void gfar_get_stats64(struct net_device *dev, struct rtnl_link_stats64 *stats)
{ … }
static void gfar_set_hash_for_addr(struct net_device *dev, u8 *addr)
{ … }
static void gfar_set_mac_for_addr(struct net_device *dev, int num,
const u8 *addr)
{ … }
static int gfar_set_mac_addr(struct net_device *dev, void *p)
{ … }
static void gfar_ints_disable(struct gfar_private *priv)
{ … }
static void gfar_ints_enable(struct gfar_private *priv)
{ … }
static int gfar_alloc_tx_queues(struct gfar_private *priv)
{ … }
static int gfar_alloc_rx_queues(struct gfar_private *priv)
{ … }
static void gfar_free_tx_queues(struct gfar_private *priv)
{ … }
static void gfar_free_rx_queues(struct gfar_private *priv)
{ … }
static void unmap_group_regs(struct gfar_private *priv)
{ … }
static void free_gfar_dev(struct gfar_private *priv)
{ … }
static void disable_napi(struct gfar_private *priv)
{ … }
static void enable_napi(struct gfar_private *priv)
{ … }
static int gfar_parse_group(struct device_node *np,
struct gfar_private *priv, const char *model)
{ … }
static int gfar_of_group_count(struct device_node *np)
{ … }
static phy_interface_t gfar_get_interface(struct net_device *dev)
{ … }
static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
{ … }
static u32 cluster_entry_per_class(struct gfar_private *priv, u32 rqfar,
u32 class)
{ … }
static void gfar_init_filer_table(struct gfar_private *priv)
{ … }
#ifdef CONFIG_PPC
static void __gfar_detect_errata_83xx(struct gfar_private *priv)
{
unsigned int pvr = mfspr(SPRN_PVR);
unsigned int svr = mfspr(SPRN_SVR);
unsigned int mod = (svr >> 16) & 0xfff6;
unsigned int rev = svr & 0xffff;
if ((pvr == 0x80850010 && mod == 0x80b0 && rev >= 0x0020) ||
(pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
priv->errata |= GFAR_ERRATA_74;
if ((pvr == 0x80850010 && mod == 0x80b0) ||
(pvr == 0x80861010 && (mod & 0xfff9) == 0x80c0))
priv->errata |= GFAR_ERRATA_76;
if (pvr == 0x80850010 && mod == 0x80b0 && rev < 0x0020)
priv->errata |= GFAR_ERRATA_12;
}
static void __gfar_detect_errata_85xx(struct gfar_private *priv)
{
unsigned int svr = mfspr(SPRN_SVR);
if ((SVR_SOC_VER(svr) == SVR_8548) && (SVR_REV(svr) == 0x20))
priv->errata |= GFAR_ERRATA_12;
if (((SVR_SOC_VER(svr) == SVR_P2020) && (SVR_REV(svr) < 0x20)) ||
((SVR_SOC_VER(svr) == SVR_P2010) && (SVR_REV(svr) < 0x20)) ||
((SVR_SOC_VER(svr) == SVR_8548) && (SVR_REV(svr) < 0x31)))
priv->errata |= GFAR_ERRATA_76;
}
#endif
static void gfar_detect_errata(struct gfar_private *priv)
{ … }
static void gfar_init_addr_hash_table(struct gfar_private *priv)
{ … }
static int __gfar_is_rx_idle(struct gfar_private *priv)
{ … }
static void gfar_halt_nodisable(struct gfar_private *priv)
{ … }
static void gfar_halt(struct gfar_private *priv)
{ … }
static void free_skb_tx_queue(struct gfar_priv_tx_q *tx_queue)
{ … }
static void free_skb_rx_queue(struct gfar_priv_rx_q *rx_queue)
{ … }
static void free_skb_resources(struct gfar_private *priv)
{ … }
void stop_gfar(struct net_device *dev)
{ … }
static void gfar_start(struct gfar_private *priv)
{ … }
static bool gfar_new_page(struct gfar_priv_rx_q *rxq, struct gfar_rx_buff *rxb)
{ … }
static void gfar_rx_alloc_err(struct gfar_priv_rx_q *rx_queue)
{ … }
static void gfar_alloc_rx_buffs(struct gfar_priv_rx_q *rx_queue,
int alloc_cnt)
{ … }
static void gfar_init_bds(struct net_device *ndev)
{ … }
static int gfar_alloc_skb_resources(struct net_device *ndev)
{ … }
int startup_gfar(struct net_device *ndev)
{ … }
static u32 gfar_get_flowctrl_cfg(struct gfar_private *priv)
{ … }
static noinline void gfar_update_link_state(struct gfar_private *priv)
{ … }
static void adjust_link(struct net_device *dev)
{ … }
static void gfar_configure_serdes(struct net_device *dev)
{ … }
static int init_phy(struct net_device *dev)
{ … }
static inline struct txfcb *gfar_add_fcb(struct sk_buff *skb)
{ … }
static inline void gfar_tx_checksum(struct sk_buff *skb, struct txfcb *fcb,
int fcb_length)
{ … }
static inline void gfar_tx_vlan(struct sk_buff *skb, struct txfcb *fcb)
{ … }
static inline struct txbd8 *skip_txbd(struct txbd8 *bdp, int stride,
struct txbd8 *base, int ring_size)
{ … }
static inline struct txbd8 *next_txbd(struct txbd8 *bdp, struct txbd8 *base,
int ring_size)
{ … }
static inline bool gfar_csum_errata_12(struct gfar_private *priv,
unsigned long fcb_addr)
{ … }
static inline bool gfar_csum_errata_76(struct gfar_private *priv,
unsigned int len)
{ … }
static netdev_tx_t gfar_start_xmit(struct sk_buff *skb, struct net_device *dev)
{ … }
static int gfar_set_mac_address(struct net_device *dev)
{ … }
static int gfar_change_mtu(struct net_device *dev, int new_mtu)
{ … }
static void reset_gfar(struct net_device *ndev)
{ … }
static void gfar_reset_task(struct work_struct *work)
{ … }
static void gfar_timeout(struct net_device *dev, unsigned int txqueue)
{ … }
static int gfar_hwtstamp_set(struct net_device *netdev, struct ifreq *ifr)
{ … }
static int gfar_hwtstamp_get(struct net_device *netdev, struct ifreq *ifr)
{ … }
static int gfar_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
{ … }
static void gfar_clean_tx_ring(struct gfar_priv_tx_q *tx_queue)
{ … }
static void count_errors(u32 lstatus, struct net_device *ndev)
{ … }
static irqreturn_t gfar_receive(int irq, void *grp_id)
{ … }
static irqreturn_t gfar_transmit(int irq, void *grp_id)
{ … }
static bool gfar_add_rx_frag(struct gfar_rx_buff *rxb, u32 lstatus,
struct sk_buff *skb, bool first)
{ … }
static void gfar_reuse_rx_page(struct gfar_priv_rx_q *rxq,
struct gfar_rx_buff *old_rxb)
{ … }
static struct sk_buff *gfar_get_next_rxbuff(struct gfar_priv_rx_q *rx_queue,
u32 lstatus, struct sk_buff *skb)
{ … }
static inline void gfar_rx_checksum(struct sk_buff *skb, struct rxfcb *fcb)
{ … }
static void gfar_process_frame(struct net_device *ndev, struct sk_buff *skb)
{ … }
static int gfar_clean_rx_ring(struct gfar_priv_rx_q *rx_queue,
int rx_work_limit)
{ … }
static int gfar_poll_rx_sq(struct napi_struct *napi, int budget)
{ … }
static int gfar_poll_tx_sq(struct napi_struct *napi, int budget)
{ … }
static irqreturn_t gfar_error(int irq, void *grp_id)
{ … }
static irqreturn_t gfar_interrupt(int irq, void *grp_id)
{ … }
#ifdef CONFIG_NET_POLL_CONTROLLER
static void gfar_netpoll(struct net_device *dev)
{ … }
#endif
static void free_grp_irqs(struct gfar_priv_grp *grp)
{ … }
static int register_grp_irqs(struct gfar_priv_grp *grp)
{ … }
static void gfar_free_irq(struct gfar_private *priv)
{ … }
static int gfar_request_irq(struct gfar_private *priv)
{ … }
static int gfar_enet_open(struct net_device *dev)
{ … }
static int gfar_close(struct net_device *dev)
{ … }
static void gfar_clear_exact_match(struct net_device *dev)
{ … }
static void gfar_set_multi(struct net_device *dev)
{ … }
void gfar_mac_reset(struct gfar_private *priv)
{ … }
static void gfar_hw_init(struct gfar_private *priv)
{ … }
static const struct net_device_ops gfar_netdev_ops = …;
static int gfar_probe(struct platform_device *ofdev)
{ … }
static void gfar_remove(struct platform_device *ofdev)
{ … }
#ifdef CONFIG_PM
static void __gfar_filer_disable(struct gfar_private *priv)
{ … }
static void __gfar_filer_enable(struct gfar_private *priv)
{ … }
static void gfar_filer_config_wol(struct gfar_private *priv)
{ … }
static void gfar_filer_restore_table(struct gfar_private *priv)
{ … }
static void gfar_start_wol_filer(struct gfar_private *priv)
{ … }
static int gfar_suspend(struct device *dev)
{ … }
static int gfar_resume(struct device *dev)
{ … }
static int gfar_restore(struct device *dev)
{ … }
static const struct dev_pm_ops gfar_pm_ops = …;
#define GFAR_PM_OPS …
#else
#define GFAR_PM_OPS …
#endif
static const struct of_device_id gfar_match[] = …;
MODULE_DEVICE_TABLE(of, gfar_match);
static struct platform_driver gfar_driver = …;
module_platform_driver(…) …;