162306a36Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */ 262306a36Sopenharmony_ci/* 362306a36Sopenharmony_ci * Copyright 2017 Broadcom. All Rights Reserved. 462306a36Sopenharmony_ci * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * Contact Information: 762306a36Sopenharmony_ci * linux-drivers@broadcom.com 862306a36Sopenharmony_ci */ 962306a36Sopenharmony_ci 1062306a36Sopenharmony_ci#ifndef _BEISCSI_MGMT_ 1162306a36Sopenharmony_ci#define _BEISCSI_MGMT_ 1262306a36Sopenharmony_ci 1362306a36Sopenharmony_ci#include <scsi/scsi_bsg_iscsi.h> 1462306a36Sopenharmony_ci#include "be_iscsi.h" 1562306a36Sopenharmony_ci#include "be_main.h" 1662306a36Sopenharmony_ci 1762306a36Sopenharmony_ci#define IP_ACTION_ADD 0x01 1862306a36Sopenharmony_ci#define IP_ACTION_DEL 0x02 1962306a36Sopenharmony_ci 2062306a36Sopenharmony_ci#define IP_V6_LEN 16 2162306a36Sopenharmony_ci#define IP_V4_LEN 4 2262306a36Sopenharmony_ci 2362306a36Sopenharmony_ci/* UE Status and Mask register */ 2462306a36Sopenharmony_ci#define PCICFG_UE_STATUS_LOW 0xA0 2562306a36Sopenharmony_ci#define PCICFG_UE_STATUS_HIGH 0xA4 2662306a36Sopenharmony_ci#define PCICFG_UE_STATUS_MASK_LOW 0xA8 2762306a36Sopenharmony_ci#define PCICFG_UE_STATUS_MASK_HI 0xAC 2862306a36Sopenharmony_ci 2962306a36Sopenharmony_ciint mgmt_open_connection(struct beiscsi_hba *phba, 3062306a36Sopenharmony_ci struct sockaddr *dst_addr, 3162306a36Sopenharmony_ci struct beiscsi_endpoint *beiscsi_ep, 3262306a36Sopenharmony_ci struct be_dma_mem *nonemb_cmd); 3362306a36Sopenharmony_ci 3462306a36Sopenharmony_ciunsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, 3562306a36Sopenharmony_ci struct beiscsi_hba *phba, 3662306a36Sopenharmony_ci struct bsg_job *job, 3762306a36Sopenharmony_ci struct be_dma_mem *nonemb_cmd); 3862306a36Sopenharmony_ci 3962306a36Sopenharmony_ci#define BE_INVLDT_CMD_TBL_SZ 128 4062306a36Sopenharmony_cistruct invldt_cmd_tbl { 4162306a36Sopenharmony_ci unsigned short icd; 4262306a36Sopenharmony_ci unsigned short cid; 4362306a36Sopenharmony_ci} __packed; 4462306a36Sopenharmony_ci 4562306a36Sopenharmony_cistruct invldt_cmds_params_in { 4662306a36Sopenharmony_ci struct be_cmd_req_hdr hdr; 4762306a36Sopenharmony_ci unsigned int ref_handle; 4862306a36Sopenharmony_ci unsigned int icd_count; 4962306a36Sopenharmony_ci struct invldt_cmd_tbl table[BE_INVLDT_CMD_TBL_SZ]; 5062306a36Sopenharmony_ci unsigned short cleanup_type; 5162306a36Sopenharmony_ci unsigned short unused; 5262306a36Sopenharmony_ci} __packed; 5362306a36Sopenharmony_ci 5462306a36Sopenharmony_cistruct invldt_cmds_params_out { 5562306a36Sopenharmony_ci struct be_cmd_resp_hdr hdr; 5662306a36Sopenharmony_ci unsigned int ref_handle; 5762306a36Sopenharmony_ci unsigned int icd_count; 5862306a36Sopenharmony_ci unsigned int icd_status[BE_INVLDT_CMD_TBL_SZ]; 5962306a36Sopenharmony_ci} __packed; 6062306a36Sopenharmony_ci 6162306a36Sopenharmony_ciunion be_invldt_cmds_params { 6262306a36Sopenharmony_ci struct invldt_cmds_params_in request; 6362306a36Sopenharmony_ci struct invldt_cmds_params_out response; 6462306a36Sopenharmony_ci} __packed; 6562306a36Sopenharmony_ci 6662306a36Sopenharmony_cistruct mgmt_hba_attributes { 6762306a36Sopenharmony_ci u8 flashrom_version_string[BEISCSI_VER_STRLEN]; 6862306a36Sopenharmony_ci u8 manufacturer_name[BEISCSI_VER_STRLEN]; 6962306a36Sopenharmony_ci u32 supported_modes; 7062306a36Sopenharmony_ci u8 seeprom_version_lo; 7162306a36Sopenharmony_ci u8 seeprom_version_hi; 7262306a36Sopenharmony_ci u8 rsvd0[2]; 7362306a36Sopenharmony_ci u32 fw_cmd_data_struct_version; 7462306a36Sopenharmony_ci u32 ep_fw_data_struct_version; 7562306a36Sopenharmony_ci u8 ncsi_version_string[12]; 7662306a36Sopenharmony_ci u32 default_extended_timeout; 7762306a36Sopenharmony_ci u8 controller_model_number[BEISCSI_VER_STRLEN]; 7862306a36Sopenharmony_ci u8 controller_description[64]; 7962306a36Sopenharmony_ci u8 controller_serial_number[BEISCSI_VER_STRLEN]; 8062306a36Sopenharmony_ci u8 ip_version_string[BEISCSI_VER_STRLEN]; 8162306a36Sopenharmony_ci u8 firmware_version_string[BEISCSI_VER_STRLEN]; 8262306a36Sopenharmony_ci u8 bios_version_string[BEISCSI_VER_STRLEN]; 8362306a36Sopenharmony_ci u8 redboot_version_string[BEISCSI_VER_STRLEN]; 8462306a36Sopenharmony_ci u8 driver_version_string[BEISCSI_VER_STRLEN]; 8562306a36Sopenharmony_ci u8 fw_on_flash_version_string[BEISCSI_VER_STRLEN]; 8662306a36Sopenharmony_ci u32 functionalities_supported; 8762306a36Sopenharmony_ci u16 max_cdblength; 8862306a36Sopenharmony_ci u8 asic_revision; 8962306a36Sopenharmony_ci u8 generational_guid[16]; 9062306a36Sopenharmony_ci u8 hba_port_count; 9162306a36Sopenharmony_ci u16 default_link_down_timeout; 9262306a36Sopenharmony_ci u8 iscsi_ver_min_max; 9362306a36Sopenharmony_ci u8 multifunction_device; 9462306a36Sopenharmony_ci u8 cache_valid; 9562306a36Sopenharmony_ci u8 hba_status; 9662306a36Sopenharmony_ci u8 max_domains_supported; 9762306a36Sopenharmony_ci u8 phy_port; 9862306a36Sopenharmony_ci u32 firmware_post_status; 9962306a36Sopenharmony_ci u32 hba_mtu[8]; 10062306a36Sopenharmony_ci u8 iscsi_features; 10162306a36Sopenharmony_ci u8 asic_generation; 10262306a36Sopenharmony_ci u8 future_u8[2]; 10362306a36Sopenharmony_ci u32 future_u32[3]; 10462306a36Sopenharmony_ci} __packed; 10562306a36Sopenharmony_ci 10662306a36Sopenharmony_cistruct mgmt_controller_attributes { 10762306a36Sopenharmony_ci struct mgmt_hba_attributes hba_attribs; 10862306a36Sopenharmony_ci u16 pci_vendor_id; 10962306a36Sopenharmony_ci u16 pci_device_id; 11062306a36Sopenharmony_ci u16 pci_sub_vendor_id; 11162306a36Sopenharmony_ci u16 pci_sub_system_id; 11262306a36Sopenharmony_ci u8 pci_bus_number; 11362306a36Sopenharmony_ci u8 pci_device_number; 11462306a36Sopenharmony_ci u8 pci_function_number; 11562306a36Sopenharmony_ci u8 interface_type; 11662306a36Sopenharmony_ci u64 unique_identifier; 11762306a36Sopenharmony_ci u8 netfilters; 11862306a36Sopenharmony_ci u8 rsvd0[3]; 11962306a36Sopenharmony_ci u32 future_u32[4]; 12062306a36Sopenharmony_ci} __packed; 12162306a36Sopenharmony_ci 12262306a36Sopenharmony_cistruct be_mgmt_controller_attributes { 12362306a36Sopenharmony_ci struct be_cmd_req_hdr hdr; 12462306a36Sopenharmony_ci struct mgmt_controller_attributes params; 12562306a36Sopenharmony_ci} __packed; 12662306a36Sopenharmony_ci 12762306a36Sopenharmony_cistruct be_mgmt_controller_attributes_resp { 12862306a36Sopenharmony_ci struct be_cmd_resp_hdr hdr; 12962306a36Sopenharmony_ci struct mgmt_controller_attributes params; 13062306a36Sopenharmony_ci} __packed; 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_cistruct be_bsg_vendor_cmd { 13362306a36Sopenharmony_ci struct be_cmd_req_hdr hdr; 13462306a36Sopenharmony_ci unsigned short region; 13562306a36Sopenharmony_ci unsigned short offset; 13662306a36Sopenharmony_ci unsigned short sector; 13762306a36Sopenharmony_ci} __packed; 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_ci/* configuration management */ 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci#define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws) 14262306a36Sopenharmony_ci 14362306a36Sopenharmony_ci#define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\ 14462306a36Sopenharmony_ci pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ 14562306a36Sopenharmony_ci bus_address.u.a32.address_lo; \ 14662306a36Sopenharmony_ci pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ 14762306a36Sopenharmony_ci bus_address.u.a32.address_hi; \ 14862306a36Sopenharmony_ci} 14962306a36Sopenharmony_ci 15062306a36Sopenharmony_ci#define BEISCSI_WRITE_FLASH 0 15162306a36Sopenharmony_ci#define BEISCSI_READ_FLASH 1 15262306a36Sopenharmony_ci 15362306a36Sopenharmony_cistruct beiscsi_endpoint { 15462306a36Sopenharmony_ci struct beiscsi_hba *phba; 15562306a36Sopenharmony_ci struct beiscsi_conn *conn; 15662306a36Sopenharmony_ci struct iscsi_endpoint *openiscsi_ep; 15762306a36Sopenharmony_ci unsigned short ip_type; 15862306a36Sopenharmony_ci char dst6_addr[ISCSI_ADDRESS_BUF_LEN]; 15962306a36Sopenharmony_ci unsigned long dst_addr; 16062306a36Sopenharmony_ci unsigned short ep_cid; 16162306a36Sopenharmony_ci unsigned int fw_handle; 16262306a36Sopenharmony_ci u16 dst_tcpport; 16362306a36Sopenharmony_ci u16 cid_vld; 16462306a36Sopenharmony_ci}; 16562306a36Sopenharmony_ci 16662306a36Sopenharmony_ciint beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba, 16762306a36Sopenharmony_ci struct invldt_cmd_tbl *inv_tbl, 16862306a36Sopenharmony_ci unsigned int nents); 16962306a36Sopenharmony_ci 17062306a36Sopenharmony_ciint beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name, bool cfg); 17162306a36Sopenharmony_ci 17262306a36Sopenharmony_ciint beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type); 17362306a36Sopenharmony_ci 17462306a36Sopenharmony_ciint beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type, 17562306a36Sopenharmony_ci u8 *ip, u8 *subnet); 17662306a36Sopenharmony_ci 17762306a36Sopenharmony_ciint beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw); 17862306a36Sopenharmony_ci 17962306a36Sopenharmony_ciint beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type, 18062306a36Sopenharmony_ci struct be_cmd_get_def_gateway_resp *resp); 18162306a36Sopenharmony_ci 18262306a36Sopenharmony_ciint mgmt_get_nic_conf(struct beiscsi_hba *phba, 18362306a36Sopenharmony_ci struct be_cmd_get_nic_conf_resp *mac); 18462306a36Sopenharmony_ci 18562306a36Sopenharmony_ciint beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type, 18662306a36Sopenharmony_ci struct be_cmd_get_if_info_resp **if_info); 18762306a36Sopenharmony_ci 18862306a36Sopenharmony_ciunsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba); 18962306a36Sopenharmony_ci 19062306a36Sopenharmony_ciint beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); 19162306a36Sopenharmony_ci 19262306a36Sopenharmony_ciunsigned int beiscsi_boot_logout_sess(struct beiscsi_hba *phba); 19362306a36Sopenharmony_ci 19462306a36Sopenharmony_ciunsigned int beiscsi_boot_reopen_sess(struct beiscsi_hba *phba); 19562306a36Sopenharmony_ci 19662306a36Sopenharmony_ciunsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba); 19762306a36Sopenharmony_ci 19862306a36Sopenharmony_ciunsigned int __beiscsi_boot_get_shandle(struct beiscsi_hba *phba, int async); 19962306a36Sopenharmony_ci 20062306a36Sopenharmony_ciint beiscsi_boot_get_shandle(struct beiscsi_hba *phba, unsigned int *s_handle); 20162306a36Sopenharmony_ci 20262306a36Sopenharmony_cissize_t beiscsi_drvr_ver_disp(struct device *dev, 20362306a36Sopenharmony_ci struct device_attribute *attr, char *buf); 20462306a36Sopenharmony_ci 20562306a36Sopenharmony_cissize_t beiscsi_fw_ver_disp(struct device *dev, 20662306a36Sopenharmony_ci struct device_attribute *attr, char *buf); 20762306a36Sopenharmony_ci 20862306a36Sopenharmony_cissize_t beiscsi_active_session_disp(struct device *dev, 20962306a36Sopenharmony_ci struct device_attribute *attr, char *buf); 21062306a36Sopenharmony_ci 21162306a36Sopenharmony_cissize_t beiscsi_adap_family_disp(struct device *dev, 21262306a36Sopenharmony_ci struct device_attribute *attr, char *buf); 21362306a36Sopenharmony_ci 21462306a36Sopenharmony_ci 21562306a36Sopenharmony_cissize_t beiscsi_free_session_disp(struct device *dev, 21662306a36Sopenharmony_ci struct device_attribute *attr, char *buf); 21762306a36Sopenharmony_ci 21862306a36Sopenharmony_cissize_t beiscsi_phys_port_disp(struct device *dev, 21962306a36Sopenharmony_ci struct device_attribute *attr, char *buf); 22062306a36Sopenharmony_ci 22162306a36Sopenharmony_civoid beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params, 22262306a36Sopenharmony_ci struct wrb_handle *pwrb_handle, 22362306a36Sopenharmony_ci struct be_mem_descriptor *mem_descr, 22462306a36Sopenharmony_ci struct hwi_wrb_context *pwrb_context); 22562306a36Sopenharmony_ci 22662306a36Sopenharmony_civoid beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params, 22762306a36Sopenharmony_ci struct wrb_handle *pwrb_handle, 22862306a36Sopenharmony_ci struct hwi_wrb_context *pwrb_context); 22962306a36Sopenharmony_ci 23062306a36Sopenharmony_ciunsigned int beiscsi_invalidate_cxn(struct beiscsi_hba *phba, 23162306a36Sopenharmony_ci struct beiscsi_endpoint *beiscsi_ep); 23262306a36Sopenharmony_ci 23362306a36Sopenharmony_ciunsigned int beiscsi_upload_cxn(struct beiscsi_hba *phba, 23462306a36Sopenharmony_ci struct beiscsi_endpoint *beiscsi_ep); 23562306a36Sopenharmony_ci 23662306a36Sopenharmony_ciint be_cmd_modify_eq_delay(struct beiscsi_hba *phba, 23762306a36Sopenharmony_ci struct be_set_eqd *, int num); 23862306a36Sopenharmony_ci 23962306a36Sopenharmony_ciint beiscsi_logout_fw_sess(struct beiscsi_hba *phba, 24062306a36Sopenharmony_ci uint32_t fw_sess_handle); 24162306a36Sopenharmony_ci 24262306a36Sopenharmony_ci#endif 243