linux/drivers/net/ethernet/emulex/benet/be_cmds.c

// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (C) 2005 - 2016 Broadcom
 * All rights reserved.
 *
 * Contact Information:
 * [email protected]
 *
 * Emulex
 * 3333 Susan Street
 * Costa Mesa, CA 92626
 */

#include <linux/module.h>
#include "be.h"
#include "be_cmds.h"

const char * const be_misconfig_evt_port_state[] =;

static char *be_port_misconfig_evt_severity[] =;

static char *phy_state_oper_desc[] =;

static struct be_cmd_priv_map cmd_priv_map[] =;

static bool be_cmd_allowed(struct be_adapter *adapter, u8 opcode, u8 subsystem)
{}

static inline void *embedded_payload(struct be_mcc_wrb *wrb)
{}

static int be_mcc_notify(struct be_adapter *adapter)
{}

/* To check if valid bit is set, check the entire word as we don't know
 * the endianness of the data (old entry is host endian while a new entry is
 * little endian)
 */
static inline bool be_mcc_compl_is_new(struct be_mcc_compl *compl)
{}

/* Need to reset the entire word that houses the valid bit */
static inline void be_mcc_compl_use(struct be_mcc_compl *compl)
{}

static struct be_cmd_resp_hdr *be_decode_resp_hdr(u32 tag0, u32 tag1)
{}

static bool be_skip_err_log(u8 opcode, u16 base_status, u16 addl_status)
{}

/* Place holder for all the async MCC cmds wherein the caller is not in a busy
 * loop (has not issued be_mcc_notify_wait())
 */
static void be_async_cmd_process(struct be_adapter *adapter,
				 struct be_mcc_compl *compl,
				 struct be_cmd_resp_hdr *resp_hdr)
{}

static int be_mcc_compl_process(struct be_adapter *adapter,
				struct be_mcc_compl *compl)
{}

/* Link state evt is a string of bytes; no need for endian swapping */
static void be_async_link_state_process(struct be_adapter *adapter,
					struct be_mcc_compl *compl)
{}

static void be_async_port_misconfig_event_process(struct be_adapter *adapter,
						  struct be_mcc_compl *compl)
{}

/* Grp5 CoS Priority evt */
static void be_async_grp5_cos_priority_process(struct be_adapter *adapter,
					       struct be_mcc_compl *compl)
{}

/* Grp5 QOS Speed evt: qos_link_speed is in units of 10 Mbps */
static void be_async_grp5_qos_speed_process(struct be_adapter *adapter,
					    struct be_mcc_compl *compl)
{}

/*Grp5 PVID evt*/
static void be_async_grp5_pvid_state_process(struct be_adapter *adapter,
					     struct be_mcc_compl *compl)
{}

#define MGMT_ENABLE_MASK
static void be_async_grp5_fw_control_process(struct be_adapter *adapter,
					     struct be_mcc_compl *compl)
{}

static void be_async_grp5_evt_process(struct be_adapter *adapter,
				      struct be_mcc_compl *compl)
{}

static void be_async_dbg_evt_process(struct be_adapter *adapter,
				     struct be_mcc_compl *cmp)
{}

static void be_async_sliport_evt_process(struct be_adapter *adapter,
					 struct be_mcc_compl *cmp)
{}

static inline bool is_link_state_evt(u32 flags)
{}

static inline bool is_grp5_evt(u32 flags)
{}

static inline bool is_dbg_evt(u32 flags)
{}

static inline bool is_sliport_evt(u32 flags)
{}

static void be_mcc_event_process(struct be_adapter *adapter,
				 struct be_mcc_compl *compl)
{}

static struct be_mcc_compl *be_mcc_compl_get(struct be_adapter *adapter)
{}

void be_async_mcc_enable(struct be_adapter *adapter)
{}

void be_async_mcc_disable(struct be_adapter *adapter)
{}

int be_process_mcc(struct be_adapter *adapter)
{}

/* Wait till no more pending mcc requests are present */
static int be_mcc_wait_compl(struct be_adapter *adapter)
{}

/* Notify MCC requests and wait for completion */
static int be_mcc_notify_wait(struct be_adapter *adapter)
{}

static int be_mbox_db_ready_wait(struct be_adapter *adapter, void __iomem *db)
{}

/* Insert the mailbox address into the doorbell in two steps
 * Polls on the mbox doorbell till a command completion (or a timeout) occurs
 */
static int be_mbox_notify_wait(struct be_adapter *adapter)
{}

u16 be_POST_stage_get(struct be_adapter *adapter)
{}

