linux/drivers/net/ethernet/qlogic/qede/qede_main.c

// SPDX-License-Identifier: (GPL-2.0-only OR BSD-3-Clause)
/* QLogic qede NIC Driver
 * Copyright (c) 2015-2017  QLogic Corporation
 * Copyright (c) 2019-2020 Marvell International Ltd.
 */

#include <linux/crash_dump.h>
#include <linux/module.h>
#include <linux/pci.h>
#include <linux/device.h>
#include <linux/netdevice.h>
#include <linux/etherdevice.h>
#include <linux/skbuff.h>
#include <linux/errno.h>
#include <linux/list.h>
#include <linux/string.h>
#include <linux/dma-mapping.h>
#include <linux/interrupt.h>
#include <asm/byteorder.h>
#include <asm/param.h>
#include <linux/io.h>
#include <linux/netdev_features.h>
#include <linux/udp.h>
#include <linux/tcp.h>
#include <net/udp_tunnel.h>
#include <linux/ip.h>
#include <net/ipv6.h>
#include <net/tcp.h>
#include <linux/if_ether.h>
#include <linux/if_vlan.h>
#include <linux/pkt_sched.h>
#include <linux/ethtool.h>
#include <linux/in.h>
#include <linux/random.h>
#include <net/ip6_checksum.h>
#include <linux/bitops.h>
#include <linux/vmalloc.h>
#include "qede.h"
#include "qede_ptp.h"

MODULE_DESCRIPTION();
MODULE_LICENSE();

static uint debug;
module_param(debug, uint, 0);
MODULE_PARM_DESC();

static const struct qed_eth_ops *qed_ops;

#define CHIP_NUM_57980S_40
#define CHIP_NUM_57980S_10
#define CHIP_NUM_57980S_MF
#define CHIP_NUM_57980S_100
#define CHIP_NUM_57980S_50
#define CHIP_NUM_57980S_25
#define CHIP_NUM_57980S_IOV
#define CHIP_NUM_AH
#define CHIP_NUM_AH_IOV

#ifndef PCI_DEVICE_ID_NX2_57980E
#define PCI_DEVICE_ID_57980S_40
#define PCI_DEVICE_ID_57980S_10
#define PCI_DEVICE_ID_57980S_MF
#define PCI_DEVICE_ID_57980S_100
#define PCI_DEVICE_ID_57980S_50
#define PCI_DEVICE_ID_57980S_25
#define PCI_DEVICE_ID_57980S_IOV
#define PCI_DEVICE_ID_AH
#define PCI_DEVICE_ID_AH_IOV

#endif

enum qede_pci_private {};

static const struct pci_device_id qede_pci_tbl[] =;

MODULE_DEVICE_TABLE(pci, qede_pci_tbl);

static int qede_probe(struct pci_dev *pdev, const struct pci_device_id *id);
static pci_ers_result_t
qede_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state);

#define TX_TIMEOUT

/* Utilize last protocol index for XDP */
#define XDP_PI

static void qede_remove(struct pci_dev *pdev);
static void qede_shutdown(struct pci_dev *pdev);
static void qede_link_update(void *dev, struct qed_link_output *link);
static void qede_schedule_recovery_handler(void *dev);
static void qede_recovery_handler(struct qede_dev *edev);
static void qede_schedule_hw_err_handler(void *dev,
					 enum qed_hw_err_type err_type);
static void qede_get_eth_tlv_data(void *edev, void *data);
static void qede_get_generic_tlv_data(void *edev,
				      struct qed_generic_tlvs *data);
static void qede_generic_hw_err_handler(struct qede_dev *edev);
#ifdef CONFIG_QED_SRIOV
static int qede_set_vf_vlan(struct net_device *ndev, int vf, u16 vlan, u8 qos,
			    __be16 vlan_proto)
{}

static int qede_set_vf_mac(struct net_device *ndev, int vfidx, u8 *mac)
{}

static int qede_sriov_configure(struct pci_dev *pdev, int num_vfs_param)
{}
#endif

static int __maybe_unused qede_suspend(struct device *dev)
{}

static DEFINE_SIMPLE_DEV_PM_OPS(qede_pm_ops, qede_suspend, NULL);

static const struct pci_error_handlers qede_err_handler =;

static struct pci_driver qede_pci_driver =;

static struct qed_eth_cb_ops qede_ll_ops =;

static int qede_netdev_event(struct notifier_block *this, unsigned long event,
			     void *ptr)
{}

static struct notifier_block qede_netdev_notifier =;

static
int __init qede_init(void)
{}

static void __exit qede_cleanup(void)
{}

module_init();
module_exit(qede_cleanup);

static int qede_open(struct net_device *ndev);
static int qede_close(struct net_device *ndev);

