Jitendra Bhivare | 942b765 | 2017-03-24 14:11:48 +0530 | [diff] [blame] | 1 | /* |
Jitendra Bhivare | 0172dc6 | 2017-10-10 16:18:19 +0530 | [diff] [blame] | 2 | * Copyright 2017 Broadcom. All Rights Reserved. |
Jitendra Bhivare | 942b765 | 2017-03-24 14:11:48 +0530 | [diff] [blame] | 3 | * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries. |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 4 | * |
| 5 | * This program is free software; you can redistribute it and/or |
| 6 | * modify it under the terms of the GNU General Public License version 2 |
Jitendra Bhivare | 942b765 | 2017-03-24 14:11:48 +0530 | [diff] [blame] | 7 | * as published by the Free Software Foundation. The full GNU General |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 8 | * Public License is included in this distribution in the file called COPYING. |
| 9 | * |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 10 | * Contact Information: |
Jitendra Bhivare | 60f36e0 | 2016-08-19 15:20:24 +0530 | [diff] [blame] | 11 | * linux-drivers@broadcom.com |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 12 | * |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 13 | */ |
| 14 | |
| 15 | #ifndef _BEISCSI_MGMT_ |
| 16 | #define _BEISCSI_MGMT_ |
| 17 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 18 | #include <scsi/scsi_bsg_iscsi.h> |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 19 | #include "be_iscsi.h" |
| 20 | #include "be_main.h" |
| 21 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 22 | #define IP_ACTION_ADD 0x01 |
| 23 | #define IP_ACTION_DEL 0x02 |
| 24 | |
| 25 | #define IP_V6_LEN 16 |
| 26 | #define IP_V4_LEN 4 |
| 27 | |
John Soni Jose | 7a15800 | 2012-10-20 04:45:51 +0530 | [diff] [blame] | 28 | /* UE Status and Mask register */ |
| 29 | #define PCICFG_UE_STATUS_LOW 0xA0 |
| 30 | #define PCICFG_UE_STATUS_HIGH 0xA4 |
| 31 | #define PCICFG_UE_STATUS_MASK_LOW 0xA8 |
| 32 | #define PCICFG_UE_STATUS_MASK_HI 0xAC |
| 33 | |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 34 | int mgmt_open_connection(struct beiscsi_hba *phba, |
| 35 | struct sockaddr *dst_addr, |
| 36 | struct beiscsi_endpoint *beiscsi_ep, |
| 37 | struct be_dma_mem *nonemb_cmd); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 38 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 39 | unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, |
| 40 | struct beiscsi_hba *phba, |
| 41 | struct bsg_job *job, |
| 42 | struct be_dma_mem *nonemb_cmd); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 43 | |
Jitendra Bhivare | f350501 | 2016-12-13 15:55:54 +0530 | [diff] [blame] | 44 | #define BE_INVLDT_CMD_TBL_SZ 128 |
| 45 | struct invldt_cmd_tbl { |
| 46 | unsigned short icd; |
| 47 | unsigned short cid; |
| 48 | } __packed; |
| 49 | |
| 50 | struct invldt_cmds_params_in { |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 51 | struct be_cmd_req_hdr hdr; |
| 52 | unsigned int ref_handle; |
| 53 | unsigned int icd_count; |
Jitendra Bhivare | f350501 | 2016-12-13 15:55:54 +0530 | [diff] [blame] | 54 | struct invldt_cmd_tbl table[BE_INVLDT_CMD_TBL_SZ]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 55 | unsigned short cleanup_type; |
| 56 | unsigned short unused; |
| 57 | } __packed; |
| 58 | |
Jitendra Bhivare | f350501 | 2016-12-13 15:55:54 +0530 | [diff] [blame] | 59 | struct invldt_cmds_params_out { |
| 60 | struct be_cmd_resp_hdr hdr; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 61 | unsigned int ref_handle; |
| 62 | unsigned int icd_count; |
Jitendra Bhivare | f350501 | 2016-12-13 15:55:54 +0530 | [diff] [blame] | 63 | unsigned int icd_status[BE_INVLDT_CMD_TBL_SZ]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 64 | } __packed; |
| 65 | |
Jitendra Bhivare | f350501 | 2016-12-13 15:55:54 +0530 | [diff] [blame] | 66 | union be_invldt_cmds_params { |
| 67 | struct invldt_cmds_params_in request; |
| 68 | struct invldt_cmds_params_out response; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 69 | } __packed; |
| 70 | |
| 71 | struct mgmt_hba_attributes { |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 72 | u8 flashrom_version_string[BEISCSI_VER_STRLEN]; |
| 73 | u8 manufacturer_name[BEISCSI_VER_STRLEN]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 74 | u32 supported_modes; |
| 75 | u8 seeprom_version_lo; |
| 76 | u8 seeprom_version_hi; |
| 77 | u8 rsvd0[2]; |
| 78 | u32 fw_cmd_data_struct_version; |
| 79 | u32 ep_fw_data_struct_version; |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 80 | u8 ncsi_version_string[12]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 81 | u32 default_extended_timeout; |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 82 | u8 controller_model_number[BEISCSI_VER_STRLEN]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 83 | u8 controller_description[64]; |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 84 | u8 controller_serial_number[BEISCSI_VER_STRLEN]; |
| 85 | u8 ip_version_string[BEISCSI_VER_STRLEN]; |
| 86 | u8 firmware_version_string[BEISCSI_VER_STRLEN]; |
| 87 | u8 bios_version_string[BEISCSI_VER_STRLEN]; |
| 88 | u8 redboot_version_string[BEISCSI_VER_STRLEN]; |
| 89 | u8 driver_version_string[BEISCSI_VER_STRLEN]; |
| 90 | u8 fw_on_flash_version_string[BEISCSI_VER_STRLEN]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 91 | u32 functionalities_supported; |
| 92 | u16 max_cdblength; |
| 93 | u8 asic_revision; |
| 94 | u8 generational_guid[16]; |
| 95 | u8 hba_port_count; |
| 96 | u16 default_link_down_timeout; |
| 97 | u8 iscsi_ver_min_max; |
| 98 | u8 multifunction_device; |
| 99 | u8 cache_valid; |
| 100 | u8 hba_status; |
| 101 | u8 max_domains_supported; |
| 102 | u8 phy_port; |
| 103 | u32 firmware_post_status; |
| 104 | u32 hba_mtu[8]; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 105 | u8 iscsi_features; |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 106 | u8 asic_generation; |
| 107 | u8 future_u8[2]; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 108 | u32 future_u32[3]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 109 | } __packed; |
| 110 | |
| 111 | struct mgmt_controller_attributes { |
| 112 | struct mgmt_hba_attributes hba_attribs; |
| 113 | u16 pci_vendor_id; |
| 114 | u16 pci_device_id; |
| 115 | u16 pci_sub_vendor_id; |
| 116 | u16 pci_sub_system_id; |
| 117 | u8 pci_bus_number; |
| 118 | u8 pci_device_number; |
| 119 | u8 pci_function_number; |
| 120 | u8 interface_type; |
| 121 | u64 unique_identifier; |
| 122 | u8 netfilters; |
| 123 | u8 rsvd0[3]; |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 124 | u32 future_u32[4]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 125 | } __packed; |
| 126 | |
| 127 | struct be_mgmt_controller_attributes { |
| 128 | struct be_cmd_req_hdr hdr; |
| 129 | struct mgmt_controller_attributes params; |
| 130 | } __packed; |
| 131 | |
| 132 | struct be_mgmt_controller_attributes_resp { |
| 133 | struct be_cmd_resp_hdr hdr; |
| 134 | struct mgmt_controller_attributes params; |
| 135 | } __packed; |
| 136 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 137 | struct be_bsg_vendor_cmd { |
| 138 | struct be_cmd_req_hdr hdr; |
| 139 | unsigned short region; |
| 140 | unsigned short offset; |
| 141 | unsigned short sector; |
| 142 | } __packed; |
| 143 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 144 | /* configuration management */ |
| 145 | |
| 146 | #define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws) |
| 147 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 148 | #define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\ |
Jayamohan Kallickal | 3ec7827 | 2012-04-03 23:41:38 -0500 | [diff] [blame] | 149 | pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 150 | bus_address.u.a32.address_lo; \ |
Jayamohan Kallickal | 3ec7827 | 2012-04-03 23:41:38 -0500 | [diff] [blame] | 151 | pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 152 | bus_address.u.a32.address_hi; \ |
| 153 | } |
| 154 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 155 | #define BEISCSI_WRITE_FLASH 0 |
| 156 | #define BEISCSI_READ_FLASH 1 |
| 157 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 158 | struct beiscsi_endpoint { |
| 159 | struct beiscsi_hba *phba; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 160 | struct beiscsi_conn *conn; |
Jayamohan Kallickal | c246228 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 161 | struct iscsi_endpoint *openiscsi_ep; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 162 | unsigned short ip_type; |
| 163 | char dst6_addr[ISCSI_ADDRESS_BUF_LEN]; |
| 164 | unsigned long dst_addr; |
| 165 | unsigned short ep_cid; |
| 166 | unsigned int fw_handle; |
| 167 | u16 dst_tcpport; |
| 168 | u16 cid_vld; |
| 169 | }; |
| 170 | |
Jitendra Bhivare | 9871321 | 2016-12-13 15:55:55 +0530 | [diff] [blame] | 171 | int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba, |
| 172 | struct invldt_cmd_tbl *inv_tbl, |
| 173 | unsigned int nents); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 174 | |
Jitendra Bhivare | 4788e73 | 2017-10-10 16:18:16 +0530 | [diff] [blame] | 175 | int beiscsi_get_initiator_name(struct beiscsi_hba *phba, char *name, bool cfg); |
Jitendra Bhivare | c5905bf | 2017-10-10 16:18:15 +0530 | [diff] [blame] | 176 | |
Jitendra Bhivare | 0152a7e | 2016-08-19 15:20:03 +0530 | [diff] [blame] | 177 | int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type); |
| 178 | |
| 179 | int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type, |
| 180 | u8 *ip, u8 *subnet); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 181 | |
Jitendra Bhivare | 480195c | 2016-08-19 15:20:15 +0530 | [diff] [blame] | 182 | int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw); |
| 183 | |
| 184 | int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type, |
| 185 | struct be_cmd_get_def_gateway_resp *resp); |
| 186 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 187 | int mgmt_get_nic_conf(struct beiscsi_hba *phba, |
| 188 | struct be_cmd_get_nic_conf_resp *mac); |
| 189 | |
Jitendra Bhivare | 96b48b9 | 2016-08-19 15:20:06 +0530 | [diff] [blame] | 190 | int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type, |
| 191 | struct be_cmd_get_if_info_resp **if_info); |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 192 | |
Jitendra Bhivare | c5bf888 | 2016-08-19 15:20:05 +0530 | [diff] [blame] | 193 | unsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba); |
John Soni Jose | 6f72238 | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 194 | |
Jitendra Bhivare | db02aea | 2016-08-19 15:20:04 +0530 | [diff] [blame] | 195 | int beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); |
John Soni Jose | 5cac759 | 2012-10-20 04:42:25 +0530 | [diff] [blame] | 196 | |
Jitendra Bhivare | 50a4b82 | 2016-08-19 15:20:12 +0530 | [diff] [blame] | 197 | unsigned int beiscsi_boot_logout_sess(struct beiscsi_hba *phba); |
| 198 | |
| 199 | unsigned int beiscsi_boot_reopen_sess(struct beiscsi_hba *phba); |
| 200 | |
| 201 | unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba); |
| 202 | |
| 203 | unsigned int __beiscsi_boot_get_shandle(struct beiscsi_hba *phba, int async); |
| 204 | |
| 205 | int beiscsi_boot_get_shandle(struct beiscsi_hba *phba, unsigned int *s_handle); |
| 206 | |
John Soni Jose | 5cac759 | 2012-10-20 04:42:25 +0530 | [diff] [blame] | 207 | ssize_t beiscsi_drvr_ver_disp(struct device *dev, |
| 208 | struct device_attribute *attr, char *buf); |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 209 | |
Jayamohan Kallickal | 22661e2 | 2013-04-05 20:38:28 -0700 | [diff] [blame] | 210 | ssize_t beiscsi_fw_ver_disp(struct device *dev, |
| 211 | struct device_attribute *attr, char *buf); |
| 212 | |
Jayamohan Kallickal | 6103c1f | 2013-09-28 15:35:52 -0700 | [diff] [blame] | 213 | ssize_t beiscsi_active_session_disp(struct device *dev, |
| 214 | struct device_attribute *attr, char *buf); |
Jayamohan Kallickal | 7ad4dfe | 2013-04-05 20:38:29 -0700 | [diff] [blame] | 215 | |
John Soni Jose | 26000db | 2012-10-20 04:45:06 +0530 | [diff] [blame] | 216 | ssize_t beiscsi_adap_family_disp(struct device *dev, |
| 217 | struct device_attribute *attr, char *buf); |
| 218 | |
Jayamohan Kallickal | 6103c1f | 2013-09-28 15:35:52 -0700 | [diff] [blame] | 219 | |
| 220 | ssize_t beiscsi_free_session_disp(struct device *dev, |
| 221 | struct device_attribute *attr, char *buf); |
| 222 | |
Jayamohan Kallickal | d3fea9a | 2013-09-28 15:35:53 -0700 | [diff] [blame] | 223 | ssize_t beiscsi_phys_port_disp(struct device *dev, |
| 224 | struct device_attribute *attr, char *buf); |
| 225 | |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 226 | void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params, |
| 227 | struct wrb_handle *pwrb_handle, |
John Soni Jose | 340c99e | 2015-08-20 04:44:30 +0530 | [diff] [blame] | 228 | struct be_mem_descriptor *mem_descr, |
| 229 | struct hwi_wrb_context *pwrb_context); |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 230 | |
| 231 | void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params, |
John Soni Jose | 340c99e | 2015-08-20 04:44:30 +0530 | [diff] [blame] | 232 | struct wrb_handle *pwrb_handle, |
| 233 | struct hwi_wrb_context *pwrb_context); |
| 234 | |
Jitendra Bhivare | 49fc515 | 2017-03-24 14:11:41 +0530 | [diff] [blame] | 235 | unsigned int beiscsi_invalidate_cxn(struct beiscsi_hba *phba, |
| 236 | struct beiscsi_endpoint *beiscsi_ep); |
| 237 | |
| 238 | unsigned int beiscsi_upload_cxn(struct beiscsi_hba *phba, |
| 239 | struct beiscsi_endpoint *beiscsi_ep); |
| 240 | |
Jayamohan Kallickal | 73af08e | 2014-05-05 21:41:26 -0400 | [diff] [blame] | 241 | int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, |
| 242 | struct be_set_eqd *, int num); |
John Soni Jose | acb9693 | 2012-10-20 04:44:35 +0530 | [diff] [blame] | 243 | |
John Soni Jose | 3f4134c | 2015-04-25 08:18:13 +0530 | [diff] [blame] | 244 | int beiscsi_logout_fw_sess(struct beiscsi_hba *phba, |
| 245 | uint32_t fw_sess_handle); |
| 246 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 247 | #endif |