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_retval { 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 */ 80 }; 81 82 enum fw_fcoe_link_sub_op { 83 FCOE_LINK_DOWN = 0x0, 84 FCOE_LINK_UP = 0x1, 85 FCOE_LINK_COND = 0x2, 86 }; 87 88 enum fw_fcoe_link_status { 89 FCOE_LINKDOWN = 0x0, 90 FCOE_LINKUP = 0x1, 91 }; 92 93 enum fw_ofld_prot { 94 PROT_FCOE = 0x1, 95 PROT_ISCSI = 0x2, 96 }; 97 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 */ 106 }; 107 108 enum event_cause_fcoe { 109 PLOGI_ACC_RCVD = 0x01, 110 PLOGI_RJT_RCVD = 0x02, 111 PLOGI_RCVD = 0x03, 112 PLOGO_RCVD = 0x04, 113 PRLI_ACC_RCVD = 0x05, 114 PRLI_RJT_RCVD = 0x06, 115 PRLI_RCVD = 0x07, 116 PRLO_RCVD = 0x08, 117 NPORT_ID_CHGD = 0x09, 118 FLOGO_RCVD = 0x0a, 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, 128 PRLI_TMO = 0x14, 129 ADISC_TMO = 0x15, 130 RSCN_DEV_LOST = 0x16, 131 SCR_ACC_RCVD = 0x17, 132 ADISC_RJT_RCVD = 0x18, 133 LOGO_SNT = 0x19, 134 PROTO_ERR_IMPL_LOGO = 0x1a, 135 }; 136 137 enum fcoe_cmn_type { 138 FCOE_ELS, 139 FCOE_CT, 140 FCOE_SCSI_CMD, 141 FCOE_UNSOL_ELS, 142 }; 143 144 enum fw_wr_stor_opcodes { 145 FW_RDEV_WR = 0x38, 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, 151 }; 152 153 struct fw_rdev_wr { 154 __be32 op_to_immdlen; 155 __be32 alloc_to_len16; 156 __be64 cookie; 157 u8 protocol; 158 u8 event_cause; 159 u8 cur_state; 160 u8 prev_state; 161 __be32 flags_to_assoc_flowid; 162 union rdev_entry { 163 struct fcoe_rdev_entry { 164 __be32 flowid; 165 u8 protocol; 166 u8 event_cause; 167 u8 flags; 168 u8 rjt_reason; 169 u8 cur_login_st; 170 u8 prev_login_st; 171 __be16 rcv_fr_sz; 172 u8 rd_xfer_rdy_to_rport_type; 173 u8 vft_to_qos; 174 u8 org_proc_assoc_to_acc_rsp_code; 175 u8 enh_disc_to_tgt; 176 u8 wwnn[8]; 177 u8 wwpn[8]; 178 __be16 iqid; 179 u8 fc_oui[3]; 180 u8 r_id[3]; 181 } fcoe_rdev; 182 struct iscsi_rdev_entry { 183 __be32 flowid; 184 u8 protocol; 185 u8 event_cause; 186 u8 flags; 187 u8 r3; 188 __be16 iscsi_opts; 189 __be16 tcp_opts; 190 __be16 ip_opts; 191 __be16 max_rcv_len; 192 __be16 max_snd_len; 193 __be16 first_brst_len; 194 __be16 max_brst_len; 195 __be16 r4; 196 __be16 def_time2wait; 197 __be16 def_time2ret; 198 __be16 nop_out_intrvl; 199 __be16 non_scsi_to; 200 __be16 isid; 201 __be16 tsid; 202 __be16 port; 203 __be16 tpgt; 204 u8 r5[6]; 205 __be16 iqid; 206 } iscsi_rdev; 207 } u; 208 }; 209 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) 220 221 struct fw_fcoe_els_ct_wr { 222 __be32 op_immdlen; 223 __be32 flowid_len16; 224 u64 cookie; 225 __be16 iqid; 226 u8 tmo_val; 227 u8 els_ct_type; 228 u8 ctl_pri; 229 u8 cp_en_class; 230 __be16 xfer_cnt; 231 u8 fl_to_sp; 232 u8 l_id[3]; 233 u8 r5; 234 u8 r_id[3]; 235 __be64 rsp_dmaaddr; 236 __be32 rsp_dmalen; 237 __be32 r6; 238 }; 239 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) 245 246 struct fw_scsi_write_wr { 247 __be32 op_immdlen; 248 __be32 flowid_len16; 249 u64 cookie; 250 __be16 iqid; 251 u8 tmo_val; 252 u8 use_xfer_cnt; 253 union fw_scsi_write_priv { 254 struct fcoe_write_priv { 255 u8 ctl_pri; 256 u8 cp_en_class; 257 u8 r3_lo[2]; 258 } fcoe; 259 struct iscsi_write_priv { 260 u8 r3[4]; 261 } iscsi; 262 } u; 263 __be32 xfer_cnt; 264 __be32 ini_xfer_cnt; 265 __be64 rsp_dmaaddr; 266 __be32 rsp_dmalen; 267 __be32 r4; 268 }; 269 270 #define FW_SCSI_WRITE_WR_IMMDLEN(x) ((x) << 0) 271 272 struct fw_scsi_read_wr { 273 __be32 op_immdlen; 274 __be32 flowid_len16; 275 u64 cookie; 276 __be16 iqid; 277 u8 tmo_val; 278 u8 use_xfer_cnt; 279 union fw_scsi_read_priv { 280 struct fcoe_read_priv { 281 u8 ctl_pri; 282 u8 cp_en_class; 283 u8 r3_lo[2]; 284 } fcoe; 285 struct iscsi_read_priv { 286 u8 r3[4]; 287 } iscsi; 288 } u; 289 __be32 xfer_cnt; 290 __be32 ini_xfer_cnt; 291 __be64 rsp_dmaaddr; 292 __be32 rsp_dmalen; 293 __be32 r4; 294 }; 295 296 #define FW_SCSI_READ_WR_IMMDLEN(x) ((x) << 0) 297 298 struct fw_scsi_cmd_wr { 299 __be32 op_immdlen; 300 __be32 flowid_len16; 301 u64 cookie; 302 __be16 iqid; 303 u8 tmo_val; 304 u8 r3; 305 union fw_scsi_cmd_priv { 306 struct fcoe_cmd_priv { 307 u8 ctl_pri; 308 u8 cp_en_class; 309 u8 r4_lo[2]; 310 } fcoe; 311 struct iscsi_cmd_priv { 312 u8 r4[4]; 313 } iscsi; 314 } u; 315 u8 r5[8]; 316 __be64 rsp_dmaaddr; 317 __be32 rsp_dmalen; 318 __be32 r6; 319 }; 320 321 #define FW_SCSI_CMD_WR_IMMDLEN(x) ((x) << 0) 322 323 #define SCSI_ABORT 0 324 #define SCSI_CLOSE 1 325 326 struct fw_scsi_abrt_cls_wr { 327 __be32 op_immdlen; 328 __be32 flowid_len16; 329 u64 cookie; 330 __be16 iqid; 331 u8 tmo_val; 332 u8 sub_opcode_to_chk_all_io; 333 u8 r3[4]; 334 u64 t_cookie; 335 }; 336 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) 340 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, 348 }; 349 350 struct fw_fcoe_res_info_cmd { 351 __be32 op_to_read; 352 __be32 retval_len16; 353 __be16 e_d_tov; 354 __be16 r_a_tov_seq; 355 __be16 r_a_tov_els; 356 __be16 r_r_tov; 357 __be32 max_xchgs; 358 __be32 max_ssns; 359 __be32 used_xchgs; 360 __be32 used_ssns; 361 __be32 max_fcfs; 362 __be32 max_vnps; 363 __be32 used_fcfs; 364 __be32 used_vnps; 365 }; 366 367 struct fw_fcoe_link_cmd { 368 __be32 op_to_portid; 369 __be32 retval_len16; 370 __be32 sub_opcode_fcfi; 371 u8 r3; 372 u8 lstatus; 373 __be16 flags; 374 u8 r4; 375 u8 set_vlan; 376 __be16 vlan_id; 377 __be32 vnpi_pkd; 378 __be16 r6; 379 u8 phy_mac[6]; 380 u8 vnport_wwnn[8]; 381 u8 vnport_wwpn[8]; 382 }; 383 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) 390 391 struct fw_fcoe_vnp_cmd { 392 __be32 op_to_fcfi; 393 __be32 alloc_to_len16; 394 __be32 gen_wwn_to_vnpi; 395 __be32 vf_id; 396 __be16 iqid; 397 u8 vnport_mac[6]; 398 u8 vnport_wwnn[8]; 399 u8 vnport_wwpn[8]; 400 u8 cmn_srv_parms[16]; 401 u8 clsp_word_0_1[8]; 402 }; 403 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) 412 413 struct fw_fcoe_sparams_cmd { 414 __be32 op_to_portid; 415 __be32 retval_len16; 416 u8 r3[7]; 417 u8 cos; 418 u8 lport_wwnn[8]; 419 u8 lport_wwpn[8]; 420 u8 cmn_srv_parms[16]; 421 u8 cls_srv_parms[16]; 422 }; 423 424 #define FW_FCOE_SPARAMS_CMD_PORTID(x) ((x) << 0) 425 426 struct fw_fcoe_stats_cmd { 427 __be32 op_to_flowid; 428 __be32 free_to_len16; 429 union fw_fcoe_stats { 430 struct fw_fcoe_stats_ctl { 431 u8 nstats_port; 432 u8 port_valid_ix; 433 __be16 r6; 434 __be32 r7; 435 __be64 stat0; 436 __be64 stat1; 437 __be64 stat2; 438 __be64 stat3; 439 __be64 stat4; 440 __be64 stat5; 441 } 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; 459 } port_stats; 460 struct fw_fcoe_fcf_stats { 461 __be32 fip_tx_bytes; 462 __be32 fip_tx_fr; 463 __be64 fcf_ka; 464 __be64 mcast_adv_rcvd; 465 __be16 ucast_adv_rcvd; 466 __be16 sol_sent; 467 __be16 vlan_req; 468 __be16 vlan_rpl; 469 __be16 clr_vlink; 470 __be16 link_down; 471 __be16 link_up; 472 __be16 logo; 473 __be16 flogi_req; 474 __be16 flogi_rpl; 475 __be16 fdisc_req; 476 __be16 fdisc_rpl; 477 __be16 fka_prd_chg; 478 __be16 fc_map_chg; 479 __be16 vfid_chg; 480 u8 no_fka_req; 481 u8 no_vnp; 482 } fcf_stats; 483 struct fw_fcoe_pcb_stats { 484 __be64 tx_bytes; 485 __be64 tx_frames; 486 __be64 rx_bytes; 487 __be64 rx_frames; 488 __be32 vnp_ka; 489 __be32 unsol_els_rcvd; 490 __be64 unsol_cmd_rcvd; 491 __be16 implicit_logo; 492 __be16 flogi_inv_sparm; 493 __be16 fdisc_inv_sparm; 494 __be16 flogi_rjt; 495 __be16 fdisc_rjt; 496 __be16 no_ssn; 497 __be16 mac_flt_fail; 498 __be16 inv_fr_rcvd; 499 } pcb_stats; 500 struct fw_fcoe_scb_stats { 501 __be64 tx_bytes; 502 __be64 tx_frames; 503 __be64 rx_bytes; 504 __be64 rx_frames; 505 __be32 host_abrt_req; 506 __be32 adap_auto_abrt; 507 __be32 adap_abrt_rsp; 508 __be32 host_ios_req; 509 __be16 ssn_offl_ios; 510 __be16 ssn_not_rdy_ios; 511 u8 rx_data_ddp_err; 512 u8 ddp_flt_set_err; 513 __be16 rx_data_fr_err; 514 u8 bad_st_abrt_req; 515 u8 no_io_abrt_req; 516 u8 abort_tmo; 517 u8 abort_tmo_2; 518 __be32 abort_req; 519 u8 no_ppod_res_tmo; 520 u8 bp_tmo; 521 u8 adap_auto_cls; 522 u8 no_io_cls_req; 523 __be32 host_cls_req; 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; 532 __be32 rscn_rcvd; 533 __be32 rrq_req_rcvd; 534 __be32 unsol_els_rcvd; 535 u8 adisc_rjt_rcvd; 536 u8 scr_rjt; 537 u8 ct_rjt; 538 u8 inval_bls_rcvd; 539 __be32 ba_rjt_rcvd; 540 } scb_stats; 541 } u; 542 }; 543 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) 550 551 struct fw_fcoe_fcf_cmd { 552 __be32 op_to_fcfi; 553 __be32 retval_len16; 554 __be16 priority_pkd; 555 u8 mac[6]; 556 u8 name_id[8]; 557 u8 fabric[8]; 558 __be16 vf_id; 559 __be16 max_fcoe_size; 560 u8 vlan_id; 561 u8 fc_map[3]; 562 __be32 fka_adv; 563 __be32 r6; 564 u8 r7_hi; 565 u8 fpma_to_portid; 566 u8 spma_mac[6]; 567 __be64 r8; 568 }; 569 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) 577 578 #endif /* _T4FW_API_STOR_H_ */ 579