Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 1 | /** |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 2 | * Copyright (C) 2005 - 2011 Emulex |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 3 | * All rights reserved. |
| 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 |
| 7 | * as published by the Free Software Foundation. The full GNU General |
| 8 | * Public License is included in this distribution in the file called COPYING. |
| 9 | * |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 10 | * Written by: Jayamohan Kallickal (jayamohan.kallickal@emulex.com) |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 11 | * |
| 12 | * Contact Information: |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 13 | * linux-drivers@emulex.com |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 14 | * |
Jayamohan Kallickal | 255fa9a | 2011-03-25 14:23:57 -0700 | [diff] [blame] | 15 | * Emulex |
| 16 | * 3333 Susan Street |
| 17 | * Costa Mesa, CA 92626 |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #ifndef _BEISCSI_MGMT_ |
| 21 | #define _BEISCSI_MGMT_ |
| 22 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 23 | #include <scsi/scsi_bsg_iscsi.h> |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 24 | #include "be_iscsi.h" |
| 25 | #include "be_main.h" |
| 26 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 27 | #define IP_ACTION_ADD 0x01 |
| 28 | #define IP_ACTION_DEL 0x02 |
| 29 | |
| 30 | #define IP_V6_LEN 16 |
| 31 | #define IP_V4_LEN 4 |
| 32 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 33 | /** |
| 34 | * Pseudo amap definition in which each bit of the actual structure is defined |
| 35 | * as a byte: used to calculate offset/shift/mask of each field |
| 36 | */ |
| 37 | struct amap_mcc_sge { |
| 38 | u8 pa_lo[32]; /* dword 0 */ |
| 39 | u8 pa_hi[32]; /* dword 1 */ |
| 40 | u8 length[32]; /* DWORD 2 */ |
| 41 | } __packed; |
| 42 | |
| 43 | /** |
| 44 | * Pseudo amap definition in which each bit of the actual structure is defined |
| 45 | * as a byte: used to calculate offset/shift/mask of each field |
| 46 | */ |
| 47 | struct amap_mcc_wrb_payload { |
| 48 | union { |
| 49 | struct amap_mcc_sge sgl[19]; |
| 50 | u8 embedded[59 * 32]; /* DWORDS 57 to 115 */ |
| 51 | } u; |
| 52 | } __packed; |
| 53 | |
| 54 | /** |
| 55 | * Pseudo amap definition in which each bit of the actual structure is defined |
| 56 | * as a byte: used to calculate offset/shift/mask of each field |
| 57 | */ |
| 58 | struct amap_mcc_wrb { |
| 59 | u8 embedded; /* DWORD 0 */ |
| 60 | u8 rsvd0[2]; /* DWORD 0 */ |
| 61 | u8 sge_count[5]; /* DWORD 0 */ |
| 62 | u8 rsvd1[16]; /* DWORD 0 */ |
| 63 | u8 special[8]; /* DWORD 0 */ |
| 64 | u8 payload_length[32]; |
| 65 | u8 tag[64]; /* DWORD 2 */ |
| 66 | u8 rsvd2[32]; /* DWORD 4 */ |
| 67 | struct amap_mcc_wrb_payload payload; |
| 68 | }; |
| 69 | |
| 70 | struct mcc_sge { |
| 71 | u32 pa_lo; /* dword 0 */ |
| 72 | u32 pa_hi; /* dword 1 */ |
| 73 | u32 length; /* DWORD 2 */ |
| 74 | } __packed; |
| 75 | |
| 76 | struct mcc_wrb_payload { |
| 77 | union { |
| 78 | struct mcc_sge sgl[19]; |
| 79 | u32 embedded[59]; /* DWORDS 57 to 115 */ |
| 80 | } u; |
| 81 | } __packed; |
| 82 | |
| 83 | #define MCC_WRB_EMBEDDED_MASK 0x00000001 |
| 84 | |
| 85 | struct mcc_wrb { |
| 86 | u32 dw[0]; /* DWORD 0 */ |
| 87 | u32 payload_length; |
| 88 | u32 tag[2]; /* DWORD 2 */ |
| 89 | u32 rsvd2[1]; /* DWORD 4 */ |
| 90 | struct mcc_wrb_payload payload; |
| 91 | }; |
| 92 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 93 | int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute); |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 94 | int mgmt_open_connection(struct beiscsi_hba *phba, |
| 95 | struct sockaddr *dst_addr, |
| 96 | struct beiscsi_endpoint *beiscsi_ep, |
| 97 | struct be_dma_mem *nonemb_cmd); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 98 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 99 | unsigned int mgmt_upload_connection(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 100 | unsigned short cid, |
| 101 | unsigned int upload_flag); |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 102 | unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 4183122 | 2010-02-20 08:02:39 +0530 | [diff] [blame] | 103 | struct invalidate_command_table *inv_tbl, |
Jayamohan Kallickal | 3cbb7a7 | 2010-07-22 04:27:47 +0530 | [diff] [blame] | 104 | unsigned int num_invalidate, unsigned int cid, |
| 105 | struct be_dma_mem *nonemb_cmd); |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 106 | unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, |
| 107 | struct beiscsi_hba *phba, |
| 108 | struct bsg_job *job, |
| 109 | struct be_dma_mem *nonemb_cmd); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 110 | |
John Soni Jose | 0a513dd | 2012-08-20 23:00:55 +0530 | [diff] [blame^] | 111 | #define BEISCSI_NO_RST_ISSUE 0 |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 112 | struct iscsi_invalidate_connection_params_in { |
| 113 | struct be_cmd_req_hdr hdr; |
| 114 | unsigned int session_handle; |
| 115 | unsigned short cid; |
| 116 | unsigned short unused; |
| 117 | unsigned short cleanup_type; |
| 118 | unsigned short save_cfg; |
| 119 | } __packed; |
| 120 | |
| 121 | struct iscsi_invalidate_connection_params_out { |
| 122 | unsigned int session_handle; |
| 123 | unsigned short cid; |
| 124 | unsigned short unused; |
| 125 | } __packed; |
| 126 | |
| 127 | union iscsi_invalidate_connection_params { |
| 128 | struct iscsi_invalidate_connection_params_in request; |
| 129 | struct iscsi_invalidate_connection_params_out response; |
| 130 | } __packed; |
| 131 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 132 | struct invalidate_commands_params_in { |
| 133 | struct be_cmd_req_hdr hdr; |
| 134 | unsigned int ref_handle; |
| 135 | unsigned int icd_count; |
| 136 | struct invalidate_command_table table[128]; |
| 137 | unsigned short cleanup_type; |
| 138 | unsigned short unused; |
| 139 | } __packed; |
| 140 | |
| 141 | struct invalidate_commands_params_out { |
| 142 | unsigned int ref_handle; |
| 143 | unsigned int icd_count; |
| 144 | unsigned int icd_status[128]; |
| 145 | } __packed; |
| 146 | |
| 147 | union invalidate_commands_params { |
| 148 | struct invalidate_commands_params_in request; |
| 149 | struct invalidate_commands_params_out response; |
| 150 | } __packed; |
| 151 | |
| 152 | struct mgmt_hba_attributes { |
| 153 | u8 flashrom_version_string[32]; |
| 154 | u8 manufacturer_name[32]; |
| 155 | u32 supported_modes; |
| 156 | u8 seeprom_version_lo; |
| 157 | u8 seeprom_version_hi; |
| 158 | u8 rsvd0[2]; |
| 159 | u32 fw_cmd_data_struct_version; |
| 160 | u32 ep_fw_data_struct_version; |
| 161 | u32 future_reserved[12]; |
| 162 | u32 default_extended_timeout; |
| 163 | u8 controller_model_number[32]; |
| 164 | u8 controller_description[64]; |
| 165 | u8 controller_serial_number[32]; |
| 166 | u8 ip_version_string[32]; |
| 167 | u8 firmware_version_string[32]; |
| 168 | u8 bios_version_string[32]; |
| 169 | u8 redboot_version_string[32]; |
| 170 | u8 driver_version_string[32]; |
| 171 | u8 fw_on_flash_version_string[32]; |
| 172 | u32 functionalities_supported; |
| 173 | u16 max_cdblength; |
| 174 | u8 asic_revision; |
| 175 | u8 generational_guid[16]; |
| 176 | u8 hba_port_count; |
| 177 | u16 default_link_down_timeout; |
| 178 | u8 iscsi_ver_min_max; |
| 179 | u8 multifunction_device; |
| 180 | u8 cache_valid; |
| 181 | u8 hba_status; |
| 182 | u8 max_domains_supported; |
| 183 | u8 phy_port; |
| 184 | u32 firmware_post_status; |
| 185 | u32 hba_mtu[8]; |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 186 | u8 iscsi_features; |
| 187 | u8 future_u8[3]; |
| 188 | u32 future_u32[3]; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 189 | } __packed; |
| 190 | |
| 191 | struct mgmt_controller_attributes { |
| 192 | struct mgmt_hba_attributes hba_attribs; |
| 193 | u16 pci_vendor_id; |
| 194 | u16 pci_device_id; |
| 195 | u16 pci_sub_vendor_id; |
| 196 | u16 pci_sub_system_id; |
| 197 | u8 pci_bus_number; |
| 198 | u8 pci_device_number; |
| 199 | u8 pci_function_number; |
| 200 | u8 interface_type; |
| 201 | u64 unique_identifier; |
| 202 | u8 netfilters; |
| 203 | u8 rsvd0[3]; |
| 204 | u8 future_u32[4]; |
| 205 | } __packed; |
| 206 | |
| 207 | struct be_mgmt_controller_attributes { |
| 208 | struct be_cmd_req_hdr hdr; |
| 209 | struct mgmt_controller_attributes params; |
| 210 | } __packed; |
| 211 | |
| 212 | struct be_mgmt_controller_attributes_resp { |
| 213 | struct be_cmd_resp_hdr hdr; |
| 214 | struct mgmt_controller_attributes params; |
| 215 | } __packed; |
| 216 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 217 | struct be_bsg_vendor_cmd { |
| 218 | struct be_cmd_req_hdr hdr; |
| 219 | unsigned short region; |
| 220 | unsigned short offset; |
| 221 | unsigned short sector; |
| 222 | } __packed; |
| 223 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 224 | /* configuration management */ |
| 225 | |
| 226 | #define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws) |
| 227 | |
| 228 | /* MGMT CMD flags */ |
| 229 | |
| 230 | #define MGMT_CMDH_FREE (1<<0) |
| 231 | |
| 232 | /* --- MGMT_ERROR_CODES --- */ |
| 233 | /* Error Codes returned in the status field of the CMD response header */ |
| 234 | #define MGMT_STATUS_SUCCESS 0 /* The CMD completed without errors */ |
| 235 | #define MGMT_STATUS_FAILED 1 /* Error status in the Status field of */ |
| 236 | /* the CMD_RESPONSE_HEADER */ |
| 237 | |
| 238 | #define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\ |
Jayamohan Kallickal | 3ec7827 | 2012-04-03 23:41:38 -0500 | [diff] [blame] | 239 | pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 240 | bus_address.u.a32.address_lo; \ |
Jayamohan Kallickal | 3ec7827 | 2012-04-03 23:41:38 -0500 | [diff] [blame] | 241 | pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 242 | bus_address.u.a32.address_hi; \ |
| 243 | } |
| 244 | |
Jayamohan Kallickal | ffce3e2 | 2012-04-03 23:41:50 -0500 | [diff] [blame] | 245 | #define BEISCSI_WRITE_FLASH 0 |
| 246 | #define BEISCSI_READ_FLASH 1 |
| 247 | |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 248 | struct beiscsi_endpoint { |
| 249 | struct beiscsi_hba *phba; |
| 250 | struct beiscsi_sess *sess; |
| 251 | struct beiscsi_conn *conn; |
Jayamohan Kallickal | c246228 | 2010-01-05 05:05:34 +0530 | [diff] [blame] | 252 | struct iscsi_endpoint *openiscsi_ep; |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 253 | unsigned short ip_type; |
| 254 | char dst6_addr[ISCSI_ADDRESS_BUF_LEN]; |
| 255 | unsigned long dst_addr; |
| 256 | unsigned short ep_cid; |
| 257 | unsigned int fw_handle; |
| 258 | u16 dst_tcpport; |
| 259 | u16 cid_vld; |
| 260 | }; |
| 261 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 262 | int mgmt_get_fw_config(struct be_ctrl_info *ctrl, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 263 | struct beiscsi_hba *phba); |
| 264 | |
Jayamohan Kallickal | 03a1231 | 2010-07-22 04:17:16 +0530 | [diff] [blame] | 265 | unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 266 | struct beiscsi_endpoint *beiscsi_ep, |
| 267 | unsigned short cid, |
| 268 | unsigned short issue_reset, |
| 269 | unsigned short savecfg_flag); |
Jayamohan Kallickal | bfead3b | 2009-10-23 11:52:33 +0530 | [diff] [blame] | 270 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 271 | int mgmt_set_ip(struct beiscsi_hba *phba, |
| 272 | struct iscsi_iface_param_info *ip_param, |
| 273 | struct iscsi_iface_param_info *subnet_param, |
| 274 | uint32_t boot_proto); |
| 275 | |
| 276 | unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba); |
| 277 | |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 278 | unsigned int mgmt_reopen_session(struct beiscsi_hba *phba, |
| 279 | unsigned int reopen_type, |
| 280 | unsigned sess_handle); |
| 281 | |
Mike Christie | 0e43895 | 2012-04-03 23:41:51 -0500 | [diff] [blame] | 282 | unsigned int mgmt_get_session_info(struct beiscsi_hba *phba, |
| 283 | u32 boot_session_handle, |
| 284 | struct be_dma_mem *nonemb_cmd); |
| 285 | |
| 286 | int mgmt_get_nic_conf(struct beiscsi_hba *phba, |
| 287 | struct be_cmd_get_nic_conf_resp *mac); |
| 288 | |
| 289 | int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type, |
| 290 | struct be_cmd_get_if_info_resp *if_info); |
| 291 | |
| 292 | int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type, |
| 293 | struct be_cmd_get_def_gateway_resp *gateway); |
| 294 | |
| 295 | int mgmt_set_gateway(struct beiscsi_hba *phba, |
| 296 | struct iscsi_iface_param_info *gateway_param); |
| 297 | |
John Soni Jose | 9aef420 | 2012-08-20 23:00:08 +0530 | [diff] [blame] | 298 | int be_mgmt_get_boot_shandle(struct beiscsi_hba *phba, |
| 299 | unsigned int *s_handle); |
John Soni Jose | 6f72238 | 2012-08-20 23:00:43 +0530 | [diff] [blame] | 300 | |
| 301 | unsigned int mgmt_get_all_if_id(struct beiscsi_hba *phba); |
| 302 | |
| 303 | int mgmt_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); |
Jayamohan Kallickal | 6733b39 | 2009-09-05 07:36:35 +0530 | [diff] [blame] | 304 | #endif |