be_mgmt.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339
  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. #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_open_connection(struct beiscsi_hba *phba,
  87. struct sockaddr *dst_addr,
  88. struct beiscsi_endpoint *beiscsi_ep,
  89. struct be_dma_mem *nonemb_cmd);
  90. unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
  91. unsigned short cid,
  92. unsigned int upload_flag);
  93. unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
  94. struct invalidate_command_table *inv_tbl,
  95. unsigned int num_invalidate, unsigned int cid,
  96. struct be_dma_mem *nonemb_cmd);
  97. unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
  98. struct beiscsi_hba *phba,
  99. struct bsg_job *job,
  100. struct be_dma_mem *nonemb_cmd);
  101. #define BEISCSI_NO_RST_ISSUE 0
  102. struct iscsi_invalidate_connection_params_in {
  103. struct be_cmd_req_hdr hdr;
  104. unsigned int session_handle;
  105. unsigned short cid;
  106. unsigned short unused;
  107. unsigned short cleanup_type;
  108. unsigned short save_cfg;
  109. } __packed;
  110. struct iscsi_invalidate_connection_params_out {
  111. unsigned int session_handle;
  112. unsigned short cid;
  113. unsigned short unused;
  114. } __packed;
  115. union iscsi_invalidate_connection_params {
  116. struct iscsi_invalidate_connection_params_in request;
  117. struct iscsi_invalidate_connection_params_out response;
  118. } __packed;
  119. struct invalidate_commands_params_in {
  120. struct be_cmd_req_hdr hdr;
  121. unsigned int ref_handle;
  122. unsigned int icd_count;
  123. struct invalidate_command_table table[128];
  124. unsigned short cleanup_type;
  125. unsigned short unused;
  126. } __packed;
  127. struct invalidate_commands_params_out {
  128. unsigned int ref_handle;
  129. unsigned int icd_count;
  130. unsigned int icd_status[128];
  131. } __packed;
  132. union invalidate_commands_params {
  133. struct invalidate_commands_params_in request;
  134. struct invalidate_commands_params_out response;
  135. } __packed;
  136. struct mgmt_hba_attributes {
  137. u8 flashrom_version_string[BEISCSI_VER_STRLEN];
  138. u8 manufacturer_name[BEISCSI_VER_STRLEN];
  139. u32 supported_modes;
  140. u8 seeprom_version_lo;
  141. u8 seeprom_version_hi;
  142. u8 rsvd0[2];
  143. u32 fw_cmd_data_struct_version;
  144. u32 ep_fw_data_struct_version;
  145. u8 ncsi_version_string[12];
  146. u32 default_extended_timeout;
  147. u8 controller_model_number[BEISCSI_VER_STRLEN];
  148. u8 controller_description[64];
  149. u8 controller_serial_number[BEISCSI_VER_STRLEN];
  150. u8 ip_version_string[BEISCSI_VER_STRLEN];
  151. u8 firmware_version_string[BEISCSI_VER_STRLEN];
  152. u8 bios_version_string[BEISCSI_VER_STRLEN];
  153. u8 redboot_version_string[BEISCSI_VER_STRLEN];
  154. u8 driver_version_string[BEISCSI_VER_STRLEN];
  155. u8 fw_on_flash_version_string[BEISCSI_VER_STRLEN];
  156. u32 functionalities_supported;
  157. u16 max_cdblength;
  158. u8 asic_revision;
  159. u8 generational_guid[16];
  160. u8 hba_port_count;
  161. u16 default_link_down_timeout;
  162. u8 iscsi_ver_min_max;
  163. u8 multifunction_device;
  164. u8 cache_valid;
  165. u8 hba_status;
  166. u8 max_domains_supported;
  167. u8 phy_port;
  168. u32 firmware_post_status;
  169. u32 hba_mtu[8];
  170. u8 iscsi_features;
  171. u8 asic_generation;
  172. u8 future_u8[2];
  173. u32 future_u32[3];
  174. } __packed;
  175. struct mgmt_controller_attributes {
  176. struct mgmt_hba_attributes hba_attribs;
  177. u16 pci_vendor_id;
  178. u16 pci_device_id;
  179. u16 pci_sub_vendor_id;
  180. u16 pci_sub_system_id;
  181. u8 pci_bus_number;
  182. u8 pci_device_number;
  183. u8 pci_function_number;
  184. u8 interface_type;
  185. u64 unique_identifier;
  186. u8 netfilters;
  187. u8 rsvd0[3];
  188. u32 future_u32[4];
  189. } __packed;
  190. struct be_mgmt_controller_attributes {
  191. struct be_cmd_req_hdr hdr;
  192. struct mgmt_controller_attributes params;
  193. } __packed;
  194. struct be_mgmt_controller_attributes_resp {
  195. struct be_cmd_resp_hdr hdr;
  196. struct mgmt_controller_attributes params;
  197. } __packed;
  198. struct be_bsg_vendor_cmd {
  199. struct be_cmd_req_hdr hdr;
  200. unsigned short region;
  201. unsigned short offset;
  202. unsigned short sector;
  203. } __packed;
  204. /* configuration management */
  205. #define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws)
  206. /* MGMT CMD flags */
  207. #define MGMT_CMDH_FREE (1<<0)
  208. /* --- MGMT_ERROR_CODES --- */
  209. /* Error Codes returned in the status field of the CMD response header */
  210. #define MGMT_STATUS_SUCCESS 0 /* The CMD completed without errors */
  211. #define MGMT_STATUS_FAILED 1 /* Error status in the Status field of */
  212. /* the CMD_RESPONSE_HEADER */
  213. #define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\
  214. pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
  215. bus_address.u.a32.address_lo; \
  216. pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
  217. bus_address.u.a32.address_hi; \
  218. }
  219. #define BEISCSI_WRITE_FLASH 0
  220. #define BEISCSI_READ_FLASH 1
  221. struct beiscsi_endpoint {
  222. struct beiscsi_hba *phba;
  223. struct beiscsi_sess *sess;
  224. struct beiscsi_conn *conn;
  225. struct iscsi_endpoint *openiscsi_ep;
  226. unsigned short ip_type;
  227. char dst6_addr[ISCSI_ADDRESS_BUF_LEN];
  228. unsigned long dst_addr;
  229. unsigned short ep_cid;
  230. unsigned int fw_handle;
  231. u16 dst_tcpport;
  232. u16 cid_vld;
  233. };
  234. unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
  235. struct beiscsi_endpoint *beiscsi_ep,
  236. unsigned short cid,
  237. unsigned short issue_reset,
  238. unsigned short savecfg_flag);
  239. int beiscsi_if_en_dhcp(struct beiscsi_hba *phba, u32 ip_type);
  240. int beiscsi_if_en_static(struct beiscsi_hba *phba, u32 ip_type,
  241. u8 *ip, u8 *subnet);
  242. int beiscsi_if_set_gw(struct beiscsi_hba *phba, u32 ip_type, u8 *gw);
  243. int beiscsi_if_get_gw(struct beiscsi_hba *phba, u32 ip_type,
  244. struct be_cmd_get_def_gateway_resp *resp);
  245. int mgmt_get_nic_conf(struct beiscsi_hba *phba,
  246. struct be_cmd_get_nic_conf_resp *mac);
  247. int beiscsi_if_get_info(struct beiscsi_hba *phba, int ip_type,
  248. struct be_cmd_get_if_info_resp **if_info);
  249. unsigned int beiscsi_if_get_handle(struct beiscsi_hba *phba);
  250. int beiscsi_if_set_vlan(struct beiscsi_hba *phba, uint16_t vlan_tag);
  251. unsigned int beiscsi_boot_logout_sess(struct beiscsi_hba *phba);
  252. unsigned int beiscsi_boot_reopen_sess(struct beiscsi_hba *phba);
  253. unsigned int beiscsi_boot_get_sinfo(struct beiscsi_hba *phba);
  254. unsigned int __beiscsi_boot_get_shandle(struct beiscsi_hba *phba, int async);
  255. int beiscsi_boot_get_shandle(struct beiscsi_hba *phba, unsigned int *s_handle);
  256. ssize_t beiscsi_drvr_ver_disp(struct device *dev,
  257. struct device_attribute *attr, char *buf);
  258. ssize_t beiscsi_fw_ver_disp(struct device *dev,
  259. struct device_attribute *attr, char *buf);
  260. ssize_t beiscsi_active_session_disp(struct device *dev,
  261. struct device_attribute *attr, char *buf);
  262. ssize_t beiscsi_adap_family_disp(struct device *dev,
  263. struct device_attribute *attr, char *buf);
  264. ssize_t beiscsi_free_session_disp(struct device *dev,
  265. struct device_attribute *attr, char *buf);
  266. ssize_t beiscsi_phys_port_disp(struct device *dev,
  267. struct device_attribute *attr, char *buf);
  268. void beiscsi_offload_cxn_v0(struct beiscsi_offload_params *params,
  269. struct wrb_handle *pwrb_handle,
  270. struct be_mem_descriptor *mem_descr,
  271. struct hwi_wrb_context *pwrb_context);
  272. void beiscsi_offload_cxn_v2(struct beiscsi_offload_params *params,
  273. struct wrb_handle *pwrb_handle,
  274. struct hwi_wrb_context *pwrb_context);
  275. int be_cmd_modify_eq_delay(struct beiscsi_hba *phba,
  276. struct be_set_eqd *, int num);
  277. int beiscsi_logout_fw_sess(struct beiscsi_hba *phba,
  278. uint32_t fw_sess_handle);
  279. #endif