2 * This file is part of the Chelsio FCoE driver for Linux.
4 * Copyright (c) 2009-2010 Chelsio Communications, Inc. All rights reserved.
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:
12 * Redistribution and use in source and binary forms, with or
13 * without modification, are permitted provided that the following
16 * - Redistributions of source code must retain the above
17 * copyright notice, this list of conditions and the following
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.
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
35 #ifndef _T4FW_API_STOR_H_
36 #define _T4FW_API_STOR_H_
39 /******************************************************************************
40 * R E T U R N V A L U E S
41 ********************************/
44 FW_SUCCESS = 0, /* completed sucessfully */
45 FW_EPERM = 1, /* operation not permitted */
46 FW_ENOENT = 2, /* no such file or directory */
47 FW_EIO = 5, /* input/output error; hw bad */
48 FW_ENOEXEC = 8, /* exec format error; inv microcode */
49 FW_EAGAIN = 11, /* try again */
50 FW_ENOMEM = 12, /* out of memory */
51 FW_EFAULT = 14, /* bad address; fw bad */
52 FW_EBUSY = 16, /* resource busy */
53 FW_EEXIST = 17, /* file exists */
54 FW_EINVAL = 22, /* invalid argument */
55 FW_ENOSPC = 28, /* no space left on device */
56 FW_ENOSYS = 38, /* functionality not implemented */
57 FW_EPROTO = 71, /* protocol error */
58 FW_EADDRINUSE = 98, /* address already in use */
59 FW_EADDRNOTAVAIL = 99, /* cannot assigned requested address */
60 FW_ENETDOWN = 100, /* network is down */
61 FW_ENETUNREACH = 101, /* network is unreachable */
62 FW_ENOBUFS = 105, /* no buffer space available */
63 FW_ETIMEDOUT = 110, /* timeout */
64 FW_EINPROGRESS = 115, /* fw internal */
65 FW_SCSI_ABORT_REQUESTED = 128, /* */
66 FW_SCSI_ABORT_TIMEDOUT = 129, /* */
67 FW_SCSI_ABORTED = 130, /* */
68 FW_SCSI_CLOSE_REQUESTED = 131, /* */
69 FW_ERR_LINK_DOWN = 132, /* */
70 FW_RDEV_NOT_READY = 133, /* */
71 FW_ERR_RDEV_LOST = 134, /* */
72 FW_ERR_RDEV_LOGO = 135, /* */
73 FW_FCOE_NO_XCHG = 136, /* */
74 FW_SCSI_RSP_ERR = 137, /* */
75 FW_ERR_RDEV_IMPL_LOGO = 138, /* */
76 FW_SCSI_UNDER_FLOW_ERR = 139, /* */
77 FW_SCSI_OVER_FLOW_ERR = 140, /* */
78 FW_SCSI_DDP_ERR = 141, /* DDP error*/
79 FW_SCSI_TASK_ERR = 142, /* No SCSI tasks available */
82 enum fw_fcoe_link_sub_op {
88 enum fw_fcoe_link_status {
98 enum rport_type_fcoe {
99 FLOGI_VFPORT = 0x1, /* 0xfffffe */
100 FDISC_VFPORT = 0x2, /* 0xfffffe */
101 NS_VNPORT = 0x3, /* 0xfffffc */
102 REG_FC4_VNPORT = 0x4, /* any FC4 type VN_PORT */
103 REG_VNPORT = 0x5, /* 0xfffxxx - non FC4 port in switch */
104 FDMI_VNPORT = 0x6, /* 0xfffffa */
105 FAB_CTLR_VNPORT = 0x7, /* 0xfffffd */
108 enum event_cause_fcoe {
109 PLOGI_ACC_RCVD = 0x01,
110 PLOGI_RJT_RCVD = 0x02,
113 PRLI_ACC_RCVD = 0x05,
114 PRLI_RJT_RCVD = 0x06,
117 NPORT_ID_CHGD = 0x09,
119 CLR_VIRT_LNK_RCVD = 0x0b,
120 FLOGI_ACC_RCVD = 0x0c,
121 FLOGI_RJT_RCVD = 0x0d,
122 FDISC_ACC_RCVD = 0x0e,
123 FDISC_RJT_RCVD = 0x0f,
124 FLOGI_TMO_MAX_RETRY = 0x10,
125 IMPL_LOGO_ADISC_ACC = 0x11,
126 IMPL_LOGO_ADISC_RJT = 0x12,
127 IMPL_LOGO_ADISC_CNFLT = 0x13,
130 RSCN_DEV_LOST = 0x16,
132 ADISC_RJT_RCVD = 0x18,
134 PROTO_ERR_IMPL_LOGO = 0x1a,
144 enum fw_wr_stor_opcodes {
146 FW_FCOE_ELS_CT_WR = 0x30,
147 FW_SCSI_WRITE_WR = 0x31,
148 FW_SCSI_READ_WR = 0x32,
149 FW_SCSI_CMD_WR = 0x33,
150 FW_SCSI_ABRT_CLS_WR = 0x34,
154 __be32 op_to_immdlen;
155 __be32 alloc_to_len16;
161 __be32 flags_to_assoc_flowid;
163 struct fcoe_rdev_entry {
172 u8 rd_xfer_rdy_to_rport_type;
174 u8 org_proc_assoc_to_acc_rsp_code;
182 struct iscsi_rdev_entry {
193 __be16 first_brst_len;
196 __be16 def_time2wait;
198 __be16 nop_out_intrvl;
210 #define FW_RDEV_WR_FLOWID_GET(x) (((x) >> 8) & 0xfffff)
211 #define FW_RDEV_WR_ASSOC_FLOWID_GET(x) (((x) >> 0) & 0xfffff)
212 #define FW_RDEV_WR_RPORT_TYPE_GET(x) (((x) >> 0) & 0x1f)
213 #define FW_RDEV_WR_NPIV_GET(x) (((x) >> 6) & 0x1)
214 #define FW_RDEV_WR_CLASS_GET(x) (((x) >> 4) & 0x3)
215 #define FW_RDEV_WR_TASK_RETRY_ID_GET(x) (((x) >> 5) & 0x1)
216 #define FW_RDEV_WR_RETRY_GET(x) (((x) >> 4) & 0x1)
217 #define FW_RDEV_WR_CONF_CMPL_GET(x) (((x) >> 3) & 0x1)
218 #define FW_RDEV_WR_INI_GET(x) (((x) >> 1) & 0x1)
219 #define FW_RDEV_WR_TGT_GET(x) (((x) >> 0) & 0x1)
221 struct fw_fcoe_els_ct_wr {
240 #define FW_FCOE_ELS_CT_WR_OPCODE(x) ((x) << 24)
241 #define FW_FCOE_ELS_CT_WR_OPCODE_GET(x) (((x) >> 24) & 0xff)
242 #define FW_FCOE_ELS_CT_WR_IMMDLEN(x) ((x) << 0)
243 #define FW_FCOE_ELS_CT_WR_IMMDLEN_GET(x) (((x) >> 0) & 0xff)
244 #define FW_FCOE_ELS_CT_WR_SP(x) ((x) << 0)
246 struct fw_scsi_write_wr {
253 union fw_scsi_write_priv {
254 struct fcoe_write_priv {
259 struct iscsi_write_priv {
270 #define FW_SCSI_WRITE_WR_IMMDLEN(x) ((x) << 0)
272 struct fw_scsi_read_wr {
279 union fw_scsi_read_priv {
280 struct fcoe_read_priv {
285 struct iscsi_read_priv {
296 #define FW_SCSI_READ_WR_IMMDLEN(x) ((x) << 0)
298 struct fw_scsi_cmd_wr {
305 union fw_scsi_cmd_priv {
306 struct fcoe_cmd_priv {
311 struct iscsi_cmd_priv {
321 #define FW_SCSI_CMD_WR_IMMDLEN(x) ((x) << 0)
326 struct fw_scsi_abrt_cls_wr {
332 u8 sub_opcode_to_chk_all_io;
337 #define FW_SCSI_ABRT_CLS_WR_SUB_OPCODE(x) ((x) << 2)
338 #define FW_SCSI_ABRT_CLS_WR_SUB_OPCODE_GET(x) (((x) >> 2) & 0x3f)
339 #define FW_SCSI_ABRT_CLS_WR_CHK_ALL_IO(x) ((x) << 0)
341 enum fw_cmd_stor_opcodes {
342 FW_FCOE_RES_INFO_CMD = 0x31,
343 FW_FCOE_LINK_CMD = 0x32,
344 FW_FCOE_VNP_CMD = 0x33,
345 FW_FCOE_SPARAMS_CMD = 0x35,
346 FW_FCOE_STATS_CMD = 0x37,
347 FW_FCOE_FCF_CMD = 0x38,
350 struct fw_fcoe_res_info_cmd {
367 struct fw_fcoe_link_cmd {
370 __be32 sub_opcode_fcfi;
384 #define FW_FCOE_LINK_CMD_PORTID(x) ((x) << 0)
385 #define FW_FCOE_LINK_CMD_PORTID_GET(x) (((x) >> 0) & 0xf)
386 #define FW_FCOE_LINK_CMD_SUB_OPCODE(x) ((x) << 24U)
387 #define FW_FCOE_LINK_CMD_FCFI(x) ((x) << 0)
388 #define FW_FCOE_LINK_CMD_FCFI_GET(x) (((x) >> 0) & 0xffffff)
389 #define FW_FCOE_LINK_CMD_VNPI_GET(x) (((x) >> 0) & 0xfffff)
391 struct fw_fcoe_vnp_cmd {
393 __be32 alloc_to_len16;
394 __be32 gen_wwn_to_vnpi;
400 u8 cmn_srv_parms[16];
404 #define FW_FCOE_VNP_CMD_FCFI(x) ((x) << 0)
405 #define FW_FCOE_VNP_CMD_ALLOC (1U << 31)
406 #define FW_FCOE_VNP_CMD_FREE (1U << 30)
407 #define FW_FCOE_VNP_CMD_MODIFY (1U << 29)
408 #define FW_FCOE_VNP_CMD_GEN_WWN (1U << 22)
409 #define FW_FCOE_VNP_CMD_VFID_EN (1U << 20)
410 #define FW_FCOE_VNP_CMD_VNPI(x) ((x) << 0)
411 #define FW_FCOE_VNP_CMD_VNPI_GET(x) (((x) >> 0) & 0xfffff)
413 struct fw_fcoe_sparams_cmd {
420 u8 cmn_srv_parms[16];
421 u8 cls_srv_parms[16];
424 #define FW_FCOE_SPARAMS_CMD_PORTID(x) ((x) << 0)
426 struct fw_fcoe_stats_cmd {
428 __be32 free_to_len16;
429 union fw_fcoe_stats {
430 struct fw_fcoe_stats_ctl {
442 struct fw_fcoe_port_stats {
443 __be64 tx_bcast_bytes;
444 __be64 tx_bcast_frames;
445 __be64 tx_mcast_bytes;
446 __be64 tx_mcast_frames;
447 __be64 tx_ucast_bytes;
448 __be64 tx_ucast_frames;
449 __be64 tx_drop_frames;
450 __be64 tx_offload_bytes;
451 __be64 tx_offload_frames;
452 __be64 rx_bcast_bytes;
453 __be64 rx_bcast_frames;
454 __be64 rx_mcast_bytes;
455 __be64 rx_mcast_frames;
456 __be64 rx_ucast_bytes;
457 __be64 rx_ucast_frames;
458 __be64 rx_err_frames;
460 struct fw_fcoe_fcf_stats {
464 __be64 mcast_adv_rcvd;
465 __be16 ucast_adv_rcvd;
483 struct fw_fcoe_pcb_stats {
489 __be32 unsol_els_rcvd;
490 __be64 unsol_cmd_rcvd;
491 __be16 implicit_logo;
492 __be16 flogi_inv_sparm;
493 __be16 fdisc_inv_sparm;
500 struct fw_fcoe_scb_stats {
505 __be32 host_abrt_req;
506 __be32 adap_auto_abrt;
507 __be32 adap_abrt_rsp;
510 __be16 ssn_not_rdy_ios;
513 __be16 rx_data_fr_err;
524 __be64 unsol_cmd_rcvd;
525 __be32 plogi_req_rcvd;
526 __be32 prli_req_rcvd;
527 __be16 logo_req_rcvd;
528 __be16 prlo_req_rcvd;
529 __be16 plogi_rjt_rcvd;
530 __be16 prli_rjt_rcvd;
531 __be32 adisc_req_rcvd;
534 __be32 unsol_els_rcvd;
544 #define FW_FCOE_STATS_CMD_FLOWID(x) ((x) << 0)
545 #define FW_FCOE_STATS_CMD_FREE (1U << 30)
546 #define FW_FCOE_STATS_CMD_NSTATS(x) ((x) << 4)
547 #define FW_FCOE_STATS_CMD_PORT(x) ((x) << 0)
548 #define FW_FCOE_STATS_CMD_PORT_VALID (1U << 7)
549 #define FW_FCOE_STATS_CMD_IX(x) ((x) << 0)
551 struct fw_fcoe_fcf_cmd {
559 __be16 max_fcoe_size;
570 #define FW_FCOE_FCF_CMD_FCFI(x) ((x) << 0)
571 #define FW_FCOE_FCF_CMD_FCFI_GET(x) (((x) >> 0) & 0xfffff)
572 #define FW_FCOE_FCF_CMD_PRIORITY_GET(x) (((x) >> 0) & 0xff)
573 #define FW_FCOE_FCF_CMD_FPMA_GET(x) (((x) >> 6) & 0x1)
574 #define FW_FCOE_FCF_CMD_SPMA_GET(x) (((x) >> 5) & 0x1)
575 #define FW_FCOE_FCF_CMD_LOGIN_GET(x) (((x) >> 4) & 0x1)
576 #define FW_FCOE_FCF_CMD_PORTID_GET(x) (((x) >> 0) & 0xf)
578 #endif /* _T4FW_API_STOR_H_ */