static int lancer_wait_ready(struct be_adapter *adapter)
{}

int be_fw_wait_ready(struct be_adapter *adapter)
{}

static inline struct be_sge *nonembedded_sgl(struct be_mcc_wrb *wrb)
{}

static inline void fill_wrb_tags(struct be_mcc_wrb *wrb, unsigned long addr)
{}

/* Don't touch the hdr after it's prepared */
/* mem will be NULL for embedded commands */
static void be_wrb_cmd_hdr_prepare(struct be_cmd_req_hdr *req_hdr,
				   u8 subsystem, u8 opcode, int cmd_len,
				   struct be_mcc_wrb *wrb,
				   struct be_dma_mem *mem)
{}

static void be_cmd_page_addrs_prepare(struct phys_addr *pages, u32 max_pages,
				      struct be_dma_mem *mem)
{}

static inline struct be_mcc_wrb *wrb_from_mbox(struct be_adapter *adapter)
{}

static struct be_mcc_wrb *wrb_from_mccq(struct be_adapter *adapter)
{}

static bool use_mcc(struct be_adapter *adapter)
{}

/* Must be used only in process context */
static int be_cmd_lock(struct be_adapter *adapter)
{}

/* Must be used only in process context */
static void be_cmd_unlock(struct be_adapter *adapter)
{}

static struct be_mcc_wrb *be_cmd_copy(struct be_adapter *adapter,
				      struct be_mcc_wrb *wrb)
{}

/* Must be used only in process context */
static int be_cmd_notify_wait(struct be_adapter *adapter,
			      struct be_mcc_wrb *wrb)
{}

/* Tell fw we're about to start firing cmds by writing a
 * special pattern across the wrb hdr; uses mbox
 */
int be_cmd_fw_init(struct be_adapter *adapter)
{}

/* Tell fw we're done with firing cmds by writing a
 * special pattern across the wrb hdr; uses mbox
 */
int be_cmd_fw_clean(struct be_adapter *adapter)
{}

int be_cmd_eq_create(struct be_adapter *adapter, struct be_eq_obj *eqo)
{}

/* Use MCC */
int be_cmd_mac_addr_query(struct be_adapter *adapter, u8 *mac_addr,
			  bool permanent, u32 if_handle, u32 pmac_id)
{}

/* Uses synchronous MCCQ */
int be_cmd_pmac_add(struct be_adapter *adapter, const u8 *mac_addr,
		    u32 if_id, u32 *pmac_id, u32 domain)
{}

/* Uses synchronous MCCQ */
int be_cmd_pmac_del(struct be_adapter *adapter, u32 if_id, int pmac_id, u32 dom)
{}

/* Uses Mbox */
int be_cmd_cq_create(struct be_adapter *adapter, struct be_queue_info *cq,
		     struct be_queue_info *eq, bool no_delay, int coalesce_wm)
{}

static u32 be_encoded_q_len(int q_len)
{}

static int be_cmd_mccq_ext_create(struct be_adapter *adapter,
				  struct be_queue_info *mccq,
				  struct be_queue_info *cq)
{}

static int be_cmd_mccq_org_create(struct be_adapter *adapter,
				  struct be_queue_info *mccq,
				  struct be_queue_info *cq)
{}

int be_cmd_mccq_create(struct be_adapter *adapter,
		       struct be_queue_info *mccq, struct be_queue_info *cq)
{}

int be_cmd_txq_create(struct be_adapter *adapter, struct be_tx_obj *txo)
{}

/* Uses MCC */
int be_cmd_rxq_create(struct be_adapter *adapter,
		      struct be_queue_info *rxq, u16 cq_id, u16 frag_size,
		      u32 if_id, u32 rss, u8 *rss_id)
{}

/* Generic destroyer function for all types of queues
 * Uses Mbox
 */
int be_cmd_q_destroy(struct be_adapter *adapter, struct be_queue_info *q,
		     int queue_type)
{}

/* Uses MCC */
int be_cmd_rxq_destroy(struct be_adapter *adapter, struct be_queue_info *q)
{}

/* Create an rx filtering policy configuration on an i/f
 * Will use MBOX only if MCCQ has not been created.
 */
int be_cmd_if_create(struct be_adapter *adapter, u32 cap_flags, u32 en_flags,
		     u32 *if_handle, u32 domain)
{}

/* Uses MCCQ if available else MBOX */
int be_cmd_if_destroy(struct be_adapter *adapter, int interface_id, u32 domain)
{}

/* Get stats is a non embedded command: the request is not embedded inside
 * WRB but is a separate dma memory block
 * Uses asynchronous MCC
 */
