linux/drivers/net/ethernet/cortina/gemini.c

// SPDX-License-Identifier: GPL-2.0
/* Ethernet device driver for Cortina Systems Gemini SoC
 * Also known as the StorLink SL3512 and SL3516 (SL351x) or Lepus
 * Net Engine and Gigabit Ethernet MAC (GMAC)
 * This hardware contains a TCP Offload Engine (TOE) but currently the
 * driver does not make use of it.
 *
 * Authors:
 * Linus Walleij <[email protected]>
 * Tobias Waldvogel <[email protected]> (OpenWRT)
 * Michał Mirosław <[email protected]>
 * Paulius Zaleckas <[email protected]>
 * Giuseppe De Robertis <[email protected]>
 * Gary Chen & Ch Hsu Storlink Semiconductor
 */
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/platform_device.h>
#include <linux/spinlock.h>
#include <linux/slab.h>
#include <linux/dma-mapping.h>
#include <linux/cache.h>
#include <linux/interrupt.h>
#include <linux/reset.h>
#include <linux/clk.h>
#include <linux/of.h>
#include <linux/of_mdio.h>
#include <linux/of_net.h>
#include <linux/of_platform.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/skbuff.h>
#include <linux/phy.h>
#include <linux/crc32.h>
#include <linux/ethtool.h>
#include <linux/tcp.h>
#include <linux/u64_stats_sync.h>

#include <linux/in.h>
#include <linux/ip.h>
#include <linux/ipv6.h>

#include "gemini.h"

#define DRV_NAME

#define DEFAULT_MSG_ENABLE
static int debug =;
module_param(debug, int, 0);
MODULE_PARM_DESC();

#define HSIZE_8
#define HSIZE_16
#define HSIZE_32

#define HBURST_SINGLE
#define HBURST_INCR
#define HBURST_INCR4
#define HBURST_INCR8

#define HPROT_DATA_CACHE
#define HPROT_PRIVILIGED
#define HPROT_BUFFERABLE
#define HPROT_CACHABLE

#define DEFAULT_RX_COALESCE_NSECS
#define DEFAULT_GMAC_RXQ_ORDER
#define DEFAULT_GMAC_TXQ_ORDER
#define DEFAULT_RX_BUF_ORDER
#define TX_MAX_FRAGS
#define TX_QUEUE_NUM
#define RX_MAX_ALLOC_ORDER

#define GMAC0_IRQ0_2
#define GMAC0_IRQ0_TXQ0_INTS
#define GMAC0_IRQ4_8

#define GMAC_OFFLOAD_FEATURES

/**
 * struct gmac_queue_page - page buffer per-page info
 * @page: the page struct
 * @mapping: the dma address handle
 */
struct gmac_queue_page {};

struct gmac_txq {};

struct gemini_ethernet;

struct gemini_ethernet_port {};

struct gemini_ethernet {};

#define GMAC_STATS_NUM

static const char gmac_stats_strings[GMAC_STATS_NUM][ETH_GSTRING_LEN] =;

static void gmac_dump_dma_state(struct net_device *netdev);

static void gmac_update_config0_reg(struct net_device *netdev,
				    u32 val, u32 vmask)
{}

static void gmac_enable_tx_rx(struct net_device *netdev)
{}

static void gmac_disable_tx_rx(struct net_device *netdev)
{}

static void gmac_set_flow_control(struct net_device *netdev, bool tx, bool rx)
{}

static void gmac_adjust_link(struct net_device *netdev)
{}

static int gmac_setup_phy(struct net_device *netdev)
{}

/* The maximum frame length is not logically enumerated in the
 * hardware, so we do a table lookup to find the applicable max
 * frame length.
 */
struct gmac_max_framelen {};

static const struct gmac_max_framelen gmac_maxlens[] =;

static int gmac_pick_rx_max_len(unsigned int max_l3_len)
{}

static int gmac_init(struct net_device *netdev)
{}

static int gmac_setup_txqs(struct net_device *netdev)
{}

static void gmac_clean_txq(struct net_device *netdev, struct gmac_txq *txq,
			   unsigned int r)
{}

static void gmac_cleanup_txqs(struct net_device *netdev)
{}

static int gmac_setup_rxq(struct net_device *netdev)
{}

static struct gmac_queue_page *
gmac_get_queue_page(struct gemini_ethernet *geth,
		    struct gemini_ethernet_port *port,
		    dma_addr_t addr)
{}

static void gmac_cleanup_rxq(struct net_device *netdev)
{}

static struct page *geth_freeq_alloc_map_page(struct gemini_ethernet *geth,
					      int pn)
{}

/**
 * geth_fill_freeq() - Fill the freeq with empty fragments to use
 * @geth: the ethernet adapter
 * @refill: whether to reset the queue by filling in all freeq entries or
 * just refill it, usually the interrupt to refill the queue happens when
 * the queue is half empty.
 */
static unsigned int geth_fill_freeq(struct gemini_ethernet *geth, bool refill)
{}

static int geth_setup_freeq(struct gemini_ethernet *geth)
{}

/**
 * geth_cleanup_freeq() - cleanup the DMA mappings and free the queue
 * @geth: the Gemini global ethernet state
 */
static void geth_cleanup_freeq(struct gemini_ethernet *geth)
{}

/**
 * geth_resize_freeq() - resize the software queue depth
 * @port: the port requesting the change
 *
 * This gets called at least once during probe() so the device queue gets
 * "resized" from the hardware defaults. Since both ports/net devices share
 * the same hardware queue, some synchronization between the ports is
 * needed.
 */
static int geth_resize_freeq(struct gemini_ethernet_port *port)
{}

