1*4882a593Smuzhiyun /*
2*4882a593Smuzhiyun * Copyright 2014 Cisco Systems, Inc. All rights reserved.
3*4882a593Smuzhiyun *
4*4882a593Smuzhiyun * This program is free software; you may redistribute it and/or modify
5*4882a593Smuzhiyun * it under the terms of the GNU General Public License as published by
6*4882a593Smuzhiyun * the Free Software Foundation; version 2 of the License.
7*4882a593Smuzhiyun *
8*4882a593Smuzhiyun * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
9*4882a593Smuzhiyun * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
10*4882a593Smuzhiyun * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
11*4882a593Smuzhiyun * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
12*4882a593Smuzhiyun * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
13*4882a593Smuzhiyun * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
14*4882a593Smuzhiyun * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
15*4882a593Smuzhiyun * SOFTWARE.
16*4882a593Smuzhiyun */
17*4882a593Smuzhiyun
18*4882a593Smuzhiyun #ifndef __SNIC_FWINT_H
19*4882a593Smuzhiyun #define __SNIC_FWINT_H
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun #define SNIC_CDB_LEN 32 /* SCSI CDB size 32, can be used for 16 bytes */
22*4882a593Smuzhiyun #define LUN_ADDR_LEN 8
23*4882a593Smuzhiyun
24*4882a593Smuzhiyun /*
25*4882a593Smuzhiyun * Command entry type
26*4882a593Smuzhiyun */
27*4882a593Smuzhiyun enum snic_io_type {
28*4882a593Smuzhiyun /*
29*4882a593Smuzhiyun * Initiator request types
30*4882a593Smuzhiyun */
31*4882a593Smuzhiyun SNIC_REQ_REPORT_TGTS = 0x2, /* Report Targets */
32*4882a593Smuzhiyun SNIC_REQ_ICMND, /* Initiator command for SCSI IO */
33*4882a593Smuzhiyun SNIC_REQ_ITMF, /* Initiator command for Task Mgmt */
34*4882a593Smuzhiyun SNIC_REQ_HBA_RESET, /* SNIC Reset */
35*4882a593Smuzhiyun SNIC_REQ_EXCH_VER, /* Exchange Version Information */
36*4882a593Smuzhiyun SNIC_REQ_TGT_INFO, /* Backend/Target Information */
37*4882a593Smuzhiyun SNIC_REQ_BOOT_LUNS,
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun /*
40*4882a593Smuzhiyun * Response type
41*4882a593Smuzhiyun */
42*4882a593Smuzhiyun SNIC_RSP_REPORT_TGTS_CMPL = 0x12,/* Report Targets Completion */
43*4882a593Smuzhiyun SNIC_RSP_ICMND_CMPL, /* SCSI IO Completion */
44*4882a593Smuzhiyun SNIC_RSP_ITMF_CMPL, /* Task Management Completion */
45*4882a593Smuzhiyun SNIC_RSP_HBA_RESET_CMPL, /* SNIC Reset Completion */
46*4882a593Smuzhiyun SNIC_RSP_EXCH_VER_CMPL, /* Exchange Version Completion*/
47*4882a593Smuzhiyun SNIC_RSP_BOOT_LUNS_CMPL,
48*4882a593Smuzhiyun
49*4882a593Smuzhiyun /*
50*4882a593Smuzhiyun * Misc Request types
51*4882a593Smuzhiyun */
52*4882a593Smuzhiyun SNIC_MSG_ACK = 0x80, /* Ack: snic_notify_msg */
53*4882a593Smuzhiyun SNIC_MSG_ASYNC_EVNOTIFY, /* Asynchronous Event Notification */
54*4882a593Smuzhiyun }; /* end of enum snic_io_type */
55*4882a593Smuzhiyun
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun /*
58*4882a593Smuzhiyun * Header status codes from firmware
59*4882a593Smuzhiyun */
60*4882a593Smuzhiyun enum snic_io_status {
61*4882a593Smuzhiyun SNIC_STAT_IO_SUCCESS = 0, /* request was successful */
62*4882a593Smuzhiyun
63*4882a593Smuzhiyun /*
64*4882a593Smuzhiyun * If a request to the fw is rejected, the original request header
65*4882a593Smuzhiyun * will be returned with the status set to one of the following:
66*4882a593Smuzhiyun */
67*4882a593Smuzhiyun SNIC_STAT_INVALID_HDR, /* header contains invalid data */
68*4882a593Smuzhiyun SNIC_STAT_OUT_OF_RES, /* out of resources to complete request */
69*4882a593Smuzhiyun SNIC_STAT_INVALID_PARM, /* some parameter in request is not valid */
70*4882a593Smuzhiyun SNIC_STAT_REQ_NOT_SUP, /* req type is not supported */
71*4882a593Smuzhiyun SNIC_STAT_IO_NOT_FOUND, /* requested IO was not found */
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun /*
74*4882a593Smuzhiyun * Once a request is processed, the fw will usually return
75*4882a593Smuzhiyun * a cmpl message type. In cases where errors occurred,
76*4882a593Smuzhiyun * the header status would be filled in with one of the following:
77*4882a593Smuzhiyun */
78*4882a593Smuzhiyun SNIC_STAT_ABORTED, /* req was aborted */
79*4882a593Smuzhiyun SNIC_STAT_TIMEOUT, /* req was timed out */
80*4882a593Smuzhiyun SNIC_STAT_SGL_INVALID, /* req was aborted due to sgl error */
81*4882a593Smuzhiyun SNIC_STAT_DATA_CNT_MISMATCH, /*recv/sent more/less data than expec */
82*4882a593Smuzhiyun SNIC_STAT_FW_ERR, /* req was terminated due to fw error */
83*4882a593Smuzhiyun SNIC_STAT_ITMF_REJECT, /* itmf req was rejected by target */
84*4882a593Smuzhiyun SNIC_STAT_ITMF_FAIL, /* itmf req was failed */
85*4882a593Smuzhiyun SNIC_STAT_ITMF_INCORRECT_LUN, /* itmf req has incorrect LUN id*/
86*4882a593Smuzhiyun SNIC_STAT_CMND_REJECT, /* req was invalid and rejected */
87*4882a593Smuzhiyun SNIC_STAT_DEV_OFFLINE, /* req sent to offline device */
88*4882a593Smuzhiyun SNIC_STAT_NO_BOOTLUN,
89*4882a593Smuzhiyun SNIC_STAT_SCSI_ERR, /* SCSI error returned by Target. */
90*4882a593Smuzhiyun SNIC_STAT_NOT_READY, /* sNIC Subsystem is not ready */
91*4882a593Smuzhiyun SNIC_STAT_FATAL_ERROR, /* sNIC is in unrecoverable state */
92*4882a593Smuzhiyun }; /* end of enum snic_io_status */
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun /*
95*4882a593Smuzhiyun * snic_io_hdr : host <--> firmware
96*4882a593Smuzhiyun *
97*4882a593Smuzhiyun * for any other message that will be queued to firmware should
98*4882a593Smuzhiyun * have the following request header
99*4882a593Smuzhiyun */
100*4882a593Smuzhiyun struct snic_io_hdr {
101*4882a593Smuzhiyun __le32 hid;
102*4882a593Smuzhiyun __le32 cmnd_id; /* tag here */
103*4882a593Smuzhiyun ulong init_ctx; /* initiator context */
104*4882a593Smuzhiyun u8 type; /* request/response type */
105*4882a593Smuzhiyun u8 status; /* header status entry */
106*4882a593Smuzhiyun u8 protocol; /* Protocol specific, may needed for RoCE*/
107*4882a593Smuzhiyun u8 flags;
108*4882a593Smuzhiyun __le16 sg_cnt;
109*4882a593Smuzhiyun u16 resvd;
110*4882a593Smuzhiyun };
111*4882a593Smuzhiyun
112*4882a593Smuzhiyun /* auxillary funciton for encoding the snic_io_hdr */
113*4882a593Smuzhiyun static inline void
snic_io_hdr_enc(struct snic_io_hdr * hdr,u8 typ,u8 status,u32 id,u32 hid,u16 sg_cnt,ulong ctx)114*4882a593Smuzhiyun snic_io_hdr_enc(struct snic_io_hdr *hdr, u8 typ, u8 status, u32 id, u32 hid,
115*4882a593Smuzhiyun u16 sg_cnt, ulong ctx)
116*4882a593Smuzhiyun {
117*4882a593Smuzhiyun hdr->type = typ;
118*4882a593Smuzhiyun hdr->status = status;
119*4882a593Smuzhiyun hdr->protocol = 0;
120*4882a593Smuzhiyun hdr->hid = cpu_to_le32(hid);
121*4882a593Smuzhiyun hdr->cmnd_id = cpu_to_le32(id);
122*4882a593Smuzhiyun hdr->sg_cnt = cpu_to_le16(sg_cnt);
123*4882a593Smuzhiyun hdr->init_ctx = ctx;
124*4882a593Smuzhiyun hdr->flags = 0;
125*4882a593Smuzhiyun }
126*4882a593Smuzhiyun
127*4882a593Smuzhiyun /* auxillary funciton for decoding the snic_io_hdr */
128*4882a593Smuzhiyun static inline void
snic_io_hdr_dec(struct snic_io_hdr * hdr,u8 * typ,u8 * stat,u32 * cmnd_id,u32 * hid,ulong * ctx)129*4882a593Smuzhiyun snic_io_hdr_dec(struct snic_io_hdr *hdr, u8 *typ, u8 *stat, u32 *cmnd_id,
130*4882a593Smuzhiyun u32 *hid, ulong *ctx)
131*4882a593Smuzhiyun {
132*4882a593Smuzhiyun *typ = hdr->type;
133*4882a593Smuzhiyun *stat = hdr->status;
134*4882a593Smuzhiyun *hid = le32_to_cpu(hdr->hid);
135*4882a593Smuzhiyun *cmnd_id = le32_to_cpu(hdr->cmnd_id);
136*4882a593Smuzhiyun *ctx = hdr->init_ctx;
137*4882a593Smuzhiyun }
138*4882a593Smuzhiyun
139*4882a593Smuzhiyun /*
140*4882a593Smuzhiyun * snic_host_info: host -> firmware
141*4882a593Smuzhiyun *
142*4882a593Smuzhiyun * Used for sending host information to firmware, and request fw version
143*4882a593Smuzhiyun */
144*4882a593Smuzhiyun struct snic_exch_ver_req {
145*4882a593Smuzhiyun __le32 drvr_ver; /* for debugging, when fw dump captured */
146*4882a593Smuzhiyun __le32 os_type; /* for OS specific features */
147*4882a593Smuzhiyun };
148*4882a593Smuzhiyun
149*4882a593Smuzhiyun /*
150*4882a593Smuzhiyun * os_type flags
151*4882a593Smuzhiyun * Bit 0-7 : OS information
152*4882a593Smuzhiyun * Bit 8-31: Feature/Capability Information
153*4882a593Smuzhiyun */
154*4882a593Smuzhiyun #define SNIC_OS_LINUX 0x1
155*4882a593Smuzhiyun #define SNIC_OS_WIN 0x2
156*4882a593Smuzhiyun #define SNIC_OS_ESX 0x3
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun /*
159*4882a593Smuzhiyun * HBA Capabilities
160*4882a593Smuzhiyun * Bit 1: Reserved.
161*4882a593Smuzhiyun * Bit 2: Dynamic Discovery of LUNs.
162*4882a593Smuzhiyun * Bit 3: Async event notifications on on tgt online/offline events.
163*4882a593Smuzhiyun * Bit 4: IO timeout support in FW.
164*4882a593Smuzhiyun * Bit 5-31: Reserved.
165*4882a593Smuzhiyun */
166*4882a593Smuzhiyun #define SNIC_HBA_CAP_DDL 0x02 /* Supports Dynamic Discovery of LUNs */
167*4882a593Smuzhiyun #define SNIC_HBA_CAP_AEN 0x04 /* Supports Async Event Noitifcation */
168*4882a593Smuzhiyun #define SNIC_HBA_CAP_TMO 0x08 /* Supports IO timeout in FW */
169*4882a593Smuzhiyun
170*4882a593Smuzhiyun /*
171*4882a593Smuzhiyun * snic_exch_ver_rsp : firmware -> host
172*4882a593Smuzhiyun *
173*4882a593Smuzhiyun * Used by firmware to send response to version request
174*4882a593Smuzhiyun */
175*4882a593Smuzhiyun struct snic_exch_ver_rsp {
176*4882a593Smuzhiyun __le32 version;
177*4882a593Smuzhiyun __le32 hid;
178*4882a593Smuzhiyun __le32 max_concur_ios; /* max concurrent ios */
179*4882a593Smuzhiyun __le32 max_sgs_per_cmd; /* max sgls per IO */
180*4882a593Smuzhiyun __le32 max_io_sz; /* max io size supported */
181*4882a593Smuzhiyun __le32 hba_cap; /* hba capabilities */
182*4882a593Smuzhiyun __le32 max_tgts; /* max tgts supported */
183*4882a593Smuzhiyun __le16 io_timeout; /* FW extended timeout */
184*4882a593Smuzhiyun u16 rsvd;
185*4882a593Smuzhiyun };
186*4882a593Smuzhiyun
187*4882a593Smuzhiyun
188*4882a593Smuzhiyun /*
189*4882a593Smuzhiyun * snic_report_tgts : host -> firmware request
190*4882a593Smuzhiyun *
191*4882a593Smuzhiyun * Used by the host to request list of targets
192*4882a593Smuzhiyun */
193*4882a593Smuzhiyun struct snic_report_tgts {
194*4882a593Smuzhiyun __le16 sg_cnt;
195*4882a593Smuzhiyun __le16 flags; /* specific flags from fw */
196*4882a593Smuzhiyun u8 _resvd[4];
197*4882a593Smuzhiyun __le64 sg_addr; /* Points to SGL */
198*4882a593Smuzhiyun __le64 sense_addr;
199*4882a593Smuzhiyun };
200*4882a593Smuzhiyun
201*4882a593Smuzhiyun enum snic_type {
202*4882a593Smuzhiyun SNIC_NONE = 0x0,
203*4882a593Smuzhiyun SNIC_DAS,
204*4882a593Smuzhiyun SNIC_SAN,
205*4882a593Smuzhiyun };
206*4882a593Smuzhiyun
207*4882a593Smuzhiyun
208*4882a593Smuzhiyun /* Report Target Response */
209*4882a593Smuzhiyun enum snic_tgt_type {
210*4882a593Smuzhiyun SNIC_TGT_NONE = 0x0,
211*4882a593Smuzhiyun SNIC_TGT_DAS, /* DAS Target */
212*4882a593Smuzhiyun SNIC_TGT_SAN, /* SAN Target */
213*4882a593Smuzhiyun };
214*4882a593Smuzhiyun
215*4882a593Smuzhiyun /* target id format */
216*4882a593Smuzhiyun struct snic_tgt_id {
217*4882a593Smuzhiyun __le32 tgt_id; /* target id */
218*4882a593Smuzhiyun __le16 tgt_type; /* tgt type */
219*4882a593Smuzhiyun __le16 vnic_id; /* corresponding vnic id */
220*4882a593Smuzhiyun };
221*4882a593Smuzhiyun
222*4882a593Smuzhiyun /*
223*4882a593Smuzhiyun * snic_report_tgts_cmpl : firmware -> host response
224*4882a593Smuzhiyun *
225*4882a593Smuzhiyun * Used by firmware to send response to Report Targets request
226*4882a593Smuzhiyun */
227*4882a593Smuzhiyun struct snic_report_tgts_cmpl {
228*4882a593Smuzhiyun __le32 tgt_cnt; /* Number of Targets accessible */
229*4882a593Smuzhiyun u32 _resvd;
230*4882a593Smuzhiyun };
231*4882a593Smuzhiyun
232*4882a593Smuzhiyun /*
233*4882a593Smuzhiyun * Command flags
234*4882a593Smuzhiyun *
235*4882a593Smuzhiyun * Bit 0: Read flags
236*4882a593Smuzhiyun * Bit 1: Write flag
237*4882a593Smuzhiyun * Bit 2: ESGL - sg/esg array contains extended sg
238*4882a593Smuzhiyun * ESGE - is a host buffer contains sg elements
239*4882a593Smuzhiyun * Bit 3-4: Task Attributes
240*4882a593Smuzhiyun * 00b - simple
241*4882a593Smuzhiyun * 01b - head of queue
242*4882a593Smuzhiyun * 10b - ordered
243*4882a593Smuzhiyun * Bit 5-7: Priority - future use
244*4882a593Smuzhiyun * Bit 8-15: Reserved
245*4882a593Smuzhiyun */
246*4882a593Smuzhiyun
247*4882a593Smuzhiyun #define SNIC_ICMND_WR 0x01 /* write command */
248*4882a593Smuzhiyun #define SNIC_ICMND_RD 0x02 /* read command */
249*4882a593Smuzhiyun #define SNIC_ICMND_ESGL 0x04 /* SGE/ESGE array contains valid data*/
250*4882a593Smuzhiyun
251*4882a593Smuzhiyun /*
252*4882a593Smuzhiyun * Priority/Task Attribute settings
253*4882a593Smuzhiyun */
254*4882a593Smuzhiyun #define SNIC_ICMND_TSK_SHIFT 2 /* task attr starts at bit 2 */
255*4882a593Smuzhiyun #define SNIC_ICMND_TSK_MASK(x) ((x>>SNIC_ICMND_TSK_SHIFT) & ~(0xffff))
256*4882a593Smuzhiyun #define SNIC_ICMND_TSK_SIMPLE 0 /* simple task attr */
257*4882a593Smuzhiyun #define SNIC_ICMND_TSK_HEAD_OF_QUEUE 1 /* head of qeuue task attr */
258*4882a593Smuzhiyun #define SNIC_ICMND_TSK_ORDERED 2 /* ordered task attr */
259*4882a593Smuzhiyun
260*4882a593Smuzhiyun #define SNIC_ICMND_PRI_SHIFT 5 /* prio val starts at bit 5 */
261*4882a593Smuzhiyun
262*4882a593Smuzhiyun /*
263*4882a593Smuzhiyun * snic_icmnd : host-> firmware request
264*4882a593Smuzhiyun *
265*4882a593Smuzhiyun * used for sending out an initiator SCSI 16/32-byte command
266*4882a593Smuzhiyun */
267*4882a593Smuzhiyun struct snic_icmnd {
268*4882a593Smuzhiyun __le16 sg_cnt; /* Number of SG Elements */
269*4882a593Smuzhiyun __le16 flags; /* flags */
270*4882a593Smuzhiyun __le32 sense_len; /* Sense buffer length */
271*4882a593Smuzhiyun __le64 tgt_id; /* Destination Target ID */
272*4882a593Smuzhiyun __le64 lun_id; /* Destination LUN ID */
273*4882a593Smuzhiyun u8 cdb_len;
274*4882a593Smuzhiyun u8 _resvd;
275*4882a593Smuzhiyun __le16 time_out; /* ms time for Res allocations fw to handle io*/
276*4882a593Smuzhiyun __le32 data_len; /* Total number of bytes to be transferred */
277*4882a593Smuzhiyun u8 cdb[SNIC_CDB_LEN];
278*4882a593Smuzhiyun __le64 sg_addr; /* Points to SG List */
279*4882a593Smuzhiyun __le64 sense_addr; /* Sense buffer address */
280*4882a593Smuzhiyun };
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun
283*4882a593Smuzhiyun /* Response flags */
284*4882a593Smuzhiyun /* Bit 0: Under run
285*4882a593Smuzhiyun * Bit 1: Over Run
286*4882a593Smuzhiyun * Bit 2-7: Reserved
287*4882a593Smuzhiyun */
288*4882a593Smuzhiyun #define SNIC_ICMND_CMPL_UNDR_RUN 0x01 /* resid under and valid */
289*4882a593Smuzhiyun #define SNIC_ICMND_CMPL_OVER_RUN 0x02 /* resid over and valid */
290*4882a593Smuzhiyun
291*4882a593Smuzhiyun /*
292*4882a593Smuzhiyun * snic_icmnd_cmpl: firmware -> host response
293*4882a593Smuzhiyun *
294*4882a593Smuzhiyun * Used for sending the host a response to an icmnd (initiator command)
295*4882a593Smuzhiyun */
296*4882a593Smuzhiyun struct snic_icmnd_cmpl {
297*4882a593Smuzhiyun u8 scsi_status; /* value as per SAM */
298*4882a593Smuzhiyun u8 flags;
299*4882a593Smuzhiyun __le16 sense_len; /* Sense Length */
300*4882a593Smuzhiyun __le32 resid; /* Residue : # bytes under or over run */
301*4882a593Smuzhiyun };
302*4882a593Smuzhiyun
303*4882a593Smuzhiyun /*
304*4882a593Smuzhiyun * snic_itmf: host->firmware request
305*4882a593Smuzhiyun *
306*4882a593Smuzhiyun * used for requesting the firmware to abort a request and/or send out
307*4882a593Smuzhiyun * a task management function
308*4882a593Smuzhiyun *
309*4882a593Smuzhiyun * the req_id field is valid in case of abort task and clear task
310*4882a593Smuzhiyun */
311*4882a593Smuzhiyun struct snic_itmf {
312*4882a593Smuzhiyun u8 tm_type; /* SCSI Task Management request */
313*4882a593Smuzhiyun u8 resvd;
314*4882a593Smuzhiyun __le16 flags; /* flags */
315*4882a593Smuzhiyun __le32 req_id; /* Command id of snic req to be aborted */
316*4882a593Smuzhiyun __le64 tgt_id; /* Target ID */
317*4882a593Smuzhiyun __le64 lun_id; /* Destination LUN ID */
318*4882a593Smuzhiyun __le16 timeout; /* in sec */
319*4882a593Smuzhiyun };
320*4882a593Smuzhiyun
321*4882a593Smuzhiyun /*
322*4882a593Smuzhiyun * Task Management Request
323*4882a593Smuzhiyun */
324*4882a593Smuzhiyun enum snic_itmf_tm_type {
325*4882a593Smuzhiyun SNIC_ITMF_ABTS_TASK = 0x01, /* Abort Task */
326*4882a593Smuzhiyun SNIC_ITMF_ABTS_TASK_SET, /* Abort Task Set */
327*4882a593Smuzhiyun SNIC_ITMF_CLR_TASK, /* Clear Task */
328*4882a593Smuzhiyun SNIC_ITMF_CLR_TASKSET, /* Clear Task Set */
329*4882a593Smuzhiyun SNIC_ITMF_LUN_RESET, /* Lun Reset */
330*4882a593Smuzhiyun SNIC_ITMF_ABTS_TASK_TERM, /* Supported for SAN Targets */
331*4882a593Smuzhiyun };
332*4882a593Smuzhiyun
333*4882a593Smuzhiyun /*
334*4882a593Smuzhiyun * snic_itmf_cmpl: firmware -> host resposne
335*4882a593Smuzhiyun *
336*4882a593Smuzhiyun * used for sending the host a response for a itmf request
337*4882a593Smuzhiyun */
338*4882a593Smuzhiyun struct snic_itmf_cmpl {
339*4882a593Smuzhiyun __le32 nterminated; /* # IOs terminated as a result of tmf */
340*4882a593Smuzhiyun u8 flags; /* flags */
341*4882a593Smuzhiyun u8 _resvd[3];
342*4882a593Smuzhiyun };
343*4882a593Smuzhiyun
344*4882a593Smuzhiyun /*
345*4882a593Smuzhiyun * itmfl_cmpl flags
346*4882a593Smuzhiyun * Bit 0 : 1 - Num terminated field valid
347*4882a593Smuzhiyun * Bit 1 - 7 : Reserved
348*4882a593Smuzhiyun */
349*4882a593Smuzhiyun #define SNIC_NUM_TERM_VALID 0x01 /* Number of IOs terminated */
350*4882a593Smuzhiyun
351*4882a593Smuzhiyun /*
352*4882a593Smuzhiyun * snic_hba_reset: host -> firmware request
353*4882a593Smuzhiyun *
354*4882a593Smuzhiyun * used for requesting firmware to reset snic
355*4882a593Smuzhiyun */
356*4882a593Smuzhiyun struct snic_hba_reset {
357*4882a593Smuzhiyun __le16 flags; /* flags */
358*4882a593Smuzhiyun u8 _resvd[6];
359*4882a593Smuzhiyun };
360*4882a593Smuzhiyun
361*4882a593Smuzhiyun /*
362*4882a593Smuzhiyun * snic_hba_reset_cmpl: firmware -> host response
363*4882a593Smuzhiyun *
364*4882a593Smuzhiyun * Used by firmware to respond to the host's hba reset request
365*4882a593Smuzhiyun */
366*4882a593Smuzhiyun struct snic_hba_reset_cmpl {
367*4882a593Smuzhiyun u8 flags; /* flags : more info needs to be added*/
368*4882a593Smuzhiyun u8 _resvd[7];
369*4882a593Smuzhiyun };
370*4882a593Smuzhiyun
371*4882a593Smuzhiyun /*
372*4882a593Smuzhiyun * snic_notify_msg: firmware -> host response
373*4882a593Smuzhiyun *
374*4882a593Smuzhiyun * Used by firmware to notify host of the last work queue entry received
375*4882a593Smuzhiyun */
376*4882a593Smuzhiyun struct snic_notify_msg {
377*4882a593Smuzhiyun __le32 wqe_num; /* wq entry number */
378*4882a593Smuzhiyun u8 flags; /* flags, macros */
379*4882a593Smuzhiyun u8 _resvd[4];
380*4882a593Smuzhiyun };
381*4882a593Smuzhiyun
382*4882a593Smuzhiyun
383*4882a593Smuzhiyun #define SNIC_EVDATA_LEN 24 /* in bytes */
384*4882a593Smuzhiyun /* snic_async_evnotify: firmware -> host notification
385*4882a593Smuzhiyun *
386*4882a593Smuzhiyun * Used by firmware to notify the host about configuration/state changes
387*4882a593Smuzhiyun */
388*4882a593Smuzhiyun struct snic_async_evnotify {
389*4882a593Smuzhiyun u8 FLS_EVENT_DESC;
390*4882a593Smuzhiyun u8 vnic; /* vnic id */
391*4882a593Smuzhiyun u8 _resvd[2];
392*4882a593Smuzhiyun __le32 ev_id; /* Event ID */
393*4882a593Smuzhiyun u8 ev_data[SNIC_EVDATA_LEN]; /* Event Data */
394*4882a593Smuzhiyun u8 _resvd2[4];
395*4882a593Smuzhiyun };
396*4882a593Smuzhiyun
397*4882a593Smuzhiyun /* async event flags */
398*4882a593Smuzhiyun enum snic_ev_type {
399*4882a593Smuzhiyun SNIC_EV_TGT_OFFLINE = 0x01, /* Target Offline, PL contains TGT ID */
400*4882a593Smuzhiyun SNIC_EV_TGT_ONLINE, /* Target Online, PL contains TGT ID */
401*4882a593Smuzhiyun SNIC_EV_LUN_OFFLINE, /* LUN Offline, PL contains LUN ID */
402*4882a593Smuzhiyun SNIC_EV_LUN_ONLINE, /* LUN Online, PL contains LUN ID */
403*4882a593Smuzhiyun SNIC_EV_CONF_CHG, /* Dev Config/Attr Change Event */
404*4882a593Smuzhiyun SNIC_EV_TGT_ADDED, /* Target Added */
405*4882a593Smuzhiyun SNIC_EV_TGT_DELTD, /* Target Del'd, PL contains TGT ID */
406*4882a593Smuzhiyun SNIC_EV_LUN_ADDED, /* LUN Added */
407*4882a593Smuzhiyun SNIC_EV_LUN_DELTD, /* LUN Del'd, PL cont. TGT & LUN ID */
408*4882a593Smuzhiyun
409*4882a593Smuzhiyun SNIC_EV_DISC_CMPL = 0x10, /* Discovery Completed Event */
410*4882a593Smuzhiyun };
411*4882a593Smuzhiyun
412*4882a593Smuzhiyun
413*4882a593Smuzhiyun #define SNIC_HOST_REQ_LEN 128 /*Exp length of host req, wq desc sz*/
414*4882a593Smuzhiyun /* Payload 88 bytes = 128 - 24 - 16 */
415*4882a593Smuzhiyun #define SNIC_HOST_REQ_PAYLOAD ((int)(SNIC_HOST_REQ_LEN - \
416*4882a593Smuzhiyun sizeof(struct snic_io_hdr) - \
417*4882a593Smuzhiyun (2 * sizeof(u64)) - sizeof(ulong)))
418*4882a593Smuzhiyun
419*4882a593Smuzhiyun /*
420*4882a593Smuzhiyun * snic_host_req: host -> firmware request
421*4882a593Smuzhiyun *
422*4882a593Smuzhiyun * Basic structure for all snic requests that are sent from the host to
423*4882a593Smuzhiyun * firmware. They are 128 bytes in size.
424*4882a593Smuzhiyun */
425*4882a593Smuzhiyun struct snic_host_req {
426*4882a593Smuzhiyun u64 ctrl_data[2]; /*16 bytes - Control Data */
427*4882a593Smuzhiyun struct snic_io_hdr hdr;
428*4882a593Smuzhiyun union {
429*4882a593Smuzhiyun /*
430*4882a593Smuzhiyun * Entry specific space, last byte contains color
431*4882a593Smuzhiyun */
432*4882a593Smuzhiyun u8 buf[SNIC_HOST_REQ_PAYLOAD];
433*4882a593Smuzhiyun
434*4882a593Smuzhiyun /*
435*4882a593Smuzhiyun * Exchange firmware version
436*4882a593Smuzhiyun */
437*4882a593Smuzhiyun struct snic_exch_ver_req exch_ver;
438*4882a593Smuzhiyun
439*4882a593Smuzhiyun /* report targets */
440*4882a593Smuzhiyun struct snic_report_tgts rpt_tgts;
441*4882a593Smuzhiyun
442*4882a593Smuzhiyun /* io request */
443*4882a593Smuzhiyun struct snic_icmnd icmnd;
444*4882a593Smuzhiyun
445*4882a593Smuzhiyun /* task management request */
446*4882a593Smuzhiyun struct snic_itmf itmf;
447*4882a593Smuzhiyun
448*4882a593Smuzhiyun /* hba reset */
449*4882a593Smuzhiyun struct snic_hba_reset reset;
450*4882a593Smuzhiyun } u;
451*4882a593Smuzhiyun
452*4882a593Smuzhiyun ulong req_pa;
453*4882a593Smuzhiyun }; /* end of snic_host_req structure */
454*4882a593Smuzhiyun
455*4882a593Smuzhiyun
456*4882a593Smuzhiyun #define SNIC_FW_REQ_LEN 64 /* Expected length of fw req */
457*4882a593Smuzhiyun struct snic_fw_req {
458*4882a593Smuzhiyun struct snic_io_hdr hdr;
459*4882a593Smuzhiyun union {
460*4882a593Smuzhiyun /*
461*4882a593Smuzhiyun * Entry specific space, last byte contains color
462*4882a593Smuzhiyun */
463*4882a593Smuzhiyun u8 buf[SNIC_FW_REQ_LEN - sizeof(struct snic_io_hdr)];
464*4882a593Smuzhiyun
465*4882a593Smuzhiyun /* Exchange Version Response */
466*4882a593Smuzhiyun struct snic_exch_ver_rsp exch_ver_cmpl;
467*4882a593Smuzhiyun
468*4882a593Smuzhiyun /* Report Targets Response */
469*4882a593Smuzhiyun struct snic_report_tgts_cmpl rpt_tgts_cmpl;
470*4882a593Smuzhiyun
471*4882a593Smuzhiyun /* scsi response */
472*4882a593Smuzhiyun struct snic_icmnd_cmpl icmnd_cmpl;
473*4882a593Smuzhiyun
474*4882a593Smuzhiyun /* task management response */
475*4882a593Smuzhiyun struct snic_itmf_cmpl itmf_cmpl;
476*4882a593Smuzhiyun
477*4882a593Smuzhiyun /* hba reset response */
478*4882a593Smuzhiyun struct snic_hba_reset_cmpl reset_cmpl;
479*4882a593Smuzhiyun
480*4882a593Smuzhiyun /* notify message */
481*4882a593Smuzhiyun struct snic_notify_msg ack;
482*4882a593Smuzhiyun
483*4882a593Smuzhiyun /* async notification event */
484*4882a593Smuzhiyun struct snic_async_evnotify async_ev;
485*4882a593Smuzhiyun
486*4882a593Smuzhiyun } u;
487*4882a593Smuzhiyun }; /* end of snic_fw_req structure */
488*4882a593Smuzhiyun
489*4882a593Smuzhiyun /*
490*4882a593Smuzhiyun * Auxillary macro to verify specific snic req/cmpl structures
491*4882a593Smuzhiyun * to ensure that it will be aligned to 64 bit, and not using
492*4882a593Smuzhiyun * color bit field
493*4882a593Smuzhiyun */
494*4882a593Smuzhiyun #define VERIFY_REQ_SZ(x)
495*4882a593Smuzhiyun #define VERIFY_CMPL_SZ(x)
496*4882a593Smuzhiyun
497*4882a593Smuzhiyun /*
498*4882a593Smuzhiyun * Access routines to encode and decode the color bit, which is the most
499*4882a593Smuzhiyun * significant bit of the structure.
500*4882a593Smuzhiyun */
501*4882a593Smuzhiyun static inline void
snic_color_enc(struct snic_fw_req * req,u8 color)502*4882a593Smuzhiyun snic_color_enc(struct snic_fw_req *req, u8 color)
503*4882a593Smuzhiyun {
504*4882a593Smuzhiyun u8 *c = ((u8 *) req) + sizeof(struct snic_fw_req) - 1;
505*4882a593Smuzhiyun
506*4882a593Smuzhiyun if (color)
507*4882a593Smuzhiyun *c |= 0x80;
508*4882a593Smuzhiyun else
509*4882a593Smuzhiyun *c &= ~0x80;
510*4882a593Smuzhiyun }
511*4882a593Smuzhiyun
512*4882a593Smuzhiyun static inline void
snic_color_dec(struct snic_fw_req * req,u8 * color)513*4882a593Smuzhiyun snic_color_dec(struct snic_fw_req *req, u8 *color)
514*4882a593Smuzhiyun {
515*4882a593Smuzhiyun u8 *c = ((u8 *) req) + sizeof(struct snic_fw_req) - 1;
516*4882a593Smuzhiyun
517*4882a593Smuzhiyun *color = *c >> 7;
518*4882a593Smuzhiyun
519*4882a593Smuzhiyun /* Make sure color bit is read from desc *before* other fields
520*4882a593Smuzhiyun * are read from desc. Hardware guarantees color bit is last
521*4882a593Smuzhiyun * bit (byte) written. Adding the rmb() prevents the compiler
522*4882a593Smuzhiyun * and/or CPU from reordering the reads which would potentially
523*4882a593Smuzhiyun * result in reading stale values.
524*4882a593Smuzhiyun */
525*4882a593Smuzhiyun rmb();
526*4882a593Smuzhiyun }
527*4882a593Smuzhiyun #endif /* end of __SNIC_FWINT_H */
528