be_mgmt.h 9.6 KB

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