int be_cmd_get_stats(struct be_adapter *adapter, struct be_dma_mem *nonemb_cmd)
{}

/* Lancer Stats */
int lancer_cmd_get_pport_stats(struct be_adapter *adapter,
			       struct be_dma_mem *nonemb_cmd)
{}

static int be_mac_to_link_speed(int mac_speed)
{}

/* Uses synchronous mcc
 * Returns link_speed in Mbps
 */
int be_cmd_link_status_query(struct be_adapter *adapter, u16 *link_speed,
			     u8 *link_status, u32 dom)
{}

/* Uses synchronous mcc */
int be_cmd_get_die_temperature(struct be_adapter *adapter)
{}

/* Uses synchronous mcc */
int be_cmd_get_fat_dump_len(struct be_adapter *adapter, u32 *dump_size)
{}

int be_cmd_get_fat_dump(struct be_adapter *adapter, u32 buf_len, void *buf)
{}

/* Uses synchronous mcc */
int be_cmd_get_fw_ver(struct be_adapter *adapter)
{}

/* set the EQ delay interval of an EQ to specified value
 * Uses async mcc
 */
static int __be_cmd_modify_eqd(struct be_adapter *adapter,
			       struct be_set_eqd *set_eqd, int num)
{}

int be_cmd_modify_eqd(struct be_adapter *adapter, struct be_set_eqd *set_eqd,
		      int num)
{}

/* Uses sycnhronous mcc */
int be_cmd_vlan_config(struct be_adapter *adapter, u32 if_id, u16 *vtag_array,
		       u32 num, u32 domain)
{}

static int __be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
{}

int be_cmd_rx_filter(struct be_adapter *adapter, u32 flags, u32 value)
{}

/* Uses synchrounous mcc */
int be_cmd_set_flow_control(struct be_adapter *adapter, u32 tx_fc, u32 rx_fc)
{}

/* Uses sycn mcc */
int be_cmd_get_flow_control(struct be_adapter *adapter, u32 *tx_fc, u32 *rx_fc)
{}

/* Uses mbox */
int be_cmd_query_fw_cfg(struct be_adapter *adapter)
{}

/* Uses mbox */
int be_cmd_reset_function(struct be_adapter *adapter)
{}

int be_cmd_rss_config(struct be_adapter *adapter, u8 *rsstable,
		      u32 rss_hash_opts, u16 table_size, const u8 *rss_hkey)
{}

/* Uses sync mcc */
int be_cmd_set_beacon_state(struct be_adapter *adapter, u8 port_num,
			    u8 bcn, u8 sts, u8 state)
{}

/* Uses sync mcc */
int be_cmd_get_beacon_state(struct be_adapter *adapter, u8 port_num, u32 *state)
{}

/* Uses sync mcc */
int be_cmd_read_port_transceiver_data(struct be_adapter *adapter,
				      u8 page_num, u32 off, u32 len, u8 *data)
{}

static int lancer_cmd_write_object(struct be_adapter *adapter,
				   struct be_dma_mem *cmd, u32 data_size,
				   u32 data_offset, const char *obj_name,
				   u32 *data_written, u8 *change_status,
				   u8 *addn_status)
{}

int be_cmd_query_cable_type(struct be_adapter *adapter)
{}

int be_cmd_query_sfp_info(struct be_adapter *adapter)
{}

static int lancer_cmd_delete_object(struct be_adapter *adapter,
				    const char *obj_name)
{}

int lancer_cmd_read_object(struct be_adapter *adapter, struct be_dma_mem *cmd,
			   u32 data_size, u32 data_offset, const char *obj_name,
			   u32 *data_read, u32 *eof, u8 *addn_status)
{}

static int be_cmd_write_flashrom(struct be_adapter *adapter,
				 struct be_dma_mem *cmd, u32 flash_type,
				 u32 flash_opcode, u32 img_offset, u32 buf_size)
{}

static int be_cmd_get_flash_crc(struct be_adapter *adapter, u8 *flashed_crc,
				u16 img_optype, u32 img_offset, u32 crc_offset)
{}

static char flash_cookie[2][16] =;

static bool phy_flashing_required(struct be_adapter *adapter)
{}

static bool is_comp_in_ufi(struct be_adapter *adapter,
			   struct flash_section_info *fsec, int type)
{}

static struct flash_section_info *get_fsec_info(struct be_adapter *adapter,
						int header_size,
						const struct firmware *fw)
{}

