linux/drivers/net/ethernet/ethoc.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * linux/drivers/net/ethernet/ethoc.c
 *
 * Copyright (C) 2007-2008 Avionic Design Development GmbH
 * Copyright (C) 2008-2009 Avionic Design GmbH
 *
 * Written by Thierry Reding <[email protected]>
 */

#include <linux/dma-mapping.h>
#include <linux/etherdevice.h>
#include <linux/clk.h>
#include <linux/crc32.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/mii.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/of.h>
#include <linux/of_net.h>
#include <linux/module.h>
#include <net/ethoc.h>

static int buffer_size =; /* 32 KBytes */
module_param(buffer_size, int, 0);
MODULE_PARM_DESC();

/* register offsets */
#define MODER
#define INT_SOURCE
#define INT_MASK
#define IPGT
#define IPGR1
#define IPGR2
#define PACKETLEN
#define COLLCONF
#define TX_BD_NUM
#define CTRLMODER
#define MIIMODER
#define MIICOMMAND
#define MIIADDRESS
#define MIITX_DATA
#define MIIRX_DATA
#define MIISTATUS
#define MAC_ADDR0
#define MAC_ADDR1
#define ETH_HASH0
#define ETH_HASH1
#define ETH_TXCTRL
#define ETH_END

/* mode register */
#define MODER_RXEN
#define MODER_TXEN
#define MODER_NOPRE
#define MODER_BRO
#define MODER_IAM
#define MODER_PRO
#define MODER_IFG
#define MODER_LOOP
#define MODER_NBO
#define MODER_EDE
#define MODER_FULLD
#define MODER_RESET
#define MODER_DCRC
#define MODER_CRC
#define MODER_HUGE
#define MODER_PAD
#define MODER_RSM

/* interrupt source and mask registers */
#define INT_MASK_TXF
#define INT_MASK_TXE
#define INT_MASK_RXF
#define INT_MASK_RXE
#define INT_MASK_BUSY
#define INT_MASK_TXC
#define INT_MASK_RXC

#define INT_MASK_TX
#define INT_MASK_RX

#define INT_MASK_ALL

/* packet length register */
#define PACKETLEN_MIN(min)
#define PACKETLEN_MAX(max)
#define PACKETLEN_MIN_MAX(min, max)

/* transmit buffer number register */
#define TX_BD_NUM_VAL(x)

/* control module mode register */
#define CTRLMODER_PASSALL
#define CTRLMODER_RXFLOW
#define CTRLMODER_TXFLOW

/* MII mode register */
#define MIIMODER_CLKDIV(x)
#define MIIMODER_NOPRE

/* MII command register */
#define MIICOMMAND_SCAN
#define MIICOMMAND_READ
#define MIICOMMAND_WRITE

/* MII address register */
#define MIIADDRESS_FIAD(x)
#define MIIADDRESS_RGAD(x)
#define MIIADDRESS_ADDR(phy, reg)

/* MII transmit data register */
#define MIITX_DATA_VAL(x)

/* MII receive data register */
#define MIIRX_DATA_VAL(x)

/* MII status register */
#define MIISTATUS_LINKFAIL
#define MIISTATUS_BUSY
#define MIISTATUS_INVALID

/* TX buffer descriptor */
#define TX_BD_CS
#define TX_BD_DF
#define TX_BD_LC
#define TX_BD_RL
#define TX_BD_RETRY_MASK
#define TX_BD_RETRY(x)
#define TX_BD_UR
#define TX_BD_CRC
#define TX_BD_PAD
#define TX_BD_WRAP
#define TX_BD_IRQ
#define TX_BD_READY
#define TX_BD_LEN(x)
#define TX_BD_LEN_MASK

#define TX_BD_STATS

/* RX buffer descriptor */
#define RX_BD_LC
#define RX_BD_CRC
#define RX_BD_SF
#define RX_BD_TL
#define RX_BD_DN
#define RX_BD_IS
#define RX_BD_OR
#define RX_BD_MISS
#define RX_BD_CF
#define RX_BD_WRAP
#define RX_BD_IRQ
#define RX_BD_EMPTY
#define RX_BD_LEN(x)

#define RX_BD_STATS

#define ETHOC_BUFSIZ
#define ETHOC_ZLEN
#define ETHOC_BD_BASE
#define ETHOC_TIMEOUT
#define ETHOC_MII_TIMEOUT

/**
 * struct ethoc - driver-private device structure
 * @iobase:	pointer to I/O memory region
 * @membase:	pointer to buffer memory region
 * @big_endian: just big or little (endian)
 * @num_bd:	number of buffer descriptors
 * @num_tx:	number of send buffers
 * @cur_tx:	last send buffer written
 * @dty_tx:	last buffer actually sent
 * @num_rx:	number of receive buffers
 * @cur_rx:	current receive buffer
 * @vma:        pointer to array of virtual memory addresses for buffers
 * @netdev:	pointer to network device structure
 * @napi:	NAPI structure
 * @msg_enable:	device state flags
 * @lock:	device lock
 * @mdio:	MDIO bus for PHY access
 * @clk:	clock
 * @phy_id:	address of attached PHY
 * @old_link:	previous link info
 * @old_duplex: previous duplex info
 */