static void gmac_tx_irq_enable(struct net_device *netdev,
			       unsigned int txq, int en)
{}

static void gmac_tx_irq(struct net_device *netdev, unsigned int txq_num)
{}

static int gmac_map_tx_bufs(struct net_device *netdev, struct sk_buff *skb,
			    struct gmac_txq *txq, unsigned short *desc)
{}

static netdev_tx_t gmac_start_xmit(struct sk_buff *skb,
				   struct net_device *netdev)
{}

static void gmac_tx_timeout(struct net_device *netdev, unsigned int txqueue)
{}

static void gmac_enable_irq(struct net_device *netdev, int enable)
{}

static void gmac_enable_rx_irq(struct net_device *netdev, int enable)
{}

static struct sk_buff *gmac_skb_if_good_frame(struct gemini_ethernet_port *port,
					      union gmac_rxdesc_0 word0,
					      unsigned int frame_len)
{}

static unsigned int gmac_rx(struct net_device *netdev, unsigned int budget)
{}

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

static void gmac_dump_dma_state(struct net_device *netdev)
{}

static void gmac_update_hw_stats(struct net_device *netdev)
{}

/**
 * gmac_get_intr_flags() - get interrupt status flags for a port from
 * @netdev: the net device for the port to get flags from
 * @i: the interrupt status register 0..4
 */
static u32 gmac_get_intr_flags(struct net_device *netdev, int i)
{}

static enum hrtimer_restart gmac_coalesce_delay_expired(struct hrtimer *timer)
{}

static irqreturn_t gmac_irq(int irq, void *data)
{}

static void gmac_start_dma(struct gemini_ethernet_port *port)
{}

static void gmac_stop_dma(struct gemini_ethernet_port *port)
{}

static int gmac_open(struct net_device *netdev)
{}

static int gmac_stop(struct net_device *netdev)
{}

static void gmac_set_rx_mode(struct net_device *netdev)
{}

static void gmac_write_mac_address(struct net_device *netdev)
{}

static int gmac_set_mac_address(struct net_device *netdev, void *addr)
{}

static void gmac_clear_hw_stats(struct net_device *netdev)
{}

static void gmac_get_stats64(struct net_device *netdev,
			     struct rtnl_link_stats64 *stats)
{}

static int gmac_change_mtu(struct net_device *netdev, int new_mtu)
{}

static int gmac_set_features(struct net_device *netdev,
			     netdev_features_t features)
{}

static int gmac_get_sset_count(struct net_device *netdev, int sset)
{}

static void gmac_get_strings(struct net_device *netdev, u32 stringset, u8 *data)
{}

static void gmac_get_ethtool_stats(struct net_device *netdev,
				   struct ethtool_stats *estats, u64 *values)
{}

static int gmac_get_ksettings(struct net_device *netdev,
			      struct ethtool_link_ksettings *cmd)
{}

static int gmac_set_ksettings(struct net_device *netdev,
			      const struct ethtool_link_ksettings *cmd)
{}

static int gmac_nway_reset(struct net_device *netdev)
{}

static void gmac_get_pauseparam(struct net_device *netdev,
				struct ethtool_pauseparam *pparam)
{}

static int gmac_set_pauseparam(struct net_device *netdev,
			       struct ethtool_pauseparam *pparam)
{}

static void gmac_get_ringparam(struct net_device *netdev,
			       struct ethtool_ringparam *rp,
			       struct kernel_ethtool_ringparam *kernel_rp,
			       struct netlink_ext_ack *extack)
{}

static int gmac_set_ringparam(struct net_device *netdev,
			      struct ethtool_ringparam *rp,
			      struct kernel_ethtool_ringparam *kernel_rp,
			      struct netlink_ext_ack *extack)
{}

static int gmac_get_coalesce(struct net_device *netdev,
			     struct ethtool_coalesce *ecmd,
			     struct kernel_ethtool_coalesce *kernel_coal,
			     struct netlink_ext_ack *extack)
{}

static int gmac_set_coalesce(struct net_device *netdev,
			     struct ethtool_coalesce *ecmd,
			     struct kernel_ethtool_coalesce *kernel_coal,
			     struct netlink_ext_ack *extack)
{}

static u32 gmac_get_msglevel(struct net_device *netdev)
{}

static void gmac_set_msglevel(struct net_device *netdev, u32 level)
{}

static void gmac_get_drvinfo(struct net_device *netdev,
			     struct ethtool_drvinfo *info)
{}

static const struct net_device_ops gmac_351x_ops =;

static const struct ethtool_ops gmac_351x_ethtool_ops =;

static irqreturn_t gemini_port_irq_thread(int irq, void *data)
{}

static irqreturn_t gemini_port_irq(int irq, void *data)
{}

static void gemini_port_remove(struct gemini_ethernet_port *port)
{}

static void gemini_ethernet_init(struct gemini_ethernet *geth)
{}

static void gemini_port_save_mac_addr(struct gemini_ethernet_port *port)
{}

static int gemini_ethernet_port_probe(struct platform_device *pdev)
{}

static void gemini_ethernet_port_remove(struct platform_device *pdev)
{}

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

static struct platform_driver gemini_ethernet_port_driver =;

static int gemini_ethernet_probe(struct platform_device *pdev)
{}

static void gemini_ethernet_remove(struct platform_device *pdev)
{}

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

static struct platform_driver gemini_ethernet_driver =;

static int __init gemini_ethernet_module_init(void)
{}
module_init();

static void __exit gemini_ethernet_module_exit(void)
{}
module_exit(gemini_ethernet_module_exit);

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