qla_target.h 34 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195
  1. /*
  2. * Copyright (C) 2004 - 2010 Vladislav Bolkhovitin <vst@vlnb.net>
  3. * Copyright (C) 2004 - 2005 Leonid Stoljar
  4. * Copyright (C) 2006 Nathaniel Clark <nate@misrule.us>
  5. * Copyright (C) 2007 - 2010 ID7 Ltd.
  6. *
  7. * Forward port and refactoring to modern qla2xxx and target/configfs
  8. *
  9. * Copyright (C) 2010-2011 Nicholas A. Bellinger <nab@kernel.org>
  10. *
  11. * Additional file for the target driver support.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. */
  23. /*
  24. * This is the global def file that is useful for including from the
  25. * target portion.
  26. */
  27. #ifndef __QLA_TARGET_H
  28. #define __QLA_TARGET_H
  29. #include "qla_def.h"
  30. /*
  31. * Must be changed on any change in any initiator visible interfaces or
  32. * data in the target add-on
  33. */
  34. #define QLA2XXX_TARGET_MAGIC 269
  35. /*
  36. * Must be changed on any change in any target visible interfaces or
  37. * data in the initiator
  38. */
  39. #define QLA2XXX_INITIATOR_MAGIC 57222
  40. #define QLA2XXX_INI_MODE_STR_EXCLUSIVE "exclusive"
  41. #define QLA2XXX_INI_MODE_STR_DISABLED "disabled"
  42. #define QLA2XXX_INI_MODE_STR_ENABLED "enabled"
  43. #define QLA2XXX_INI_MODE_EXCLUSIVE 0
  44. #define QLA2XXX_INI_MODE_DISABLED 1
  45. #define QLA2XXX_INI_MODE_ENABLED 2
  46. #define QLA2XXX_COMMAND_COUNT_INIT 250
  47. #define QLA2XXX_IMMED_NOTIFY_COUNT_INIT 250
  48. /*
  49. * Used to mark which completion handles (for RIO Status's) are for CTIO's
  50. * vs. regular (non-target) info. This is checked for in
  51. * qla2x00_process_response_queue() to see if a handle coming back in a
  52. * multi-complete should come to the tgt driver or be handled there by qla2xxx
  53. */
  54. #define CTIO_COMPLETION_HANDLE_MARK BIT_29
  55. #if (CTIO_COMPLETION_HANDLE_MARK <= DEFAULT_OUTSTANDING_COMMANDS)
  56. #error "CTIO_COMPLETION_HANDLE_MARK not larger than "
  57. "DEFAULT_OUTSTANDING_COMMANDS"
  58. #endif
  59. #define HANDLE_IS_CTIO_COMP(h) (h & CTIO_COMPLETION_HANDLE_MARK)
  60. /* Used to mark CTIO as intermediate */
  61. #define CTIO_INTERMEDIATE_HANDLE_MARK BIT_30
  62. #ifndef OF_SS_MODE_0
  63. /*
  64. * ISP target entries - Flags bit definitions.
  65. */
  66. #define OF_SS_MODE_0 0
  67. #define OF_SS_MODE_1 1
  68. #define OF_SS_MODE_2 2
  69. #define OF_SS_MODE_3 3
  70. #define OF_EXPL_CONF BIT_5 /* Explicit Confirmation Requested */
  71. #define OF_DATA_IN BIT_6 /* Data in to initiator */
  72. /* (data from target to initiator) */
  73. #define OF_DATA_OUT BIT_7 /* Data out from initiator */
  74. /* (data from initiator to target) */
  75. #define OF_NO_DATA (BIT_7 | BIT_6)
  76. #define OF_INC_RC BIT_8 /* Increment command resource count */
  77. #define OF_FAST_POST BIT_9 /* Enable mailbox fast posting. */
  78. #define OF_CONF_REQ BIT_13 /* Confirmation Requested */
  79. #define OF_TERM_EXCH BIT_14 /* Terminate exchange */
  80. #define OF_SSTS BIT_15 /* Send SCSI status */
  81. #endif
  82. #ifndef QLA_TGT_DATASEGS_PER_CMD32
  83. #define QLA_TGT_DATASEGS_PER_CMD32 3
  84. #define QLA_TGT_DATASEGS_PER_CONT32 7
  85. #define QLA_TGT_MAX_SG32(ql) \
  86. (((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD32 + \
  87. QLA_TGT_DATASEGS_PER_CONT32*((ql) - 1)) : 0)
  88. #define QLA_TGT_DATASEGS_PER_CMD64 2
  89. #define QLA_TGT_DATASEGS_PER_CONT64 5
  90. #define QLA_TGT_MAX_SG64(ql) \
  91. (((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD64 + \
  92. QLA_TGT_DATASEGS_PER_CONT64*((ql) - 1)) : 0)
  93. #endif
  94. #ifndef QLA_TGT_DATASEGS_PER_CMD_24XX
  95. #define QLA_TGT_DATASEGS_PER_CMD_24XX 1
  96. #define QLA_TGT_DATASEGS_PER_CONT_24XX 5
  97. #define QLA_TGT_MAX_SG_24XX(ql) \
  98. (min(1270, ((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD_24XX + \
  99. QLA_TGT_DATASEGS_PER_CONT_24XX*((ql) - 1)) : 0))
  100. #endif
  101. #endif
  102. #define GET_TARGET_ID(ha, iocb) ((HAS_EXTENDED_IDS(ha)) \
  103. ? le16_to_cpu((iocb)->u.isp2x.target.extended) \
  104. : (uint16_t)(iocb)->u.isp2x.target.id.standard)
  105. #ifndef IMMED_NOTIFY_TYPE
  106. #define IMMED_NOTIFY_TYPE 0x0D /* Immediate notify entry. */
  107. /*
  108. * ISP queue - immediate notify entry structure definition.
  109. * This is sent by the ISP to the Target driver.
  110. * This IOCB would have report of events sent by the
  111. * initiator, that needs to be handled by the target
  112. * driver immediately.
  113. */
  114. struct imm_ntfy_from_isp {
  115. uint8_t entry_type; /* Entry type. */
  116. uint8_t entry_count; /* Entry count. */
  117. uint8_t sys_define; /* System defined. */
  118. uint8_t entry_status; /* Entry Status. */
  119. union {
  120. struct {
  121. uint32_t sys_define_2; /* System defined. */
  122. target_id_t target;
  123. uint16_t lun;
  124. uint8_t target_id;
  125. uint8_t reserved_1;
  126. uint16_t status_modifier;
  127. uint16_t status;
  128. uint16_t task_flags;
  129. uint16_t seq_id;
  130. uint16_t srr_rx_id;
  131. uint32_t srr_rel_offs;
  132. uint16_t srr_ui;
  133. #define SRR_IU_DATA_IN 0x1
  134. #define SRR_IU_DATA_OUT 0x5
  135. #define SRR_IU_STATUS 0x7
  136. uint16_t srr_ox_id;
  137. uint8_t reserved_2[28];
  138. } isp2x;
  139. struct {
  140. uint32_t reserved;
  141. uint16_t nport_handle;
  142. uint16_t reserved_2;
  143. uint16_t flags;
  144. #define NOTIFY24XX_FLAGS_GLOBAL_TPRLO BIT_1
  145. #define NOTIFY24XX_FLAGS_PUREX_IOCB BIT_0
  146. uint16_t srr_rx_id;
  147. uint16_t status;
  148. uint8_t status_subcode;
  149. uint8_t fw_handle;
  150. uint32_t exchange_address;
  151. uint32_t srr_rel_offs;
  152. uint16_t srr_ui;
  153. uint16_t srr_ox_id;
  154. union {
  155. struct {
  156. uint8_t node_name[8];
  157. } plogi; /* PLOGI/ADISC/PDISC */
  158. struct {
  159. /* PRLI word 3 bit 0-15 */
  160. uint16_t wd3_lo;
  161. uint8_t resv0[6];
  162. } prli;
  163. struct {
  164. uint8_t port_id[3];
  165. uint8_t resv1;
  166. uint16_t nport_handle;
  167. uint16_t resv2;
  168. } req_els;
  169. } u;
  170. uint8_t port_name[8];
  171. uint8_t resv3[3];
  172. uint8_t vp_index;
  173. uint32_t reserved_5;
  174. uint8_t port_id[3];
  175. uint8_t reserved_6;
  176. } isp24;
  177. } u;
  178. uint16_t reserved_7;
  179. uint16_t ox_id;
  180. } __packed;
  181. #endif
  182. #ifndef NOTIFY_ACK_TYPE
  183. #define NOTIFY_ACK_TYPE 0x0E /* Notify acknowledge entry. */
  184. /*
  185. * ISP queue - notify acknowledge entry structure definition.
  186. * This is sent to the ISP from the target driver.
  187. */
  188. struct nack_to_isp {
  189. uint8_t entry_type; /* Entry type. */
  190. uint8_t entry_count; /* Entry count. */
  191. uint8_t sys_define; /* System defined. */
  192. uint8_t entry_status; /* Entry Status. */
  193. union {
  194. struct {
  195. uint32_t sys_define_2; /* System defined. */
  196. target_id_t target;
  197. uint8_t target_id;
  198. uint8_t reserved_1;
  199. uint16_t flags;
  200. uint16_t resp_code;
  201. uint16_t status;
  202. uint16_t task_flags;
  203. uint16_t seq_id;
  204. uint16_t srr_rx_id;
  205. uint32_t srr_rel_offs;
  206. uint16_t srr_ui;
  207. uint16_t srr_flags;
  208. uint16_t srr_reject_code;
  209. uint8_t srr_reject_vendor_uniq;
  210. uint8_t srr_reject_code_expl;
  211. uint8_t reserved_2[24];
  212. } isp2x;
  213. struct {
  214. uint32_t handle;
  215. uint16_t nport_handle;
  216. uint16_t reserved_1;
  217. uint16_t flags;
  218. uint16_t srr_rx_id;
  219. uint16_t status;
  220. uint8_t status_subcode;
  221. uint8_t fw_handle;
  222. uint32_t exchange_address;
  223. uint32_t srr_rel_offs;
  224. uint16_t srr_ui;
  225. uint16_t srr_flags;
  226. uint8_t reserved_4[19];
  227. uint8_t vp_index;
  228. uint8_t srr_reject_vendor_uniq;
  229. uint8_t srr_reject_code_expl;
  230. uint8_t srr_reject_code;
  231. uint8_t reserved_5[5];
  232. } isp24;
  233. } u;
  234. uint8_t reserved[2];
  235. uint16_t ox_id;
  236. } __packed;
  237. #define NOTIFY_ACK_FLAGS_TERMINATE BIT_3
  238. #define NOTIFY_ACK_SRR_FLAGS_ACCEPT 0
  239. #define NOTIFY_ACK_SRR_FLAGS_REJECT 1
  240. #define NOTIFY_ACK_SRR_REJECT_REASON_UNABLE_TO_PERFORM 0x9
  241. #define NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_NO_EXPL 0
  242. #define NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_UNABLE_TO_SUPPLY_DATA 0x2a
  243. #define NOTIFY_ACK_SUCCESS 0x01
  244. #endif
  245. #ifndef ACCEPT_TGT_IO_TYPE
  246. #define ACCEPT_TGT_IO_TYPE 0x16 /* Accept target I/O entry. */
  247. #endif
  248. #ifndef CONTINUE_TGT_IO_TYPE
  249. #define CONTINUE_TGT_IO_TYPE 0x17
  250. /*
  251. * ISP queue - Continue Target I/O (CTIO) entry for status mode 0 structure.
  252. * This structure is sent to the ISP 2xxx from target driver.
  253. */
  254. struct ctio_to_2xxx {
  255. uint8_t entry_type; /* Entry type. */
  256. uint8_t entry_count; /* Entry count. */
  257. uint8_t sys_define; /* System defined. */
  258. uint8_t entry_status; /* Entry Status. */
  259. uint32_t handle; /* System defined handle */
  260. target_id_t target;
  261. uint16_t rx_id;
  262. uint16_t flags;
  263. uint16_t status;
  264. uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */
  265. uint16_t dseg_count; /* Data segment count. */
  266. uint32_t relative_offset;
  267. uint32_t residual;
  268. uint16_t reserved_1[3];
  269. uint16_t scsi_status;
  270. uint32_t transfer_length;
  271. uint32_t dseg_0_address; /* Data segment 0 address. */
  272. uint32_t dseg_0_length; /* Data segment 0 length. */
  273. uint32_t dseg_1_address; /* Data segment 1 address. */
  274. uint32_t dseg_1_length; /* Data segment 1 length. */
  275. uint32_t dseg_2_address; /* Data segment 2 address. */
  276. uint32_t dseg_2_length; /* Data segment 2 length. */
  277. } __packed;
  278. #define ATIO_PATH_INVALID 0x07
  279. #define ATIO_CANT_PROV_CAP 0x16
  280. #define ATIO_CDB_VALID 0x3D
  281. #define ATIO_EXEC_READ BIT_1
  282. #define ATIO_EXEC_WRITE BIT_0
  283. #endif
  284. #ifndef CTIO_A64_TYPE
  285. #define CTIO_A64_TYPE 0x1F
  286. #define CTIO_SUCCESS 0x01
  287. #define CTIO_ABORTED 0x02
  288. #define CTIO_INVALID_RX_ID 0x08
  289. #define CTIO_TIMEOUT 0x0B
  290. #define CTIO_DIF_ERROR 0x0C /* DIF error detected */
  291. #define CTIO_LIP_RESET 0x0E
  292. #define CTIO_TARGET_RESET 0x17
  293. #define CTIO_PORT_UNAVAILABLE 0x28
  294. #define CTIO_PORT_LOGGED_OUT 0x29
  295. #define CTIO_PORT_CONF_CHANGED 0x2A
  296. #define CTIO_SRR_RECEIVED 0x45
  297. #endif
  298. #ifndef CTIO_RET_TYPE
  299. #define CTIO_RET_TYPE 0x17 /* CTIO return entry */
  300. #define ATIO_TYPE7 0x06 /* Accept target I/O entry for 24xx */
  301. struct fcp_hdr {
  302. uint8_t r_ctl;
  303. uint8_t d_id[3];
  304. uint8_t cs_ctl;
  305. uint8_t s_id[3];
  306. uint8_t type;
  307. uint8_t f_ctl[3];
  308. uint8_t seq_id;
  309. uint8_t df_ctl;
  310. uint16_t seq_cnt;
  311. __be16 ox_id;
  312. uint16_t rx_id;
  313. uint32_t parameter;
  314. } __packed;
  315. struct fcp_hdr_le {
  316. uint8_t d_id[3];
  317. uint8_t r_ctl;
  318. uint8_t s_id[3];
  319. uint8_t cs_ctl;
  320. uint8_t f_ctl[3];
  321. uint8_t type;
  322. uint16_t seq_cnt;
  323. uint8_t df_ctl;
  324. uint8_t seq_id;
  325. uint16_t rx_id;
  326. uint16_t ox_id;
  327. uint32_t parameter;
  328. } __packed;
  329. #define F_CTL_EXCH_CONTEXT_RESP BIT_23
  330. #define F_CTL_SEQ_CONTEXT_RESIP BIT_22
  331. #define F_CTL_LAST_SEQ BIT_20
  332. #define F_CTL_END_SEQ BIT_19
  333. #define F_CTL_SEQ_INITIATIVE BIT_16
  334. #define R_CTL_BASIC_LINK_SERV 0x80
  335. #define R_CTL_B_ACC 0x4
  336. #define R_CTL_B_RJT 0x5
  337. struct atio7_fcp_cmnd {
  338. uint64_t lun;
  339. uint8_t cmnd_ref;
  340. uint8_t task_attr:3;
  341. uint8_t reserved:5;
  342. uint8_t task_mgmt_flags;
  343. #define FCP_CMND_TASK_MGMT_CLEAR_ACA 6
  344. #define FCP_CMND_TASK_MGMT_TARGET_RESET 5
  345. #define FCP_CMND_TASK_MGMT_LU_RESET 4
  346. #define FCP_CMND_TASK_MGMT_CLEAR_TASK_SET 2
  347. #define FCP_CMND_TASK_MGMT_ABORT_TASK_SET 1
  348. uint8_t wrdata:1;
  349. uint8_t rddata:1;
  350. uint8_t add_cdb_len:6;
  351. uint8_t cdb[16];
  352. /*
  353. * add_cdb is optional and can absent from struct atio7_fcp_cmnd. Size 4
  354. * only to make sizeof(struct atio7_fcp_cmnd) be as expected by
  355. * BUILD_BUG_ON in qlt_init().
  356. */
  357. uint8_t add_cdb[4];
  358. /* uint32_t data_length; */
  359. } __packed;
  360. /*
  361. * ISP queue - Accept Target I/O (ATIO) type entry IOCB structure.
  362. * This is sent from the ISP to the target driver.
  363. */
  364. struct atio_from_isp {
  365. union {
  366. struct {
  367. uint16_t entry_hdr;
  368. uint8_t sys_define; /* System defined. */
  369. uint8_t entry_status; /* Entry Status. */
  370. uint32_t sys_define_2; /* System defined. */
  371. target_id_t target;
  372. uint16_t rx_id;
  373. uint16_t flags;
  374. uint16_t status;
  375. uint8_t command_ref;
  376. uint8_t task_codes;
  377. uint8_t task_flags;
  378. uint8_t execution_codes;
  379. uint8_t cdb[MAX_CMDSZ];
  380. uint32_t data_length;
  381. uint16_t lun;
  382. uint8_t initiator_port_name[WWN_SIZE]; /* on qla23xx */
  383. uint16_t reserved_32[6];
  384. uint16_t ox_id;
  385. } isp2x;
  386. struct {
  387. uint16_t entry_hdr;
  388. uint8_t fcp_cmnd_len_low;
  389. uint8_t fcp_cmnd_len_high:4;
  390. uint8_t attr:4;
  391. uint32_t exchange_addr;
  392. #define ATIO_EXCHANGE_ADDRESS_UNKNOWN 0xFFFFFFFF
  393. struct fcp_hdr fcp_hdr;
  394. struct atio7_fcp_cmnd fcp_cmnd;
  395. } isp24;
  396. struct {
  397. uint8_t entry_type; /* Entry type. */
  398. uint8_t entry_count; /* Entry count. */
  399. uint8_t data[58];
  400. uint32_t signature;
  401. #define ATIO_PROCESSED 0xDEADDEAD /* Signature */
  402. } raw;
  403. } u;
  404. } __packed;
  405. #define CTIO_TYPE7 0x12 /* Continue target I/O entry (for 24xx) */
  406. /*
  407. * ISP queue - Continue Target I/O (ATIO) type 7 entry (for 24xx) structure.
  408. * This structure is sent to the ISP 24xx from the target driver.
  409. */
  410. struct ctio7_to_24xx {
  411. uint8_t entry_type; /* Entry type. */
  412. uint8_t entry_count; /* Entry count. */
  413. uint8_t sys_define; /* System defined. */
  414. uint8_t entry_status; /* Entry Status. */
  415. uint32_t handle; /* System defined handle */
  416. uint16_t nport_handle;
  417. #define CTIO7_NHANDLE_UNRECOGNIZED 0xFFFF
  418. uint16_t timeout;
  419. uint16_t dseg_count; /* Data segment count. */
  420. uint8_t vp_index;
  421. uint8_t add_flags;
  422. uint8_t initiator_id[3];
  423. uint8_t reserved;
  424. uint32_t exchange_addr;
  425. union {
  426. struct {
  427. uint16_t reserved1;
  428. __le16 flags;
  429. uint32_t residual;
  430. __le16 ox_id;
  431. uint16_t scsi_status;
  432. uint32_t relative_offset;
  433. uint32_t reserved2;
  434. uint32_t transfer_length;
  435. uint32_t reserved3;
  436. /* Data segment 0 address. */
  437. uint32_t dseg_0_address[2];
  438. /* Data segment 0 length. */
  439. uint32_t dseg_0_length;
  440. } status0;
  441. struct {
  442. uint16_t sense_length;
  443. uint16_t flags;
  444. uint32_t residual;
  445. __le16 ox_id;
  446. uint16_t scsi_status;
  447. uint16_t response_len;
  448. uint16_t reserved;
  449. uint8_t sense_data[24];
  450. } status1;
  451. } u;
  452. } __packed;
  453. /*
  454. * ISP queue - CTIO type 7 from ISP 24xx to target driver
  455. * returned entry structure.
  456. */
  457. struct ctio7_from_24xx {
  458. uint8_t entry_type; /* Entry type. */
  459. uint8_t entry_count; /* Entry count. */
  460. uint8_t sys_define; /* System defined. */
  461. uint8_t entry_status; /* Entry Status. */
  462. uint32_t handle; /* System defined handle */
  463. uint16_t status;
  464. uint16_t timeout;
  465. uint16_t dseg_count; /* Data segment count. */
  466. uint8_t vp_index;
  467. uint8_t reserved1[5];
  468. uint32_t exchange_address;
  469. uint16_t reserved2;
  470. uint16_t flags;
  471. uint32_t residual;
  472. uint16_t ox_id;
  473. uint16_t reserved3;
  474. uint32_t relative_offset;
  475. uint8_t reserved4[24];
  476. } __packed;
  477. /* CTIO7 flags values */
  478. #define CTIO7_FLAGS_SEND_STATUS BIT_15
  479. #define CTIO7_FLAGS_TERMINATE BIT_14
  480. #define CTIO7_FLAGS_CONFORM_REQ BIT_13
  481. #define CTIO7_FLAGS_DONT_RET_CTIO BIT_8
  482. #define CTIO7_FLAGS_STATUS_MODE_0 0
  483. #define CTIO7_FLAGS_STATUS_MODE_1 BIT_6
  484. #define CTIO7_FLAGS_STATUS_MODE_2 BIT_7
  485. #define CTIO7_FLAGS_EXPLICIT_CONFORM BIT_5
  486. #define CTIO7_FLAGS_CONFIRM_SATISF BIT_4
  487. #define CTIO7_FLAGS_DSD_PTR BIT_2
  488. #define CTIO7_FLAGS_DATA_IN BIT_1 /* data to initiator */
  489. #define CTIO7_FLAGS_DATA_OUT BIT_0 /* data from initiator */
  490. #define ELS_PLOGI 0x3
  491. #define ELS_FLOGI 0x4
  492. #define ELS_LOGO 0x5
  493. #define ELS_PRLI 0x20
  494. #define ELS_PRLO 0x21
  495. #define ELS_TPRLO 0x24
  496. #define ELS_PDISC 0x50
  497. #define ELS_ADISC 0x52
  498. /*
  499. *CTIO Type CRC_2 IOCB
  500. */
  501. struct ctio_crc2_to_fw {
  502. uint8_t entry_type; /* Entry type. */
  503. #define CTIO_CRC2 0x7A
  504. uint8_t entry_count; /* Entry count. */
  505. uint8_t sys_define; /* System defined. */
  506. uint8_t entry_status; /* Entry Status. */
  507. uint32_t handle; /* System handle. */
  508. uint16_t nport_handle; /* N_PORT handle. */
  509. __le16 timeout; /* Command timeout. */
  510. uint16_t dseg_count; /* Data segment count. */
  511. uint8_t vp_index;
  512. uint8_t add_flags; /* additional flags */
  513. #define CTIO_CRC2_AF_DIF_DSD_ENA BIT_3
  514. uint8_t initiator_id[3]; /* initiator ID */
  515. uint8_t reserved1;
  516. uint32_t exchange_addr; /* rcv exchange address */
  517. uint16_t reserved2;
  518. __le16 flags; /* refer to CTIO7 flags values */
  519. uint32_t residual;
  520. __le16 ox_id;
  521. uint16_t scsi_status;
  522. __le32 relative_offset;
  523. uint32_t reserved5;
  524. __le32 transfer_length; /* total fc transfer length */
  525. uint32_t reserved6;
  526. __le32 crc_context_address[2];/* Data segment address. */
  527. uint16_t crc_context_len; /* Data segment length. */
  528. uint16_t reserved_1; /* MUST be set to 0. */
  529. } __packed;
  530. /* CTIO Type CRC_x Status IOCB */
  531. struct ctio_crc_from_fw {
  532. uint8_t entry_type; /* Entry type. */
  533. uint8_t entry_count; /* Entry count. */
  534. uint8_t sys_define; /* System defined. */
  535. uint8_t entry_status; /* Entry Status. */
  536. uint32_t handle; /* System handle. */
  537. uint16_t status;
  538. uint16_t timeout; /* Command timeout. */
  539. uint16_t dseg_count; /* Data segment count. */
  540. uint32_t reserved1;
  541. uint16_t state_flags;
  542. #define CTIO_CRC_SF_DIF_CHOPPED BIT_4
  543. uint32_t exchange_address; /* rcv exchange address */
  544. uint16_t reserved2;
  545. uint16_t flags;
  546. uint32_t resid_xfer_length;
  547. uint16_t ox_id;
  548. uint8_t reserved3[12];
  549. uint16_t runt_guard; /* reported runt blk guard */
  550. uint8_t actual_dif[8];
  551. uint8_t expected_dif[8];
  552. } __packed;
  553. /*
  554. * ISP queue - ABTS received/response entries structure definition for 24xx.
  555. */
  556. #define ABTS_RECV_24XX 0x54 /* ABTS received (for 24xx) */
  557. #define ABTS_RESP_24XX 0x55 /* ABTS responce (for 24xx) */
  558. /*
  559. * ISP queue - ABTS received IOCB entry structure definition for 24xx.
  560. * The ABTS BLS received from the wire is sent to the
  561. * target driver by the ISP 24xx.
  562. * The IOCB is placed on the response queue.
  563. */
  564. struct abts_recv_from_24xx {
  565. uint8_t entry_type; /* Entry type. */
  566. uint8_t entry_count; /* Entry count. */
  567. uint8_t sys_define; /* System defined. */
  568. uint8_t entry_status; /* Entry Status. */
  569. uint8_t reserved_1[6];
  570. uint16_t nport_handle;
  571. uint8_t reserved_2[2];
  572. uint8_t vp_index;
  573. uint8_t reserved_3:4;
  574. uint8_t sof_type:4;
  575. uint32_t exchange_address;
  576. struct fcp_hdr_le fcp_hdr_le;
  577. uint8_t reserved_4[16];
  578. uint32_t exchange_addr_to_abort;
  579. } __packed;
  580. #define ABTS_PARAM_ABORT_SEQ BIT_0
  581. struct ba_acc_le {
  582. uint16_t reserved;
  583. uint8_t seq_id_last;
  584. uint8_t seq_id_valid;
  585. #define SEQ_ID_VALID 0x80
  586. #define SEQ_ID_INVALID 0x00
  587. uint16_t rx_id;
  588. uint16_t ox_id;
  589. uint16_t high_seq_cnt;
  590. uint16_t low_seq_cnt;
  591. } __packed;
  592. struct ba_rjt_le {
  593. uint8_t vendor_uniq;
  594. uint8_t reason_expl;
  595. uint8_t reason_code;
  596. #define BA_RJT_REASON_CODE_INVALID_COMMAND 0x1
  597. #define BA_RJT_REASON_CODE_UNABLE_TO_PERFORM 0x9
  598. uint8_t reserved;
  599. } __packed;
  600. /*
  601. * ISP queue - ABTS Response IOCB entry structure definition for 24xx.
  602. * The ABTS response to the ABTS received is sent by the
  603. * target driver to the ISP 24xx.
  604. * The IOCB is placed on the request queue.
  605. */
  606. struct abts_resp_to_24xx {
  607. uint8_t entry_type; /* Entry type. */
  608. uint8_t entry_count; /* Entry count. */
  609. uint8_t sys_define; /* System defined. */
  610. uint8_t entry_status; /* Entry Status. */
  611. uint32_t handle;
  612. uint16_t reserved_1;
  613. uint16_t nport_handle;
  614. uint16_t control_flags;
  615. #define ABTS_CONTR_FLG_TERM_EXCHG BIT_0
  616. uint8_t vp_index;
  617. uint8_t reserved_3:4;
  618. uint8_t sof_type:4;
  619. uint32_t exchange_address;
  620. struct fcp_hdr_le fcp_hdr_le;
  621. union {
  622. struct ba_acc_le ba_acct;
  623. struct ba_rjt_le ba_rjt;
  624. } __packed payload;
  625. uint32_t reserved_4;
  626. uint32_t exchange_addr_to_abort;
  627. } __packed;
  628. /*
  629. * ISP queue - ABTS Response IOCB from ISP24xx Firmware entry structure.
  630. * The ABTS response with completion status to the ABTS response
  631. * (sent by the target driver to the ISP 24xx) is sent by the
  632. * ISP24xx firmware to the target driver.
  633. * The IOCB is placed on the response queue.
  634. */
  635. struct abts_resp_from_24xx_fw {
  636. uint8_t entry_type; /* Entry type. */
  637. uint8_t entry_count; /* Entry count. */
  638. uint8_t sys_define; /* System defined. */
  639. uint8_t entry_status; /* Entry Status. */
  640. uint32_t handle;
  641. uint16_t compl_status;
  642. #define ABTS_RESP_COMPL_SUCCESS 0
  643. #define ABTS_RESP_COMPL_SUBCODE_ERROR 0x31
  644. uint16_t nport_handle;
  645. uint16_t reserved_1;
  646. uint8_t reserved_2;
  647. uint8_t reserved_3:4;
  648. uint8_t sof_type:4;
  649. uint32_t exchange_address;
  650. struct fcp_hdr_le fcp_hdr_le;
  651. uint8_t reserved_4[8];
  652. uint32_t error_subcode1;
  653. #define ABTS_RESP_SUBCODE_ERR_ABORTED_EXCH_NOT_TERM 0x1E
  654. uint32_t error_subcode2;
  655. uint32_t exchange_addr_to_abort;
  656. } __packed;
  657. /********************************************************************\
  658. * Type Definitions used by initiator & target halves
  659. \********************************************************************/
  660. struct qla_tgt_mgmt_cmd;
  661. struct qla_tgt_sess;
  662. /*
  663. * This structure provides a template of function calls that the
  664. * target driver (from within qla_target.c) can issue to the
  665. * target module (tcm_qla2xxx).
  666. */
  667. struct qla_tgt_func_tmpl {
  668. int (*handle_cmd)(struct scsi_qla_host *, struct qla_tgt_cmd *,
  669. unsigned char *, uint32_t, int, int, int);
  670. void (*handle_data)(struct qla_tgt_cmd *);
  671. void (*handle_dif_err)(struct qla_tgt_cmd *);
  672. int (*handle_tmr)(struct qla_tgt_mgmt_cmd *, uint32_t, uint8_t,
  673. uint32_t);
  674. void (*free_cmd)(struct qla_tgt_cmd *);
  675. void (*free_mcmd)(struct qla_tgt_mgmt_cmd *);
  676. void (*free_session)(struct qla_tgt_sess *);
  677. int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *,
  678. struct qla_tgt_sess *);
  679. void (*update_sess)(struct qla_tgt_sess *, port_id_t, uint16_t, bool);
  680. struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *,
  681. const uint16_t);
  682. struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *,
  683. const uint8_t *);
  684. void (*clear_nacl_from_fcport_map)(struct qla_tgt_sess *);
  685. void (*shutdown_sess)(struct qla_tgt_sess *);
  686. };
  687. int qla2x00_wait_for_hba_online(struct scsi_qla_host *);
  688. #include <target/target_core_base.h>
  689. #define QLA_TGT_TIMEOUT 10 /* in seconds */
  690. #define QLA_TGT_MAX_HW_PENDING_TIME 60 /* in seconds */
  691. /* Immediate notify status constants */
  692. #define IMM_NTFY_LIP_RESET 0x000E
  693. #define IMM_NTFY_LIP_LINK_REINIT 0x000F
  694. #define IMM_NTFY_IOCB_OVERFLOW 0x0016
  695. #define IMM_NTFY_ABORT_TASK 0x0020
  696. #define IMM_NTFY_PORT_LOGOUT 0x0029
  697. #define IMM_NTFY_PORT_CONFIG 0x002A
  698. #define IMM_NTFY_GLBL_TPRLO 0x002D
  699. #define IMM_NTFY_GLBL_LOGO 0x002E
  700. #define IMM_NTFY_RESOURCE 0x0034
  701. #define IMM_NTFY_MSG_RX 0x0036
  702. #define IMM_NTFY_SRR 0x0045
  703. #define IMM_NTFY_ELS 0x0046
  704. /* Immediate notify task flags */
  705. #define IMM_NTFY_TASK_MGMT_SHIFT 8
  706. #define QLA_TGT_CLEAR_ACA 0x40
  707. #define QLA_TGT_TARGET_RESET 0x20
  708. #define QLA_TGT_LUN_RESET 0x10
  709. #define QLA_TGT_CLEAR_TS 0x04
  710. #define QLA_TGT_ABORT_TS 0x02
  711. #define QLA_TGT_ABORT_ALL_SESS 0xFFFF
  712. #define QLA_TGT_ABORT_ALL 0xFFFE
  713. #define QLA_TGT_NEXUS_LOSS_SESS 0xFFFD
  714. #define QLA_TGT_NEXUS_LOSS 0xFFFC
  715. /* Notify Acknowledge flags */
  716. #define NOTIFY_ACK_RES_COUNT BIT_8
  717. #define NOTIFY_ACK_CLEAR_LIP_RESET BIT_5
  718. #define NOTIFY_ACK_TM_RESP_CODE_VALID BIT_4
  719. /* Command's states */
  720. #define QLA_TGT_STATE_NEW 0 /* New command + target processing */
  721. #define QLA_TGT_STATE_NEED_DATA 1 /* target needs data to continue */
  722. #define QLA_TGT_STATE_DATA_IN 2 /* Data arrived + target processing */
  723. #define QLA_TGT_STATE_PROCESSED 3 /* target done processing */
  724. /* Special handles */
  725. #define QLA_TGT_NULL_HANDLE 0
  726. #define QLA_TGT_SKIP_HANDLE (0xFFFFFFFF & ~CTIO_COMPLETION_HANDLE_MARK)
  727. /* ATIO task_codes field */
  728. #define ATIO_SIMPLE_QUEUE 0
  729. #define ATIO_HEAD_OF_QUEUE 1
  730. #define ATIO_ORDERED_QUEUE 2
  731. #define ATIO_ACA_QUEUE 4
  732. #define ATIO_UNTAGGED 5
  733. /* TM failed response codes, see FCP (9.4.11 FCP_RSP_INFO) */
  734. #define FC_TM_SUCCESS 0
  735. #define FC_TM_BAD_FCP_DATA 1
  736. #define FC_TM_BAD_CMD 2
  737. #define FC_TM_FCP_DATA_MISMATCH 3
  738. #define FC_TM_REJECT 4
  739. #define FC_TM_FAILED 5
  740. #if (BITS_PER_LONG > 32) || defined(CONFIG_HIGHMEM64G)
  741. #define pci_dma_lo32(a) (a & 0xffffffff)
  742. #define pci_dma_hi32(a) ((((a) >> 16)>>16) & 0xffffffff)
  743. #else
  744. #define pci_dma_lo32(a) (a & 0xffffffff)
  745. #define pci_dma_hi32(a) 0
  746. #endif
  747. #define QLA_TGT_SENSE_VALID(sense) ((sense != NULL) && \
  748. (((const uint8_t *)(sense))[0] & 0x70) == 0x70)
  749. struct qla_port_24xx_data {
  750. uint8_t port_name[WWN_SIZE];
  751. uint16_t loop_id;
  752. uint16_t reserved;
  753. };
  754. struct qla_tgt {
  755. struct scsi_qla_host *vha;
  756. struct qla_hw_data *ha;
  757. /*
  758. * To sync between IRQ handlers and qlt_target_release(). Needed,
  759. * because req_pkt() can drop/reaquire HW lock inside. Protected by
  760. * HW lock.
  761. */
  762. int irq_cmd_count;
  763. int atio_irq_cmd_count;
  764. int datasegs_per_cmd, datasegs_per_cont, sg_tablesize;
  765. /* Target's flags, serialized by pha->hardware_lock */
  766. unsigned int tgt_enable_64bit_addr:1; /* 64-bits PCI addr enabled */
  767. unsigned int link_reinit_iocb_pending:1;
  768. /*
  769. * Protected by tgt_mutex AND hardware_lock for writing and tgt_mutex
  770. * OR hardware_lock for reading.
  771. */
  772. int tgt_stop; /* the target mode driver is being stopped */
  773. int tgt_stopped; /* the target mode driver has been stopped */
  774. /* Count of sessions refering qla_tgt. Protected by hardware_lock. */
  775. int sess_count;
  776. /* Protected by hardware_lock. Addition also protected by tgt_mutex. */
  777. struct list_head sess_list;
  778. /* Protected by hardware_lock */
  779. struct list_head del_sess_list;
  780. struct delayed_work sess_del_work;
  781. spinlock_t sess_work_lock;
  782. struct list_head sess_works_list;
  783. struct work_struct sess_work;
  784. struct imm_ntfy_from_isp link_reinit_iocb;
  785. wait_queue_head_t waitQ;
  786. int notify_ack_expected;
  787. int abts_resp_expected;
  788. int modify_lun_expected;
  789. int ctio_srr_id;
  790. int imm_srr_id;
  791. spinlock_t srr_lock;
  792. struct list_head srr_ctio_list;
  793. struct list_head srr_imm_list;
  794. struct work_struct srr_work;
  795. atomic_t tgt_global_resets_count;
  796. struct list_head tgt_list_entry;
  797. };
  798. struct qla_tgt_sess_op {
  799. struct scsi_qla_host *vha;
  800. uint32_t chip_reset;
  801. struct atio_from_isp atio;
  802. struct work_struct work;
  803. struct list_head cmd_list;
  804. bool aborted;
  805. };
  806. enum qla_sess_deletion {
  807. QLA_SESS_DELETION_NONE = 0,
  808. QLA_SESS_DELETION_PENDING = 1, /* hopefully we can get rid of
  809. * this one */
  810. QLA_SESS_DELETION_IN_PROGRESS = 2,
  811. };
  812. typedef enum {
  813. QLT_PLOGI_LINK_SAME_WWN,
  814. QLT_PLOGI_LINK_CONFLICT,
  815. QLT_PLOGI_LINK_MAX
  816. } qlt_plogi_link_t;
  817. typedef struct {
  818. struct list_head list;
  819. struct imm_ntfy_from_isp iocb;
  820. port_id_t id;
  821. int ref_count;
  822. } qlt_plogi_ack_t;
  823. /*
  824. * Equivilant to IT Nexus (Initiator-Target)
  825. */
  826. struct qla_tgt_sess {
  827. uint16_t loop_id;
  828. port_id_t s_id;
  829. unsigned int conf_compl_supported:1;
  830. unsigned int deleted:2;
  831. unsigned int local:1;
  832. unsigned int logout_on_delete:1;
  833. unsigned int keep_nport_handle:1;
  834. unsigned int send_els_logo:1;
  835. unsigned char logout_completed;
  836. int generation;
  837. struct se_session *se_sess;
  838. struct kref sess_kref;
  839. struct scsi_qla_host *vha;
  840. struct qla_tgt *tgt;
  841. struct list_head sess_list_entry;
  842. unsigned long expires;
  843. struct list_head del_list_entry;
  844. uint8_t port_name[WWN_SIZE];
  845. struct work_struct free_work;
  846. qlt_plogi_ack_t *plogi_link[QLT_PLOGI_LINK_MAX];
  847. };
  848. typedef enum {
  849. /*
  850. * BIT_0 - Atio Arrival / schedule to work
  851. * BIT_1 - qlt_do_work
  852. * BIT_2 - qlt_do work failed
  853. * BIT_3 - xfer rdy/tcm_qla2xxx_write_pending
  854. * BIT_4 - read respond/tcm_qla2xx_queue_data_in
  855. * BIT_5 - status respond / tcm_qla2xx_queue_status
  856. * BIT_6 - tcm request to abort/Term exchange.
  857. * pre_xmit_response->qlt_send_term_exchange
  858. * BIT_7 - SRR received (qlt_handle_srr->qlt_xmit_response)
  859. * BIT_8 - SRR received (qlt_handle_srr->qlt_rdy_to_xfer)
  860. * BIT_9 - SRR received (qla_handle_srr->qlt_send_term_exchange)
  861. * BIT_10 - Data in - hanlde_data->tcm_qla2xxx_handle_data
  862. * BIT_12 - good completion - qlt_ctio_do_completion -->free_cmd
  863. * BIT_13 - Bad completion -
  864. * qlt_ctio_do_completion --> qlt_term_ctio_exchange
  865. * BIT_14 - Back end data received/sent.
  866. * BIT_15 - SRR prepare ctio
  867. * BIT_16 - complete free
  868. * BIT_17 - flush - qlt_abort_cmd_on_host_reset
  869. * BIT_18 - completion w/abort status
  870. * BIT_19 - completion w/unknown status
  871. * BIT_20 - tcm_qla2xxx_free_cmd
  872. */
  873. CMD_FLAG_DATA_WORK = BIT_11,
  874. CMD_FLAG_DATA_WORK_FREE = BIT_21,
  875. } cmd_flags_t;
  876. struct qla_tgt_cmd {
  877. struct se_cmd se_cmd;
  878. struct qla_tgt_sess *sess;
  879. int state;
  880. struct work_struct free_work;
  881. struct work_struct work;
  882. /* Sense buffer that will be mapped into outgoing status */
  883. unsigned char sense_buffer[TRANSPORT_SENSE_BUFFER];
  884. spinlock_t cmd_lock;
  885. /* to save extra sess dereferences */
  886. unsigned int conf_compl_supported:1;
  887. unsigned int sg_mapped:1;
  888. unsigned int free_sg:1;
  889. unsigned int write_data_transferred:1;
  890. unsigned int ctx_dsd_alloced:1;
  891. unsigned int q_full:1;
  892. unsigned int term_exchg:1;
  893. unsigned int cmd_sent_to_fw:1;
  894. unsigned int cmd_in_wq:1;
  895. unsigned int aborted:1;
  896. struct scatterlist *sg; /* cmd data buffer SG vector */
  897. int sg_cnt; /* SG segments count */
  898. int bufflen; /* cmd buffer length */
  899. int offset;
  900. uint32_t unpacked_lun;
  901. enum dma_data_direction dma_data_direction;
  902. uint32_t reset_count;
  903. uint16_t loop_id; /* to save extra sess dereferences */
  904. struct qla_tgt *tgt; /* to save extra sess dereferences */
  905. struct scsi_qla_host *vha;
  906. struct list_head cmd_list;
  907. struct atio_from_isp atio;
  908. /* t10dif */
  909. struct scatterlist *prot_sg;
  910. uint32_t prot_sg_cnt;
  911. uint32_t blk_sz;
  912. struct crc_context *ctx;
  913. uint64_t jiffies_at_alloc;
  914. uint64_t jiffies_at_free;
  915. cmd_flags_t cmd_flags;
  916. };
  917. struct qla_tgt_sess_work_param {
  918. struct list_head sess_works_list_entry;
  919. #define QLA_TGT_SESS_WORK_ABORT 1
  920. #define QLA_TGT_SESS_WORK_TM 2
  921. int type;
  922. union {
  923. struct abts_recv_from_24xx abts;
  924. struct imm_ntfy_from_isp tm_iocb;
  925. struct atio_from_isp tm_iocb2;
  926. };
  927. };
  928. struct qla_tgt_mgmt_cmd {
  929. uint8_t tmr_func;
  930. uint8_t fc_tm_rsp;
  931. struct qla_tgt_sess *sess;
  932. struct se_cmd se_cmd;
  933. struct work_struct free_work;
  934. unsigned int flags;
  935. uint32_t reset_count;
  936. #define QLA24XX_MGMT_SEND_NACK 1
  937. union {
  938. struct atio_from_isp atio;
  939. struct imm_ntfy_from_isp imm_ntfy;
  940. struct abts_recv_from_24xx abts;
  941. } __packed orig_iocb;
  942. };
  943. struct qla_tgt_prm {
  944. struct qla_tgt_cmd *cmd;
  945. struct qla_tgt *tgt;
  946. void *pkt;
  947. struct scatterlist *sg; /* cmd data buffer SG vector */
  948. unsigned char *sense_buffer;
  949. int seg_cnt;
  950. int req_cnt;
  951. uint16_t rq_result;
  952. uint16_t scsi_status;
  953. int sense_buffer_len;
  954. int residual;
  955. int add_status_pkt;
  956. /* dif */
  957. struct scatterlist *prot_sg;
  958. uint16_t prot_seg_cnt;
  959. uint16_t tot_dsds;
  960. };
  961. struct qla_tgt_srr_imm {
  962. struct list_head srr_list_entry;
  963. int srr_id;
  964. struct imm_ntfy_from_isp imm_ntfy;
  965. };
  966. struct qla_tgt_srr_ctio {
  967. struct list_head srr_list_entry;
  968. int srr_id;
  969. struct qla_tgt_cmd *cmd;
  970. };
  971. /* Check for Switch reserved address */
  972. #define IS_SW_RESV_ADDR(_s_id) \
  973. ((_s_id.b.domain == 0xff) && (_s_id.b.area == 0xfc))
  974. #define QLA_TGT_XMIT_DATA 1
  975. #define QLA_TGT_XMIT_STATUS 2
  976. #define QLA_TGT_XMIT_ALL (QLA_TGT_XMIT_STATUS|QLA_TGT_XMIT_DATA)
  977. extern struct qla_tgt_data qla_target;
  978. /*
  979. * Function prototypes for qla_target.c logic used by qla2xxx LLD code.
  980. */
  981. extern int qlt_add_target(struct qla_hw_data *, struct scsi_qla_host *);
  982. extern int qlt_remove_target(struct qla_hw_data *, struct scsi_qla_host *);
  983. extern int qlt_lport_register(void *, u64, u64, u64,
  984. int (*callback)(struct scsi_qla_host *, void *, u64, u64));
  985. extern void qlt_lport_deregister(struct scsi_qla_host *);
  986. void qlt_put_sess(struct qla_tgt_sess *sess);
  987. extern void qlt_fc_port_added(struct scsi_qla_host *, fc_port_t *);
  988. extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *, int);
  989. extern int __init qlt_init(void);
  990. extern void qlt_exit(void);
  991. extern void qlt_update_vp_map(struct scsi_qla_host *, int);
  992. /*
  993. * This macro is used during early initializations when host->active_mode
  994. * is not set. Right now, ha value is ignored.
  995. */
  996. #define QLA_TGT_MODE_ENABLED() (ql2x_ini_mode != QLA2XXX_INI_MODE_ENABLED)
  997. extern int ql2x_ini_mode;
  998. static inline bool qla_tgt_mode_enabled(struct scsi_qla_host *ha)
  999. {
  1000. return ha->host->active_mode & MODE_TARGET;
  1001. }
  1002. static inline bool qla_ini_mode_enabled(struct scsi_qla_host *ha)
  1003. {
  1004. return ha->host->active_mode & MODE_INITIATOR;
  1005. }
  1006. static inline void qla_reverse_ini_mode(struct scsi_qla_host *ha)
  1007. {
  1008. if (ha->host->active_mode & MODE_INITIATOR)
  1009. ha->host->active_mode &= ~MODE_INITIATOR;
  1010. else
  1011. ha->host->active_mode |= MODE_INITIATOR;
  1012. }
  1013. static inline uint32_t sid_to_key(const uint8_t *s_id)
  1014. {
  1015. uint32_t key;
  1016. key = (((unsigned long)s_id[0] << 16) |
  1017. ((unsigned long)s_id[1] << 8) |
  1018. (unsigned long)s_id[2]);
  1019. return key;
  1020. }
  1021. static inline void sid_to_portid(const uint8_t *s_id, port_id_t *p)
  1022. {
  1023. memset(p, 0, sizeof(*p));
  1024. p->b.domain = s_id[0];
  1025. p->b.area = s_id[1];
  1026. p->b.al_pa = s_id[2];
  1027. }
  1028. /*
  1029. * Exported symbols from qla_target.c LLD logic used by qla2xxx code..
  1030. */
  1031. extern void qlt_response_pkt_all_vps(struct scsi_qla_host *, response_t *);
  1032. extern int qlt_rdy_to_xfer(struct qla_tgt_cmd *);
  1033. extern int qlt_xmit_response(struct qla_tgt_cmd *, int, uint8_t);
  1034. extern int qlt_abort_cmd(struct qla_tgt_cmd *);
  1035. extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *);
  1036. extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *);
  1037. extern void qlt_free_cmd(struct qla_tgt_cmd *cmd);
  1038. extern void qlt_async_event(uint16_t, struct scsi_qla_host *, uint16_t *);
  1039. extern void qlt_enable_vha(struct scsi_qla_host *);
  1040. extern void qlt_vport_create(struct scsi_qla_host *, struct qla_hw_data *);
  1041. extern void qlt_rff_id(struct scsi_qla_host *, struct ct_sns_req *);
  1042. extern void qlt_init_atio_q_entries(struct scsi_qla_host *);
  1043. extern void qlt_24xx_process_atio_queue(struct scsi_qla_host *, uint8_t);
  1044. extern void qlt_24xx_config_rings(struct scsi_qla_host *);
  1045. extern void qlt_24xx_config_nvram_stage1(struct scsi_qla_host *,
  1046. struct nvram_24xx *);
  1047. extern void qlt_24xx_config_nvram_stage2(struct scsi_qla_host *,
  1048. struct init_cb_24xx *);
  1049. extern void qlt_81xx_config_nvram_stage2(struct scsi_qla_host *,
  1050. struct init_cb_81xx *);
  1051. extern void qlt_81xx_config_nvram_stage1(struct scsi_qla_host *,
  1052. struct nvram_81xx *);
  1053. extern int qlt_24xx_process_response_error(struct scsi_qla_host *,
  1054. struct sts_entry_24xx *);
  1055. extern void qlt_modify_vp_config(struct scsi_qla_host *,
  1056. struct vp_config_entry_24xx *);
  1057. extern void qlt_probe_one_stage1(struct scsi_qla_host *, struct qla_hw_data *);
  1058. extern int qlt_mem_alloc(struct qla_hw_data *);
  1059. extern void qlt_mem_free(struct qla_hw_data *);
  1060. extern int qlt_stop_phase1(struct qla_tgt *);
  1061. extern void qlt_stop_phase2(struct qla_tgt *);
  1062. extern irqreturn_t qla83xx_msix_atio_q(int, void *);
  1063. extern void qlt_83xx_iospace_config(struct qla_hw_data *);
  1064. extern int qlt_free_qfull_cmds(struct scsi_qla_host *);
  1065. extern void qlt_logo_completion_handler(fc_port_t *, int);
  1066. extern void qlt_do_generation_tick(struct scsi_qla_host *, int *);
  1067. #endif /* __QLA_TARGET_H */