xref: /linux/drivers/scsi/qla2xxx/qla_nvme.h (revision 6e7fd890f1d6ac83805409e9c346240de2705584)
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3  * QLogic Fibre Channel HBA Driver
4  * Copyright (c)  2003-2017 QLogic Corporation
5  */
6 #ifndef __QLA_NVME_H
7 #define __QLA_NVME_H
8 
9 #include <uapi/scsi/fc/fc_fs.h>
10 #include <uapi/scsi/fc/fc_els.h>
11 #include <linux/nvme-fc-driver.h>
12 
13 #include "qla_def.h"
14 #include "qla_dsd.h"
15 
16 #define MIN_NVME_HW_QUEUES 1
17 #define DEF_NVME_HW_QUEUES 8
18 
19 #define NVME_ATIO_CMD_OFF 32
20 #define NVME_FIRST_PACKET_CMDLEN (64 - NVME_ATIO_CMD_OFF)
21 #define Q2T_NVME_NUM_TAGS 2048
22 #define QLA_MAX_FC_SEGMENTS 64
23 
24 struct qla_nvme_unsol_ctx;
25 struct scsi_qla_host;
26 struct qla_hw_data;
27 struct req_que;
28 struct srb;
29 
30 struct nvme_private {
31 	struct srb	*sp;
32 	struct nvmefc_ls_req *fd;
33 	struct work_struct ls_work;
34 	struct work_struct abort_work;
35 	int comp_status;
36 	spinlock_t cmd_lock;
37 };
38 
39 struct qla_nvme_rport {
40 	struct fc_port *fcport;
41 	struct qla_nvme_unsol_ctx *uctx;
42 };
43 
44 #define COMMAND_NVME    0x88            /* Command Type FC-NVMe IOCB */
45 struct cmd_nvme {
46 	uint8_t entry_type;             /* Entry type. */
47 	uint8_t entry_count;            /* Entry count. */
48 	uint8_t sys_define;             /* System defined. */
49 	uint8_t entry_status;           /* Entry Status. */
50 
51 	uint32_t handle;                /* System handle. */
52 	__le16	nport_handle;		/* N_PORT handle. */
53 	__le16	timeout;		/* Command timeout. */
54 
55 	__le16	dseg_count;		/* Data segment count. */
56 	__le16	nvme_rsp_dsd_len;	/* NVMe RSP DSD length */
57 
58 	uint64_t rsvd;
59 
60 	__le16	control_flags;		/* Control Flags */
61 #define CF_ADMIN_ASYNC_EVENT		BIT_13
62 #define CF_NVME_FIRST_BURST_ENABLE	BIT_11
63 #define CF_DIF_SEG_DESCR_ENABLE         BIT_3
64 #define CF_DATA_SEG_DESCR_ENABLE        BIT_2
65 #define CF_READ_DATA                    BIT_1
66 #define CF_WRITE_DATA                   BIT_0
67 
68 	__le16	nvme_cmnd_dseg_len;             /* Data segment length. */
69 	__le64	 nvme_cmnd_dseg_address __packed;/* Data segment address. */
70 	__le64	 nvme_rsp_dseg_address __packed; /* Data segment address. */
71 
72 	__le32	byte_count;		/* Total byte count. */
73 
74 	uint8_t port_id[3];             /* PortID of destination port. */
75 	uint8_t vp_index;
76 
77 	struct dsd64 nvme_dsd;
78 };
79 
80 #define PURLS_MSLEEP_INTERVAL	1
81 #define PURLS_RETRY_COUNT	5
82 
83 #define PT_LS4_REQUEST 0x89	/* Link Service pass-through IOCB (request) */
84 struct pt_ls4_request {
85 	uint8_t entry_type;
86 	uint8_t entry_count;
87 	uint8_t sys_define;
88 	uint8_t entry_status;
89 	uint32_t handle;
90 	__le16	status;
91 	__le16	nport_handle;
92 	__le16	tx_dseg_count;
93 	uint8_t  vp_index;
94 	uint8_t  rsvd;
95 	__le16	timeout;
96 	__le16	control_flags;
97 #define CF_LS4_SHIFT		13
98 #define CF_LS4_ORIGINATOR	0
99 #define CF_LS4_RESPONDER	1
100 #define CF_LS4_RESPONDER_TERM	2
101 
102 	__le16	rx_dseg_count;
103 	__le16	rsvd2;
104 	__le32	exchange_address;
105 	__le32	rsvd3;
106 	__le32	rx_byte_count;
107 	__le32	tx_byte_count;
108 	struct dsd64 dsd[2];
109 };
110 
111 #define PT_LS4_UNSOL 0x56	/* pass-up unsolicited rec FC-NVMe request */
112 struct pt_ls4_rx_unsol {
113 	uint8_t entry_type;
114 	uint8_t entry_count;
115 	__le16	rsvd0;
116 	__le16	rsvd1;
117 	uint8_t vp_index;
118 	uint8_t rsvd2;
119 	__le16	rsvd3;
120 	__le16	nport_handle;
121 	__le16	frame_size;
122 	__le16	rsvd4;
123 	__le32	exchange_address;
124 	uint8_t d_id[3];
125 	uint8_t r_ctl;
126 	le_id_t s_id;
127 	uint8_t cs_ctl;
128 	uint8_t f_ctl[3];
129 	uint8_t type;
130 	__le16	seq_cnt;
131 	uint8_t df_ctl;
132 	uint8_t seq_id;
133 	__le16 rx_id;
134 	__le16 ox_id;
135 	__le32  desc0;
136 #define PT_LS4_PAYLOAD_OFFSET 0x2c
137 #define PT_LS4_FIRST_PACKET_LEN 20
138 	__le32 payload[5];
139 };
140 
141 /*
142  * Global functions prototype in qla_nvme.c source file.
143  */
144 int qla_nvme_register_hba(struct scsi_qla_host *);
145 int  qla_nvme_register_remote(struct scsi_qla_host *, struct fc_port *);
146 void qla_nvme_delete(struct scsi_qla_host *);
147 void qla24xx_nvme_ls4_iocb(struct scsi_qla_host *, struct pt_ls4_request *,
148     struct req_que *);
149 void qla24xx_async_gffid_sp_done(struct srb *sp, int);
150 #endif
151