18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0-only */
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 2017 Broadcom. All Rights Reserved.
48c2ecf20Sopenharmony_ci * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
58c2ecf20Sopenharmony_ci *
68c2ecf20Sopenharmony_ci * Contact Information:
78c2ecf20Sopenharmony_ci * linux-drivers@broadcom.com
88c2ecf20Sopenharmony_ci */
98c2ecf20Sopenharmony_ci
108c2ecf20Sopenharmony_ci#ifndef _BEISCSI_MGMT_
118c2ecf20Sopenharmony_ci#define _BEISCSI_MGMT_
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_ci#include <scsi/scsi_bsg_iscsi.h>
148c2ecf20Sopenharmony_ci#include "be_iscsi.h"
158c2ecf20Sopenharmony_ci#include "be_main.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#define IP_ACTION_ADD	0x01
188c2ecf20Sopenharmony_ci#define IP_ACTION_DEL	0x02
198c2ecf20Sopenharmony_ci
208c2ecf20Sopenharmony_ci#define IP_V6_LEN	16
218c2ecf20Sopenharmony_ci#define IP_V4_LEN	4
228c2ecf20Sopenharmony_ci
238c2ecf20Sopenharmony_ci/* UE Status and Mask register */
248c2ecf20Sopenharmony_ci#define PCICFG_UE_STATUS_LOW            0xA0
258c2ecf20Sopenharmony_ci#define PCICFG_UE_STATUS_HIGH           0xA4
268c2ecf20Sopenharmony_ci#define PCICFG_UE_STATUS_MASK_LOW       0xA8
278c2ecf20Sopenharmony_ci#define PCICFG_UE_STATUS_MASK_HI        0xAC
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ciint mgmt_open_connection(struct beiscsi_hba *phba,
308c2ecf20Sopenharmony_ci			 struct sockaddr *dst_addr,
318c2ecf20Sopenharmony_ci			 struct beiscsi_endpoint *beiscsi_ep,
328c2ecf20Sopenharmony_ci			 struct be_dma_mem *nonemb_cmd);
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciunsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
358c2ecf20Sopenharmony_ci					 struct beiscsi_hba *phba,
368c2ecf20Sopenharmony_ci					 struct bsg_job *job,
378c2ecf20Sopenharmony_ci					 struct be_dma_mem *nonemb_cmd);
388c2ecf20Sopenharmony_ci
398c2ecf20Sopenharmony_ci#define BE_INVLDT_CMD_TBL_SZ	128
408c2ecf20Sopenharmony_cistruct invldt_cmd_tbl {
418c2ecf20Sopenharmony_ci	unsigned short icd;
428c2ecf20Sopenharmony_ci	unsigned short cid;
438c2ecf20Sopenharmony_ci} __packed;
448c2ecf20Sopenharmony_ci
458c2ecf20Sopenharmony_cistruct invldt_cmds_params_in {
468c2ecf20Sopenharmony_ci	struct be_cmd_req_hdr hdr;
478c2ecf20Sopenharmony_ci	unsigned int ref_handle;
488c2ecf20Sopenharmony_ci	unsigned int icd_count;
498c2ecf20Sopenharmony_ci	struct invldt_cmd_tbl table[BE_INVLDT_CMD_TBL_SZ];
508c2ecf20Sopenharmony_ci	unsigned short cleanup_type;
518c2ecf20Sopenharmony_ci	unsigned short unused;
528c2ecf20Sopenharmony_ci} __packed;
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_cistruct invldt_cmds_params_out {
558c2ecf20Sopenharmony_ci	struct be_cmd_resp_hdr hdr;
568c2ecf20Sopenharmony_ci	unsigned int ref_handle;
578c2ecf20Sopenharmony_ci	unsigned int icd_count;
588c2ecf20Sopenharmony_ci	unsigned int icd_status[BE_INVLDT_CMD_TBL_SZ];
598c2ecf20Sopenharmony_ci} __packed;
608c2ecf20Sopenharmony_ci
618c2ecf20Sopenharmony_ciunion be_invldt_cmds_params {
628c2ecf20Sopenharmony_ci	struct invldt_cmds_params_in request;
638c2ecf20Sopenharmony_ci	struct invldt_cmds_params_out response;
648c2ecf20Sopenharmony_ci} __packed;
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_cistruct mgmt_hba_attributes {
678c2ecf20Sopenharmony_ci	u8 flashrom_version_string[BEISCSI_VER_STRLEN];
688c2ecf20Sopenharmony_ci	u8 manufacturer_name[BEISCSI_VER_STRLEN];
698c2ecf20Sopenharmony_ci	u32 supported_modes;
708c2ecf20Sopenharmony_ci	u8 seeprom_version_lo;
718c2ecf20Sopenharmony_ci	u8 seeprom_version_hi;
728c2ecf20Sopenharmony_ci	u8 rsvd0[2];
738c2ecf20Sopenharmony_ci	u32 fw_cmd_data_struct_version;
748c2ecf20Sopenharmony_ci	u32 ep_fw_data_struct_version;
758c2ecf20Sopenharmony_ci	u8 ncsi_version_string[12];
768c2ecf20Sopenharmony_ci	u32 default_extended_timeout;
778c2ecf20Sopenharmony_ci	u8 controller_model_number[BEISCSI_VER_STRLEN];
788c2ecf20Sopenharmony_ci	u8 controller_description[64];
798c2ecf20Sopenharmony_ci	u8 controller_serial_number[BEISCSI_VER_STRLEN];
808c2ecf20Sopenharmony_ci	u8 ip_version_string[BEISCSI_VER_STRLEN];
818c2ecf20Sopenharmony_ci	u8 firmware_version_string[BEISCSI_VER_STRLEN];
828c2ecf20Sopenharmony_ci	u8 bios_version_string[BEISCSI_VER_STRLEN];
838c2ecf20Sopenharmony_ci	u8 redboot_version_string[BEISCSI_VER_STRLEN];
848c2ecf20Sopenharmony_ci	u8 driver_version_string[BEISCSI_VER_STRLEN];
858c2ecf20Sopenharmony_ci	u8 fw_on_flash_version_string[BEISCSI_VER_STRLEN];
868c2ecf20Sopenharmony_ci	u32 functionalities_supported;
878c2ecf20Sopenharmony_ci	u16 max_cdblength;
888c2ecf20Sopenharmony_ci	u8 asic_revision;
898c2ecf20Sopenharmony_ci	u8 generational_guid[16];
908c2ecf20Sopenharmony_ci	u8 hba_port_count;
918c2ecf20Sopenharmony_ci	u16 default_link_down_timeout;
928c2ecf20Sopenharmony_ci	u8 iscsi_ver_min_max;
938c2ecf20Sopenharmony_ci	u8 multifunction_device;
948c2ecf20Sopenharmony_ci	u8 cache_valid;
958c2ecf20Sopenharmony_ci	u8 hba_status;
968c2ecf20Sopenharmony_ci	u8 max_domains_supported;
978c2ecf20Sopenharmony_ci	u8 phy_port;
988c2ecf20Sopenharmony_ci	u32 firmware_post_status;
998c2ecf20Sopenharmony_ci	u32 hba_mtu[8];
1008c2ecf20Sopenharmony_ci	u8 iscsi_features;
1018c2ecf20Sopenharmony_ci	u8 asic_generation;
1028c2ecf20Sopenharmony_ci	u8 future_u8[2];
1038c2ecf20Sopenharmony_ci	u32 future_u32[3];
1048c2ecf20Sopenharmony_ci} __packed;
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_cistruct mgmt_controller_attributes {
1078c2ecf20Sopenharmony_ci	struct mgmt_hba_attributes hba_attribs;
1088c2ecf20Sopenharmony_ci	u16 pci_vendor_id;
1098c2ecf20Sopenharmony_ci	u16 pci_device_id;
1108c2ecf20Sopenharmony_ci	u16 pci_sub_vendor_id;
1118c2ecf20Sopenharmony_ci	u16 pci_sub_system_id;
1128c2ecf20Sopenharmony_ci	u8 pci_bus_number;
1138c2ecf20Sopenharmony_ci	u8 pci_device_number;
1148c2ecf20Sopenharmony_ci	u8 pci_function_number;
1158c2ecf20Sopenharmony_ci	u8 interface_type;
1168c2ecf20Sopenharmony_ci	u64 unique_identifier;
1178c2ecf20Sopenharmony_ci	u8 netfilters;
1188c2ecf20Sopenharmony_ci	u8 rsvd0[3];
1198c2ecf20Sopenharmony_ci	u32 future_u32[4];
1208c2ecf20Sopenharmony_ci} __packed;
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_cistruct be_mgmt_controller_attributes {
1238c2ecf20Sopenharmony_ci	struct be_cmd_req_hdr hdr;
1248c2ecf20Sopenharmony_ci	struct mgmt_controller_attributes params;
1258c2ecf20Sopenharmony_ci} __packed;
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_cistruct be_mgmt_controller_attributes_resp {
1288c2ecf20Sopenharmony_ci	struct be_cmd_resp_hdr hdr;
1298c2ecf20Sopenharmony_ci	struct mgmt_controller_attributes params;
1308c2ecf20Sopenharmony_ci} __packed;
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_cistruct be_bsg_vendor_cmd {
1338c2ecf20Sopenharmony_ci	struct be_cmd_req_hdr hdr;
1348c2ecf20Sopenharmony_ci	unsigned short region;
1358c2ecf20Sopenharmony_ci	unsigned short offset;
1368c2ecf20Sopenharmony_ci	unsigned short sector;
1378c2ecf20Sopenharmony_ci} __packed;
1388c2ecf20Sopenharmony_ci
1398c2ecf20Sopenharmony_ci/* configuration management */
1408c2ecf20Sopenharmony_ci
1418c2ecf20Sopenharmony_ci#define GET_MGMT_CONTROLLER_WS(phba)    (phba->pmgmt_ws)
1428c2ecf20Sopenharmony_ci
1438c2ecf20Sopenharmony_ci#define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\
1448c2ecf20Sopenharmony_ci	pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
1458c2ecf20Sopenharmony_ci					bus_address.u.a32.address_lo;  \
1468c2ecf20Sopenharmony_ci	pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
1478c2ecf20Sopenharmony_ci					bus_address.u.a32.address_hi;  \
1488c2ecf20Sopenharmony_ci}
1498c2ecf20Sopenharmony_ci
1508c2ecf20Sopenharmony_ci#define BEISCSI_WRITE_FLASH 0
1518c2ecf20Sopenharmony_ci#define BEISCSI_READ_FLASH 1
1528c2ecf20Sopenharmony_ci
1538c2ecf20Sopenharmony_cistruct beiscsi_endpoint {
1548c2ecf20Sopenharmony_ci	struct beiscsi_hba *phba;
1558c2ecf20Sopenharmony_ci	struct beiscsi_conn *conn;
1568c2ecf20Sopenharmony_ci	struct iscsi_endpoint *openiscsi_ep;
1578c2ecf20Sopenharmony_ci	unsigned short ip_type;
1588c2ecf20Sopenharmony_ci	char dst6_addr[ISCSI_ADDRESS_BUF_LEN];
1598c2ecf20Sopenharmony_ci	unsigned long dst_addr;
1608c2ecf20Sopenharmony_ci	unsigned short ep_cid;
1618c2ecf20Sopenharmony_ci	unsigned int fw_handle;
1628c2ecf20Sopenharmony_ci	u16 dst_tcpport;
1638c2ecf20Sopenharmony_ci	u16 cid_vld;
1648c2ecf20Sopenharmony_ci};
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ciint beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba,
1678c2ecf20Sopenharmony_ci				 struct invldt_cmd_tbl *inv_tbl,
1688c2ecf20Sopenharmony_ci				 unsigned int nents);
1698c2ecf20Sopenharmony_ci
1708c2ecf20Sopenharmony_ciint beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name, bool cfg);
1718c2ecf20Sopenharmony_ci
1728c2ecf20Sopenharmony_ciint beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type);
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_ciint beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type,
1758c2ecf20Sopenharmony_ci			 u8 *ip, u8 *subnet);
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ciint beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw);
1788c2ecf20Sopenharmony_ci
1798c2ecf20Sopenharmony_ciint beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type,
1808c2ecf20Sopenharmony_ci		      struct be_cmd_get_def_gateway_resp *resp);
1818c2ecf20Sopenharmony_ci
1828c2ecf20Sopenharmony_ciint mgmt_get_nic_conf(struct beiscsi_hba *phba,
1838c2ecf20Sopenharmony_ci		      struct be_cmd_get_nic_conf_resp *mac);
1848c2ecf20Sopenharmony_ci
1858c2ecf20Sopenharmony_ciint beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type,
1868c2ecf20Sopenharmony_ci			struct be_cmd_get_if_info_resp **if_info);
1878c2ecf20Sopenharmony_ci
1888c2ecf20Sopenharmony_ciunsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba);
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ciint beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
1918c2ecf20Sopenharmony_ci
1928c2ecf20Sopenharmony_ciunsigned int beiscsi_boot_logout_sess(struct beiscsi_hba *phba);
1938c2ecf20Sopenharmony_ci
1948c2ecf20Sopenharmony_ciunsigned int beiscsi_boot_reopen_sess(struct beiscsi_hba *phba);
1958c2ecf20Sopenharmony_ci
1968c2ecf20Sopenharmony_ciunsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba);
1978c2ecf20Sopenharmony_ci
1988c2ecf20Sopenharmony_ciunsigned int __beiscsi_boot_get_shandle(struct beiscsi_hba *phba, int async);
1998c2ecf20Sopenharmony_ci
2008c2ecf20Sopenharmony_ciint beiscsi_boot_get_shandle(struct beiscsi_hba *phba, unsigned int *s_handle);
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_cissize_t beiscsi_drvr_ver_disp(struct device *dev,
2038c2ecf20Sopenharmony_ci			       struct device_attribute *attr, char *buf);
2048c2ecf20Sopenharmony_ci
2058c2ecf20Sopenharmony_cissize_t beiscsi_fw_ver_disp(struct device *dev,
2068c2ecf20Sopenharmony_ci			     struct device_attribute *attr, char *buf);
2078c2ecf20Sopenharmony_ci
2088c2ecf20Sopenharmony_cissize_t beiscsi_active_session_disp(struct device *dev,
2098c2ecf20Sopenharmony_ci				     struct device_attribute *attr, char *buf);
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_cissize_t beiscsi_adap_family_disp(struct device *dev,
2128c2ecf20Sopenharmony_ci				  struct device_attribute *attr, char *buf);
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ci
2158c2ecf20Sopenharmony_cissize_t beiscsi_free_session_disp(struct device *dev,
2168c2ecf20Sopenharmony_ci				   struct device_attribute *attr, char *buf);
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_cissize_t beiscsi_phys_port_disp(struct device *dev,
2198c2ecf20Sopenharmony_ci				struct device_attribute *attr, char *buf);
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_civoid beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
2228c2ecf20Sopenharmony_ci			     struct wrb_handle *pwrb_handle,
2238c2ecf20Sopenharmony_ci			     struct be_mem_descriptor *mem_descr,
2248c2ecf20Sopenharmony_ci			     struct hwi_wrb_context *pwrb_context);
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_civoid beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params,
2278c2ecf20Sopenharmony_ci			     struct wrb_handle *pwrb_handle,
2288c2ecf20Sopenharmony_ci			     struct hwi_wrb_context *pwrb_context);
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_ciunsigned int beiscsi_invalidate_cxn(struct beiscsi_hba *phba,
2318c2ecf20Sopenharmony_ci				    struct beiscsi_endpoint *beiscsi_ep);
2328c2ecf20Sopenharmony_ci
2338c2ecf20Sopenharmony_ciunsigned int beiscsi_upload_cxn(struct beiscsi_hba *phba,
2348c2ecf20Sopenharmony_ci				struct beiscsi_endpoint *beiscsi_ep);
2358c2ecf20Sopenharmony_ci
2368c2ecf20Sopenharmony_ciint be_cmd_modify_eq_delay(struct beiscsi_hba *phba,
2378c2ecf20Sopenharmony_ci			 struct be_set_eqd *, int num);
2388c2ecf20Sopenharmony_ci
2398c2ecf20Sopenharmony_ciint beiscsi_logout_fw_sess(struct beiscsi_hba *phba,
2408c2ecf20Sopenharmony_ci			    uint32_t fw_sess_handle);
2418c2ecf20Sopenharmony_ci
2428c2ecf20Sopenharmony_ci#endif
243