linux/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c

/* Broadcom NetXtreme-C/E network driver.
 *
 * Copyright (c) 2014-2016 Broadcom Corporation
 * Copyright (c) 2016-2017 Broadcom Limited
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation.
 */

#include <linux/bitops.h>
#include <linux/ctype.h>
#include <linux/stringify.h>
#include <linux/ethtool.h>
#include <linux/ethtool_netlink.h>
#include <linux/linkmode.h>
#include <linux/interrupt.h>
#include <linux/pci.h>
#include <linux/etherdevice.h>
#include <linux/crc32.h>
#include <linux/firmware.h>
#include <linux/utsname.h>
#include <linux/time.h>
#include <linux/ptp_clock_kernel.h>
#include <linux/net_tstamp.h>
#include <linux/timecounter.h>
#include <net/netlink.h>
#include "bnxt_hsi.h"
#include "bnxt.h"
#include "bnxt_hwrm.h"
#include "bnxt_ulp.h"
#include "bnxt_xdp.h"
#include "bnxt_ptp.h"
#include "bnxt_ethtool.h"
#include "bnxt_nvm_defs.h"	/* NVRAM content constant and structure defs */
#include "bnxt_fw_hdr.h"	/* Firmware hdr constant and structure defs */
#include "bnxt_coredump.h"

#define BNXT_NVM_ERR_MSG(dev, extack, msg)

static u32 bnxt_get_msglevel(struct net_device *dev)
{}

static void bnxt_set_msglevel(struct net_device *dev, u32 value)
{}

static int bnxt_get_coalesce(struct net_device *dev,
			     struct ethtool_coalesce *coal,
			     struct kernel_ethtool_coalesce *kernel_coal,
			     struct netlink_ext_ack *extack)
{}

static int bnxt_set_coalesce(struct net_device *dev,
			     struct ethtool_coalesce *coal,
			     struct kernel_ethtool_coalesce *kernel_coal,
			     struct netlink_ext_ack *extack)
{}

static const char * const bnxt_ring_rx_stats_str[] =;

static const char * const bnxt_ring_tx_stats_str[] =;

static const char * const bnxt_ring_tpa_stats_str[] =;

static const char * const bnxt_ring_tpa2_stats_str[] =;

static const char * const bnxt_rx_sw_stats_str[] =;

static const char * const bnxt_cmn_sw_stats_str[] =;

#define BNXT_RX_STATS_ENTRY(counter)

#define BNXT_TX_STATS_ENTRY(counter)

#define BNXT_RX_STATS_EXT_ENTRY(counter)

#define BNXT_TX_STATS_EXT_ENTRY(counter)

#define BNXT_RX_STATS_EXT_PFC_ENTRY(n)

#define BNXT_TX_STATS_EXT_PFC_ENTRY(n)

#define BNXT_RX_STATS_EXT_PFC_ENTRIES

#define BNXT_TX_STATS_EXT_PFC_ENTRIES

#define BNXT_RX_STATS_EXT_COS_ENTRY(n)

#define BNXT_TX_STATS_EXT_COS_ENTRY(n)

#define BNXT_RX_STATS_EXT_COS_ENTRIES				\

#define BNXT_TX_STATS_EXT_COS_ENTRIES				\

#define BNXT_RX_STATS_EXT_DISCARD_COS_ENTRY(n)

#define BNXT_RX_STATS_EXT_DISCARD_COS_ENTRIES

#define BNXT_RX_STATS_PRI_ENTRY(counter, n)

#define BNXT_TX_STATS_PRI_ENTRY(counter, n)

#define BNXT_RX_STATS_PRI_ENTRIES(counter)

#define BNXT_TX_STATS_PRI_ENTRIES(counter)

enum {};

static const char *const bnxt_ring_err_stats_arr[] =;

#define NUM_RING_RX_SW_STATS
#define NUM_RING_CMN_SW_STATS
#define NUM_RING_RX_HW_STATS
#define NUM_RING_TX_HW_STATS

