be_main.h 31 KB

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