18c2ecf20Sopenharmony_ci/* 28c2ecf20Sopenharmony_ci * This file is part of the Chelsio FCoE driver for Linux. 38c2ecf20Sopenharmony_ci * 48c2ecf20Sopenharmony_ci * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. 58c2ecf20Sopenharmony_ci * 68c2ecf20Sopenharmony_ci * This software is available to you under a choice of one of two 78c2ecf20Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 88c2ecf20Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 98c2ecf20Sopenharmony_ci * COPYING in the main directory of this source tree, or the 108c2ecf20Sopenharmony_ci * OpenIB.org BSD license below: 118c2ecf20Sopenharmony_ci * 128c2ecf20Sopenharmony_ci * Redistribution and use in source and binary forms, with or 138c2ecf20Sopenharmony_ci * without modification, are permitted provided that the following 148c2ecf20Sopenharmony_ci * conditions are met: 158c2ecf20Sopenharmony_ci * 168c2ecf20Sopenharmony_ci * - Redistributions of source code must retain the above 178c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 188c2ecf20Sopenharmony_ci * disclaimer. 198c2ecf20Sopenharmony_ci * 208c2ecf20Sopenharmony_ci * - Redistributions in binary form must reproduce the above 218c2ecf20Sopenharmony_ci * copyright notice, this list of conditions and the following 228c2ecf20Sopenharmony_ci * disclaimer in the documentation and/or other materials 238c2ecf20Sopenharmony_ci * provided with the distribution. 248c2ecf20Sopenharmony_ci * 258c2ecf20Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 268c2ecf20Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 278c2ecf20Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 288c2ecf20Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 298c2ecf20Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 308c2ecf20Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 318c2ecf20Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 328c2ecf20Sopenharmony_ci * SOFTWARE. 338c2ecf20Sopenharmony_ci */ 348c2ecf20Sopenharmony_ci 358c2ecf20Sopenharmony_ci#ifndef __CSIO_RNODE_H__ 368c2ecf20Sopenharmony_ci#define __CSIO_RNODE_H__ 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci#include "csio_defs.h" 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ci/* State machine evets */ 418c2ecf20Sopenharmony_cienum csio_rn_ev { 428c2ecf20Sopenharmony_ci CSIO_RNFE_NONE = (uint32_t)0, /* None */ 438c2ecf20Sopenharmony_ci CSIO_RNFE_LOGGED_IN, /* [N/F]Port login 448c2ecf20Sopenharmony_ci * complete. 458c2ecf20Sopenharmony_ci */ 468c2ecf20Sopenharmony_ci CSIO_RNFE_PRLI_DONE, /* PRLI completed */ 478c2ecf20Sopenharmony_ci CSIO_RNFE_PLOGI_RECV, /* Received PLOGI */ 488c2ecf20Sopenharmony_ci CSIO_RNFE_PRLI_RECV, /* Received PLOGI */ 498c2ecf20Sopenharmony_ci CSIO_RNFE_LOGO_RECV, /* Received LOGO */ 508c2ecf20Sopenharmony_ci CSIO_RNFE_PRLO_RECV, /* Received PRLO */ 518c2ecf20Sopenharmony_ci CSIO_RNFE_DOWN, /* Rnode is down */ 528c2ecf20Sopenharmony_ci CSIO_RNFE_CLOSE, /* Close rnode */ 538c2ecf20Sopenharmony_ci CSIO_RNFE_NAME_MISSING, /* Rnode name missing 548c2ecf20Sopenharmony_ci * in name server. 558c2ecf20Sopenharmony_ci */ 568c2ecf20Sopenharmony_ci CSIO_RNFE_MAX_EVENT, 578c2ecf20Sopenharmony_ci}; 588c2ecf20Sopenharmony_ci 598c2ecf20Sopenharmony_ci/* rnode stats */ 608c2ecf20Sopenharmony_cistruct csio_rnode_stats { 618c2ecf20Sopenharmony_ci uint32_t n_err; /* error */ 628c2ecf20Sopenharmony_ci uint32_t n_err_inval; /* invalid parameter */ 638c2ecf20Sopenharmony_ci uint32_t n_err_nomem; /* error nomem */ 648c2ecf20Sopenharmony_ci uint32_t n_evt_unexp; /* unexpected event */ 658c2ecf20Sopenharmony_ci uint32_t n_evt_drop; /* unexpected event */ 668c2ecf20Sopenharmony_ci uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO + 1]; /* fw events */ 678c2ecf20Sopenharmony_ci enum csio_rn_ev n_evt_sm[CSIO_RNFE_MAX_EVENT]; /* State m/c events */ 688c2ecf20Sopenharmony_ci uint32_t n_lun_rst; /* Number of resets of 698c2ecf20Sopenharmony_ci * of LUNs under this 708c2ecf20Sopenharmony_ci * target 718c2ecf20Sopenharmony_ci */ 728c2ecf20Sopenharmony_ci uint32_t n_lun_rst_fail; /* Number of LUN reset 738c2ecf20Sopenharmony_ci * failures. 748c2ecf20Sopenharmony_ci */ 758c2ecf20Sopenharmony_ci uint32_t n_tgt_rst; /* Number of target resets */ 768c2ecf20Sopenharmony_ci uint32_t n_tgt_rst_fail; /* Number of target reset 778c2ecf20Sopenharmony_ci * failures. 788c2ecf20Sopenharmony_ci */ 798c2ecf20Sopenharmony_ci}; 808c2ecf20Sopenharmony_ci 818c2ecf20Sopenharmony_ci/* Defines for rnode role */ 828c2ecf20Sopenharmony_ci#define CSIO_RNFR_INITIATOR 0x1 838c2ecf20Sopenharmony_ci#define CSIO_RNFR_TARGET 0x2 848c2ecf20Sopenharmony_ci#define CSIO_RNFR_FABRIC 0x4 858c2ecf20Sopenharmony_ci#define CSIO_RNFR_NS 0x8 868c2ecf20Sopenharmony_ci#define CSIO_RNFR_NPORT 0x10 878c2ecf20Sopenharmony_ci 888c2ecf20Sopenharmony_cistruct csio_rnode { 898c2ecf20Sopenharmony_ci struct csio_sm sm; /* State machine - 908c2ecf20Sopenharmony_ci * should be the 918c2ecf20Sopenharmony_ci * 1st member 928c2ecf20Sopenharmony_ci */ 938c2ecf20Sopenharmony_ci struct csio_lnode *lnp; /* Pointer to owning 948c2ecf20Sopenharmony_ci * Lnode */ 958c2ecf20Sopenharmony_ci uint32_t flowid; /* Firmware ID */ 968c2ecf20Sopenharmony_ci struct list_head host_cmpl_q; /* SCSI IOs 978c2ecf20Sopenharmony_ci * pending to completed 988c2ecf20Sopenharmony_ci * to Mid-layer. 998c2ecf20Sopenharmony_ci */ 1008c2ecf20Sopenharmony_ci /* FC identifiers for remote node */ 1018c2ecf20Sopenharmony_ci uint32_t nport_id; 1028c2ecf20Sopenharmony_ci uint16_t fcp_flags; /* FCP Flags */ 1038c2ecf20Sopenharmony_ci uint8_t cur_evt; /* Current event */ 1048c2ecf20Sopenharmony_ci uint8_t prev_evt; /* Previous event */ 1058c2ecf20Sopenharmony_ci uint32_t role; /* Fabric/Target/ 1068c2ecf20Sopenharmony_ci * Initiator/NS 1078c2ecf20Sopenharmony_ci */ 1088c2ecf20Sopenharmony_ci struct fcoe_rdev_entry *rdev_entry; /* Rdev entry */ 1098c2ecf20Sopenharmony_ci struct csio_service_parms rn_sparm; 1108c2ecf20Sopenharmony_ci 1118c2ecf20Sopenharmony_ci /* FC transport attributes */ 1128c2ecf20Sopenharmony_ci struct fc_rport *rport; /* FC transport rport */ 1138c2ecf20Sopenharmony_ci uint32_t supp_classes; /* Supported FC classes */ 1148c2ecf20Sopenharmony_ci uint32_t maxframe_size; /* Max Frame size */ 1158c2ecf20Sopenharmony_ci uint32_t scsi_id; /* Transport given SCSI id */ 1168c2ecf20Sopenharmony_ci 1178c2ecf20Sopenharmony_ci struct csio_rnode_stats stats; /* Common rnode stats */ 1188c2ecf20Sopenharmony_ci}; 1198c2ecf20Sopenharmony_ci 1208c2ecf20Sopenharmony_ci#define csio_rn_flowid(rn) ((rn)->flowid) 1218c2ecf20Sopenharmony_ci#define csio_rn_wwpn(rn) ((rn)->rn_sparm.wwpn) 1228c2ecf20Sopenharmony_ci#define csio_rn_wwnn(rn) ((rn)->rn_sparm.wwnn) 1238c2ecf20Sopenharmony_ci#define csio_rnode_to_lnode(rn) ((rn)->lnp) 1248c2ecf20Sopenharmony_ci 1258c2ecf20Sopenharmony_ciint csio_is_rnode_ready(struct csio_rnode *rn); 1268c2ecf20Sopenharmony_civoid csio_rnode_state_to_str(struct csio_rnode *rn, int8_t *str); 1278c2ecf20Sopenharmony_ci 1288c2ecf20Sopenharmony_cistruct csio_rnode *csio_rnode_lookup_portid(struct csio_lnode *, uint32_t); 1298c2ecf20Sopenharmony_cistruct csio_rnode *csio_confirm_rnode(struct csio_lnode *, 1308c2ecf20Sopenharmony_ci uint32_t, struct fcoe_rdev_entry *); 1318c2ecf20Sopenharmony_ci 1328c2ecf20Sopenharmony_civoid csio_rnode_fwevt_handler(struct csio_rnode *rn, uint8_t fwevt); 1338c2ecf20Sopenharmony_ci 1348c2ecf20Sopenharmony_civoid csio_put_rnode(struct csio_lnode *ln, struct csio_rnode *rn); 1358c2ecf20Sopenharmony_ci 1368c2ecf20Sopenharmony_civoid csio_reg_rnode(struct csio_rnode *); 1378c2ecf20Sopenharmony_civoid csio_unreg_rnode(struct csio_rnode *); 1388c2ecf20Sopenharmony_ci 1398c2ecf20Sopenharmony_civoid csio_rnode_devloss_handler(struct csio_rnode *); 1408c2ecf20Sopenharmony_ci 1418c2ecf20Sopenharmony_ci#endif /* ifndef __CSIO_RNODE_H__ */ 142