be_mgmt.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /**
  2. * Copyright (C) 2005 - 2011 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@emulex.com)
  11. *
  12. * Contact Information:
  13. * linux-drivers@emulex.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. /**
  29. * Pseudo amap definition in which each bit of the actual structure is defined
  30. * as a byte: used to calculate offset/shift/mask of each field
  31. */
  32. struct amap_mcc_sge {
  33. u8 pa_lo[32]; /* dword 0 */
  34. u8 pa_hi[32]; /* dword 1 */
  35. u8 length[32]; /* DWORD 2 */
  36. } __packed;
  37. /**
  38. * Pseudo amap definition in which each bit of the actual structure is defined
  39. * as a byte: used to calculate offset/shift/mask of each field
  40. */
  41. struct amap_mcc_wrb_payload {
  42. union {
  43. struct amap_mcc_sge sgl[19];
  44. u8 embedded[59 * 32]; /* DWORDS 57 to 115 */
  45. } u;
  46. } __packed;
  47. /**
  48. * Pseudo amap definition in which each bit of the actual structure is defined
  49. * as a byte: used to calculate offset/shift/mask of each field
  50. */
  51. struct amap_mcc_wrb {
  52. u8 embedded; /* DWORD 0 */
  53. u8 rsvd0[2]; /* DWORD 0 */
  54. u8 sge_count[5]; /* DWORD 0 */
  55. u8 rsvd1[16]; /* DWORD 0 */
  56. u8 special[8]; /* DWORD 0 */
  57. u8 payload_length[32];
  58. u8 tag[64]; /* DWORD 2 */
  59. u8 rsvd2[32]; /* DWORD 4 */
  60. struct amap_mcc_wrb_payload payload;
  61. };
  62. struct mcc_sge {
  63. u32 pa_lo; /* dword 0 */
  64. u32 pa_hi; /* dword 1 */
  65. u32 length; /* DWORD 2 */
  66. } __packed;
  67. struct mcc_wrb_payload {
  68. union {
  69. struct mcc_sge sgl[19];
  70. u32 embedded[59]; /* DWORDS 57 to 115 */
  71. } u;
  72. } __packed;
  73. #define MCC_WRB_EMBEDDED_MASK 0x00000001
  74. struct mcc_wrb {
  75. u32 dw[0]; /* DWORD 0 */
  76. u32 payload_length;
  77. u32 tag[2]; /* DWORD 2 */
  78. u32 rsvd2[1]; /* DWORD 4 */
  79. struct mcc_wrb_payload payload;
  80. };
  81. int mgmt_epfw_cleanup(struct beiscsi_hba *phba, unsigned short chute);
  82. int mgmt_open_connection(struct beiscsi_hba *phba,
  83. struct sockaddr *dst_addr,
  84. struct beiscsi_endpoint *beiscsi_ep,
  85. struct be_dma_mem *nonemb_cmd);
  86. unsigned int mgmt_upload_connection(struct beiscsi_hba *phba,
  87. unsigned short cid,
  88. unsigned int upload_flag);
  89. unsigned int mgmt_invalidate_icds(struct beiscsi_hba *phba,
  90. struct invalidate_command_table *inv_tbl,
  91. unsigned int num_invalidate, unsigned int cid,
  92. struct be_dma_mem *nonemb_cmd);
  93. unsigned int mgmt_vendor_specific_fw_cmd(struct be_ctrl_info *ctrl,
  94. struct beiscsi_hba *phba,
  95. struct bsg_job *job,
  96. struct be_dma_mem *nonemb_cmd);
  97. struct iscsi_invalidate_connection_params_in {
  98. struct be_cmd_req_hdr hdr;
  99. unsigned int session_handle;
  100. unsigned short cid;
  101. unsigned short unused;
  102. unsigned short cleanup_type;
  103. unsigned short save_cfg;
  104. } __packed;
  105. struct iscsi_invalidate_connection_params_out {
  106. unsigned int session_handle;
  107. unsigned short cid;
  108. unsigned short unused;
  109. } __packed;
  110. union iscsi_invalidate_connection_params {
  111. struct iscsi_invalidate_connection_params_in request;
  112. struct iscsi_invalidate_connection_params_out response;
  113. } __packed;
  114. struct invalidate_commands_params_in {
  115. struct be_cmd_req_hdr hdr;
  116. unsigned int ref_handle;
  117. unsigned int icd_count;
  118. struct invalidate_command_table table[128];
  119. unsigned short cleanup_type;
  120. unsigned short unused;
  121. } __packed;
  122. struct invalidate_commands_params_out {
  123. unsigned int ref_handle;
  124. unsigned int icd_count;
  125. unsigned int icd_status[128];
  126. } __packed;
  127. union invalidate_commands_params {
  128. struct invalidate_commands_params_in request;
  129. struct invalidate_commands_params_out response;
  130. } __packed;
  131. struct mgmt_hba_attributes {
  132. u8 flashrom_version_string[32];
  133. u8 manufacturer_name[32];
  134. u32 supported_modes;
  135. u8 seeprom_version_lo;
  136. u8 seeprom_version_hi;
  137. u8 rsvd0[2];
  138. u32 fw_cmd_data_struct_version;
  139. u32 ep_fw_data_struct_version;
  140. u32 future_reserved[12];
  141. u32 default_extended_timeout;
  142. u8 controller_model_number[32];
  143. u8 controller_description[64];
  144. u8 controller_serial_number[32];
  145. u8 ip_version_string[32];
  146. u8 firmware_version_string[32];
  147. u8 bios_version_string[32];
  148. u8 redboot_version_string[32];
  149. u8 driver_version_string[32];
  150. u8 fw_on_flash_version_string[32];
  151. u32 functionalities_supported;
  152. u16 max_cdblength;
  153. u8 asic_revision;
  154. u8 generational_guid[16];
  155. u8 hba_port_count;
  156. u16 default_link_down_timeout;
  157. u8 iscsi_ver_min_max;
  158. u8 multifunction_device;
  159. u8 cache_valid;
  160. u8 hba_status;
  161. u8 max_domains_supported;
  162. u8 phy_port;
  163. u32 firmware_post_status;
  164. u32 hba_mtu[8];
  165. u8 iscsi_features;
  166. u8 future_u8[3];
  167. u32 future_u32[3];
  168. } __packed;
  169. struct mgmt_controller_attributes {
  170. struct mgmt_hba_attributes hba_attribs;
  171. u16 pci_vendor_id;
  172. u16 pci_device_id;
  173. u16 pci_sub_vendor_id;
  174. u16 pci_sub_system_id;
  175. u8 pci_bus_number;
  176. u8 pci_device_number;
  177. u8 pci_function_number;
  178. u8 interface_type;
  179. u64 unique_identifier;
  180. u8 netfilters;
  181. u8 rsvd0[3];
  182. u8 future_u32[4];
  183. } __packed;
  184. struct be_mgmt_controller_attributes {
  185. struct be_cmd_req_hdr hdr;
  186. struct mgmt_controller_attributes params;
  187. } __packed;
  188. struct be_mgmt_controller_attributes_resp {
  189. struct be_cmd_resp_hdr hdr;
  190. struct mgmt_controller_attributes params;
  191. } __packed;
  192. struct be_bsg_vendor_cmd {
  193. struct be_cmd_req_hdr hdr;
  194. unsigned short region;
  195. unsigned short offset;
  196. unsigned short sector;
  197. } __packed;
  198. /* configuration management */
  199. #define GET_MGMT_CONTROLLER_WS(phba) (phba->pmgmt_ws)
  200. /* MGMT CMD flags */
  201. #define MGMT_CMDH_FREE (1<<0)
  202. /* --- MGMT_ERROR_CODES --- */
  203. /* Error Codes returned in the status field of the CMD response header */
  204. #define MGMT_STATUS_SUCCESS 0 /* The CMD completed without errors */
  205. #define MGMT_STATUS_FAILED 1 /* Error status in the Status field of */
  206. /* the CMD_RESPONSE_HEADER */
  207. #define ISCSI_GET_PDU_TEMPLATE_ADDRESS(pc, pa) {\
  208. pa->lo = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
  209. bus_address.u.a32.address_lo; \
  210. pa->hi = phba->init_mem[ISCSI_MEM_GLOBAL_HEADER].mem_array[0].\
  211. bus_address.u.a32.address_hi; \
  212. }
  213. #define BEISCSI_WRITE_FLASH 0
  214. #define BEISCSI_READ_FLASH 1
  215. struct beiscsi_endpoint {
  216. struct beiscsi_hba *phba;
  217. struct beiscsi_sess *sess;
  218. struct beiscsi_conn *conn;
  219. struct iscsi_endpoint *openiscsi_ep;
  220. unsigned short ip_type;
  221. char dst6_addr[ISCSI_ADDRESS_BUF_LEN];
  222. unsigned long dst_addr;
  223. unsigned short ep_cid;
  224. unsigned int fw_handle;
  225. u16 dst_tcpport;
  226. u16 cid_vld;
  227. };
  228. int mgmt_get_fw_config(struct be_ctrl_info *ctrl,
  229. struct beiscsi_hba *phba);
  230. unsigned int mgmt_invalidate_connection(struct beiscsi_hba *phba,
  231. struct beiscsi_endpoint *beiscsi_ep,
  232. unsigned short cid,
  233. unsigned short issue_reset,
  234. unsigned short savecfg_flag);
  235. int mgmt_set_ip(struct beiscsi_hba *phba,
  236. struct iscsi_iface_param_info *ip_param,
  237. struct iscsi_iface_param_info *subnet_param,
  238. uint32_t boot_proto);
  239. unsigned int mgmt_get_boot_target(struct beiscsi_hba *phba);
  240. unsigned int mgmt_get_session_info(struct beiscsi_hba *phba,
  241. u32 boot_session_handle,
  242. struct be_dma_mem *nonemb_cmd);
  243. int mgmt_get_nic_conf(struct beiscsi_hba *phba,
  244. struct be_cmd_get_nic_conf_resp *mac);
  245. int mgmt_get_if_info(struct beiscsi_hba *phba, int ip_type,
  246. struct be_cmd_get_if_info_resp *if_info);
  247. int mgmt_get_gateway(struct beiscsi_hba *phba, int ip_type,
  248. struct be_cmd_get_def_gateway_resp *gateway);
  249. int mgmt_set_gateway(struct beiscsi_hba *phba,
  250. struct iscsi_iface_param_info *gateway_param);
  251. #endif