static const struct {} bnxt_port_stats_arr[] =;

static const struct {} bnxt_port_stats_ext_arr[] =;

static const struct {} bnxt_tx_port_stats_ext_arr[] =;

static const struct {} bnxt_rx_bytes_pri_arr[] =;

static const struct {} bnxt_rx_pkts_pri_arr[] =;

static const struct {} bnxt_tx_bytes_pri_arr[] =;

static const struct {} bnxt_tx_pkts_pri_arr[] =;

#define BNXT_NUM_RING_ERR_STATS
#define BNXT_NUM_PORT_STATS
#define BNXT_NUM_STATS_PRI

static int bnxt_get_num_tpa_ring_stats(struct bnxt *bp)
{}

static int bnxt_get_num_ring_stats(struct bnxt *bp)
{}

static int bnxt_get_num_stats(struct bnxt *bp)
{}

static int bnxt_get_sset_count(struct net_device *dev, int sset)
{}

static bool is_rx_ring(struct bnxt *bp, int ring_num)
{}

static bool is_tx_ring(struct bnxt *bp, int ring_num)
{}

static void bnxt_get_ethtool_stats(struct net_device *dev,
				   struct ethtool_stats *stats, u64 *buf)
{}

static void bnxt_get_strings(struct net_device *dev, u32 stringset, u8 *buf)
{}

static void bnxt_get_ringparam(struct net_device *dev,
			       struct ethtool_ringparam *ering,
			       struct kernel_ethtool_ringparam *kernel_ering,
			       struct netlink_ext_ack *extack)
{}

static int bnxt_set_ringparam(struct net_device *dev,
			      struct ethtool_ringparam *ering,
			      struct kernel_ethtool_ringparam *kernel_ering,
			      struct netlink_ext_ack *extack)
{}

static void bnxt_get_channels(struct net_device *dev,
			      struct ethtool_channels *channel)
{}

static int bnxt_set_channels(struct net_device *dev,
			     struct ethtool_channels *channel)
{}

static u32 bnxt_get_all_fltr_ids_rcu(struct bnxt *bp, struct hlist_head tbl[],
				     int tbl_size, u32 *ids, u32 start,
				     u32 id_cnt)
{}

static struct bnxt_filter_base *bnxt_get_one_fltr_rcu(struct bnxt *bp,
						      struct hlist_head tbl[],
						      int tbl_size, u32 id)
{}

static int bnxt_grxclsrlall(struct bnxt *bp, struct ethtool_rxnfc *cmd,
			    u32 *rule_locs)
{}

static int bnxt_grxclsrule(struct bnxt *bp, struct ethtool_rxnfc *cmd)
{}

static struct bnxt_rss_ctx *bnxt_get_rss_ctx_from_index(struct bnxt *bp,
							u32 index)
{}

static int bnxt_alloc_vnic_rss_table(struct bnxt *bp,
				     struct bnxt_vnic_info *vnic)
{}

static int bnxt_add_l2_cls_rule(struct bnxt *bp,
				struct ethtool_rx_flow_spec *fs)
{}

static bool bnxt_verify_ntuple_ip4_flow(struct ethtool_usrip4_spec *ip_spec,
					struct ethtool_usrip4_spec *ip_mask)
{}

static bool bnxt_verify_ntuple_ip6_flow(struct ethtool_usrip6_spec *ip_spec,
					struct ethtool_usrip6_spec *ip_mask)
{}

static int bnxt_add_ntuple_cls_rule(struct bnxt *bp,
				    struct ethtool_rxnfc *cmd)
{}

static int bnxt_srxclsrlins(struct bnxt *bp, struct ethtool_rxnfc *cmd)
{}

static int bnxt_srxclsrldel(struct bnxt *bp, struct ethtool_rxnfc *cmd)
{}

static u64 get_ethtool_ipv4_rss(struct bnxt *bp)
{}