void qede_fill_by_demand_stats(struct qede_dev *edev)
{}

static void qede_get_stats64(struct net_device *dev,
			     struct rtnl_link_stats64 *stats)
{}

#ifdef CONFIG_QED_SRIOV
static int qede_get_vf_config(struct net_device *dev, int vfidx,
			      struct ifla_vf_info *ivi)
{}

static int qede_set_vf_rate(struct net_device *dev, int vfidx,
			    int min_tx_rate, int max_tx_rate)
{}

static int qede_set_vf_spoofchk(struct net_device *dev, int vfidx, bool val)
{}

static int qede_set_vf_link_state(struct net_device *dev, int vfidx,
				  int link_state)
{}

static int qede_set_vf_trust(struct net_device *dev, int vfidx, bool setting)
{}
#endif

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

static void qede_fp_sb_dump(struct qede_dev *edev, struct qede_fastpath *fp)
{}

static void
qede_txq_fp_log_metadata(struct qede_dev *edev,
			 struct qede_fastpath *fp, struct qede_tx_queue *txq)
{}

static void
qede_tx_log_print(struct qede_dev *edev, struct qede_fastpath *fp, struct qede_tx_queue *txq)
{}

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

static int qede_setup_tc(struct net_device *ndev, u8 num_tc)
{}

static int
qede_set_flower(struct qede_dev *edev, struct flow_cls_offload *f,
		__be16 proto)
{}

static int qede_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
				  void *cb_priv)
{}

static LIST_HEAD(qede_block_cb_list);

static int
qede_setup_tc_offload(struct net_device *dev, enum tc_setup_type type,
		      void *type_data)
{}

static const struct net_device_ops qede_netdev_ops =;

static const struct net_device_ops qede_netdev_vf_ops =;

static const struct net_device_ops qede_netdev_vf_xdp_ops =;

/* -------------------------------------------------------------------------
 * START OF PROBE / REMOVE
 * -------------------------------------------------------------------------
 */

static struct qede_dev *qede_alloc_etherdev(struct qed_dev *cdev,
					    struct pci_dev *pdev,
					    struct qed_dev_eth_info *info,
					    u32 dp_module, u8 dp_level)
{}

static void qede_init_ndev(struct qede_dev *edev)
{}

/* This function converts from 32b param to two params of level and module
 * Input 32b decoding:
 * b31 - enable all NOTICE prints. NOTICE prints are for deviation from the
 * 'happy' flow, e.g. memory allocation failed.
 * b30 - enable all INFO prints. INFO prints are for major steps in the flow
 * and provide important parameters.
 * b29-b0 - per-module bitmap, where each bit enables VERBOSE prints of that
 * module. VERBOSE prints are for tracking the specific flow in low level.
 *
 * Notice that the level should be that of the lowest required logs.
 */
void qede_config_debug(uint debug, u32 *p_dp_module, u8 *p_dp_level)
{}

static void qede_free_fp_array(struct qede_dev *edev)
{}

static int qede_alloc_fp_array(struct qede_dev *edev)
{}

/* The qede lock is used to protect driver state change and driver flows that
 * are not reentrant.
 */
void __qede_lock(struct qede_dev *edev)
{}

void __qede_unlock(struct qede_dev *edev)
{}

/* This version of the lock should be used when acquiring the RTNL lock is also
 * needed in addition to the internal qede lock.
 */
static void qede_lock(struct qede_dev *edev)
{}

static void qede_unlock(struct qede_dev *edev)
{}

static void qede_periodic_task(struct work_struct *work)
{}

static void qede_init_periodic_task(struct qede_dev *edev)
{}

static void qede_sp_task(struct work_struct *work)
{}

static void qede_update_pf_params(struct qed_dev *cdev)
{}

#define QEDE_FW_VER_STR_SIZE

static void qede_log_probe(struct qede_dev *edev)
{}

enum qede_probe_mode {};

static int __qede_probe(struct pci_dev *pdev, u32 dp_module, u8 dp_level,
			bool is_vf, enum qede_probe_mode mode)
{}

static int qede_probe(struct pci_dev *pdev, const struct pci_device_id *id)
{}

enum qede_remove_mode {};

static void __qede_remove(struct pci_dev *pdev, enum qede_remove_mode mode)
{}

static void qede_remove(struct pci_dev *pdev)
{}

static void qede_shutdown(struct pci_dev *pdev)
{}

/* -------------------------------------------------------------------------
 * START OF LOAD / UNLOAD
 * -------------------------------------------------------------------------
 */

static int qede_set_num_queues(struct qede_dev *edev)
{}

static void qede_free_mem_sb(struct qede_dev *edev, struct qed_sb_info *sb_info,
			     u16 sb_id)
{}

