1 /** 2 * Copyright (C) 2005 - 2016 Broadcom 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 * 10 * Written by: Jayamohan Kallickal (jayamohan.kallickal@broadcom.com) 11 * 12 * Contact Information: 13 * linux-drivers@broadcom.com 14 * 15 * Emulex 16 * 3333 Susan Street 17 * Costa Mesa, CA 92626 18 */ 19 20 #ifndef _BEISCSI_MGMT_ 21 #define _BEISCSI_MGMT_ 22 23 #include <scsi/scsi_bsg_iscsi.h> 24 #include "be_iscsi.h" 25 #include "be_main.h" 26 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 33 /* UE Status and Mask register */ 34 #define PCICFG_UE_STATUS_LOW 0xA0 35 #define PCICFG_UE_STATUS_HIGH 0xA4 36 #define PCICFG_UE_STATUS_MASK_LOW 0xA8 37 #define PCICFG_UE_STATUS_MASK_HI 0xAC 38 39 int mgmt_open_connection(struct beiscsi_hba *phba, 40 struct sockaddr *dst_addr, 41 struct beiscsi_endpoint *beiscsi_ep, 42 struct be_dma_mem *nonemb_cmd); 43 44 unsigned int mgmt_upload_connection(struct beiscsi_hba *phba, 45 unsigned short cid, 46 unsigned int upload_flag); 47 unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl, 48 struct beiscsi_hba *phba, 49 struct bsg_job *job, 50 struct be_dma_mem *nonemb_cmd); 51 52 #define BEISCSI_NO_RST_ISSUE 0 53 struct iscsi_invalidate_connection_params_in { 54 struct be_cmd_req_hdr hdr; 55 unsigned int session_handle; 56 unsigned short cid; 57 unsigned short unused; 58 unsigned short cleanup_type; 59 unsigned short save_cfg; 60 } __packed; 61 62 struct iscsi_invalidate_connection_params_out { 63 unsigned int session_handle; 64 unsigned short cid; 65 unsigned short unused; 66 } __packed; 67 68 union iscsi_invalidate_connection_params { 69 struct iscsi_invalidate_connection_params_in request; 70 struct iscsi_invalidate_connection_params_out response; 71 } __packed; 72 73 #define BE_INVLDT_CMD_TBL_SZ 128 74 struct invldt_cmd_tbl { 75 unsigned short icd; 76 unsigned short cid; 77 } __packed; 78 79 struct invldt_cmds_params_in { 80 struct be_cmd_req_hdr hdr; 81 unsigned int ref_handle; 82 unsigned int icd_count; 83 struct invldt_cmd_tbl table[BE_INVLDT_CMD_TBL_SZ]; 84 unsigned short cleanup_type; 85 unsigned short unused; 86 } __packed; 87 88 struct invldt_cmds_params_out { 89 struct be_cmd_resp_hdr hdr; 90 unsigned int ref_handle; 91 unsigned int icd_count; 92 unsigned int icd_status[BE_INVLDT_CMD_TBL_SZ]; 93 } __packed; 94 95 union be_invldt_cmds_params { 96 struct invldt_cmds_params_in request; 97 struct invldt_cmds_params_out response; 98 } __packed; 99 100 struct mgmt_hba_attributes { 101 u8 flashrom_version_string[BEISCSI_VER_STRLEN]; 102 u8 manufacturer_name[BEISCSI_VER_STRLEN]; 103 u32 supported_modes; 104 u8 seeprom_version_lo; 105 u8 seeprom_version_hi; 106 u8 rsvd0[2]; 107 u32 fw_cmd_data_struct_version; 108 u32 ep_fw_data_struct_version; 109 u8 ncsi_version_string[12]; 110 u32 default_extended_timeout; 111 u8 controller_model_number[BEISCSI_VER_STRLEN]; 112 u8 controller_description[64]; 113 u8 controller_serial_number[BEISCSI_VER_STRLEN]; 114 u8 ip_version_string[BEISCSI_VER_STRLEN]; 115 u8 firmware_version_string[BEISCSI_VER_STRLEN]; 116 u8 bios_version_string[BEISCSI_VER_STRLEN]; 117 u8 redboot_version_string[BEISCSI_VER_STRLEN]; 118 u8 driver_version_string[BEISCSI_VER_STRLEN]; 119 u8 fw_on_flash_version_string[BEISCSI_VER_STRLEN]; 120 u32 functionalities_supported; 121 u16 max_cdblength; 122 u8 asic_revision; 123 u8 generational_guid[16]; 124 u8 hba_port_count; 125 u16 default_link_down_timeout; 126 u8 iscsi_ver_min_max; 127 u8 multifunction_device; 128 u8 cache_valid; 129 u8 hba_status; 130 u8 max_domains_supported; 131 u8 phy_port; 132 u32 firmware_post_status; 133 u32 hba_mtu[8]; 134 u8 iscsi_features; 135 u8 asic_generation; 136 u8 future_u8[2]; 137 u32 future_u32[3]; 138 } __packed; 139 140 struct mgmt_controller_attributes { 141 struct mgmt_hba_attributes hba_attribs; 142 u16 pci_vendor_id; 143 u16 pci_device_id; 144 u16 pci_sub_vendor_id; 145 u16 pci_sub_system_id; 146 u8 pci_bus_number; 147 u8 pci_device_number; 148 u8 pci_function_number; 149 u8 interface_type; 150 u64 unique_identifier; 151 u8 netfilters; 152 u8 rsvd0[3]; 153 u32 future_u32[4]; 154 } __packed; 155 156 struct be_mgmt_controller_attributes { 157 struct be_cmd_req_hdr hdr; 158 struct mgmt_controller_attributes params; 159 } __packed; 160 161 struct be_mgmt_controller_attributes_resp { 162 struct be_cmd_resp_hdr hdr; 163 struct mgmt_controller_attributes params; 164 } __packed; 165 166 struct be_bsg_vendor_cmd { 167 struct be_cmd_req_hdr hdr; 168 unsigned short region; 169 unsigned short offset; 170 unsigned short sector; 171 } __packed; 172 173 /* configuration management */ 174 175 #define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws) 176 177 #define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\ 178 pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ 179 bus_address.u.a32.address_lo; \ 180 pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\ 181 bus_address.u.a32.address_hi; \ 182 } 183 184 #define BEISCSI_WRITE_FLASH 0 185 #define BEISCSI_READ_FLASH 1 186 187 struct beiscsi_endpoint { 188 struct beiscsi_hba *phba; 189 struct beiscsi_sess *sess; 190 struct beiscsi_conn *conn; 191 struct iscsi_endpoint *openiscsi_ep; 192 unsigned short ip_type; 193 char dst6_addr[ISCSI_ADDRESS_BUF_LEN]; 194 unsigned long dst_addr; 195 unsigned short ep_cid; 196 unsigned int fw_handle; 197 u16 dst_tcpport; 198 u16 cid_vld; 199 }; 200 201 unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba, 202 struct beiscsi_endpoint *beiscsi_ep, 203 unsigned short cid, 204 unsigned short issue_reset, 205 unsigned short savecfg_flag); 206 int beiscsi_mgmt_invalidate_icds(struct beiscsi_hba *phba, 207 struct invldt_cmd_tbl *inv_tbl, 208 unsigned int nents); 209 210 int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type); 211 212 int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type, 213 u8 *ip, u8 *subnet); 214 215 int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw); 216 217 int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type, 218 struct be_cmd_get_def_gateway_resp *resp); 219 220 int mgmt_get_nic_conf(struct beiscsi_hba *phba, 221 struct be_cmd_get_nic_conf_resp *mac); 222 223 int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type, 224 struct be_cmd_get_if_info_resp **if_info); 225 226 unsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba); 227 228 int beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag); 229 230 unsigned int beiscsi_boot_logout_sess(struct beiscsi_hba *phba); 231 232 unsigned int beiscsi_boot_reopen_sess(struct beiscsi_hba *phba); 233 234 unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba); 235 236 unsigned int __beiscsi_boot_get_shandle(struct beiscsi_hba *phba, int async); 237 238 int beiscsi_boot_get_shandle(struct beiscsi_hba *phba, unsigned int *s_handle); 239 240 ssize_t beiscsi_drvr_ver_disp(struct device *dev, 241 struct device_attribute *attr, char *buf); 242 243 ssize_t beiscsi_fw_ver_disp(struct device *dev, 244 struct device_attribute *attr, char *buf); 245 246 ssize_t beiscsi_active_session_disp(struct device *dev, 247 struct device_attribute *attr, char *buf); 248 249 ssize_t beiscsi_adap_family_disp(struct device *dev, 250 struct device_attribute *attr, char *buf); 251 252 253 ssize_t beiscsi_free_session_disp(struct device *dev, 254 struct device_attribute *attr, char *buf); 255 256 ssize_t beiscsi_phys_port_disp(struct device *dev, 257 struct device_attribute *attr, char *buf); 258 259 void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params, 260 struct wrb_handle *pwrb_handle, 261 struct be_mem_descriptor *mem_descr, 262 struct hwi_wrb_context *pwrb_context); 263 264 void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params, 265 struct wrb_handle *pwrb_handle, 266 struct hwi_wrb_context *pwrb_context); 267 268 int be_cmd_modify_eq_delay(struct beiscsi_hba *phba, 269 struct be_set_eqd *, int num); 270 271 int beiscsi_logout_fw_sess(struct beiscsi_hba *phba, 272 uint32_t fw_sess_handle); 273 274 #endif 275