static u64 get_ethtool_ipv6_rss(struct bnxt *bp)
{}

static int bnxt_grxfh(struct bnxt *bp, struct ethtool_rxnfc *cmd)
{}

#define RXH_4TUPLE
#define RXH_2TUPLE

static int bnxt_srxfh(struct bnxt *bp, struct ethtool_rxnfc *cmd)
{}

static int bnxt_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,
			  u32 *rule_locs)
{}

static int bnxt_set_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd)
{}

u32 bnxt_get_rxfh_indir_size(struct net_device *dev)
{}

static u32 bnxt_get_rxfh_key_size(struct net_device *dev)
{}

static int bnxt_get_rxfh(struct net_device *dev,
			 struct ethtool_rxfh_param *rxfh)
{}

static void bnxt_modify_rss(struct bnxt *bp, struct ethtool_rxfh_context *ctx,
			    struct bnxt_rss_ctx *rss_ctx,
			    const struct ethtool_rxfh_param *rxfh)
{}

static int bnxt_rxfh_context_check(struct bnxt *bp,
				   const struct ethtool_rxfh_param *rxfh,
				   struct netlink_ext_ack *extack)
{}

static int bnxt_create_rxfh_context(struct net_device *dev,
				    struct ethtool_rxfh_context *ctx,
				    const struct ethtool_rxfh_param *rxfh,
				    struct netlink_ext_ack *extack)
{}

static int bnxt_modify_rxfh_context(struct net_device *dev,
				    struct ethtool_rxfh_context *ctx,
				    const struct ethtool_rxfh_param *rxfh,
				    struct netlink_ext_ack *extack)
{}

static int bnxt_remove_rxfh_context(struct net_device *dev,
				    struct ethtool_rxfh_context *ctx,
				    u32 rss_context,
				    struct netlink_ext_ack *extack)
{}

static int bnxt_set_rxfh(struct net_device *dev,
			 struct ethtool_rxfh_param *rxfh,
			 struct netlink_ext_ack *extack)
{}

static void bnxt_get_drvinfo(struct net_device *dev,
			     struct ethtool_drvinfo *info)
{}

static int bnxt_get_regs_len(struct net_device *dev)
{}

static void bnxt_get_regs(struct net_device *dev, struct ethtool_regs *regs,
			  void *_p)
{}

static void bnxt_get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{}

static int bnxt_set_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
{}

/* TODO: support 25GB, 40GB, 50GB with different cable type */
void _bnxt_fw_to_linkmode(unsigned long *mode, u16 fw_speeds)
{}

enum bnxt_media_type {};

static const enum bnxt_media_type bnxt_phy_types[] =;

static enum bnxt_media_type
bnxt_get_media(struct bnxt_link_info *link_info)
{}

enum bnxt_link_speed_indices {};

static enum bnxt_link_speed_indices bnxt_fw_speed_idx(u16 speed)
{}

static const enum ethtool_link_mode_bit_indices
bnxt_link_modes[__BNXT_LINK_SPEED_END][BNXT_SIG_MODE_MAX][__BNXT_MEDIA_END] =;

#define BNXT_LINK_MODE_UNKNOWN

static enum ethtool_link_mode_bit_indices
bnxt_get_link_mode(struct bnxt_link_info *link_info)
{}

static void bnxt_get_ethtool_modes(struct bnxt_link_info *link_info,
				   struct ethtool_link_ksettings *lk_ksettings)
{}

static const u16 bnxt_nrz_speed_masks[] =;

static const u16 bnxt_pam4_speed_masks[] =;

static const u16 bnxt_nrz_speeds2_masks[] =;

static const u16 bnxt_pam4_speeds2_masks[] =;

static const u16 bnxt_pam4_112_speeds2_masks[] =;

static enum bnxt_link_speed_indices
bnxt_encoding_speed_idx(u8 sig_mode, u16 phy_flags, u16 speed_msk)
{}

