qla_bsg.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * QLogic Fibre Channel HBA Driver
  4. * Copyright (c) 2003-2014 QLogic Corporation
  5. */
  6. #ifndef __QLA_BSG_H
  7. #define __QLA_BSG_H
  8. /* BSG Vendor specific commands */
  9. #define QL_VND_LOOPBACK 0x01
  10. #define QL_VND_A84_RESET 0x02
  11. #define QL_VND_A84_UPDATE_FW 0x03
  12. #define QL_VND_A84_MGMT_CMD 0x04
  13. #define QL_VND_IIDMA 0x05
  14. #define QL_VND_FCP_PRIO_CFG_CMD 0x06
  15. #define QL_VND_READ_FLASH 0x07
  16. #define QL_VND_UPDATE_FLASH 0x08
  17. #define QL_VND_SET_FRU_VERSION 0x0B
  18. #define QL_VND_READ_FRU_STATUS 0x0C
  19. #define QL_VND_WRITE_FRU_STATUS 0x0D
  20. #define QL_VND_DIAG_IO_CMD 0x0A
  21. #define QL_VND_WRITE_I2C 0x10
  22. #define QL_VND_READ_I2C 0x11
  23. #define QL_VND_FX00_MGMT_CMD 0x12
  24. #define QL_VND_SERDES_OP 0x13
  25. #define QL_VND_SERDES_OP_EX 0x14
  26. #define QL_VND_GET_FLASH_UPDATE_CAPS 0x15
  27. #define QL_VND_SET_FLASH_UPDATE_CAPS 0x16
  28. #define QL_VND_GET_BBCR_DATA 0x17
  29. #define QL_VND_GET_PRIV_STATS 0x18
  30. #define QL_VND_DPORT_DIAGNOSTICS 0x19
  31. #define QL_VND_GET_PRIV_STATS_EX 0x1A
  32. #define QL_VND_SS_GET_FLASH_IMAGE_STATUS 0x1E
  33. #define QL_VND_EDIF_MGMT 0X1F
  34. #define QL_VND_MANAGE_HOST_STATS 0x23
  35. #define QL_VND_GET_HOST_STATS 0x24
  36. #define QL_VND_GET_TGT_STATS 0x25
  37. #define QL_VND_MANAGE_HOST_PORT 0x26
  38. #define QL_VND_MBX_PASSTHRU 0x2B
  39. #define QL_VND_DPORT_DIAGNOSTICS_V2 0x2C
  40. /* BSG Vendor specific subcode returns */
  41. #define EXT_STATUS_OK 0
  42. #define EXT_STATUS_ERR 1
  43. #define EXT_STATUS_BUSY 2
  44. #define EXT_STATUS_INVALID_PARAM 6
  45. #define EXT_STATUS_DATA_OVERRUN 7
  46. #define EXT_STATUS_DATA_UNDERRUN 8
  47. #define EXT_STATUS_MAILBOX 11
  48. #define EXT_STATUS_BUFFER_TOO_SMALL 16
  49. #define EXT_STATUS_NO_MEMORY 17
  50. #define EXT_STATUS_DEVICE_OFFLINE 22
  51. /*
  52. * To support bidirectional iocb
  53. * BSG Vendor specific returns
  54. */
  55. #define EXT_STATUS_NOT_SUPPORTED 27
  56. #define EXT_STATUS_INVALID_CFG 28
  57. #define EXT_STATUS_DMA_ERR 29
  58. #define EXT_STATUS_TIMEOUT 30
  59. #define EXT_STATUS_THREAD_FAILED 31
  60. #define EXT_STATUS_DATA_CMP_FAILED 32
  61. #define EXT_STATUS_DPORT_DIAG_ERR 40
  62. #define EXT_STATUS_DPORT_DIAG_IN_PROCESS 41
  63. #define EXT_STATUS_DPORT_DIAG_NOT_RUNNING 42
  64. /* BSG definations for interpreting CommandSent field */
  65. #define INT_DEF_LB_LOOPBACK_CMD 0
  66. #define INT_DEF_LB_ECHO_CMD 1
  67. /* Loopback related definations */
  68. #define INTERNAL_LOOPBACK 0xF1
  69. #define EXTERNAL_LOOPBACK 0xF2
  70. #define ENABLE_INTERNAL_LOOPBACK 0x02
  71. #define ENABLE_EXTERNAL_LOOPBACK 0x04
  72. #define INTERNAL_LOOPBACK_MASK 0x000E
  73. #define MAX_ELS_FRAME_PAYLOAD 252
  74. #define ELS_OPCODE_BYTE 0x10
  75. /* BSG Vendor specific definations */
  76. #define A84_ISSUE_WRITE_TYPE_CMD 0
  77. #define A84_ISSUE_READ_TYPE_CMD 1
  78. #define A84_CLEANUP_CMD 2
  79. #define A84_ISSUE_RESET_OP_FW 3
  80. #define A84_ISSUE_RESET_DIAG_FW 4
  81. #define A84_ISSUE_UPDATE_OPFW_CMD 5
  82. #define A84_ISSUE_UPDATE_DIAGFW_CMD 6
  83. struct qla84_mgmt_param {
  84. union {
  85. struct {
  86. uint32_t start_addr;
  87. } mem; /* for QLA84_MGMT_READ/WRITE_MEM */
  88. struct {
  89. uint32_t id;
  90. #define QLA84_MGMT_CONFIG_ID_UIF 1
  91. #define QLA84_MGMT_CONFIG_ID_FCOE_COS 2
  92. #define QLA84_MGMT_CONFIG_ID_PAUSE 3
  93. #define QLA84_MGMT_CONFIG_ID_TIMEOUTS 4
  94. uint32_t param0;
  95. uint32_t param1;
  96. } config; /* for QLA84_MGMT_CHNG_CONFIG */
  97. struct {
  98. uint32_t type;
  99. #define QLA84_MGMT_INFO_CONFIG_LOG_DATA 1 /* Get Config Log Data */
  100. #define QLA84_MGMT_INFO_LOG_DATA 2 /* Get Log Data */
  101. #define QLA84_MGMT_INFO_PORT_STAT 3 /* Get Port Statistics */
  102. #define QLA84_MGMT_INFO_LIF_STAT 4 /* Get LIF Statistics */
  103. #define QLA84_MGMT_INFO_ASIC_STAT 5 /* Get ASIC Statistics */
  104. #define QLA84_MGMT_INFO_CONFIG_PARAMS 6 /* Get Config Parameters */
  105. #define QLA84_MGMT_INFO_PANIC_LOG 7 /* Get Panic Log */
  106. uint32_t context;
  107. /*
  108. * context definitions for QLA84_MGMT_INFO_CONFIG_LOG_DATA
  109. */
  110. #define IC_LOG_DATA_LOG_ID_DEBUG_LOG 0
  111. #define IC_LOG_DATA_LOG_ID_LEARN_LOG 1
  112. #define IC_LOG_DATA_LOG_ID_FC_ACL_INGRESS_LOG 2
  113. #define IC_LOG_DATA_LOG_ID_FC_ACL_EGRESS_LOG 3
  114. #define IC_LOG_DATA_LOG_ID_ETHERNET_ACL_INGRESS_LOG 4
  115. #define IC_LOG_DATA_LOG_ID_ETHERNET_ACL_EGRESS_LOG 5
  116. #define IC_LOG_DATA_LOG_ID_MESSAGE_TRANSMIT_LOG 6
  117. #define IC_LOG_DATA_LOG_ID_MESSAGE_RECEIVE_LOG 7
  118. #define IC_LOG_DATA_LOG_ID_LINK_EVENT_LOG 8
  119. #define IC_LOG_DATA_LOG_ID_DCX_LOG 9
  120. /*
  121. * context definitions for QLA84_MGMT_INFO_PORT_STAT
  122. */
  123. #define IC_PORT_STATISTICS_PORT_NUMBER_ETHERNET_PORT0 0
  124. #define IC_PORT_STATISTICS_PORT_NUMBER_ETHERNET_PORT1 1
  125. #define IC_PORT_STATISTICS_PORT_NUMBER_NSL_PORT0 2
  126. #define IC_PORT_STATISTICS_PORT_NUMBER_NSL_PORT1 3
  127. #define IC_PORT_STATISTICS_PORT_NUMBER_FC_PORT0 4
  128. #define IC_PORT_STATISTICS_PORT_NUMBER_FC_PORT1 5
  129. /*
  130. * context definitions for QLA84_MGMT_INFO_LIF_STAT
  131. */
  132. #define IC_LIF_STATISTICS_LIF_NUMBER_ETHERNET_PORT0 0
  133. #define IC_LIF_STATISTICS_LIF_NUMBER_ETHERNET_PORT1 1
  134. #define IC_LIF_STATISTICS_LIF_NUMBER_FC_PORT0 2
  135. #define IC_LIF_STATISTICS_LIF_NUMBER_FC_PORT1 3
  136. #define IC_LIF_STATISTICS_LIF_NUMBER_CPU 6
  137. } info; /* for QLA84_MGMT_GET_INFO */
  138. } u;
  139. };
  140. struct qla84_msg_mgmt {
  141. uint16_t cmd;
  142. #define QLA84_MGMT_READ_MEM 0x00
  143. #define QLA84_MGMT_WRITE_MEM 0x01
  144. #define QLA84_MGMT_CHNG_CONFIG 0x02
  145. #define QLA84_MGMT_GET_INFO 0x03
  146. uint16_t rsrvd;
  147. struct qla84_mgmt_param mgmtp;/* parameters for cmd */
  148. uint32_t len; /* bytes in payload following this struct */
  149. uint8_t payload[]; /* payload for cmd */
  150. };
  151. struct qla_bsg_a84_mgmt {
  152. struct qla84_msg_mgmt mgmt;
  153. } __attribute__ ((packed));
  154. struct qla_scsi_addr {
  155. uint16_t bus;
  156. uint16_t target;
  157. } __attribute__ ((packed));
  158. struct qla_ext_dest_addr {
  159. union {
  160. uint8_t wwnn[8];
  161. uint8_t wwpn[8];
  162. uint8_t id[4];
  163. struct qla_scsi_addr scsi_addr;
  164. } dest_addr;
  165. uint16_t dest_type;
  166. #define EXT_DEF_TYPE_WWPN 2
  167. uint16_t lun;
  168. uint16_t padding[2];
  169. } __attribute__ ((packed));
  170. struct qla_port_param {
  171. struct qla_ext_dest_addr fc_scsi_addr;
  172. uint16_t mode;
  173. uint16_t speed;
  174. } __attribute__ ((packed));
  175. struct qla_mbx_passthru {
  176. uint16_t reserved1[2];
  177. uint16_t mbx_in[32];
  178. uint16_t mbx_out[32];
  179. uint32_t reserved2[16];
  180. } __packed;
  181. /* FRU VPD */
  182. #define MAX_FRU_SIZE 36
  183. struct qla_field_address {
  184. uint16_t offset;
  185. uint16_t device;
  186. uint16_t option;
  187. } __packed;
  188. struct qla_field_info {
  189. uint8_t version[MAX_FRU_SIZE];
  190. } __packed;
  191. struct qla_image_version {
  192. struct qla_field_address field_address;
  193. struct qla_field_info field_info;
  194. } __packed;
  195. struct qla_image_version_list {
  196. uint32_t count;
  197. struct qla_image_version version[];
  198. } __packed;
  199. struct qla_status_reg {
  200. struct qla_field_address field_address;
  201. uint8_t status_reg;
  202. uint8_t reserved[7];
  203. } __packed;
  204. struct qla_i2c_access {
  205. uint16_t device;
  206. uint16_t offset;
  207. uint16_t option;
  208. uint16_t length;
  209. uint8_t buffer[0x40];
  210. } __packed;
  211. /* 26xx serdes register interface */
  212. /* serdes reg commands */
  213. #define INT_SC_SERDES_READ_REG 1
  214. #define INT_SC_SERDES_WRITE_REG 2
  215. struct qla_serdes_reg {
  216. uint16_t cmd;
  217. uint16_t addr;
  218. uint16_t val;
  219. } __packed;
  220. struct qla_serdes_reg_ex {
  221. uint16_t cmd;
  222. uint32_t addr;
  223. uint32_t val;
  224. } __packed;
  225. struct qla_flash_update_caps {
  226. uint64_t capabilities;
  227. uint32_t outage_duration;
  228. uint8_t reserved[20];
  229. } __packed;
  230. /* BB_CR Status */
  231. #define QLA_BBCR_STATUS_DISABLED 0
  232. #define QLA_BBCR_STATUS_ENABLED 1
  233. #define QLA_BBCR_STATUS_UNKNOWN 2
  234. /* BB_CR State */
  235. #define QLA_BBCR_STATE_OFFLINE 0
  236. #define QLA_BBCR_STATE_ONLINE 1
  237. /* BB_CR Offline Reason Code */
  238. #define QLA_BBCR_REASON_PORT_SPEED 1
  239. #define QLA_BBCR_REASON_PEER_PORT 2
  240. #define QLA_BBCR_REASON_SWITCH 3
  241. #define QLA_BBCR_REASON_LOGIN_REJECT 4
  242. struct qla_bbcr_data {
  243. uint8_t status; /* 1 - enabled, 0 - Disabled */
  244. uint8_t state; /* 1 - online, 0 - offline */
  245. uint8_t configured_bbscn; /* 0-15 */
  246. uint8_t negotiated_bbscn; /* 0-15 */
  247. uint8_t offline_reason_code;
  248. uint16_t mbx1; /* Port state */
  249. uint8_t reserved[9];
  250. } __packed;
  251. struct qla_dport_diag {
  252. uint16_t options;
  253. uint32_t buf[16];
  254. uint8_t unused[62];
  255. } __packed;
  256. #define QLA_GET_DPORT_RESULT_V2 0 /* Get Result */
  257. #define QLA_RESTART_DPORT_TEST_V2 1 /* Restart test */
  258. #define QLA_START_DPORT_TEST_V2 2 /* Start test */
  259. struct qla_dport_diag_v2 {
  260. uint16_t options;
  261. uint16_t mbx1;
  262. uint16_t mbx2;
  263. uint8_t unused[58];
  264. uint8_t buf[1024]; /* Test Result */
  265. } __packed;
  266. /* D_Port options */
  267. #define QLA_DPORT_RESULT 0x0
  268. #define QLA_DPORT_START 0x2
  269. /* active images in flash */
  270. struct qla_active_regions {
  271. uint8_t global_image;
  272. uint8_t board_config;
  273. uint8_t vpd_nvram;
  274. uint8_t npiv_config_0_1;
  275. uint8_t npiv_config_2_3;
  276. uint8_t nvme_params;
  277. uint8_t reserved[31];
  278. } __packed;
  279. #include "qla_edif_bsg.h"
  280. #endif