xref: /openbmc/linux/drivers/scsi/csiostor/t4fw_api_stor.h (revision e5451c8f8330e03ad3cfa16048b4daf961af434f)
1  /*
2   * This file is part of the Chelsio FCoE driver for Linux.
3   *
4   * Copyright (c) 2009-2010 Chelsio Communications, Inc. All rights reserved.
5   *
6   * This software is available to you under a choice of one of two
7   * licenses.  You may choose to be licensed under the terms of the GNU
8   * General Public License (GPL) Version 2, available from the file
9   * COPYING in the main directory of this source tree, or the
10   * OpenIB.org BSD license below:
11   *
12   *     Redistribution and use in source and binary forms, with or
13   *     without modification, are permitted provided that the following
14   *     conditions are met:
15   *
16   *      - Redistributions of source code must retain the above
17   *        copyright notice, this list of conditions and the following
18   *        disclaimer.
19   *
20   *      - Redistributions in binary form must reproduce the above
21   *        copyright notice, this list of conditions and the following
22   *        disclaimer in the documentation and/or other materials
23   *        provided with the distribution.
24   *
25   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
26   * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
27   * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
28   * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
29   * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
30   * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
31   * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
32   * SOFTWARE.
33   */
34  
35  #ifndef _T4FW_API_STOR_H_
36  #define _T4FW_API_STOR_H_
37  
38  
39  /******************************************************************************
40   *   R E T U R N   V A L U E S
41   ********************************/
42  
43  enum fw_fcoe_link_sub_op {
44  	FCOE_LINK_DOWN	= 0x0,
45  	FCOE_LINK_UP	= 0x1,
46  	FCOE_LINK_COND	= 0x2,
47  };
48  
49  enum fw_fcoe_link_status {
50  	FCOE_LINKDOWN	= 0x0,
51  	FCOE_LINKUP	= 0x1,
52  };
53  
54  enum fw_ofld_prot {
55  	PROT_FCOE	= 0x1,
56  	PROT_ISCSI	= 0x2,
57  };
58  
59  enum rport_type_fcoe {
60  	FLOGI_VFPORT	= 0x1,		/* 0xfffffe */
61  	FDISC_VFPORT	= 0x2,		/* 0xfffffe */
62  	NS_VNPORT	= 0x3,		/* 0xfffffc */
63  	REG_FC4_VNPORT	= 0x4,		/* any FC4 type VN_PORT */
64  	REG_VNPORT	= 0x5,		/* 0xfffxxx - non FC4 port in switch */
65  	FDMI_VNPORT	= 0x6,		/* 0xfffffa */
66  	FAB_CTLR_VNPORT	= 0x7,		/* 0xfffffd */
67  };
68  
69  enum event_cause_fcoe {
70  	PLOGI_ACC_RCVD		= 0x01,
71  	PLOGI_RJT_RCVD		= 0x02,
72  	PLOGI_RCVD		= 0x03,
73  	PLOGO_RCVD		= 0x04,
74  	PRLI_ACC_RCVD		= 0x05,
75  	PRLI_RJT_RCVD		= 0x06,
76  	PRLI_RCVD		= 0x07,
77  	PRLO_RCVD		= 0x08,
78  	NPORT_ID_CHGD		= 0x09,
79  	FLOGO_RCVD		= 0x0a,
80  	CLR_VIRT_LNK_RCVD	= 0x0b,
81  	FLOGI_ACC_RCVD		= 0x0c,
82  	FLOGI_RJT_RCVD		= 0x0d,
83  	FDISC_ACC_RCVD		= 0x0e,
84  	FDISC_RJT_RCVD		= 0x0f,
85  	FLOGI_TMO_MAX_RETRY	= 0x10,
86  	IMPL_LOGO_ADISC_ACC	= 0x11,
87  	IMPL_LOGO_ADISC_RJT	= 0x12,
88  	IMPL_LOGO_ADISC_CNFLT	= 0x13,
89  	PRLI_TMO		= 0x14,
90  	ADISC_TMO		= 0x15,
91  	RSCN_DEV_LOST		= 0x16,
92  	SCR_ACC_RCVD		= 0x17,
93  	ADISC_RJT_RCVD		= 0x18,
94  	LOGO_SNT		= 0x19,
95  	PROTO_ERR_IMPL_LOGO	= 0x1a,
96  };
97  
98  enum fcoe_cmn_type {
99  	FCOE_ELS,
100  	FCOE_CT,
101  	FCOE_SCSI_CMD,
102  	FCOE_UNSOL_ELS,
103  };
104  
105  enum fw_wr_stor_opcodes {
106  	FW_RDEV_WR                     = 0x38,
107  	FW_FCOE_ELS_CT_WR              = 0x30,
108  	FW_SCSI_WRITE_WR               = 0x31,
109  	FW_SCSI_READ_WR                = 0x32,
110  	FW_SCSI_CMD_WR                 = 0x33,
111  	FW_SCSI_ABRT_CLS_WR            = 0x34,
112  };
113  
114  struct fw_rdev_wr {
115  	__be32 op_to_immdlen;
116  	__be32 alloc_to_len16;
117  	__be64 cookie;
118  	u8     protocol;
119  	u8     event_cause;
120  	u8     cur_state;
121  	u8     prev_state;
122  	__be32 flags_to_assoc_flowid;
123  	union rdev_entry {
124  		struct fcoe_rdev_entry {
125  			__be32 flowid;
126  			u8     protocol;
127  			u8     event_cause;
128  			u8     flags;
129  			u8     rjt_reason;
130  			u8     cur_login_st;
131  			u8     prev_login_st;
132  			__be16 rcv_fr_sz;
133  			u8     rd_xfer_rdy_to_rport_type;
134  			u8     vft_to_qos;
135  			u8     org_proc_assoc_to_acc_rsp_code;
136  			u8     enh_disc_to_tgt;
137  			u8     wwnn[8];
138  			u8     wwpn[8];
139  			__be16 iqid;
140  			u8     fc_oui[3];
141  			u8     r_id[3];
142  		} fcoe_rdev;
143  		struct iscsi_rdev_entry {
144  			__be32 flowid;
145  			u8     protocol;
146  			u8     event_cause;
147  			u8     flags;
148  			u8     r3;
149  			__be16 iscsi_opts;
150  			__be16 tcp_opts;
151  			__be16 ip_opts;
152  			__be16 max_rcv_len;
153  			__be16 max_snd_len;
154  			__be16 first_brst_len;
155  			__be16 max_brst_len;
156  			__be16 r4;
157  			__be16 def_time2wait;
158  			__be16 def_time2ret;
159  			__be16 nop_out_intrvl;
160  			__be16 non_scsi_to;
161  			__be16 isid;
162  			__be16 tsid;
163  			__be16 port;
164  			__be16 tpgt;
165  			u8     r5[6];
166  			__be16 iqid;
167  		} iscsi_rdev;
168  	} u;
169  };
170  
171  #define FW_RDEV_WR_FLOWID_GET(x)	(((x) >> 8) & 0xfffff)
172  #define FW_RDEV_WR_ASSOC_FLOWID_GET(x)	(((x) >> 0) & 0xfffff)
173  #define FW_RDEV_WR_RPORT_TYPE_GET(x)	(((x) >> 0) & 0x1f)
174  #define FW_RDEV_WR_NPIV_GET(x)		(((x) >> 6) & 0x1)
175  #define FW_RDEV_WR_CLASS_GET(x)		(((x) >> 4) & 0x3)
176  #define FW_RDEV_WR_TASK_RETRY_ID_GET(x)	(((x) >> 5) & 0x1)
177  #define FW_RDEV_WR_RETRY_GET(x)		(((x) >> 4) & 0x1)
178  #define FW_RDEV_WR_CONF_CMPL_GET(x)	(((x) >> 3) & 0x1)
179  #define FW_RDEV_WR_INI_GET(x)		(((x) >> 1) & 0x1)
180  #define FW_RDEV_WR_TGT_GET(x)		(((x) >> 0) & 0x1)
181  
182  struct fw_fcoe_els_ct_wr {
183  	__be32 op_immdlen;
184  	__be32 flowid_len16;
185  	u64    cookie;
186  	__be16 iqid;
187  	u8     tmo_val;
188  	u8     els_ct_type;
189  	u8     ctl_pri;
190  	u8     cp_en_class;
191  	__be16 xfer_cnt;
192  	u8     fl_to_sp;
193  	u8     l_id[3];
194  	u8     r5;
195  	u8     r_id[3];
196  	__be64 rsp_dmaaddr;
197  	__be32 rsp_dmalen;
198  	__be32 r6;
199  };
200  
201  #define FW_FCOE_ELS_CT_WR_OPCODE(x)		((x) << 24)
202  #define FW_FCOE_ELS_CT_WR_OPCODE_GET(x)		(((x) >> 24) & 0xff)
203  #define FW_FCOE_ELS_CT_WR_IMMDLEN(x)		((x) << 0)
204  #define FW_FCOE_ELS_CT_WR_IMMDLEN_GET(x)	(((x) >> 0) & 0xff)
205  #define FW_FCOE_ELS_CT_WR_SP(x)			((x) << 0)
206  
207  struct fw_scsi_write_wr {
208  	__be32 op_immdlen;
209  	__be32 flowid_len16;
210  	u64    cookie;
211  	__be16 iqid;
212  	u8     tmo_val;
213  	u8     use_xfer_cnt;
214  	union fw_scsi_write_priv {
215  		struct fcoe_write_priv {
216  			u8   ctl_pri;
217  			u8   cp_en_class;
218  			u8   r3_lo[2];
219  		} fcoe;
220  		struct iscsi_write_priv {
221  			u8   r3[4];
222  		} iscsi;
223  	} u;
224  	__be32 xfer_cnt;
225  	__be32 ini_xfer_cnt;
226  	__be64 rsp_dmaaddr;
227  	__be32 rsp_dmalen;
228  	__be32 r4;
229  };
230  
231  #define FW_SCSI_WRITE_WR_IMMDLEN(x)	((x) << 0)
232  
233  struct fw_scsi_read_wr {
234  	__be32 op_immdlen;
235  	__be32 flowid_len16;
236  	u64    cookie;
237  	__be16 iqid;
238  	u8     tmo_val;
239  	u8     use_xfer_cnt;
240  	union fw_scsi_read_priv {
241  		struct fcoe_read_priv {
242  			u8   ctl_pri;
243  			u8   cp_en_class;
244  			u8   r3_lo[2];
245  		} fcoe;
246  		struct iscsi_read_priv {
247  			u8   r3[4];
248  		} iscsi;
249  	} u;
250  	__be32 xfer_cnt;
251  	__be32 ini_xfer_cnt;
252  	__be64 rsp_dmaaddr;
253  	__be32 rsp_dmalen;
254  	__be32 r4;
255  };
256  
257  #define FW_SCSI_READ_WR_IMMDLEN(x)	((x) << 0)
258  
259  struct fw_scsi_cmd_wr {
260  	__be32 op_immdlen;
261  	__be32 flowid_len16;
262  	u64    cookie;
263  	__be16 iqid;
264  	u8     tmo_val;
265  	u8     r3;
266  	union fw_scsi_cmd_priv {
267  		struct fcoe_cmd_priv {
268  			u8   ctl_pri;
269  			u8   cp_en_class;
270  			u8   r4_lo[2];
271  		} fcoe;
272  		struct iscsi_cmd_priv {
273  			u8   r4[4];
274  		} iscsi;
275  	} u;
276  	u8     r5[8];
277  	__be64 rsp_dmaaddr;
278  	__be32 rsp_dmalen;
279  	__be32 r6;
280  };
281  
282  #define FW_SCSI_CMD_WR_IMMDLEN(x)	((x) << 0)
283  
284  #define SCSI_ABORT 0
285  #define SCSI_CLOSE 1
286  
287  struct fw_scsi_abrt_cls_wr {
288  	__be32 op_immdlen;
289  	__be32 flowid_len16;
290  	u64    cookie;
291  	__be16 iqid;
292  	u8     tmo_val;
293  	u8     sub_opcode_to_chk_all_io;
294  	u8     r3[4];
295  	u64    t_cookie;
296  };
297  
298  #define FW_SCSI_ABRT_CLS_WR_SUB_OPCODE(x)	((x) << 2)
299  #define FW_SCSI_ABRT_CLS_WR_SUB_OPCODE_GET(x)	(((x) >> 2) & 0x3f)
300  #define FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO(x)	((x) << 0)
301  
302  enum fw_cmd_stor_opcodes {
303  	FW_FCOE_RES_INFO_CMD           = 0x31,
304  	FW_FCOE_LINK_CMD               = 0x32,
305  	FW_FCOE_VNP_CMD                = 0x33,
306  	FW_FCOE_SPARAMS_CMD            = 0x35,
307  	FW_FCOE_STATS_CMD              = 0x37,
308  	FW_FCOE_FCF_CMD                = 0x38,
309  };
310  
311  struct fw_fcoe_res_info_cmd {
312  	__be32 op_to_read;
313  	__be32 retval_len16;
314  	__be16 e_d_tov;
315  	__be16 r_a_tov_seq;
316  	__be16 r_a_tov_els;
317  	__be16 r_r_tov;
318  	__be32 max_xchgs;
319  	__be32 max_ssns;
320  	__be32 used_xchgs;
321  	__be32 used_ssns;
322  	__be32 max_fcfs;
323  	__be32 max_vnps;
324  	__be32 used_fcfs;
325  	__be32 used_vnps;
326  };
327  
328  struct fw_fcoe_link_cmd {
329  	__be32 op_to_portid;
330  	__be32 retval_len16;
331  	__be32 sub_opcode_fcfi;
332  	u8     r3;
333  	u8     lstatus;
334  	__be16 flags;
335  	u8     r4;
336  	u8     set_vlan;
337  	__be16 vlan_id;
338  	__be32 vnpi_pkd;
339  	__be16 r6;
340  	u8     phy_mac[6];
341  	u8     vnport_wwnn[8];
342  	u8     vnport_wwpn[8];
343  };
344  
345  #define FW_FCOE_LINK_CMD_PORTID(x)	((x) << 0)
346  #define FW_FCOE_LINK_CMD_PORTID_GET(x)	(((x) >> 0) & 0xf)
347  #define FW_FCOE_LINK_CMD_SUB_OPCODE(x)  ((x) << 24U)
348  #define FW_FCOE_LINK_CMD_FCFI(x)	((x) << 0)
349  #define FW_FCOE_LINK_CMD_FCFI_GET(x)	(((x) >> 0) & 0xffffff)
350  #define FW_FCOE_LINK_CMD_VNPI_GET(x)	(((x) >> 0) & 0xfffff)
351  
352  struct fw_fcoe_vnp_cmd {
353  	__be32 op_to_fcfi;
354  	__be32 alloc_to_len16;
355  	__be32 gen_wwn_to_vnpi;
356  	__be32 vf_id;
357  	__be16 iqid;
358  	u8   vnport_mac[6];
359  	u8   vnport_wwnn[8];
360  	u8   vnport_wwpn[8];
361  	u8   cmn_srv_parms[16];
362  	u8   clsp_word_0_1[8];
363  };
364  
365  #define FW_FCOE_VNP_CMD_FCFI(x)		((x) << 0)
366  #define FW_FCOE_VNP_CMD_ALLOC		(1U << 31)
367  #define FW_FCOE_VNP_CMD_FREE		(1U << 30)
368  #define FW_FCOE_VNP_CMD_MODIFY		(1U << 29)
369  #define FW_FCOE_VNP_CMD_GEN_WWN		(1U << 22)
370  #define FW_FCOE_VNP_CMD_VFID_EN		(1U << 20)
371  #define FW_FCOE_VNP_CMD_VNPI(x)		((x) << 0)
372  #define FW_FCOE_VNP_CMD_VNPI_GET(x)	(((x) >> 0) & 0xfffff)
373  
374  struct fw_fcoe_sparams_cmd {
375  	__be32 op_to_portid;
376  	__be32 retval_len16;
377  	u8     r3[7];
378  	u8     cos;
379  	u8     lport_wwnn[8];
380  	u8     lport_wwpn[8];
381  	u8     cmn_srv_parms[16];
382  	u8     cls_srv_parms[16];
383  };
384  
385  #define FW_FCOE_SPARAMS_CMD_PORTID(x)	((x) << 0)
386  
387  struct fw_fcoe_stats_cmd {
388  	__be32 op_to_flowid;
389  	__be32 free_to_len16;
390  	union fw_fcoe_stats {
391  		struct fw_fcoe_stats_ctl {
392  			u8   nstats_port;
393  			u8   port_valid_ix;
394  			__be16 r6;
395  			__be32 r7;
396  			__be64 stat0;
397  			__be64 stat1;
398  			__be64 stat2;
399  			__be64 stat3;
400  			__be64 stat4;
401  			__be64 stat5;
402  		} ctl;
403  		struct fw_fcoe_port_stats {
404  			__be64 tx_bcast_bytes;
405  			__be64 tx_bcast_frames;
406  			__be64 tx_mcast_bytes;
407  			__be64 tx_mcast_frames;
408  			__be64 tx_ucast_bytes;
409  			__be64 tx_ucast_frames;
410  			__be64 tx_drop_frames;
411  			__be64 tx_offload_bytes;
412  			__be64 tx_offload_frames;
413  			__be64 rx_bcast_bytes;
414  			__be64 rx_bcast_frames;
415  			__be64 rx_mcast_bytes;
416  			__be64 rx_mcast_frames;
417  			__be64 rx_ucast_bytes;
418  			__be64 rx_ucast_frames;
419  			__be64 rx_err_frames;
420  		} port_stats;
421  		struct fw_fcoe_fcf_stats {
422  			__be32 fip_tx_bytes;
423  			__be32 fip_tx_fr;
424  			__be64 fcf_ka;
425  			__be64 mcast_adv_rcvd;
426  			__be16 ucast_adv_rcvd;
427  			__be16 sol_sent;
428  			__be16 vlan_req;
429  			__be16 vlan_rpl;
430  			__be16 clr_vlink;
431  			__be16 link_down;
432  			__be16 link_up;
433  			__be16 logo;
434  			__be16 flogi_req;
435  			__be16 flogi_rpl;
436  			__be16 fdisc_req;
437  			__be16 fdisc_rpl;
438  			__be16 fka_prd_chg;
439  			__be16 fc_map_chg;
440  			__be16 vfid_chg;
441  			u8   no_fka_req;
442  			u8   no_vnp;
443  		} fcf_stats;
444  		struct fw_fcoe_pcb_stats {
445  			__be64 tx_bytes;
446  			__be64 tx_frames;
447  			__be64 rx_bytes;
448  			__be64 rx_frames;
449  			__be32 vnp_ka;
450  			__be32 unsol_els_rcvd;
451  			__be64 unsol_cmd_rcvd;
452  			__be16 implicit_logo;
453  			__be16 flogi_inv_sparm;
454  			__be16 fdisc_inv_sparm;
455  			__be16 flogi_rjt;
456  			__be16 fdisc_rjt;
457  			__be16 no_ssn;
458  			__be16 mac_flt_fail;
459  			__be16 inv_fr_rcvd;
460  		} pcb_stats;
461  		struct fw_fcoe_scb_stats {
462  			__be64 tx_bytes;
463  			__be64 tx_frames;
464  			__be64 rx_bytes;
465  			__be64 rx_frames;
466  			__be32 host_abrt_req;
467  			__be32 adap_auto_abrt;
468  			__be32 adap_abrt_rsp;
469  			__be32 host_ios_req;
470  			__be16 ssn_offl_ios;
471  			__be16 ssn_not_rdy_ios;
472  			u8   rx_data_ddp_err;
473  			u8   ddp_flt_set_err;
474  			__be16 rx_data_fr_err;
475  			u8   bad_st_abrt_req;
476  			u8   no_io_abrt_req;
477  			u8   abort_tmo;
478  			u8   abort_tmo_2;
479  			__be32 abort_req;
480  			u8   no_ppod_res_tmo;
481  			u8   bp_tmo;
482  			u8   adap_auto_cls;
483  			u8   no_io_cls_req;
484  			__be32 host_cls_req;
485  			__be64 unsol_cmd_rcvd;
486  			__be32 plogi_req_rcvd;
487  			__be32 prli_req_rcvd;
488  			__be16 logo_req_rcvd;
489  			__be16 prlo_req_rcvd;
490  			__be16 plogi_rjt_rcvd;
491  			__be16 prli_rjt_rcvd;
492  			__be32 adisc_req_rcvd;
493  			__be32 rscn_rcvd;
494  			__be32 rrq_req_rcvd;
495  			__be32 unsol_els_rcvd;
496  			u8   adisc_rjt_rcvd;
497  			u8   scr_rjt;
498  			u8   ct_rjt;
499  			u8   inval_bls_rcvd;
500  			__be32 ba_rjt_rcvd;
501  		} scb_stats;
502  	} u;
503  };
504  
505  #define FW_FCOE_STATS_CMD_FLOWID(x)	((x) << 0)
506  #define FW_FCOE_STATS_CMD_FREE		(1U << 30)
507  #define FW_FCOE_STATS_CMD_NSTATS(x)	((x) << 4)
508  #define FW_FCOE_STATS_CMD_PORT(x)	((x) << 0)
509  #define FW_FCOE_STATS_CMD_PORT_VALID	(1U << 7)
510  #define FW_FCOE_STATS_CMD_IX(x)		((x) << 0)
511  
512  struct fw_fcoe_fcf_cmd {
513  	__be32 op_to_fcfi;
514  	__be32 retval_len16;
515  	__be16 priority_pkd;
516  	u8     mac[6];
517  	u8     name_id[8];
518  	u8     fabric[8];
519  	__be16 vf_id;
520  	__be16 max_fcoe_size;
521  	u8     vlan_id;
522  	u8     fc_map[3];
523  	__be32 fka_adv;
524  	__be32 r6;
525  	u8     r7_hi;
526  	u8     fpma_to_portid;
527  	u8     spma_mac[6];
528  	__be64 r8;
529  };
530  
531  #define FW_FCOE_FCF_CMD_FCFI(x)		((x) << 0)
532  #define FW_FCOE_FCF_CMD_FCFI_GET(x)	(((x) >> 0) & 0xfffff)
533  #define FW_FCOE_FCF_CMD_PRIORITY_GET(x)	(((x) >> 0) & 0xff)
534  #define FW_FCOE_FCF_CMD_FPMA_GET(x)	(((x) >> 6) & 0x1)
535  #define FW_FCOE_FCF_CMD_SPMA_GET(x)	(((x) >> 5) & 0x1)
536  #define FW_FCOE_FCF_CMD_LOGIN_GET(x)	(((x) >> 4) & 0x1)
537  #define FW_FCOE_FCF_CMD_PORTID_GET(x)	(((x) >> 0) & 0xf)
538  
539  #endif /* _T4FW_API_STOR_H_ */
540