static int be_check_flash_crc(struct be_adapter *adapter, const u8 *p,
			      u32 img_offset, u32 img_size, int hdr_size,
			      u16 img_optype, bool *crc_match)
{}

static int be_flash(struct be_adapter *adapter, const u8 *img,
		    struct be_dma_mem *flash_cmd, int optype, int img_size,
		    u32 img_offset)
{}

#define NCSI_UPDATE_LOG
static bool be_fw_ncsi_supported(char *ver)
{}

/* For BE2, BE3 and BE3-R */
static int be_flash_BEx(struct be_adapter *adapter,
			const struct firmware *fw,
			struct be_dma_mem *flash_cmd, int num_of_images)
{}

static u16 be_get_img_optype(struct flash_section_entry fsec_entry)
{}

static int be_flash_skyhawk(struct be_adapter *adapter,
			    const struct firmware *fw,
			    struct be_dma_mem *flash_cmd, int num_of_images)
{}

int lancer_fw_download(struct be_adapter *adapter,
		       const struct firmware *fw)
{}

/* Check if the flash image file is compatible with the adapter that
 * is being flashed.
 */
static bool be_check_ufi_compatibility(struct be_adapter *adapter,
				       struct flash_file_hdr_g3 *fhdr)
{}

int be_fw_download(struct be_adapter *adapter, const struct firmware *fw)
{}

int be_cmd_enable_magic_wol(struct be_adapter *adapter, u8 *mac,
			    struct be_dma_mem *nonemb_cmd)
{}

int be_cmd_set_loopback(struct be_adapter *adapter, u8 port_num,
			u8 loopback_type, u8 enable)
{}

int be_cmd_loopback_test(struct be_adapter *adapter, u32 port_num,
			 u32 loopback_type, u32 pkt_size, u32 num_pkts,
			 u64 pattern)
{}

int be_cmd_ddr_dma_test(struct be_adapter *adapter, u64 pattern,
			u32 byte_cnt, struct be_dma_mem *cmd)
{}

int be_cmd_get_seeprom_data(struct be_adapter *adapter,
			    struct be_dma_mem *nonemb_cmd)
{}

int be_cmd_get_phy_info(struct be_adapter *adapter)
{}

static int be_cmd_set_qos(struct be_adapter *adapter, u32 bps, u32 domain)
{}

int be_cmd_get_cntl_attributes(struct be_adapter *adapter)
{}

/* Uses mbox */
int be_cmd_req_native_mode(struct be_adapter *adapter)
{}

/* Get privilege(s) for a function */
int be_cmd_get_fn_privileges(struct be_adapter *adapter, u32 *privilege,
			     u32 domain)
{}

/* Set privilege(s) for a function */
int be_cmd_set_fn_privileges(struct be_adapter *adapter, u32 privileges,
			     u32 domain)
{}

/* pmac_id_valid: true => pmac_id is supplied and MAC address is requested.
 * pmac_id_valid: false => pmac_id or MAC address is requested.
 *		  If pmac_id is returned, pmac_id_valid is returned as true
 */
int be_cmd_get_mac_from_list(struct be_adapter *adapter, u8 *mac,
			     bool *pmac_id_valid, u32 *pmac_id, u32 if_handle,
			     u8 domain)
{}

int be_cmd_get_active_mac(struct be_adapter *adapter, u32 curr_pmac_id,
			  u8 *mac, u32 if_handle, bool active, u32 domain)
{}

int be_cmd_get_perm_mac(struct be_adapter *adapter, u8 *mac)
{}

/* Uses synchronous MCCQ */
int be_cmd_set_mac_list(struct be_adapter *adapter, u8 *mac_array,
			u8 mac_count, u32 domain)
{}

/* Wrapper to delete any active MACs and provision the new mac.
 * Changes to MAC_LIST are allowed iff none of the MAC addresses in the
 * current list are active.
 */
int be_cmd_set_mac(struct be_adapter *adapter, u8 *mac, int if_id, u32 dom)
{}

int be_cmd_set_hsw_config(struct be_adapter *adapter, u16 pvid,
			  u32 domain, u16 intf_id, u16 hsw_mode, u8 spoofchk)
{}

/* Get Hyper switch config */
int be_cmd_get_hsw_config(struct be_adapter *adapter, u16 *pvid,
			  u32 domain, u16 intf_id, u8 *mode, bool *spoofchk)
{}

static bool be_is_wol_excluded(struct be_adapter *adapter)
{}

int be_cmd_get_acpi_wol_cap(struct be_adapter *adapter)
{}

int be_cmd_set_fw_log_level(struct be_adapter *adapter, u32 level)
{}