#define BNXT_FW_SPEED_MSK_BITS

static void
__bnxt_get_ethtool_speeds(unsigned long fw_mask, enum bnxt_media_type media,
			  u8 sig_mode, u16 phy_flags, unsigned long *et_mask)
{}

static void
bnxt_get_ethtool_speeds(unsigned long fw_mask, enum bnxt_media_type media,
			u8 sig_mode, u16 phy_flags, unsigned long *et_mask)
{}

static void
bnxt_get_all_ethtool_support_speeds(struct bnxt_link_info *link_info,
				    enum bnxt_media_type media,
				    struct ethtool_link_ksettings *lk_ksettings)
{}

static void
bnxt_get_all_ethtool_adv_speeds(struct bnxt_link_info *link_info,
				enum bnxt_media_type media,
				struct ethtool_link_ksettings *lk_ksettings)
{}

static void
bnxt_get_all_ethtool_lp_speeds(struct bnxt_link_info *link_info,
			       enum bnxt_media_type media,
			       struct ethtool_link_ksettings *lk_ksettings)
{}

static void bnxt_update_speed(u32 *delta, bool installed_media, u16 *speeds,
			      u16 speed_msk, const unsigned long *et_mask,
			      enum ethtool_link_mode_bit_indices mode)
{}

static void bnxt_set_ethtool_speeds(struct bnxt_link_info *link_info,
				    const unsigned long *et_mask)
{}

static void bnxt_fw_to_ethtool_advertised_fec(struct bnxt_link_info *link_info,
				struct ethtool_link_ksettings *lk_ksettings)
{}

static void bnxt_fw_to_ethtool_support_fec(struct bnxt_link_info *link_info,
				struct ethtool_link_ksettings *lk_ksettings)
{}

u32 bnxt_fw_to_ethtool_speed(u16 fw_link_speed)
{}

static void bnxt_get_default_speeds(struct ethtool_link_ksettings *lk_ksettings,
				    struct bnxt_link_info *link_info)
{}

static int bnxt_get_link_ksettings(struct net_device *dev,
				   struct ethtool_link_ksettings *lk_ksettings)
{}

static int
bnxt_force_link_speed(struct net_device *dev, u32 ethtool_speed, u32 lanes)
{}

u16 bnxt_get_fw_auto_link_speeds(const unsigned long *mode)
{}

static int bnxt_set_link_ksettings(struct net_device *dev,
			   const struct ethtool_link_ksettings *lk_ksettings)
{}

static int bnxt_get_fecparam(struct net_device *dev,
			     struct ethtool_fecparam *fec)
{}

static void bnxt_get_fec_stats(struct net_device *dev,
			       struct ethtool_fec_stats *fec_stats)
{}

static u32 bnxt_ethtool_forced_fec_to_fw(struct bnxt_link_info *link_info,
					 u32 fec)
{}

static int bnxt_set_fecparam(struct net_device *dev,
			     struct ethtool_fecparam *fecparam)
{}

static void bnxt_get_pauseparam(struct net_device *dev,
				struct ethtool_pauseparam *epause)
{}

static void bnxt_get_pause_stats(struct net_device *dev,
				 struct ethtool_pause_stats *epstat)
{}

static int bnxt_set_pauseparam(struct net_device *dev,
			       struct ethtool_pauseparam *epause)
{}

static u32 bnxt_get_link(struct net_device *dev)
{}

int bnxt_hwrm_nvm_get_dev_info(struct bnxt *bp,
			       struct hwrm_nvm_get_dev_info_output *nvm_dev_info)
{}

static void bnxt_print_admin_err(struct bnxt *bp)
{}

int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal,
			 u16 ext, u16 *index, u32 *item_length,
			 u32 *data_length);

int bnxt_flash_nvram(struct net_device *dev, u16 dir_type,
		     u16 dir_ordinal, u16 dir_ext, u16 dir_attr,
		     u32 dir_item_len, const u8 *data,
		     size_t data_len)
{}

