Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
qla_target.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2004 - 2010 Vladislav Bolkhovitin <[email protected]>
3  * Copyright (C) 2004 - 2005 Leonid Stoljar
4  * Copyright (C) 2006 Nathaniel Clark <[email protected]>
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 <[email protected]>
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 
28 #ifndef __QLA_TARGET_H
29 #define __QLA_TARGET_H
30 
31 #include "qla_def.h"
32 
33 /*
34  * Must be changed on any change in any initiator visible interfaces or
35  * data in the target add-on
36  */
37 #define QLA2XXX_TARGET_MAGIC 269
38 
39 /*
40  * Must be changed on any change in any target visible interfaces or
41  * data in the initiator
42  */
43 #define QLA2XXX_INITIATOR_MAGIC 57222
44 
45 #define QLA2XXX_INI_MODE_STR_EXCLUSIVE "exclusive"
46 #define QLA2XXX_INI_MODE_STR_DISABLED "disabled"
47 #define QLA2XXX_INI_MODE_STR_ENABLED "enabled"
48 
49 #define QLA2XXX_INI_MODE_EXCLUSIVE 0
50 #define QLA2XXX_INI_MODE_DISABLED 1
51 #define QLA2XXX_INI_MODE_ENABLED 2
52 
53 #define QLA2XXX_COMMAND_COUNT_INIT 250
54 #define QLA2XXX_IMMED_NOTIFY_COUNT_INIT 250
55 
56 /*
57  * Used to mark which completion handles (for RIO Status's) are for CTIO's
58  * vs. regular (non-target) info. This is checked for in
59  * qla2x00_process_response_queue() to see if a handle coming back in a
60  * multi-complete should come to the tgt driver or be handled there by qla2xxx
61  */
62 #define CTIO_COMPLETION_HANDLE_MARK BIT_29
63 #if (CTIO_COMPLETION_HANDLE_MARK <= MAX_OUTSTANDING_COMMANDS)
64 #error "CTIO_COMPLETION_HANDLE_MARK not larger than MAX_OUTSTANDING_COMMANDS"
65 #endif
66 #define HANDLE_IS_CTIO_COMP(h) (h & CTIO_COMPLETION_HANDLE_MARK)
67 
68 /* Used to mark CTIO as intermediate */
69 #define CTIO_INTERMEDIATE_HANDLE_MARK BIT_30
70 
71 #ifndef OF_SS_MODE_0
72 /*
73  * ISP target entries - Flags bit definitions.
74  */
75 #define OF_SS_MODE_0 0
76 #define OF_SS_MODE_1 1
77 #define OF_SS_MODE_2 2
78 #define OF_SS_MODE_3 3
79 
80 #define OF_EXPL_CONF BIT_5 /* Explicit Confirmation Requested */
81 #define OF_DATA_IN BIT_6 /* Data in to initiator */
82  /* (data from target to initiator) */
83 #define OF_DATA_OUT BIT_7 /* Data out from initiator */
84  /* (data from initiator to target) */
85 #define OF_NO_DATA (BIT_7 | BIT_6)
86 #define OF_INC_RC BIT_8 /* Increment command resource count */
87 #define OF_FAST_POST BIT_9 /* Enable mailbox fast posting. */
88 #define OF_CONF_REQ BIT_13 /* Confirmation Requested */
89 #define OF_TERM_EXCH BIT_14 /* Terminate exchange */
90 #define OF_SSTS BIT_15 /* Send SCSI status */
91 #endif
92 
93 #ifndef QLA_TGT_DATASEGS_PER_CMD32
94 #define QLA_TGT_DATASEGS_PER_CMD32 3
95 #define QLA_TGT_DATASEGS_PER_CONT32 7
96 #define QLA_TGT_MAX_SG32(ql) \
97  (((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD32 + \
98  QLA_TGT_DATASEGS_PER_CONT32*((ql) - 1)) : 0)
99 
100 #define QLA_TGT_DATASEGS_PER_CMD64 2
101 #define QLA_TGT_DATASEGS_PER_CONT64 5
102 #define QLA_TGT_MAX_SG64(ql) \
103  (((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD64 + \
104  QLA_TGT_DATASEGS_PER_CONT64*((ql) - 1)) : 0)
105 #endif
106 
107 #ifndef QLA_TGT_DATASEGS_PER_CMD_24XX
108 #define QLA_TGT_DATASEGS_PER_CMD_24XX 1
109 #define QLA_TGT_DATASEGS_PER_CONT_24XX 5
110 #define QLA_TGT_MAX_SG_24XX(ql) \
111  (min(1270, ((ql) > 0) ? (QLA_TGT_DATASEGS_PER_CMD_24XX + \
112  QLA_TGT_DATASEGS_PER_CONT_24XX*((ql) - 1)) : 0))
113 #endif
114 #endif
115 
116 #define GET_TARGET_ID(ha, iocb) ((HAS_EXTENDED_IDS(ha)) \
117  ? le16_to_cpu((iocb)->u.isp2x.target.extended) \
118  : (uint16_t)(iocb)->u.isp2x.target.id.standard)
119 
120 #ifndef IMMED_NOTIFY_TYPE
121 #define IMMED_NOTIFY_TYPE 0x0D /* Immediate notify entry. */
122 /*
123  * ISP queue - immediate notify entry structure definition.
124  * This is sent by the ISP to the Target driver.
125  * This IOCB would have report of events sent by the
126  * initiator, that needs to be handled by the target
127  * driver immediately.
128  */
130  uint8_t entry_type; /* Entry type. */
131  uint8_t entry_count; /* Entry count. */
132  uint8_t sys_define; /* System defined. */
133  uint8_t entry_status; /* Entry Status. */
134  union {
135  struct {
136  uint32_t sys_define_2; /* System defined. */
148 #define SRR_IU_DATA_IN 0x1
149 #define SRR_IU_DATA_OUT 0x5
150 #define SRR_IU_STATUS 0x7
153  } isp2x;
154  struct {
159 #define NOTIFY24XX_FLAGS_GLOBAL_TPRLO BIT_1
160 #define NOTIFY24XX_FLAGS_PUREX_IOCB BIT_0
174  } isp24;
175  } u;
178 } __packed;
179 #endif
180 
181 #ifndef NOTIFY_ACK_TYPE
182 #define NOTIFY_ACK_TYPE 0x0E /* Notify acknowledge entry. */
183 /*
184  * ISP queue - notify acknowledge entry structure definition.
185  * This is sent to the ISP from the target driver.
186  */
187 struct nack_to_isp {
188  uint8_t entry_type; /* Entry type. */
189  uint8_t entry_count; /* Entry count. */
190  uint8_t sys_define; /* System defined. */
191  uint8_t entry_status; /* Entry Status. */
192  union {
193  struct {
194  uint32_t sys_define_2; /* System defined. */
211  } isp2x;
212  struct {
216  uint16_t flags;
231  } isp24;
232  } u;
235 } __packed;
236 #define NOTIFY_ACK_SRR_FLAGS_ACCEPT 0
237 #define NOTIFY_ACK_SRR_FLAGS_REJECT 1
238 
239 #define NOTIFY_ACK_SRR_REJECT_REASON_UNABLE_TO_PERFORM 0x9
240 
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 
244 #define NOTIFY_ACK_SUCCESS 0x01
245 #endif
246 
247 #ifndef ACCEPT_TGT_IO_TYPE
248 #define ACCEPT_TGT_IO_TYPE 0x16 /* Accept target I/O entry. */
249 #endif
250 
251 #ifndef CONTINUE_TGT_IO_TYPE
252 #define CONTINUE_TGT_IO_TYPE 0x17
253 /*
254  * ISP queue - Continue Target I/O (CTIO) entry for status mode 0 structure.
255  * This structure is sent to the ISP 2xxx from target driver.
256  */
257 struct ctio_to_2xxx {
258  uint8_t entry_type; /* Entry type. */
259  uint8_t entry_count; /* Entry count. */
260  uint8_t sys_define; /* System defined. */
261  uint8_t entry_status; /* Entry Status. */
262  uint32_t handle; /* System defined handle */
267  uint16_t timeout; /* 0 = 30 seconds, 0xFFFF = disable */
268  uint16_t dseg_count; /* Data segment count. */
274  uint32_t dseg_0_address; /* Data segment 0 address. */
275  uint32_t dseg_0_length; /* Data segment 0 length. */
276  uint32_t dseg_1_address; /* Data segment 1 address. */
277  uint32_t dseg_1_length; /* Data segment 1 length. */
278  uint32_t dseg_2_address; /* Data segment 2 address. */
279  uint32_t dseg_2_length; /* Data segment 2 length. */
280 } __packed;
281 #define ATIO_PATH_INVALID 0x07
282 #define ATIO_CANT_PROV_CAP 0x16
283 #define ATIO_CDB_VALID 0x3D
284 
285 #define ATIO_EXEC_READ BIT_1
286 #define ATIO_EXEC_WRITE BIT_0
287 #endif
288 
289 #ifndef CTIO_A64_TYPE
290 #define CTIO_A64_TYPE 0x1F
291 #define CTIO_SUCCESS 0x01
292 #define CTIO_ABORTED 0x02
293 #define CTIO_INVALID_RX_ID 0x08
294 #define CTIO_TIMEOUT 0x0B
295 #define CTIO_LIP_RESET 0x0E
296 #define CTIO_TARGET_RESET 0x17
297 #define CTIO_PORT_UNAVAILABLE 0x28
298 #define CTIO_PORT_LOGGED_OUT 0x29
299 #define CTIO_PORT_CONF_CHANGED 0x2A
300 #define CTIO_SRR_RECEIVED 0x45
301 #endif
302 
303 #ifndef CTIO_RET_TYPE
304 #define CTIO_RET_TYPE 0x17 /* CTIO return entry */
305 #define ATIO_TYPE7 0x06 /* Accept target I/O entry for 24xx */
306 
307 struct fcp_hdr {
320 } __packed;
321 
322 struct fcp_hdr_le {
335 } __packed;
336 
337 #define F_CTL_EXCH_CONTEXT_RESP BIT_23
338 #define F_CTL_SEQ_CONTEXT_RESIP BIT_22
339 #define F_CTL_LAST_SEQ BIT_20
340 #define F_CTL_END_SEQ BIT_19
341 #define F_CTL_SEQ_INITIATIVE BIT_16
342 
343 #define R_CTL_BASIC_LINK_SERV 0x80
344 #define R_CTL_B_ACC 0x4
345 #define R_CTL_B_RJT 0x5
346 
353 #define FCP_CMND_TASK_MGMT_CLEAR_ACA 6
354 #define FCP_CMND_TASK_MGMT_TARGET_RESET 5
355 #define FCP_CMND_TASK_MGMT_LU_RESET 4
356 #define FCP_CMND_TASK_MGMT_CLEAR_TASK_SET 2
357 #define FCP_CMND_TASK_MGMT_ABORT_TASK_SET 1
362  /*
363  * add_cdb is optional and can absent from struct atio7_fcp_cmnd. Size 4
364  * only to make sizeof(struct atio7_fcp_cmnd) be as expected by
365  * BUILD_BUG_ON in qlt_init().
366  */
368  /* uint32_t data_length; */
369 } __packed;
370 
371 /*
372  * ISP queue - Accept Target I/O (ATIO) type entry IOCB structure.
373  * This is sent from the ISP to the target driver.
374  */
376  union {
377  struct {
379  uint8_t sys_define; /* System defined. */
380  uint8_t entry_status; /* Entry Status. */
381  uint32_t sys_define_2; /* System defined. */
396  } isp2x;
397  struct {
403 #define ATIO_EXCHANGE_ADDRESS_UNKNOWN 0xFFFFFFFF
404  struct fcp_hdr fcp_hdr;
406  } isp24;
407  struct {
408  uint8_t entry_type; /* Entry type. */
409  uint8_t entry_count; /* Entry count. */
412 #define ATIO_PROCESSED 0xDEADDEAD /* Signature */
413  } raw;
414  } u;
415 } __packed;
416 
417 #define CTIO_TYPE7 0x12 /* Continue target I/O entry (for 24xx) */
418 
419 /*
420  * ISP queue - Continue Target I/O (ATIO) type 7 entry (for 24xx) structure.
421  * This structure is sent to the ISP 24xx from the target driver.
422  */
423 
425  uint8_t entry_type; /* Entry type. */
426  uint8_t entry_count; /* Entry count. */
427  uint8_t sys_define; /* System defined. */
428  uint8_t entry_status; /* Entry Status. */
429  uint32_t handle; /* System defined handle */
431 #define CTIO7_NHANDLE_UNRECOGNIZED 0xFFFF
433  uint16_t dseg_count; /* Data segment count. */
439  union {
440  struct {
450  /* Data segment 0 address. */
452  /* Data segment 0 length. */
454  } status0;
455  struct {
457  uint16_t flags;
459  uint16_t ox_id;
464  } status1;
465  } u;
466 } __packed;
467 
468 /*
469  * ISP queue - CTIO type 7 from ISP 24xx to target driver
470  * returned entry structure.
471  */
473  uint8_t entry_type; /* Entry type. */
474  uint8_t entry_count; /* Entry count. */
475  uint8_t sys_define; /* System defined. */
476  uint8_t entry_status; /* Entry Status. */
477  uint32_t handle; /* System defined handle */
480  uint16_t dseg_count; /* Data segment count. */
491 } __packed;
492 
493 /* CTIO7 flags values */
494 #define CTIO7_FLAGS_SEND_STATUS BIT_15
495 #define CTIO7_FLAGS_TERMINATE BIT_14
496 #define CTIO7_FLAGS_CONFORM_REQ BIT_13
497 #define CTIO7_FLAGS_DONT_RET_CTIO BIT_8
498 #define CTIO7_FLAGS_STATUS_MODE_0 0
499 #define CTIO7_FLAGS_STATUS_MODE_1 BIT_6
500 #define CTIO7_FLAGS_EXPLICIT_CONFORM BIT_5
501 #define CTIO7_FLAGS_CONFIRM_SATISF BIT_4
502 #define CTIO7_FLAGS_DSD_PTR BIT_2
503 #define CTIO7_FLAGS_DATA_IN BIT_1
504 #define CTIO7_FLAGS_DATA_OUT BIT_0
505 
506 #define ELS_PLOGI 0x3
507 #define ELS_FLOGI 0x4
508 #define ELS_LOGO 0x5
509 #define ELS_PRLI 0x20
510 #define ELS_PRLO 0x21
511 #define ELS_TPRLO 0x24
512 #define ELS_PDISC 0x50
513 #define ELS_ADISC 0x52
514 
515 /*
516  * ISP queue - ABTS received/response entries structure definition for 24xx.
517  */
518 #define ABTS_RECV_24XX 0x54 /* ABTS received (for 24xx) */
519 #define ABTS_RESP_24XX 0x55 /* ABTS responce (for 24xx) */
520 
521 /*
522  * ISP queue - ABTS received IOCB entry structure definition for 24xx.
523  * The ABTS BLS received from the wire is sent to the
524  * target driver by the ISP 24xx.
525  * The IOCB is placed on the response queue.
526  */
528  uint8_t entry_type; /* Entry type. */
529  uint8_t entry_count; /* Entry count. */
530  uint8_t sys_define; /* System defined. */
531  uint8_t entry_status; /* Entry Status. */
542 } __packed;
543 
544 #define ABTS_PARAM_ABORT_SEQ BIT_0
545 
546 struct ba_acc_le {
550 #define SEQ_ID_VALID 0x80
551 #define SEQ_ID_INVALID 0x00
556 } __packed;
557 
558 struct ba_rjt_le {
562 #define BA_RJT_REASON_CODE_INVALID_COMMAND 0x1
563 #define BA_RJT_REASON_CODE_UNABLE_TO_PERFORM 0x9
565 } __packed;
566 
567 /*
568  * ISP queue - ABTS Response IOCB entry structure definition for 24xx.
569  * The ABTS response to the ABTS received is sent by the
570  * target driver to the ISP 24xx.
571  * The IOCB is placed on the request queue.
572  */
574  uint8_t entry_type; /* Entry type. */
575  uint8_t entry_count; /* Entry count. */
576  uint8_t sys_define; /* System defined. */
577  uint8_t entry_status; /* Entry Status. */
582 #define ABTS_CONTR_FLG_TERM_EXCHG BIT_0
588  union {
591  } __packed payload;
594 } __packed;
595 
596 /*
597  * ISP queue - ABTS Response IOCB from ISP24xx Firmware entry structure.
598  * The ABTS response with completion status to the ABTS response
599  * (sent by the target driver to the ISP 24xx) is sent by the
600  * ISP24xx firmware to the target driver.
601  * The IOCB is placed on the response queue.
602  */
604  uint8_t entry_type; /* Entry type. */
605  uint8_t entry_count; /* Entry count. */
606  uint8_t sys_define; /* System defined. */
607  uint8_t entry_status; /* Entry Status. */
610 #define ABTS_RESP_COMPL_SUCCESS 0
611 #define ABTS_RESP_COMPL_SUBCODE_ERROR 0x31
621 #define ABTS_RESP_SUBCODE_ERR_ABORTED_EXCH_NOT_TERM 0x1E
624 } __packed;
625 
626 /********************************************************************\
627  * Type Definitions used by initiator & target halves
628 \********************************************************************/
629 
630 struct qla_tgt_mgmt_cmd;
631 struct qla_tgt_sess;
632 
633 /*
634  * This structure provides a template of function calls that the
635  * target driver (from within qla_target.c) can issue to the
636  * target module (tcm_qla2xxx).
637  */
639 
640  int (*handle_cmd)(struct scsi_qla_host *, struct qla_tgt_cmd *,
641  unsigned char *, uint32_t, int, int, int);
644  uint32_t);
645  void (*free_cmd)(struct qla_tgt_cmd *);
648 
649  int (*check_initiator_node_acl)(struct scsi_qla_host *, unsigned char *,
650  void *, uint8_t *, uint16_t);
652  struct qla_tgt_sess *(*find_sess_by_loop_id)(struct scsi_qla_host *,
653  const uint16_t);
654  struct qla_tgt_sess *(*find_sess_by_s_id)(struct scsi_qla_host *,
655  const uint8_t *);
657  void (*put_sess)(struct qla_tgt_sess *);
659 };
660 
662 
663 #include <target/target_core_base.h>
664 
665 #define QLA_TGT_TIMEOUT 10 /* in seconds */
666 
667 #define QLA_TGT_MAX_HW_PENDING_TIME 60 /* in seconds */
668 
669 /* Immediate notify status constants */
670 #define IMM_NTFY_LIP_RESET 0x000E
671 #define IMM_NTFY_LIP_LINK_REINIT 0x000F
672 #define IMM_NTFY_IOCB_OVERFLOW 0x0016
673 #define IMM_NTFY_ABORT_TASK 0x0020
674 #define IMM_NTFY_PORT_LOGOUT 0x0029
675 #define IMM_NTFY_PORT_CONFIG 0x002A
676 #define IMM_NTFY_GLBL_TPRLO 0x002D
677 #define IMM_NTFY_GLBL_LOGO 0x002E
678 #define IMM_NTFY_RESOURCE 0x0034
679 #define IMM_NTFY_MSG_RX 0x0036
680 #define IMM_NTFY_SRR 0x0045
681 #define IMM_NTFY_ELS 0x0046
682 
683 /* Immediate notify task flags */
684 #define IMM_NTFY_TASK_MGMT_SHIFT 8
685 
686 #define QLA_TGT_CLEAR_ACA 0x40
687 #define QLA_TGT_TARGET_RESET 0x20
688 #define QLA_TGT_LUN_RESET 0x10
689 #define QLA_TGT_CLEAR_TS 0x04
690 #define QLA_TGT_ABORT_TS 0x02
691 #define QLA_TGT_ABORT_ALL_SESS 0xFFFF
692 #define QLA_TGT_ABORT_ALL 0xFFFE
693 #define QLA_TGT_NEXUS_LOSS_SESS 0xFFFD
694 #define QLA_TGT_NEXUS_LOSS 0xFFFC
695 
696 /* Notify Acknowledge flags */
697 #define NOTIFY_ACK_RES_COUNT BIT_8
698 #define NOTIFY_ACK_CLEAR_LIP_RESET BIT_5
699 #define NOTIFY_ACK_TM_RESP_CODE_VALID BIT_4
700 
701 /* Command's states */
702 #define QLA_TGT_STATE_NEW 0 /* New command + target processing */
703 #define QLA_TGT_STATE_NEED_DATA 1 /* target needs data to continue */
704 #define QLA_TGT_STATE_DATA_IN 2 /* Data arrived + target processing */
705 #define QLA_TGT_STATE_PROCESSED 3 /* target done processing */
706 #define QLA_TGT_STATE_ABORTED 4 /* Command aborted */
707 
708 /* Special handles */
709 #define QLA_TGT_NULL_HANDLE 0
710 #define QLA_TGT_SKIP_HANDLE (0xFFFFFFFF & ~CTIO_COMPLETION_HANDLE_MARK)
711 
712 /* ATIO task_codes field */
713 #define ATIO_SIMPLE_QUEUE 0
714 #define ATIO_HEAD_OF_QUEUE 1
715 #define ATIO_ORDERED_QUEUE 2
716 #define ATIO_ACA_QUEUE 4
717 #define ATIO_UNTAGGED 5
718 
719 /* TM failed response codes, see FCP (9.4.11 FCP_RSP_INFO) */
720 #define FC_TM_SUCCESS 0
721 #define FC_TM_BAD_FCP_DATA 1
722 #define FC_TM_BAD_CMD 2
723 #define FC_TM_FCP_DATA_MISMATCH 3
724 #define FC_TM_REJECT 4
725 #define FC_TM_FAILED 5
726 
727 /*
728  * Error code of qlt_pre_xmit_response() meaning that cmd's exchange was
729  * terminated, so no more actions is needed and success should be returned
730  * to target.
731  */
732 #define QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED 0x1717
733 
734 #if (BITS_PER_LONG > 32) || defined(CONFIG_HIGHMEM64G)
735 #define pci_dma_lo32(a) (a & 0xffffffff)
736 #define pci_dma_hi32(a) ((((a) >> 16)>>16) & 0xffffffff)
737 #else
738 #define pci_dma_lo32(a) (a & 0xffffffff)
739 #define pci_dma_hi32(a) 0
740 #endif
741 
742 #define QLA_TGT_SENSE_VALID(sense) ((sense != NULL) && \
743  (((const uint8_t *)(sense))[0] & 0x70) == 0x70)
744 
749 };
750 
751 struct qla_tgt {
753  struct qla_hw_data *ha;
754 
755  /*
756  * To sync between IRQ handlers and qlt_target_release(). Needed,
757  * because req_pkt() can drop/reaquire HW lock inside. Protected by
758  * HW lock.
759  */
761 
763 
764  /* Target's flags, serialized by pha->hardware_lock */
765  unsigned int tgt_enable_64bit_addr:1; /* 64-bits PCI addr enabled */
766  unsigned int link_reinit_iocb_pending:1;
767 
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 
775  /* Count of sessions refering qla_tgt. Protected by hardware_lock. */
777 
778  /* Protected by hardware_lock. Addition also protected by tgt_mutex. */
780 
781  /* Protected by hardware_lock */
784 
788 
794 
801 
803 
805 };
806 
807 /*
808  * Equivilant to IT Nexus (Initiator-Target)
809  */
810 struct qla_tgt_sess {
813 
814  unsigned int conf_compl_supported:1;
815  unsigned int deleted:1;
816  unsigned int local:1;
817 
820  struct qla_tgt *tgt;
821 
823  unsigned long expires;
825 
828 };
829 
830 struct qla_tgt_cmd {
832  int state;
833  struct se_cmd se_cmd;
836  /* Sense buffer that will be mapped into outgoing status */
838 
839  /* to save extra sess dereferences */
840  unsigned int conf_compl_supported:1;
841  unsigned int sg_mapped:1;
842  unsigned int free_sg:1;
843  unsigned int aborted:1; /* Needed in case of SRR */
844  unsigned int write_data_transferred:1;
845 
846  struct scatterlist *sg; /* cmd data buffer SG vector */
847  int sg_cnt; /* SG segments count */
848  int bufflen; /* cmd buffer length */
849  int offset;
853 
854  uint16_t loop_id; /* to save extra sess dereferences */
855  struct qla_tgt *tgt; /* to save extra sess dereferences */
858 
860 };
861 
864 
865 #define QLA_TGT_SESS_WORK_ABORT 1
866 #define QLA_TGT_SESS_WORK_TM 2
867  int type;
868 
869  union {
873  };
874 };
875 
880  struct se_cmd se_cmd;
882  unsigned int flags;
883 #define QLA24XX_MGMT_SEND_NACK 1
884  union {
889 };
890 
891 struct qla_tgt_prm {
892  struct qla_tgt_cmd *cmd;
893  struct qla_tgt *tgt;
894  void *pkt;
895  struct scatterlist *sg; /* cmd data buffer SG vector */
896  int seg_cnt;
897  int req_cnt;
900  unsigned char *sense_buffer;
902  int residual;
904 };
905 
908  int srr_id;
910 };
911 
914  int srr_id;
915  struct qla_tgt_cmd *cmd;
916 };
917 
918 #define QLA_TGT_XMIT_DATA 1
919 #define QLA_TGT_XMIT_STATUS 2
920 #define QLA_TGT_XMIT_ALL (QLA_TGT_XMIT_STATUS|QLA_TGT_XMIT_DATA)
921 
922 
923 extern struct qla_tgt_data qla_target;
924 /*
925  * Internal function prototypes
926  */
927 void qlt_disable_vha(struct scsi_qla_host *);
928 
929 /*
930  * Function prototypes for qla_target.c logic used by qla2xxx LLD code.
931  */
932 extern int qlt_add_target(struct qla_hw_data *, struct scsi_qla_host *);
933 extern int qlt_remove_target(struct qla_hw_data *, struct scsi_qla_host *);
934 extern int qlt_lport_register(struct qla_tgt_func_tmpl *, u64,
935  int (*callback)(struct scsi_qla_host *), void *);
936 extern void qlt_lport_deregister(struct scsi_qla_host *);
937 extern void qlt_unreg_sess(struct qla_tgt_sess *);
938 extern void qlt_fc_port_added(struct scsi_qla_host *, fc_port_t *);
939 extern void qlt_fc_port_deleted(struct scsi_qla_host *, fc_port_t *);
940 extern void qlt_set_mode(struct scsi_qla_host *ha);
941 extern void qlt_clear_mode(struct scsi_qla_host *ha);
942 extern int __init qlt_init(void);
943 extern void qlt_exit(void);
944 extern void qlt_update_vp_map(struct scsi_qla_host *, int);
945 
946 /*
947  * This macro is used during early initializations when host->active_mode
948  * is not set. Right now, ha value is ignored.
949  */
950 #define QLA_TGT_MODE_ENABLED() (ql2x_ini_mode != QLA2XXX_INI_MODE_ENABLED)
951 
952 static inline bool qla_tgt_mode_enabled(struct scsi_qla_host *ha)
953 {
954  return ha->host->active_mode & MODE_TARGET;
955 }
956 
957 static inline bool qla_ini_mode_enabled(struct scsi_qla_host *ha)
958 {
959  return ha->host->active_mode & MODE_INITIATOR;
960 }
961 
962 static inline void qla_reverse_ini_mode(struct scsi_qla_host *ha)
963 {
964  if (ha->host->active_mode & MODE_INITIATOR)
965  ha->host->active_mode &= ~MODE_INITIATOR;
966  else
967  ha->host->active_mode |= MODE_INITIATOR;
968 }
969 
970 /*
971  * Exported symbols from qla_target.c LLD logic used by qla2xxx code..
972  */
973 extern void qlt_24xx_atio_pkt_all_vps(struct scsi_qla_host *,
974  struct atio_from_isp *);
975 extern void qlt_response_pkt_all_vps(struct scsi_qla_host *, response_t *);
976 extern int qlt_rdy_to_xfer(struct qla_tgt_cmd *);
977 extern int qlt_xmit_response(struct qla_tgt_cmd *, int, uint8_t);
978 extern void qlt_xmit_tm_rsp(struct qla_tgt_mgmt_cmd *);
979 extern void qlt_free_mcmd(struct qla_tgt_mgmt_cmd *);
980 extern void qlt_free_cmd(struct qla_tgt_cmd *cmd);
981 extern void qlt_ctio_completion(struct scsi_qla_host *, uint32_t);
982 extern void qlt_async_event(uint16_t, struct scsi_qla_host *, uint16_t *);
983 extern void qlt_enable_vha(struct scsi_qla_host *);
984 extern void qlt_vport_create(struct scsi_qla_host *, struct qla_hw_data *);
985 extern void qlt_rff_id(struct scsi_qla_host *, struct ct_sns_req *);
986 extern void qlt_init_atio_q_entries(struct scsi_qla_host *);
987 extern void qlt_24xx_process_atio_queue(struct scsi_qla_host *);
988 extern void qlt_24xx_config_rings(struct scsi_qla_host *,
990 extern void qlt_24xx_config_nvram_stage1(struct scsi_qla_host *,
991  struct nvram_24xx *);
992 extern void qlt_24xx_config_nvram_stage2(struct scsi_qla_host *,
993  struct init_cb_24xx *);
995  struct sts_entry_24xx *);
996 extern void qlt_modify_vp_config(struct scsi_qla_host *,
997  struct vp_config_entry_24xx *);
998 extern void qlt_probe_one_stage1(struct scsi_qla_host *, struct qla_hw_data *);
999 extern int qlt_mem_alloc(struct qla_hw_data *);
1000 extern void qlt_mem_free(struct qla_hw_data *);
1001 extern void qlt_stop_phase1(struct qla_tgt *);
1002 extern void qlt_stop_phase2(struct qla_tgt *);
1003 
1004 #endif /* __QLA_TARGET_H */