be_main.h 29 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036
  1. /*
  2. * Copyright 2017 Broadcom. All Rights Reserved.
  3. * The term "Broadcom" refers to Broadcom Limited and/or its subsidiaries.
  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. * Contact Information:
  11. * linux-drivers@broadcom.com
  12. *
  13. */
  14. #ifndef _BEISCSI_MAIN_
  15. #define _BEISCSI_MAIN_
  16. #include <linux/kernel.h>
  17. #include <linux/pci.h>
  18. #include <linux/if_ether.h>
  19. #include <linux/in.h>
  20. #include <linux/ctype.h>
  21. #include <linux/module.h>
  22. #include <linux/aer.h>
  23. #include <scsi/scsi.h>
  24. #include <scsi/scsi_cmnd.h>
  25. #include <scsi/scsi_device.h>
  26. #include <scsi/scsi_host.h>
  27. #include <scsi/iscsi_proto.h>
  28. #include <scsi/libiscsi.h>
  29. #include <scsi/scsi_transport_iscsi.h>
  30. #define DRV_NAME "be2iscsi"
  31. #define BUILD_STR "11.4.0.1"
  32. #define BE_NAME "Emulex OneConnect" \
  33. "Open-iSCSI Driver version" BUILD_STR
  34. #define DRV_DESC BE_NAME " " "Driver"
  35. #define BE_VENDOR_ID 0x19A2
  36. #define ELX_VENDOR_ID 0x10DF
  37. /* DEVICE ID's for BE2 */
  38. #define BE_DEVICE_ID1 0x212
  39. #define OC_DEVICE_ID1 0x702
  40. #define OC_DEVICE_ID2 0x703
  41. /* DEVICE ID's for BE3 */
  42. #define BE_DEVICE_ID2 0x222
  43. #define OC_DEVICE_ID3 0x712
  44. /* DEVICE ID for SKH */
  45. #define OC_SKH_ID1 0x722
  46. #define BE2_IO_DEPTH 1024
  47. #define BE2_MAX_SESSIONS 256
  48. #define BE2_TMFS 16
  49. #define BE2_NOPOUT_REQ 16
  50. #define BE2_SGE 32
  51. #define BE2_DEFPDU_HDR_SZ 64
  52. #define BE2_DEFPDU_DATA_SZ 8192
  53. #define BE2_MAX_NUM_CQ_PROC 512
  54. #define MAX_CPUS 64U
  55. #define BEISCSI_MAX_NUM_CPUS 7
  56. #define BEISCSI_VER_STRLEN 32
  57. #define BEISCSI_SGLIST_ELEMENTS 30
  58. /**
  59. * BE_INVLDT_CMD_TBL_SZ is 128 which is total number commands that can
  60. * be invalidated at a time, consider it before changing the value of
  61. * BEISCSI_CMD_PER_LUN.
  62. */
  63. #define BEISCSI_CMD_PER_LUN 128 /* scsi_host->cmd_per_lun */
  64. #define BEISCSI_MAX_SECTORS 1024 /* scsi_host->max_sectors */
  65. #define BEISCSI_TEMPLATE_HDR_PER_CXN_SIZE 128 /* Template size per cxn */
  66. #define BEISCSI_MAX_CMD_LEN 16 /* scsi_host->max_cmd_len */
  67. #define BEISCSI_NUM_MAX_LUN 256 /* scsi_host->max_lun */
  68. #define BEISCSI_MAX_FRAGS_INIT 192
  69. #define BE_SENSE_INFO_SIZE 258
  70. #define BE_ISCSI_PDU_HEADER_SIZE 64
  71. #define BE_MIN_MEM_SIZE 16384
  72. #define MAX_CMD_SZ 65536
  73. #define IIOC_SCSI_DATA 0x05 /* Write Operation */
  74. /**
  75. * hardware needs the async PDU buffers to be posted in multiples of 8
  76. * So have atleast 8 of them by default
  77. */
  78. #define HWI_GET_ASYNC_PDU_CTX(phwi, ulp_num) \
  79. (phwi->phwi_ctxt->pasync_ctx[ulp_num])
  80. /********* Memory BAR register ************/
  81. #define PCICFG_MEMBAR_CTRL_INT_CTRL_OFFSET 0xfc
  82. /**
  83. * Host Interrupt Enable, if set interrupts are enabled although "PCI Interrupt
  84. * Disable" may still globally block interrupts in addition to individual
  85. * interrupt masks; a mechanism for the device driver to block all interrupts
  86. * atomically without having to arbitrate for the PCI Interrupt Disable bit
  87. * with the OS.
  88. */
  89. #define MEMBAR_CTRL_INT_CTRL_HOSTINTR_MASK (1 << 29) /* bit 29 */
  90. /********* ISR0 Register offset **********/
  91. #define CEV_ISR0_OFFSET 0xC18
  92. #define CEV_ISR_SIZE 4
  93. /**
  94. * Macros for reading/writing a protection domain or CSR registers
  95. * in BladeEngine.
  96. */
  97. #define DB_TXULP0_OFFSET 0x40
  98. #define DB_RXULP0_OFFSET 0xA0
  99. /********* Event Q door bell *************/
  100. #define DB_EQ_OFFSET DB_CQ_OFFSET
  101. #define DB_EQ_RING_ID_LOW_MASK 0x1FF /* bits 0 - 8 */
  102. /* Clear the interrupt for this eq */
  103. #define DB_EQ_CLR_SHIFT (9) /* bit 9 */
  104. /* Must be 1 */
  105. #define DB_EQ_EVNT_SHIFT (10) /* bit 10 */
  106. /* Higher Order EQ_ID bit */
  107. #define DB_EQ_RING_ID_HIGH_MASK 0x1F /* bits 11 - 15 */
  108. #define DB_EQ_HIGH_SET_SHIFT 11
  109. #define DB_EQ_HIGH_FEILD_SHIFT 9
  110. /* Number of event entries processed */
  111. #define DB_EQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */
  112. /* Rearm bit */
  113. #define DB_EQ_REARM_SHIFT (29) /* bit 29 */
  114. /********* Compl Q door bell *************/
  115. #define DB_CQ_OFFSET 0x120
  116. #define DB_CQ_RING_ID_LOW_MASK 0x3FF /* bits 0 - 9 */
  117. /* Higher Order CQ_ID bit */
  118. #define DB_CQ_RING_ID_HIGH_MASK 0x1F /* bits 11 - 15 */
  119. #define DB_CQ_HIGH_SET_SHIFT 11
  120. #define DB_CQ_HIGH_FEILD_SHIFT 10
  121. /* Number of event entries processed */
  122. #define DB_CQ_NUM_POPPED_SHIFT (16) /* bits 16 - 28 */
  123. /* Rearm bit */
  124. #define DB_CQ_REARM_SHIFT (29) /* bit 29 */
  125. #define GET_HWI_CONTROLLER_WS(pc) (pc->phwi_ctrlr)
  126. #define HWI_GET_DEF_BUFQ_ID(pc, ulp_num) (((struct hwi_controller *)\
  127. (GET_HWI_CONTROLLER_WS(pc)))->default_pdu_data[ulp_num].id)
  128. #define HWI_GET_DEF_HDRQ_ID(pc, ulp_num) (((struct hwi_controller *)\
  129. (GET_HWI_CONTROLLER_WS(pc)))->default_pdu_hdr[ulp_num].id)
  130. #define PAGES_REQUIRED(x) \
  131. ((x < PAGE_SIZE) ? 1 : ((x + PAGE_SIZE - 1) / PAGE_SIZE))
  132. #define MEM_DESCR_OFFSET 8
  133. #define BEISCSI_DEFQ_HDR 1
  134. #define BEISCSI_DEFQ_DATA 0
  135. enum be_mem_enum {
  136. HWI_MEM_ADDN_CONTEXT,
  137. HWI_MEM_WRB,
  138. HWI_MEM_WRBH,
  139. HWI_MEM_SGLH,
  140. HWI_MEM_SGE,
  141. HWI_MEM_TEMPLATE_HDR_ULP0,
  142. HWI_MEM_ASYNC_HEADER_BUF_ULP0, /* 6 */
  143. HWI_MEM_ASYNC_DATA_BUF_ULP0,
  144. HWI_MEM_ASYNC_HEADER_RING_ULP0,
  145. HWI_MEM_ASYNC_DATA_RING_ULP0,
  146. HWI_MEM_ASYNC_HEADER_HANDLE_ULP0,
  147. HWI_MEM_ASYNC_DATA_HANDLE_ULP0, /* 11 */
  148. HWI_MEM_ASYNC_PDU_CONTEXT_ULP0,
  149. HWI_MEM_TEMPLATE_HDR_ULP1,
  150. HWI_MEM_ASYNC_HEADER_BUF_ULP1, /* 14 */
  151. HWI_MEM_ASYNC_DATA_BUF_ULP1,
  152. HWI_MEM_ASYNC_HEADER_RING_ULP1,
  153. HWI_MEM_ASYNC_DATA_RING_ULP1,
  154. HWI_MEM_ASYNC_HEADER_HANDLE_ULP1,
  155. HWI_MEM_ASYNC_DATA_HANDLE_ULP1, /* 19 */
  156. HWI_MEM_ASYNC_PDU_CONTEXT_ULP1,
  157. ISCSI_MEM_GLOBAL_HEADER,
  158. SE_MEM_MAX
  159. };
  160. struct be_bus_address32 {
  161. unsigned int address_lo;
  162. unsigned int address_hi;
  163. };
  164. struct be_bus_address64 {
  165. unsigned long long address;
  166. };
  167. struct be_bus_address {
  168. union {
  169. struct be_bus_address32 a32;
  170. struct be_bus_address64 a64;
  171. } u;
  172. };
  173. struct mem_array {
  174. struct be_bus_address bus_address; /* Bus address of location */
  175. void *virtual_address; /* virtual address to the location */
  176. unsigned int size; /* Size required by memory block */
  177. };
  178. struct be_mem_descriptor {
  179. unsigned int size_in_bytes; /* Size required by memory block */
  180. unsigned int num_elements;
  181. struct mem_array *mem_array;
  182. };
  183. struct sgl_handle {
  184. unsigned int sgl_index;
  185. unsigned int type;
  186. unsigned int cid;
  187. struct iscsi_task *task;
  188. struct iscsi_sge *pfrag;
  189. };
  190. struct hba_parameters {
  191. unsigned int ios_per_ctrl;
  192. unsigned int cxns_per_ctrl;
  193. unsigned int icds_per_ctrl;
  194. unsigned int num_sge_per_io;
  195. unsigned int defpdu_hdr_sz;
  196. unsigned int defpdu_data_sz;
  197. unsigned int num_cq_entries;
  198. unsigned int num_eq_entries;
  199. unsigned int wrbs_per_cxn;
  200. unsigned int hwi_ws_sz;
  201. };
  202. #define BEISCSI_GET_ULP_FROM_CRI(phwi_ctrlr, cri) \
  203. (phwi_ctrlr->wrb_context[cri].ulp_num)
  204. struct hwi_wrb_context {
  205. spinlock_t wrb_lock;
  206. struct wrb_handle **pwrb_handle_base;
  207. struct wrb_handle **pwrb_handle_basestd;
  208. struct iscsi_wrb *plast_wrb;
  209. unsigned short alloc_index;
  210. unsigned short free_index;
  211. unsigned short wrb_handles_available;
  212. unsigned short cid;
  213. uint8_t ulp_num; /* ULP to which CID binded */
  214. uint32_t doorbell_offset;
  215. };
  216. struct ulp_cid_info {
  217. unsigned short *cid_array;
  218. unsigned short avlbl_cids;
  219. unsigned short cid_alloc;
  220. unsigned short cid_free;
  221. };
  222. #include "be.h"
  223. #define chip_be2(phba) (phba->generation == BE_GEN2)
  224. #define chip_be3_r(phba) (phba->generation == BE_GEN3)
  225. #define is_chip_be2_be3r(phba) (chip_be3_r(phba) || (chip_be2(phba)))
  226. #define BEISCSI_ULP0 0
  227. #define BEISCSI_ULP1 1
  228. #define BEISCSI_ULP_COUNT 2
  229. #define BEISCSI_ULP0_LOADED 0x01
  230. #define BEISCSI_ULP1_LOADED 0x02
  231. #define BEISCSI_ULP_AVLBL_CID(phba, ulp_num) \
  232. (((struct ulp_cid_info *)phba->cid_array_info[ulp_num])->avlbl_cids)
  233. #define BEISCSI_ULP0_AVLBL_CID(phba) \
  234. BEISCSI_ULP_AVLBL_CID(phba, BEISCSI_ULP0)
  235. #define BEISCSI_ULP1_AVLBL_CID(phba) \
  236. BEISCSI_ULP_AVLBL_CID(phba, BEISCSI_ULP1)
  237. struct beiscsi_hba {
  238. struct hba_parameters params;
  239. struct hwi_controller *phwi_ctrlr;
  240. unsigned int mem_req[SE_MEM_MAX];
  241. /* PCI BAR mapped addresses */
  242. u8 __iomem *csr_va; /* CSR */
  243. u8 __iomem *db_va; /* Door Bell */
  244. u8 __iomem *pci_va; /* PCI Config */
  245. /* PCI representation of our HBA */
  246. struct pci_dev *pcidev;
  247. unsigned int num_cpus;
  248. unsigned int nxt_cqid;
  249. char *msi_name[MAX_CPUS];
  250. struct be_mem_descriptor *init_mem;
  251. unsigned short io_sgl_alloc_index;
  252. unsigned short io_sgl_free_index;
  253. unsigned short io_sgl_hndl_avbl;
  254. struct sgl_handle **io_sgl_hndl_base;
  255. unsigned short eh_sgl_alloc_index;
  256. unsigned short eh_sgl_free_index;
  257. unsigned short eh_sgl_hndl_avbl;
  258. struct sgl_handle **eh_sgl_hndl_base;
  259. spinlock_t io_sgl_lock;
  260. spinlock_t mgmt_sgl_lock;
  261. spinlock_t async_pdu_lock;
  262. struct list_head hba_queue;
  263. #define BE_MAX_SESSION 2048
  264. #define BE_INVALID_CID 0xffff
  265. #define BE_SET_CID_TO_CRI(cri_index, cid) \
  266. (phba->cid_to_cri_map[cid] = cri_index)
  267. #define BE_GET_CRI_FROM_CID(cid) (phba->cid_to_cri_map[cid])
  268. unsigned short cid_to_cri_map[BE_MAX_SESSION];
  269. struct ulp_cid_info *cid_array_info[BEISCSI_ULP_COUNT];
  270. struct iscsi_endpoint **ep_array;
  271. struct beiscsi_conn **conn_table;
  272. struct Scsi_Host *shost;
  273. struct iscsi_iface *ipv4_iface;
  274. struct iscsi_iface *ipv6_iface;
  275. struct {
  276. /**
  277. * group together since they are used most frequently
  278. * for cid to cri conversion
  279. */
  280. #define BEISCSI_PHYS_PORT_MAX 4
  281. unsigned int phys_port;
  282. /* valid values of phys_port id are 0, 1, 2, 3 */
  283. unsigned int eqid_count;
  284. unsigned int cqid_count;
  285. unsigned int iscsi_cid_start[BEISCSI_ULP_COUNT];
  286. #define BEISCSI_GET_CID_COUNT(phba, ulp_num) \
  287. (phba->fw_config.iscsi_cid_count[ulp_num])
  288. unsigned int iscsi_cid_count[BEISCSI_ULP_COUNT];
  289. unsigned int iscsi_icd_count[BEISCSI_ULP_COUNT];
  290. unsigned int iscsi_icd_start[BEISCSI_ULP_COUNT];
  291. unsigned int iscsi_chain_start[BEISCSI_ULP_COUNT];
  292. unsigned int iscsi_chain_count[BEISCSI_ULP_COUNT];
  293. unsigned short iscsi_features;
  294. uint16_t dual_ulp_aware;
  295. unsigned long ulp_supported;
  296. } fw_config;
  297. unsigned long state;
  298. #define BEISCSI_HBA_ONLINE 0
  299. #define BEISCSI_HBA_LINK_UP 1
  300. #define BEISCSI_HBA_BOOT_FOUND 2
  301. #define BEISCSI_HBA_BOOT_WORK 3
  302. #define BEISCSI_HBA_UER_SUPP 4
  303. #define BEISCSI_HBA_PCI_ERR 5
  304. #define BEISCSI_HBA_FW_TIMEOUT 6
  305. #define BEISCSI_HBA_IN_UE 7
  306. #define BEISCSI_HBA_IN_TPE 8
  307. /* error bits */
  308. #define BEISCSI_HBA_IN_ERR ((1 << BEISCSI_HBA_PCI_ERR) | \
  309. (1 << BEISCSI_HBA_FW_TIMEOUT) | \
  310. (1 << BEISCSI_HBA_IN_UE) | \
  311. (1 << BEISCSI_HBA_IN_TPE))
  312. u8 optic_state;
  313. struct delayed_work eqd_update;
  314. /* update EQ delay timer every 1000ms */
  315. #define BEISCSI_EQD_UPDATE_INTERVAL 1000
  316. struct timer_list hw_check;
  317. /* check for UE every 1000ms */
  318. #define BEISCSI_UE_DETECT_INTERVAL 1000
  319. u32 ue2rp;
  320. struct delayed_work recover_port;
  321. struct work_struct sess_work;
  322. bool mac_addr_set;
  323. u8 mac_address[ETH_ALEN];
  324. u8 port_name;
  325. u8 port_speed;
  326. char fw_ver_str[BEISCSI_VER_STRLEN];
  327. struct workqueue_struct *wq; /* The actuak work queue */
  328. struct be_ctrl_info ctrl;
  329. unsigned int generation;
  330. unsigned int interface_handle;
  331. struct be_aic_obj aic_obj[MAX_CPUS];
  332. unsigned int attr_log_enable;
  333. int (*iotask_fn)(struct iscsi_task *,
  334. struct scatterlist *sg,
  335. uint32_t num_sg, uint32_t xferlen,
  336. uint32_t writedir);
  337. struct boot_struct {
  338. int retry;
  339. unsigned int tag;
  340. unsigned int s_handle;
  341. struct be_dma_mem nonemb_cmd;
  342. enum {
  343. BEISCSI_BOOT_REOPEN_SESS = 1,
  344. BEISCSI_BOOT_GET_SHANDLE,
  345. BEISCSI_BOOT_GET_SINFO,
  346. BEISCSI_BOOT_LOGOUT_SESS,
  347. BEISCSI_BOOT_CREATE_KSET,
  348. } action;
  349. struct mgmt_session_info boot_sess;
  350. struct iscsi_boot_kset *boot_kset;
  351. } boot_struct;
  352. struct work_struct boot_work;
  353. };
  354. #define beiscsi_hba_in_error(phba) ((phba)->state & BEISCSI_HBA_IN_ERR)
  355. #define beiscsi_hba_is_online(phba) \
  356. (!beiscsi_hba_in_error((phba)) && \
  357. test_bit(BEISCSI_HBA_ONLINE, &phba->state))
  358. struct beiscsi_session {
  359. struct dma_pool *bhs_pool;
  360. };
  361. /**
  362. * struct beiscsi_conn - iscsi connection structure
  363. */
  364. struct beiscsi_conn {
  365. struct iscsi_conn *conn;
  366. struct beiscsi_hba *phba;
  367. u32 exp_statsn;
  368. u32 doorbell_offset;
  369. u32 beiscsi_conn_cid;
  370. struct beiscsi_endpoint *ep;
  371. unsigned short login_in_progress;
  372. struct wrb_handle *plogin_wrb_handle;
  373. struct sgl_handle *plogin_sgl_handle;
  374. struct beiscsi_session *beiscsi_sess;
  375. struct iscsi_task *task;
  376. };
  377. /* This structure is used by the chip */
  378. struct pdu_data_out {
  379. u32 dw[12];
  380. };
  381. /**
  382. * Pseudo amap definition in which each bit of the actual structure is defined
  383. * as a byte: used to calculate offset/shift/mask of each field
  384. */
  385. struct amap_pdu_data_out {
  386. u8 opcode[6]; /* opcode */
  387. u8 rsvd0[2]; /* should be 0 */
  388. u8 rsvd1[7];
  389. u8 final_bit; /* F bit */
  390. u8 rsvd2[16];
  391. u8 ahs_length[8]; /* no AHS */
  392. u8 data_len_hi[8];
  393. u8 data_len_lo[16]; /* DataSegmentLength */
  394. u8 lun[64];
  395. u8 itt[32]; /* ITT; initiator task tag */
  396. u8 ttt[32]; /* TTT; valid for R2T or 0xffffffff */
  397. u8 rsvd3[32];
  398. u8 exp_stat_sn[32];
  399. u8 rsvd4[32];
  400. u8 data_sn[32];
  401. u8 buffer_offset[32];
  402. u8 rsvd5[32];
  403. };
  404. struct be_cmd_bhs {
  405. struct iscsi_scsi_req iscsi_hdr;
  406. unsigned char pad1[16];
  407. struct pdu_data_out iscsi_data_pdu;
  408. unsigned char pad2[BE_SENSE_INFO_SIZE -
  409. sizeof(struct pdu_data_out)];
  410. };
  411. struct beiscsi_io_task {
  412. struct wrb_handle *pwrb_handle;
  413. struct sgl_handle *psgl_handle;
  414. struct beiscsi_conn *conn;
  415. struct scsi_cmnd *scsi_cmnd;
  416. int num_sg;
  417. struct hwi_wrb_context *pwrb_context;
  418. itt_t libiscsi_itt;
  419. struct be_cmd_bhs *cmd_bhs;
  420. struct be_bus_address bhs_pa;
  421. unsigned short bhs_len;
  422. dma_addr_t mtask_addr;
  423. uint32_t mtask_data_count;
  424. uint8_t wrb_type;
  425. };
  426. struct be_nonio_bhs {
  427. struct iscsi_hdr iscsi_hdr;
  428. unsigned char pad1[16];
  429. struct pdu_data_out iscsi_data_pdu;
  430. unsigned char pad2[BE_SENSE_INFO_SIZE -
  431. sizeof(struct pdu_data_out)];
  432. };
  433. struct be_status_bhs {
  434. struct iscsi_scsi_req iscsi_hdr;
  435. unsigned char pad1[16];
  436. /**
  437. * The plus 2 below is to hold the sense info length that gets
  438. * DMA'ed by RxULP
  439. */
  440. unsigned char sense_info[BE_SENSE_INFO_SIZE];
  441. };
  442. struct iscsi_sge {
  443. u32 dw[4];
  444. };
  445. /**
  446. * Pseudo amap definition in which each bit of the actual structure is defined
  447. * as a byte: used to calculate offset/shift/mask of each field
  448. */
  449. struct amap_iscsi_sge {
  450. u8 addr_hi[32];
  451. u8 addr_lo[32];
  452. u8 sge_offset[22]; /* DWORD 2 */
  453. u8 rsvd0[9]; /* DWORD 2 */
  454. u8 last_sge; /* DWORD 2 */
  455. u8 len[17]; /* DWORD 3 */
  456. u8 rsvd1[15]; /* DWORD 3 */
  457. };
  458. struct beiscsi_offload_params {
  459. u32 dw[6];
  460. };
  461. #define OFFLD_PARAMS_ERL 0x00000003
  462. #define OFFLD_PARAMS_DDE 0x00000004
  463. #define OFFLD_PARAMS_HDE 0x00000008
  464. #define OFFLD_PARAMS_IR2T 0x00000010
  465. #define OFFLD_PARAMS_IMD 0x00000020
  466. #define OFFLD_PARAMS_DATA_SEQ_INORDER 0x00000040
  467. #define OFFLD_PARAMS_PDU_SEQ_INORDER 0x00000080
  468. #define OFFLD_PARAMS_MAX_R2T 0x00FFFF00
  469. /**
  470. * Pseudo amap definition in which each bit of the actual structure is defined
  471. * as a byte: used to calculate offset/shift/mask of each field
  472. */
  473. struct amap_beiscsi_offload_params {
  474. u8 max_burst_length[32];
  475. u8 max_send_data_segment_length[32];
  476. u8 first_burst_length[32];
  477. u8 erl[2];
  478. u8 dde[1];
  479. u8 hde[1];
  480. u8 ir2t[1];
  481. u8 imd[1];
  482. u8 data_seq_inorder[1];
  483. u8 pdu_seq_inorder[1];
  484. u8 max_r2t[16];
  485. u8 pad[8];
  486. u8 exp_statsn[32];
  487. u8 max_recv_data_segment_length[32];
  488. };
  489. struct hd_async_handle {
  490. struct list_head link;
  491. struct be_bus_address pa;
  492. void *pbuffer;
  493. u32 buffer_len;
  494. u16 index;
  495. u16 cri;
  496. u8 is_header;
  497. u8 is_final;
  498. u8 in_use;
  499. };
  500. #define BEISCSI_ASYNC_HDQ_SIZE(phba, ulp) \
  501. (BEISCSI_GET_CID_COUNT((phba), (ulp)) * 2)
  502. /**
  503. * This has list of async PDUs that are waiting to be processed.
  504. * Buffers live in this list for a brief duration before they get
  505. * processed and posted back to hardware.
  506. * Note that we don't really need one cri_wait_queue per async_entry.
  507. * We need one cri_wait_queue per CRI. Its easier to manage if this
  508. * is tagged along with the async_entry.
  509. */
  510. struct hd_async_entry {
  511. struct cri_wait_queue {
  512. unsigned short hdr_len;
  513. unsigned int bytes_received;
  514. unsigned int bytes_needed;
  515. struct list_head list;
  516. } wq;
  517. /* handles posted to FW resides here */
  518. struct hd_async_handle *header;
  519. struct hd_async_handle *data;
  520. };
  521. struct hd_async_buf_context {
  522. struct be_bus_address pa_base;
  523. void *va_base;
  524. void *ring_base;
  525. struct hd_async_handle *handle_base;
  526. u32 buffer_size;
  527. u16 pi;
  528. };
  529. /**
  530. * hd_async_context is declared for each ULP supporting iSCSI function.
  531. */
  532. struct hd_async_context {
  533. struct hd_async_buf_context async_header;
  534. struct hd_async_buf_context async_data;
  535. u16 num_entries;
  536. /**
  537. * When unsol PDU is in, it needs to be chained till all the bytes are
  538. * received and then processing is done. hd_async_entry is created
  539. * based on the cid_count for each ULP. When unsol PDU comes in based
  540. * on the conn_id it needs to be added to the correct async_entry wq.
  541. * Below defined cid_to_async_cri_map is used to reterive the
  542. * async_cri_map for a particular connection.
  543. *
  544. * This array is initialized after beiscsi_create_wrb_rings returns.
  545. *
  546. * - this method takes more memory space, fixed to 2K
  547. * - any support for connections greater than this the array size needs
  548. * to be incremented
  549. */
  550. #define BE_GET_ASYNC_CRI_FROM_CID(cid) (pasync_ctx->cid_to_async_cri_map[cid])
  551. unsigned short cid_to_async_cri_map[BE_MAX_SESSION];
  552. /**
  553. * This is a variable size array. Don`t add anything after this field!!
  554. */
  555. struct hd_async_entry *async_entry;
  556. };
  557. struct i_t_dpdu_cqe {
  558. u32 dw[4];
  559. } __packed;
  560. /**
  561. * Pseudo amap definition in which each bit of the actual structure is defined
  562. * as a byte: used to calculate offset/shift/mask of each field
  563. */
  564. struct amap_i_t_dpdu_cqe {
  565. u8 db_addr_hi[32];
  566. u8 db_addr_lo[32];
  567. u8 code[6];
  568. u8 cid[10];
  569. u8 dpl[16];
  570. u8 index[16];
  571. u8 num_cons[10];
  572. u8 rsvd0[4];
  573. u8 final;
  574. u8 valid;
  575. } __packed;
  576. struct amap_i_t_dpdu_cqe_v2 {
  577. u8 db_addr_hi[32]; /* DWORD 0 */
  578. u8 db_addr_lo[32]; /* DWORD 1 */
  579. u8 code[6]; /* DWORD 2 */
  580. u8 num_cons; /* DWORD 2*/
  581. u8 rsvd0[8]; /* DWORD 2 */
  582. u8 dpl[17]; /* DWORD 2 */
  583. u8 index[16]; /* DWORD 3 */
  584. u8 cid[13]; /* DWORD 3 */
  585. u8 rsvd1; /* DWORD 3 */
  586. u8 final; /* DWORD 3 */
  587. u8 valid; /* DWORD 3 */
  588. } __packed;
  589. #define CQE_VALID_MASK 0x80000000
  590. #define CQE_CODE_MASK 0x0000003F
  591. #define CQE_CID_MASK 0x0000FFC0
  592. #define EQE_VALID_MASK 0x00000001
  593. #define EQE_MAJORCODE_MASK 0x0000000E
  594. #define EQE_RESID_MASK 0xFFFF0000
  595. struct be_eq_entry {
  596. u32 dw[1];
  597. } __packed;
  598. /**
  599. * Pseudo amap definition in which each bit of the actual structure is defined
  600. * as a byte: used to calculate offset/shift/mask of each field
  601. */
  602. struct amap_eq_entry {
  603. u8 valid; /* DWORD 0 */
  604. u8 major_code[3]; /* DWORD 0 */
  605. u8 minor_code[12]; /* DWORD 0 */
  606. u8 resource_id[16]; /* DWORD 0 */
  607. } __packed;
  608. struct cq_db {
  609. u32 dw[1];
  610. } __packed;
  611. /**
  612. * Pseudo amap definition in which each bit of the actual structure is defined
  613. * as a byte: used to calculate offset/shift/mask of each field
  614. */
  615. struct amap_cq_db {
  616. u8 qid[10];
  617. u8 event[1];
  618. u8 rsvd0[5];
  619. u8 num_popped[13];
  620. u8 rearm[1];
  621. u8 rsvd1[2];
  622. } __packed;
  623. void beiscsi_process_eq(struct beiscsi_hba *phba);
  624. struct iscsi_wrb {
  625. u32 dw[16];
  626. } __packed;
  627. #define WRB_TYPE_MASK 0xF0000000
  628. #define SKH_WRB_TYPE_OFFSET 27
  629. #define BE_WRB_TYPE_OFFSET 28
  630. #define ADAPTER_SET_WRB_TYPE(pwrb, wrb_type, type_offset) \
  631. (pwrb->dw[0] |= (wrb_type << type_offset))
  632. /**
  633. * Pseudo amap definition in which each bit of the actual structure is defined
  634. * as a byte: used to calculate offset/shift/mask of each field
  635. */
  636. struct amap_iscsi_wrb {
  637. u8 lun[14]; /* DWORD 0 */
  638. u8 lt; /* DWORD 0 */
  639. u8 invld; /* DWORD 0 */
  640. u8 wrb_idx[8]; /* DWORD 0 */
  641. u8 dsp; /* DWORD 0 */
  642. u8 dmsg; /* DWORD 0 */
  643. u8 undr_run; /* DWORD 0 */
  644. u8 over_run; /* DWORD 0 */
  645. u8 type[4]; /* DWORD 0 */
  646. u8 ptr2nextwrb[8]; /* DWORD 1 */
  647. u8 r2t_exp_dtl[24]; /* DWORD 1 */
  648. u8 sgl_icd_idx[12]; /* DWORD 2 */
  649. u8 rsvd0[20]; /* DWORD 2 */
  650. u8 exp_data_sn[32]; /* DWORD 3 */
  651. u8 iscsi_bhs_addr_hi[32]; /* DWORD 4 */
  652. u8 iscsi_bhs_addr_lo[32]; /* DWORD 5 */
  653. u8 cmdsn_itt[32]; /* DWORD 6 */
  654. u8 dif_ref_tag[32]; /* DWORD 7 */
  655. u8 sge0_addr_hi[32]; /* DWORD 8 */
  656. u8 sge0_addr_lo[32]; /* DWORD 9 */
  657. u8 sge0_offset[22]; /* DWORD 10 */
  658. u8 pbs; /* DWORD 10 */
  659. u8 dif_mode[2]; /* DWORD 10 */
  660. u8 rsvd1[6]; /* DWORD 10 */
  661. u8 sge0_last; /* DWORD 10 */
  662. u8 sge0_len[17]; /* DWORD 11 */
  663. u8 dif_meta_tag[14]; /* DWORD 11 */
  664. u8 sge0_in_ddr; /* DWORD 11 */
  665. u8 sge1_addr_hi[32]; /* DWORD 12 */
  666. u8 sge1_addr_lo[32]; /* DWORD 13 */
  667. u8 sge1_r2t_offset[22]; /* DWORD 14 */
  668. u8 rsvd2[9]; /* DWORD 14 */
  669. u8 sge1_last; /* DWORD 14 */
  670. u8 sge1_len[17]; /* DWORD 15 */
  671. u8 ref_sgl_icd_idx[12]; /* DWORD 15 */
  672. u8 rsvd3[2]; /* DWORD 15 */
  673. u8 sge1_in_ddr; /* DWORD 15 */
  674. } __packed;
  675. struct amap_iscsi_wrb_v2 {
  676. u8 r2t_exp_dtl[25]; /* DWORD 0 */
  677. u8 rsvd0[2]; /* DWORD 0*/
  678. u8 type[5]; /* DWORD 0 */
  679. u8 ptr2nextwrb[8]; /* DWORD 1 */
  680. u8 wrb_idx[8]; /* DWORD 1 */
  681. u8 lun[16]; /* DWORD 1 */
  682. u8 sgl_idx[16]; /* DWORD 2 */
  683. u8 ref_sgl_icd_idx[16]; /* DWORD 2 */
  684. u8 exp_data_sn[32]; /* DWORD 3 */
  685. u8 iscsi_bhs_addr_hi[32]; /* DWORD 4 */
  686. u8 iscsi_bhs_addr_lo[32]; /* DWORD 5 */
  687. u8 cq_id[16]; /* DWORD 6 */
  688. u8 rsvd1[16]; /* DWORD 6 */
  689. u8 cmdsn_itt[32]; /* DWORD 7 */
  690. u8 sge0_addr_hi[32]; /* DWORD 8 */
  691. u8 sge0_addr_lo[32]; /* DWORD 9 */
  692. u8 sge0_offset[24]; /* DWORD 10 */
  693. u8 rsvd2[7]; /* DWORD 10 */
  694. u8 sge0_last; /* DWORD 10 */
  695. u8 sge0_len[17]; /* DWORD 11 */
  696. u8 rsvd3[7]; /* DWORD 11 */
  697. u8 diff_enbl; /* DWORD 11 */
  698. u8 u_run; /* DWORD 11 */
  699. u8 o_run; /* DWORD 11 */
  700. u8 invld; /* DWORD 11 */
  701. u8 dsp; /* DWORD 11 */
  702. u8 dmsg; /* DWORD 11 */
  703. u8 rsvd4; /* DWORD 11 */
  704. u8 lt; /* DWORD 11 */
  705. u8 sge1_addr_hi[32]; /* DWORD 12 */
  706. u8 sge1_addr_lo[32]; /* DWORD 13 */
  707. u8 sge1_r2t_offset[24]; /* DWORD 14 */
  708. u8 rsvd5[7]; /* DWORD 14 */
  709. u8 sge1_last; /* DWORD 14 */
  710. u8 sge1_len[17]; /* DWORD 15 */
  711. u8 rsvd6[15]; /* DWORD 15 */
  712. } __packed;
  713. struct wrb_handle *alloc_wrb_handle(struct beiscsi_hba *phba, unsigned int cid,
  714. struct hwi_wrb_context **pcontext);
  715. void
  716. free_mgmt_sgl_handle(struct beiscsi_hba *phba, struct sgl_handle *psgl_handle);
  717. void beiscsi_free_mgmt_task_handles(struct beiscsi_conn *beiscsi_conn,
  718. struct iscsi_task *task);
  719. void hwi_ring_cq_db(struct beiscsi_hba *phba,
  720. unsigned int id, unsigned int num_processed,
  721. unsigned char rearm);
  722. unsigned int beiscsi_process_cq(struct be_eq_obj *pbe_eq, int budget);
  723. void beiscsi_process_mcc_cq(struct beiscsi_hba *phba);
  724. struct pdu_nop_out {
  725. u32 dw[12];
  726. };
  727. /**
  728. * Pseudo amap definition in which each bit of the actual structure is defined
  729. * as a byte: used to calculate offset/shift/mask of each field
  730. */
  731. struct amap_pdu_nop_out {
  732. u8 opcode[6]; /* opcode 0x00 */
  733. u8 i_bit; /* I Bit */
  734. u8 x_bit; /* reserved; should be 0 */
  735. u8 fp_bit_filler1[7];
  736. u8 f_bit; /* always 1 */
  737. u8 reserved1[16];
  738. u8 ahs_length[8]; /* no AHS */
  739. u8 data_len_hi[8];
  740. u8 data_len_lo[16]; /* DataSegmentLength */
  741. u8 lun[64];
  742. u8 itt[32]; /* initiator id for ping or 0xffffffff */
  743. u8 ttt[32]; /* target id for ping or 0xffffffff */
  744. u8 cmd_sn[32];
  745. u8 exp_stat_sn[32];
  746. u8 reserved5[128];
  747. };
  748. #define PDUBASE_OPCODE_MASK 0x0000003F
  749. #define PDUBASE_DATALENHI_MASK 0x0000FF00
  750. #define PDUBASE_DATALENLO_MASK 0xFFFF0000
  751. struct pdu_base {
  752. u32 dw[16];
  753. } __packed;
  754. /**
  755. * Pseudo amap definition in which each bit of the actual structure is defined
  756. * as a byte: used to calculate offset/shift/mask of each field
  757. */
  758. struct amap_pdu_base {
  759. u8 opcode[6];
  760. u8 i_bit; /* immediate bit */
  761. u8 x_bit; /* reserved, always 0 */
  762. u8 reserved1[24]; /* opcode-specific fields */
  763. u8 ahs_length[8]; /* length units is 4 byte words */
  764. u8 data_len_hi[8];
  765. u8 data_len_lo[16]; /* DatasegmentLength */
  766. u8 lun[64]; /* lun or opcode-specific fields */
  767. u8 itt[32]; /* initiator task tag */
  768. u8 reserved4[224];
  769. };
  770. struct iscsi_target_context_update_wrb {
  771. u32 dw[16];
  772. } __packed;
  773. /**
  774. * Pseudo amap definition in which each bit of the actual structure is defined
  775. * as a byte: used to calculate offset/shift/mask of each field
  776. */
  777. #define BE_TGT_CTX_UPDT_CMD 0x07
  778. struct amap_iscsi_target_context_update_wrb {
  779. u8 lun[14]; /* DWORD 0 */
  780. u8 lt; /* DWORD 0 */
  781. u8 invld; /* DWORD 0 */
  782. u8 wrb_idx[8]; /* DWORD 0 */
  783. u8 dsp; /* DWORD 0 */
  784. u8 dmsg; /* DWORD 0 */
  785. u8 undr_run; /* DWORD 0 */
  786. u8 over_run; /* DWORD 0 */
  787. u8 type[4]; /* DWORD 0 */
  788. u8 ptr2nextwrb[8]; /* DWORD 1 */
  789. u8 max_burst_length[19]; /* DWORD 1 */
  790. u8 rsvd0[5]; /* DWORD 1 */
  791. u8 rsvd1[15]; /* DWORD 2 */
  792. u8 max_send_data_segment_length[17]; /* DWORD 2 */
  793. u8 first_burst_length[14]; /* DWORD 3 */
  794. u8 rsvd2[2]; /* DWORD 3 */
  795. u8 tx_wrbindex_drv_msg[8]; /* DWORD 3 */
  796. u8 rsvd3[5]; /* DWORD 3 */
  797. u8 session_state[3]; /* DWORD 3 */
  798. u8 rsvd4[16]; /* DWORD 4 */
  799. u8 tx_jumbo; /* DWORD 4 */
  800. u8 hde; /* DWORD 4 */
  801. u8 dde; /* DWORD 4 */
  802. u8 erl[2]; /* DWORD 4 */
  803. u8 domain_id[5]; /* DWORD 4 */
  804. u8 mode; /* DWORD 4 */
  805. u8 imd; /* DWORD 4 */
  806. u8 ir2t; /* DWORD 4 */
  807. u8 notpredblq[2]; /* DWORD 4 */
  808. u8 compltonack; /* DWORD 4 */
  809. u8 stat_sn[32]; /* DWORD 5 */
  810. u8 pad_buffer_addr_hi[32]; /* DWORD 6 */
  811. u8 pad_buffer_addr_lo[32]; /* DWORD 7 */
  812. u8 pad_addr_hi[32]; /* DWORD 8 */
  813. u8 pad_addr_lo[32]; /* DWORD 9 */
  814. u8 rsvd5[32]; /* DWORD 10 */
  815. u8 rsvd6[32]; /* DWORD 11 */
  816. u8 rsvd7[32]; /* DWORD 12 */
  817. u8 rsvd8[32]; /* DWORD 13 */
  818. u8 rsvd9[32]; /* DWORD 14 */
  819. u8 rsvd10[32]; /* DWORD 15 */
  820. } __packed;
  821. #define BEISCSI_MAX_RECV_DATASEG_LEN (64 * 1024)
  822. #define BEISCSI_MAX_CXNS 1
  823. struct amap_iscsi_target_context_update_wrb_v2 {
  824. u8 max_burst_length[24]; /* DWORD 0 */
  825. u8 rsvd0[3]; /* DWORD 0 */
  826. u8 type[5]; /* DWORD 0 */
  827. u8 ptr2nextwrb[8]; /* DWORD 1 */
  828. u8 wrb_idx[8]; /* DWORD 1 */
  829. u8 rsvd1[16]; /* DWORD 1 */
  830. u8 max_send_data_segment_length[24]; /* DWORD 2 */
  831. u8 rsvd2[8]; /* DWORD 2 */
  832. u8 first_burst_length[24]; /* DWORD 3 */
  833. u8 rsvd3[8]; /* DOWRD 3 */
  834. u8 max_r2t[16]; /* DWORD 4 */
  835. u8 rsvd4; /* DWORD 4 */
  836. u8 hde; /* DWORD 4 */
  837. u8 dde; /* DWORD 4 */
  838. u8 erl[2]; /* DWORD 4 */
  839. u8 rsvd5[6]; /* DWORD 4 */
  840. u8 imd; /* DWORD 4 */
  841. u8 ir2t; /* DWORD 4 */
  842. u8 rsvd6[3]; /* DWORD 4 */
  843. u8 stat_sn[32]; /* DWORD 5 */
  844. u8 rsvd7[32]; /* DWORD 6 */
  845. u8 rsvd8[32]; /* DWORD 7 */
  846. u8 max_recv_dataseg_len[24]; /* DWORD 8 */
  847. u8 rsvd9[8]; /* DWORD 8 */
  848. u8 rsvd10[32]; /* DWORD 9 */
  849. u8 rsvd11[32]; /* DWORD 10 */
  850. u8 max_cxns[16]; /* DWORD 11 */
  851. u8 rsvd12[11]; /* DWORD 11*/
  852. u8 invld; /* DWORD 11 */
  853. u8 rsvd13;/* DWORD 11*/
  854. u8 dmsg; /* DWORD 11 */
  855. u8 data_seq_inorder; /* DWORD 11 */
  856. u8 pdu_seq_inorder; /* DWORD 11 */
  857. u8 rsvd14[32]; /*DWORD 12 */
  858. u8 rsvd15[32]; /* DWORD 13 */
  859. u8 rsvd16[32]; /* DWORD 14 */
  860. u8 rsvd17[32]; /* DWORD 15 */
  861. } __packed;
  862. struct be_ring {
  863. u32 pages; /* queue size in pages */
  864. u32 id; /* queue id assigned by beklib */
  865. u32 num; /* number of elements in queue */
  866. u32 cidx; /* consumer index */
  867. u32 pidx; /* producer index -- not used by most rings */
  868. u32 item_size; /* size in bytes of one object */
  869. u8 ulp_num; /* ULP to which CID binded */
  870. u16 register_set;
  871. u16 doorbell_format;
  872. u32 doorbell_offset;
  873. void *va; /* The virtual address of the ring. This
  874. * should be last to allow 32 & 64 bit debugger
  875. * extensions to work.
  876. */
  877. };
  878. struct hwi_controller {
  879. struct hwi_wrb_context *wrb_context;
  880. struct be_ring default_pdu_hdr[BEISCSI_ULP_COUNT];
  881. struct be_ring default_pdu_data[BEISCSI_ULP_COUNT];
  882. struct hwi_context_memory *phwi_ctxt;
  883. };
  884. enum hwh_type_enum {
  885. HWH_TYPE_IO = 1,
  886. HWH_TYPE_LOGOUT = 2,
  887. HWH_TYPE_TMF = 3,
  888. HWH_TYPE_NOP = 4,
  889. HWH_TYPE_IO_RD = 5,
  890. HWH_TYPE_LOGIN = 11,
  891. HWH_TYPE_INVALID = 0xFFFFFFFF
  892. };
  893. struct wrb_handle {
  894. unsigned short wrb_index;
  895. struct iscsi_task *pio_handle;
  896. struct iscsi_wrb *pwrb;
  897. };
  898. struct hwi_context_memory {
  899. struct be_eq_obj be_eq[MAX_CPUS];
  900. struct be_queue_info be_cq[MAX_CPUS - 1];
  901. struct be_queue_info *be_wrbq;
  902. /**
  903. * Create array of ULP number for below entries as DEFQ
  904. * will be created for both ULP if iSCSI Protocol is
  905. * loaded on both ULP.
  906. */
  907. struct be_queue_info be_def_hdrq[BEISCSI_ULP_COUNT];
  908. struct be_queue_info be_def_dataq[BEISCSI_ULP_COUNT];
  909. struct hd_async_context *pasync_ctx[BEISCSI_ULP_COUNT];
  910. };
  911. void beiscsi_start_boot_work(struct beiscsi_hba *phba, unsigned int s_handle);
  912. /* Logging related definitions */
  913. #define BEISCSI_LOG_INIT 0x0001 /* Initialization events */
  914. #define BEISCSI_LOG_MBOX 0x0002 /* Mailbox Events */
  915. #define BEISCSI_LOG_MISC 0x0004 /* Miscllaneous Events */
  916. #define BEISCSI_LOG_EH 0x0008 /* Error Handler */
  917. #define BEISCSI_LOG_IO 0x0010 /* IO Code Path */
  918. #define BEISCSI_LOG_CONFIG 0x0020 /* CONFIG Code Path */
  919. #define BEISCSI_LOG_ISCSI 0x0040 /* SCSI/iSCSI Protocol related Logs */
  920. #define __beiscsi_log(phba, level, fmt, arg...) \
  921. shost_printk(level, phba->shost, fmt, __LINE__, ##arg)
  922. #define beiscsi_log(phba, level, mask, fmt, arg...) \
  923. do { \
  924. uint32_t log_value = phba->attr_log_enable; \
  925. if (((mask) & log_value) || (level[1] <= '3')) \
  926. __beiscsi_log(phba, level, fmt, ##arg); \
  927. } while (0);
  928. #endif