int bnxt_hwrm_firmware_reset(struct net_device *dev, u8 proc_type,
			     u8 self_reset, u8 flags)
{}

static int bnxt_firmware_reset(struct net_device *dev,
			       enum bnxt_nvm_directory_type dir_type)
{}

static int bnxt_firmware_reset_chip(struct net_device *dev)
{}

static int bnxt_firmware_reset_ap(struct net_device *dev)
{}

static int bnxt_flash_firmware(struct net_device *dev,
			       u16 dir_type,
			       const u8 *fw_data,
			       size_t fw_size)
{}

static int bnxt_flash_microcode(struct net_device *dev,
				u16 dir_type,
				const u8 *fw_data,
				size_t fw_size)
{}

static bool bnxt_dir_type_is_ape_bin_format(u16 dir_type)
{}

static bool bnxt_dir_type_is_other_exec_format(u16 dir_type)
{}

static bool bnxt_dir_type_is_executable(u16 dir_type)
{}

static int bnxt_flash_firmware_from_file(struct net_device *dev,
					 u16 dir_type,
					 const char *filename)
{}

#define MSG_INTEGRITY_ERR
#define MSG_INVALID_PKG
#define MSG_AUTHENTICATION_ERR
#define MSG_INVALID_DEV
#define MSG_INTERNAL_ERR
#define MSG_NO_PKG_UPDATE_AREA_ERR
#define MSG_NO_SPACE_ERR
#define MSG_RESIZE_UPDATE_ERR
#define MSG_ANTI_ROLLBACK_ERR
#define MSG_GENERIC_FAILURE_ERR

static int nvm_update_err_to_stderr(struct net_device *dev, u8 result,
				    struct netlink_ext_ack *extack)
{}

#define BNXT_PKG_DMA_SIZE
#define BNXT_NVM_MORE_FLAG
#define BNXT_NVM_LAST_FLAG

static int bnxt_resize_update_entry(struct net_device *dev, size_t fw_size,
				    struct netlink_ext_ack *extack)
{}

int bnxt_flash_package_from_fw_obj(struct net_device *dev, const struct firmware *fw,
				   u32 install_type, struct netlink_ext_ack *extack)
{}

static int bnxt_flash_package_from_file(struct net_device *dev, const char *filename,
					u32 install_type, struct netlink_ext_ack *extack)
{}

static int bnxt_flash_device(struct net_device *dev,
			     struct ethtool_flash *flash)
{}

static int nvm_get_dir_info(struct net_device *dev, u32 *entries, u32 *length)
{}

static int bnxt_get_eeprom_len(struct net_device *dev)
{}

static int bnxt_get_nvram_directory(struct net_device *dev, u32 len, u8 *data)
{}

int bnxt_get_nvram_item(struct net_device *dev, u32 index, u32 offset,
			u32 length, u8 *data)
{}

int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal,
			 u16 ext, u16 *index, u32 *item_length,
			 u32 *data_length)
{}

static char *bnxt_parse_pkglog(int desired_field, u8 *data, size_t datalen)
{}

int bnxt_get_pkginfo(struct net_device *dev, char *ver, int size)
{}

static void bnxt_get_pkgver(struct net_device *dev)
{}

static int bnxt_get_eeprom(struct net_device *dev,
			   struct ethtool_eeprom *eeprom,
			   u8 *data)
{}

static int bnxt_erase_nvram_directory(struct net_device *dev, u8 index)
{}

static int bnxt_set_eeprom(struct net_device *dev,
			   struct ethtool_eeprom *eeprom,
			   u8 *data)
{}

static int bnxt_set_eee(struct net_device *dev, struct ethtool_keee *edata)
{}

static int bnxt_get_eee(struct net_device *dev, struct ethtool_keee *edata)
{}

static int bnxt_read_sfp_module_eeprom_info(struct bnxt *bp, u16 i2c_addr,
					    u16 page_number, u8 bank,
					    u16 start_addr, u16 data_length,
					    u8 *buf)
{}