struct ethoc {};

/**
 * struct ethoc_bd - buffer descriptor
 * @stat:	buffer statistics
 * @addr:	physical memory address
 */
struct ethoc_bd {};

static inline u32 ethoc_read(struct ethoc *dev, loff_t offset)
{}

static inline void ethoc_write(struct ethoc *dev, loff_t offset, u32 data)
{}

static inline void ethoc_read_bd(struct ethoc *dev, int index,
		struct ethoc_bd *bd)
{}

static inline void ethoc_write_bd(struct ethoc *dev, int index,
		const struct ethoc_bd *bd)
{}

static inline void ethoc_enable_irq(struct ethoc *dev, u32 mask)
{}

static inline void ethoc_disable_irq(struct ethoc *dev, u32 mask)
{}

static inline void ethoc_ack_irq(struct ethoc *dev, u32 mask)
{}

static inline void ethoc_enable_rx_and_tx(struct ethoc *dev)
{}

static inline void ethoc_disable_rx_and_tx(struct ethoc *dev)
{}

static int ethoc_init_ring(struct ethoc *dev, unsigned long mem_start)
{}

static int ethoc_reset(struct ethoc *dev)
{}

static unsigned int ethoc_update_rx_stats(struct ethoc *dev,
		struct ethoc_bd *bd)
{}

static int ethoc_rx(struct net_device *dev, int limit)
{}

static void ethoc_update_tx_stats(struct ethoc *dev, struct ethoc_bd *bd)
{}

static int ethoc_tx(struct net_device *dev, int limit)
{}

static irqreturn_t ethoc_interrupt(int irq, void *dev_id)
{}

static int ethoc_get_mac_address(struct net_device *dev, void *addr)
{}

static int ethoc_poll(struct napi_struct *napi, int budget)
{}

static int ethoc_mdio_read(struct mii_bus *bus, int phy, int reg)
{}

static int ethoc_mdio_write(struct mii_bus *bus, int phy, int reg, u16 val)
{}

static void ethoc_mdio_poll(struct net_device *dev)
{}

static int ethoc_mdio_probe(struct net_device *dev)
{}

static int ethoc_open(struct net_device *dev)
{}

static int ethoc_stop(struct net_device *dev)
{}

static int ethoc_ioctl(struct net_device *dev, struct ifreq *ifr, int cmd)
{}

static void ethoc_do_set_mac_address(struct net_device *dev)
{}

static int ethoc_set_mac_address(struct net_device *dev, void *p)
{}

static void ethoc_set_multicast_list(struct net_device *dev)
{}

static int ethoc_change_mtu(struct net_device *dev, int new_mtu)
{}

static void ethoc_tx_timeout(struct net_device *dev, unsigned int txqueue)
{}

static netdev_tx_t ethoc_start_xmit(struct sk_buff *skb, struct net_device *dev)
{}

static int ethoc_get_regs_len(struct net_device *netdev)
{}

static void ethoc_get_regs(struct net_device *dev, struct ethtool_regs *regs,
			   void *p)
{}

static void ethoc_get_ringparam(struct net_device *dev,
				struct ethtool_ringparam *ring,
				struct kernel_ethtool_ringparam *kernel_ring,
				struct netlink_ext_ack *extack)
{}

static int ethoc_set_ringparam(struct net_device *dev,
			       struct ethtool_ringparam *ring,
			       struct kernel_ethtool_ringparam *kernel_ring,
			       struct netlink_ext_ack *extack)
{}

static const struct ethtool_ops ethoc_ethtool_ops =;

static const struct net_device_ops ethoc_netdev_ops =;

/**
 * ethoc_probe - initialize OpenCores ethernet MAC
 * @pdev:	platform device
 */
static int ethoc_probe(struct platform_device *pdev)
{}

/**
 * ethoc_remove - shutdown OpenCores ethernet MAC
 * @pdev:	platform device
 */
static void ethoc_remove(struct platform_device *pdev)
{}

#ifdef CONFIG_PM
static int ethoc_suspend(struct platform_device *pdev, pm_message_t state)
{}

static int ethoc_resume(struct platform_device *pdev)
{}
#else
#define ethoc_suspend
#define ethoc_resume
#endif

static const struct of_device_id ethoc_match[] =;
MODULE_DEVICE_TABLE(of, ethoc_match);

static struct platform_driver ethoc_driver =;

module_platform_driver();

MODULE_AUTHOR();
MODULE_DESCRIPTION();
MODULE_LICENSE();