linux/drivers/net/ethernet/hisilicon/hns/hns_enet.c

// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (c) 2014-2015 Hisilicon Limited.
 */

#include <linux/clk.h>
#include <linux/cpumask.h>
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/interrupt.h>
#include <linux/io.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/irq.h>
#include <linux/module.h>
#include <linux/phy.h>
#include <linux/platform_device.h>
#include <linux/skbuff.h>

#include "hnae.h"
#include "hns_enet.h"
#include "hns_dsaf_mac.h"

#define NIC_MAX_Q_PER_VF
#define HNS_NIC_TX_TIMEOUT

#define SERVICE_TIMER_HZ

#define RCB_IRQ_NOT_INITED
#define RCB_IRQ_INITED
#define HNS_BUFFER_SIZE_2048

#define BD_MAX_SEND_SIZE

static void fill_v2_desc_hw(struct hnae_ring *ring, void *priv, int size,
			    int send_sz, dma_addr_t dma, int frag_end,
			    int buf_num, enum hns_desc_type type, int mtu)
{}

static void fill_v2_desc(struct hnae_ring *ring, void *priv,
			 int size, dma_addr_t dma, int frag_end,
			 int buf_num, enum hns_desc_type type, int mtu)
{}

static const struct acpi_device_id hns_enet_acpi_match[] =;
MODULE_DEVICE_TABLE(acpi, hns_enet_acpi_match);

static void fill_desc(struct hnae_ring *ring, void *priv,
		      int size, dma_addr_t dma, int frag_end,
		      int buf_num, enum hns_desc_type type, int mtu,
		      bool is_gso)
{}

static void unfill_desc(struct hnae_ring *ring)
{}

static int hns_nic_maybe_stop_tx(
	struct sk_buff **out_skb, int *bnum, struct hnae_ring *ring)
{}

static int hns_nic_maybe_stop_tso(
	struct sk_buff **out_skb, int *bnum, struct hnae_ring *ring)
{}

static int hns_nic_maybe_stop_tx_v2(struct sk_buff **out_skb, int *bnum,
				    struct hnae_ring *ring)
{}

static void fill_tso_desc(struct hnae_ring *ring, void *priv,
			  int size, dma_addr_t dma, int frag_end,
			  int buf_num, enum hns_desc_type type, int mtu)
{}

static void fill_desc_v2(struct hnae_ring *ring, void *priv,
			 int size, dma_addr_t dma, int frag_end,
			 int buf_num, enum hns_desc_type type, int mtu,
			 bool is_gso)
{}

netdev_tx_t hns_nic_net_xmit_hw(struct net_device *ndev,
				struct sk_buff *skb,
				struct hns_nic_ring_data *ring_data)
{}

static void hns_nic_reuse_page(struct sk_buff *skb, int i,
			       struct hnae_ring *ring, int pull_len,
			       struct hnae_desc_cb *desc_cb)
{}

static void get_v2rx_desc_bnum(u32 bnum_flag, int *out_bnum)
{}

static void get_rx_desc_bnum(u32 bnum_flag, int *out_bnum)
{}

static void hns_nic_rx_checksum(struct hns_nic_ring_data *ring_data,
				struct sk_buff *skb, u32 flag)
{}

static int hns_nic_poll_rx_skb(struct hns_nic_ring_data *ring_data,
			       struct sk_buff **out_skb, int *out_bnum)
{}

static void
hns_nic_alloc_rx_buffers(struct hns_nic_ring_data *ring_data, int cleand_count)
{}

/* return error number for error or number of desc left to take
 */
static void hns_nic_rx_up_pro(struct hns_nic_ring_data *ring_data,
			      struct sk_buff *skb)
{}

static int hns_desc_unused(struct hnae_ring *ring)
{}

#define HNS_LOWEST_LATENCY_RATE
#define HNS_LOW_LATENCY_RATE

#define HNS_COAL_BDNUM

static u32 hns_coal_rx_bdnum(struct hnae_ring *ring)
{}

static void hns_update_rx_rate(struct hnae_ring *ring)
{}

/**
 * smooth_alg - smoothing algrithm for adjusting coalesce parameter
 * @new_param: new value
 * @old_param: old value
 **/
static u32 smooth_alg(u32 new_param, u32 old_param)
{}

/**
 * hns_nic_adpt_coalesce - self adapte coalesce according to rx rate
 * @ring_data: pointer to hns_nic_ring_data
 **/
static void hns_nic_adpt_coalesce(struct hns_nic_ring_data *ring_data)
{}

static int hns_nic_rx_poll_one(struct hns_nic_ring_data *ring_data,
			       int budget, void *v)
{}

static bool hns_nic_rx_fini_pro(struct hns_nic_ring_data *ring_data)
{}

static bool hns_nic_rx_fini_pro_v2(struct hns_nic_ring_data *ring_data)
{}

static inline void hns_nic_reclaim_one_desc(struct hnae_ring *ring,
					    int *bytes, int *pkts)
{}

static int is_valid_clean_head(struct hnae_ring *ring, int h)
{}

/* reclaim all desc in one budget
 * return error or number of desc left
 */
static int hns_nic_tx_poll_one(struct hns_nic_ring_data *ring_data,
			       int budget, void *v)
{}

static bool hns_nic_tx_fini_pro(struct hns_nic_ring_data *ring_data)
{}

static bool hns_nic_tx_fini_pro_v2(struct hns_nic_ring_data *ring_data)
{}

static void hns_nic_tx_clr_all_bufs(struct hns_nic_ring_data *ring_data)
{}

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