static int bnxt_get_module_info(struct net_device *dev,
				struct ethtool_modinfo *modinfo)
{}

static int bnxt_get_module_eeprom(struct net_device *dev,
				  struct ethtool_eeprom *eeprom,
				  u8 *data)
{}

static int bnxt_get_module_status(struct bnxt *bp, struct netlink_ext_ack *extack)
{}

static int bnxt_get_module_eeprom_by_page(struct net_device *dev,
					  const struct ethtool_module_eeprom *page_data,
					  struct netlink_ext_ack *extack)
{}

static int bnxt_nway_reset(struct net_device *dev)
{}

static int bnxt_set_phys_id(struct net_device *dev,
			    enum ethtool_phys_id_state state)
{}

static int bnxt_hwrm_selftest_irq(struct bnxt *bp, u16 cmpl_ring)
{}

static int bnxt_test_irq(struct bnxt *bp)
{}

static int bnxt_hwrm_mac_loopback(struct bnxt *bp, bool enable)
{}

static int bnxt_query_force_speeds(struct bnxt *bp, u16 *force_speeds)
{}

static int bnxt_disable_an_for_lpbk(struct bnxt *bp,
				    struct hwrm_port_phy_cfg_input *req)
{}

static int bnxt_hwrm_phy_loopback(struct bnxt *bp, bool enable, bool ext)
{}

static int bnxt_rx_loopback(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
			    u32 raw_cons, int pkt_size)
{}

static int bnxt_poll_loopback(struct bnxt *bp, struct bnxt_cp_ring_info *cpr,
			      int pkt_size)
{}

static int bnxt_run_loopback(struct bnxt *bp)
{}

static int bnxt_run_fw_tests(struct bnxt *bp, u8 test_mask, u8 *test_results)
{}

#define BNXT_DRV_TESTS
#define BNXT_MACLPBK_TEST_IDX
#define BNXT_PHYLPBK_TEST_IDX
#define BNXT_EXTLPBK_TEST_IDX
#define BNXT_IRQ_TEST_IDX

static void bnxt_self_test(struct net_device *dev, struct ethtool_test *etest,
			   u64 *buf)
{}

static int bnxt_reset(struct net_device *dev, u32 *flags)
{}

static int bnxt_set_dump(struct net_device *dev, struct ethtool_dump *dump)
{}

static int bnxt_get_dump_flag(struct net_device *dev, struct ethtool_dump *dump)
{}

static int bnxt_get_dump_data(struct net_device *dev, struct ethtool_dump *dump,
			      void *buf)
{}

static int bnxt_get_ts_info(struct net_device *dev,
			    struct kernel_ethtool_ts_info *info)
{}

void bnxt_ethtool_init(struct bnxt *bp)
{}

static void bnxt_get_eth_phy_stats(struct net_device *dev,
				   struct ethtool_eth_phy_stats *phy_stats)
{}

static void bnxt_get_eth_mac_stats(struct net_device *dev,
				   struct ethtool_eth_mac_stats *mac_stats)
{}

static void bnxt_get_eth_ctrl_stats(struct net_device *dev,
				    struct ethtool_eth_ctrl_stats *ctrl_stats)
{}

static const struct ethtool_rmon_hist_range bnxt_rmon_ranges[] =;

static void bnxt_get_rmon_stats(struct net_device *dev,
				struct ethtool_rmon_stats *rmon_stats,
				const struct ethtool_rmon_hist_range **ranges)
{}

static void bnxt_get_ptp_stats(struct net_device *dev,
			       struct ethtool_ts_stats *ts_stats)
{}

static void bnxt_get_link_ext_stats(struct net_device *dev,
				    struct ethtool_link_ext_stats *stats)
{}

void bnxt_ethtool_free(struct bnxt *bp)
{}

const struct ethtool_ops bnxt_ethtool_ops =;