/* This function allocates fast-path status block memory */
static int qede_alloc_mem_sb(struct qede_dev *edev,
			     struct qed_sb_info *sb_info, u16 sb_id)
{}

static void qede_free_rx_buffers(struct qede_dev *edev,
				 struct qede_rx_queue *rxq)
{}

static void qede_free_mem_rxq(struct qede_dev *edev, struct qede_rx_queue *rxq)
{}

static void qede_set_tpa_param(struct qede_rx_queue *rxq)
{}

/* This function allocates all memory needed per Rx queue */
static int qede_alloc_mem_rxq(struct qede_dev *edev, struct qede_rx_queue *rxq)
{}

static void qede_free_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq)
{}

/* This function allocates all memory needed per Tx queue */
static int qede_alloc_mem_txq(struct qede_dev *edev, struct qede_tx_queue *txq)
{}

/* This function frees all memory of a single fp */
static void qede_free_mem_fp(struct qede_dev *edev, struct qede_fastpath *fp)
{}

/* This function allocates all memory needed for a single fp (i.e. an entity
 * which contains status block, one rx queue and/or multiple per-TC tx queues.
 */
static int qede_alloc_mem_fp(struct qede_dev *edev, struct qede_fastpath *fp)
{}

static void qede_free_mem_load(struct qede_dev *edev)
{}

/* This function allocates all qede memory at NIC load. */
static int qede_alloc_mem_load(struct qede_dev *edev)
{}

static void qede_empty_tx_queue(struct qede_dev *edev,
				struct qede_tx_queue *txq)
{}

static void qede_empty_tx_queues(struct qede_dev *edev)
{}

/* This function inits fp content and resets the SB, RXQ and TXQ structures */
static void qede_init_fp(struct qede_dev *edev)
{}

static int qede_set_real_num_queues(struct qede_dev *edev)
{}

static void qede_napi_disable_remove(struct qede_dev *edev)
{}

static void qede_napi_add_enable(struct qede_dev *edev)
{}

static void qede_sync_free_irqs(struct qede_dev *edev)
{}

static int qede_req_msix_irqs(struct qede_dev *edev)
{}

static void qede_simd_fp_handler(void *cookie)
{}

static int qede_setup_irqs(struct qede_dev *edev)
{}

static int qede_drain_txq(struct qede_dev *edev,
			  struct qede_tx_queue *txq, bool allow_drain)
{}

static int qede_stop_txq(struct qede_dev *edev,
			 struct qede_tx_queue *txq, int rss_id)
{}

static int qede_stop_queues(struct qede_dev *edev)
{}

static int qede_start_txq(struct qede_dev *edev,
			  struct qede_fastpath *fp,
			  struct qede_tx_queue *txq, u8 rss_id, u16 sb_idx)
{}

static int qede_start_queues(struct qede_dev *edev, bool clear_stats)
{}

enum qede_unload_mode {};

static void qede_unload(struct qede_dev *edev, enum qede_unload_mode mode,
			bool is_locked)
{}

enum qede_load_mode {};

static int qede_load(struct qede_dev *edev, enum qede_load_mode mode,
		     bool is_locked)
{}

/* 'func' should be able to run between unload and reload assuming interface
 * is actually running, or afterwards in case it's currently DOWN.
 */
void qede_reload(struct qede_dev *edev,
		 struct qede_reload_args *args, bool is_locked)
{}

/* called with rtnl_lock */
static int qede_open(struct net_device *ndev)
{}

static int qede_close(struct net_device *ndev)
{}

static void qede_link_update(void *dev, struct qed_link_output *link)
{}

static void qede_schedule_recovery_handler(void *dev)
{}

static void qede_recovery_failed(struct qede_dev *edev)
{}

static void qede_recovery_handler(struct qede_dev *edev)
{}

static void qede_atomic_hw_err_handler(struct qede_dev *edev)
{}

static void qede_generic_hw_err_handler(struct qede_dev *edev)
{}

static void qede_set_hw_err_flags(struct qede_dev *edev,
				  enum qed_hw_err_type err_type)
{}

static void qede_schedule_hw_err_handler(void *dev,
					 enum qed_hw_err_type err_type)
{}

static bool qede_is_txq_full(struct qede_dev *edev, struct qede_tx_queue *txq)
{}

static void qede_get_generic_tlv_data(void *dev, struct qed_generic_tlvs *data)
{}

static void qede_get_eth_tlv_data(void *dev, void *data)
{}

/**
 * qede_io_error_detected(): Called when PCI error is detected
 *
 * @pdev: Pointer to PCI device
 * @state: The current pci connection state
 *
 *Return: pci_ers_result_t.
 *
 * This function is called after a PCI bus error affecting
 * this device has been detected.
 */
static pci_ers_result_t
qede_io_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
{}