static irqreturn_t hns_irq_handle(int irq, void *dev)
{}

/**
 *hns_nic_adjust_link - adjust net work mode by the phy stat or new param
 *@ndev: net device
 */
static void hns_nic_adjust_link(struct net_device *ndev)
{}

/**
 *hns_nic_init_phy - init phy
 *@ndev: net device
 *@h: ae handle
 * Return 0 on success, negative on failure
 */
int hns_nic_init_phy(struct net_device *ndev, struct hnae_handle *h)
{}

static int hns_nic_ring_open(struct net_device *netdev, int idx)
{}

static int hns_nic_net_set_mac_address(struct net_device *ndev, void *p)
{}

static void hns_nic_update_stats(struct net_device *netdev)
{}

/* set mac addr if it is configed. or leave it to the AE driver */
static void hns_init_mac_addr(struct net_device *ndev)
{}

static void hns_nic_ring_close(struct net_device *netdev, int idx)
{}

static int hns_nic_init_affinity_mask(int q_num, int ring_idx,
				      struct hnae_ring *ring, cpumask_t *mask)
{}

static void hns_nic_free_irq(int q_num, struct hns_nic_priv *priv)
{}

static int hns_nic_init_irq(struct hns_nic_priv *priv)
{}

static int hns_nic_net_up(struct net_device *ndev)
{}

static void hns_nic_net_down(struct net_device *ndev)
{}

void hns_nic_net_reset(struct net_device *ndev)
{}

void hns_nic_net_reinit(struct net_device *netdev)
{}

static int hns_nic_net_open(struct net_device *ndev)
{}

static int hns_nic_net_stop(struct net_device *ndev)
{}

static void hns_tx_timeout_reset(struct hns_nic_priv *priv);
#define HNS_TX_TIMEO_LIMIT
static void hns_nic_net_timeout(struct net_device *ndev, unsigned int txqueue)
{}

static netdev_tx_t hns_nic_net_xmit(struct sk_buff *skb,
				    struct net_device *ndev)
{}

static void hns_nic_drop_rx_fetch(struct hns_nic_ring_data *ring_data,
				  struct sk_buff *skb)
{}

#define HNS_LB_TX_RING
static struct sk_buff *hns_assemble_skb(struct net_device *ndev)
{}

static int hns_enable_serdes_lb(struct net_device *ndev)
{}

static void hns_disable_serdes_lb(struct net_device *ndev)
{}

/**
 *hns_nic_clear_all_rx_fetch - clear the chip fetched descriptions. The
 *function as follows:
 *    1. if one rx ring has found the page_offset is not equal 0 between head
 *       and tail, it means that the chip fetched the wrong descs for the ring
 *       which buffer size is 4096.
 *    2. we set the chip serdes loopback and set rss indirection to the ring.
 *    3. construct 64-bytes ip broadcast packages, wait the associated rx ring
 *       receiving all packages and it will fetch new descriptions.
 *    4. recover to the original state.
 *
 *@ndev: net device
 */
static int hns_nic_clear_all_rx_fetch(struct net_device *ndev)
{}

static int hns_nic_change_mtu(struct net_device *ndev, int new_mtu)
{}

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

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

static int hns_nic_uc_sync(struct net_device *netdev, const unsigned char *addr)
{}

static int hns_nic_uc_unsync(struct net_device *netdev,
			     const unsigned char *addr)
{}

/**
 * hns_set_multicast_list - set mutl mac address
 * @ndev: net device
 *
 * return void
 */
static void hns_set_multicast_list(struct net_device *ndev)
{}

static void hns_nic_set_rx_mode(struct net_device *ndev)
{}

static void hns_nic_get_stats64(struct net_device *ndev,
				struct rtnl_link_stats64 *stats)
{}

static u16
hns_nic_select_queue(struct net_device *ndev, struct sk_buff *skb,
		     struct net_device *sb_dev)
{}

static const struct net_device_ops hns_nic_netdev_ops =;

static void hns_nic_update_link_status(struct net_device *netdev)
{}

/* for dumping key regs*/
static void hns_nic_dump(struct hns_nic_priv *priv)
{}

/* for resetting subtask */
static void hns_nic_reset_subtask(struct hns_nic_priv *priv)
{}

/* for doing service complete*/
static void hns_nic_service_event_complete(struct hns_nic_priv *priv)
{}

static void hns_nic_service_task(struct work_struct *work)
{}

static void hns_nic_task_schedule(struct hns_nic_priv *priv)
{}

static void hns_nic_service_timer(struct timer_list *t)
{}

/**
 * hns_tx_timeout_reset - initiate reset due to Tx timeout
 * @priv: driver private struct
 **/
static void hns_tx_timeout_reset(struct hns_nic_priv *priv)
{}

static int hns_nic_init_ring_data(struct hns_nic_priv *priv)
{}

static void hns_nic_uninit_ring_data(struct hns_nic_priv *priv)
{}

static void hns_nic_set_priv_ops(struct net_device *netdev)
{}

static int hns_nic_try_get_ae(struct net_device *ndev)
{}

static int hns_nic_notifier_action(struct notifier_block *nb,
				   unsigned long action, void *data)
{}

static int hns_nic_dev_probe(struct platform_device *pdev)
{}

static void hns_nic_dev_remove(struct platform_device *pdev)
{}

static const struct of_device_id hns_enet_of_match[] =;

MODULE_DEVICE_TABLE(of, hns_enet_of_match);

static struct platform_driver hns_nic_dev_driver =;

module_platform_driver();

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