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