int be_cmd_get_fw_log_level(struct be_adapter *adapter)
{}

int be_cmd_get_ext_fat_capabilites(struct be_adapter *adapter,
				   struct be_dma_mem *cmd)
{}

int be_cmd_set_ext_fat_capabilites(struct be_adapter *adapter,
				   struct be_dma_mem *cmd,
				   struct be_fat_conf_params *configs)
{}

int be_cmd_query_port_name(struct be_adapter *adapter)
{}

/* When more than 1 NIC descriptor is present in the descriptor list,
 * the caller must specify the pf_num to obtain the NIC descriptor
 * corresponding to its pci function.
 * get_vft must be true when the caller wants the VF-template desc of the
 * PF-pool.
 * The pf_num should be set to PF_NUM_IGNORE when the caller knows
 * that only it's NIC descriptor is present in the descriptor list.
 */
static struct be_nic_res_desc *be_get_nic_desc(u8 *buf, u32 desc_count,
					       bool get_vft, u8 pf_num)
{}

static struct be_nic_res_desc *be_get_vft_desc(u8 *buf, u32 desc_count,
					       u8 pf_num)
{}

static struct be_nic_res_desc *be_get_func_nic_desc(u8 *buf, u32 desc_count,
						    u8 pf_num)
{}

static struct be_pcie_res_desc *be_get_pcie_desc(u8 *buf, u32 desc_count,
						 u8 pf_num)
{}

static struct be_port_res_desc *be_get_port_desc(u8 *buf, u32 desc_count)
{}

static void be_copy_nic_desc(struct be_resources *res,
			     struct be_nic_res_desc *desc)
{}

/* Uses Mbox */
int be_cmd_get_func_config(struct be_adapter *adapter, struct be_resources *res)
{}

/* This routine returns a list of all the NIC PF_nums in the adapter */
static u16 be_get_nic_pf_num_list(u8 *buf, u32 desc_count, u16 *nic_pf_nums)
{}

/* Will use MBOX only if MCCQ has not been created */
int be_cmd_get_profile_config(struct be_adapter *adapter,
			      struct be_resources *res,
			      struct be_port_resources *port_res,
			      u8 profile_type, u8 query, u8 domain)
{}

/* Will use MBOX only if MCCQ has not been created */
static int be_cmd_set_profile_config(struct be_adapter *adapter, void *desc,
				     int size, int count, u8 version, u8 domain)
{}

/* Mark all fields invalid */
static void be_reset_nic_desc(struct be_nic_res_desc *nic)
{}

/* Mark all fields invalid */
static void be_reset_pcie_desc(struct be_pcie_res_desc *pcie)
{}

int be_cmd_config_qos(struct be_adapter *adapter, u32 max_rate, u16 link_speed,
		      u8 domain)
{}

int be_cmd_set_sriov_config(struct be_adapter *adapter,
			    struct be_resources pool_res, u16 num_vfs,
			    struct be_resources *vft_res)
{}

int be_cmd_manage_iface(struct be_adapter *adapter, u32 iface, u8 op)
{}

int be_cmd_set_vxlan_port(struct be_adapter *adapter, __be16 port)
{}

int be_cmd_get_if_id(struct be_adapter *adapter, struct be_vf_cfg *vf_cfg,
		     int vf_num)
{}

static int lancer_wait_idle(struct be_adapter *adapter)
{}

int lancer_physdev_ctrl(struct be_adapter *adapter, u32 mask)
{}

/* Routine to check whether dump image is present or not */
bool dump_present(struct be_adapter *adapter)
{}

int lancer_initiate_dump(struct be_adapter *adapter)
{}

int lancer_delete_dump(struct be_adapter *adapter)
{}

/* Uses sync mcc */
int be_cmd_enable_vf(struct be_adapter *adapter, u8 domain)
{}

int be_cmd_intr_set(struct be_adapter *adapter, bool intr_enable)
{}

/* Uses MBOX */
int be_cmd_get_active_profile(struct be_adapter *adapter, u16 *profile_id)
{}

static int
__be_cmd_set_logical_link_config(struct be_adapter *adapter,
				 int link_state, int version, u8 domain)
{}

int be_cmd_set_logical_link_config(struct be_adapter *adapter,
				   int link_state, u8 domain)
{}

int be_cmd_set_features(struct be_adapter *adapter)
{}

int be_roce_mcc_cmd(void *netdev_handle, void *wrb_payload,
		    int wrb_payload_size, u16 *cmd_status, u16 *ext_status)
{}
EXPORT_SYMBOL();