162306a36Sopenharmony_ci/* 262306a36Sopenharmony_ci * This file is part of the Chelsio FCoE driver for Linux. 362306a36Sopenharmony_ci * 462306a36Sopenharmony_ci * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved. 562306a36Sopenharmony_ci * 662306a36Sopenharmony_ci * This software is available to you under a choice of one of two 762306a36Sopenharmony_ci * licenses. You may choose to be licensed under the terms of the GNU 862306a36Sopenharmony_ci * General Public License (GPL) Version 2, available from the file 962306a36Sopenharmony_ci * COPYING in the main directory of this source tree, or the 1062306a36Sopenharmony_ci * OpenIB.org BSD license below: 1162306a36Sopenharmony_ci * 1262306a36Sopenharmony_ci * Redistribution and use in source and binary forms, with or 1362306a36Sopenharmony_ci * without modification, are permitted provided that the following 1462306a36Sopenharmony_ci * conditions are met: 1562306a36Sopenharmony_ci * 1662306a36Sopenharmony_ci * - Redistributions of source code must retain the above 1762306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 1862306a36Sopenharmony_ci * disclaimer. 1962306a36Sopenharmony_ci * 2062306a36Sopenharmony_ci * - Redistributions in binary form must reproduce the above 2162306a36Sopenharmony_ci * copyright notice, this list of conditions and the following 2262306a36Sopenharmony_ci * disclaimer in the documentation and/or other materials 2362306a36Sopenharmony_ci * provided with the distribution. 2462306a36Sopenharmony_ci * 2562306a36Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 2662306a36Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 2762306a36Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 2862306a36Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 2962306a36Sopenharmony_ci * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 3062306a36Sopenharmony_ci * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 3162306a36Sopenharmony_ci * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 3262306a36Sopenharmony_ci * SOFTWARE. 3362306a36Sopenharmony_ci */ 3462306a36Sopenharmony_ci 3562306a36Sopenharmony_ci#ifndef __CSIO_RNODE_H__ 3662306a36Sopenharmony_ci#define __CSIO_RNODE_H__ 3762306a36Sopenharmony_ci 3862306a36Sopenharmony_ci#include "csio_defs.h" 3962306a36Sopenharmony_ci 4062306a36Sopenharmony_ci/* State machine evets */ 4162306a36Sopenharmony_cienum csio_rn_ev { 4262306a36Sopenharmony_ci CSIO_RNFE_NONE = (uint32_t)0, /* None */ 4362306a36Sopenharmony_ci CSIO_RNFE_LOGGED_IN, /* [N/F]Port login 4462306a36Sopenharmony_ci * complete. 4562306a36Sopenharmony_ci */ 4662306a36Sopenharmony_ci CSIO_RNFE_PRLI_DONE, /* PRLI completed */ 4762306a36Sopenharmony_ci CSIO_RNFE_PLOGI_RECV, /* Received PLOGI */ 4862306a36Sopenharmony_ci CSIO_RNFE_PRLI_RECV, /* Received PLOGI */ 4962306a36Sopenharmony_ci CSIO_RNFE_LOGO_RECV, /* Received LOGO */ 5062306a36Sopenharmony_ci CSIO_RNFE_PRLO_RECV, /* Received PRLO */ 5162306a36Sopenharmony_ci CSIO_RNFE_DOWN, /* Rnode is down */ 5262306a36Sopenharmony_ci CSIO_RNFE_CLOSE, /* Close rnode */ 5362306a36Sopenharmony_ci CSIO_RNFE_NAME_MISSING, /* Rnode name missing 5462306a36Sopenharmony_ci * in name server. 5562306a36Sopenharmony_ci */ 5662306a36Sopenharmony_ci CSIO_RNFE_MAX_EVENT, 5762306a36Sopenharmony_ci}; 5862306a36Sopenharmony_ci 5962306a36Sopenharmony_ci/* rnode stats */ 6062306a36Sopenharmony_cistruct csio_rnode_stats { 6162306a36Sopenharmony_ci uint32_t n_err; /* error */ 6262306a36Sopenharmony_ci uint32_t n_err_inval; /* invalid parameter */ 6362306a36Sopenharmony_ci uint32_t n_err_nomem; /* error nomem */ 6462306a36Sopenharmony_ci uint32_t n_evt_unexp; /* unexpected event */ 6562306a36Sopenharmony_ci uint32_t n_evt_drop; /* unexpected event */ 6662306a36Sopenharmony_ci uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO + 1]; /* fw events */ 6762306a36Sopenharmony_ci enum csio_rn_ev n_evt_sm[CSIO_RNFE_MAX_EVENT]; /* State m/c events */ 6862306a36Sopenharmony_ci uint32_t n_lun_rst; /* Number of resets of 6962306a36Sopenharmony_ci * of LUNs under this 7062306a36Sopenharmony_ci * target 7162306a36Sopenharmony_ci */ 7262306a36Sopenharmony_ci uint32_t n_lun_rst_fail; /* Number of LUN reset 7362306a36Sopenharmony_ci * failures. 7462306a36Sopenharmony_ci */ 7562306a36Sopenharmony_ci uint32_t n_tgt_rst; /* Number of target resets */ 7662306a36Sopenharmony_ci uint32_t n_tgt_rst_fail; /* Number of target reset 7762306a36Sopenharmony_ci * failures. 7862306a36Sopenharmony_ci */ 7962306a36Sopenharmony_ci}; 8062306a36Sopenharmony_ci 8162306a36Sopenharmony_ci/* Defines for rnode role */ 8262306a36Sopenharmony_ci#define CSIO_RNFR_INITIATOR 0x1 8362306a36Sopenharmony_ci#define CSIO_RNFR_TARGET 0x2 8462306a36Sopenharmony_ci#define CSIO_RNFR_FABRIC 0x4 8562306a36Sopenharmony_ci#define CSIO_RNFR_NS 0x8 8662306a36Sopenharmony_ci#define CSIO_RNFR_NPORT 0x10 8762306a36Sopenharmony_ci 8862306a36Sopenharmony_cistruct csio_rnode { 8962306a36Sopenharmony_ci struct csio_sm sm; /* State machine - 9062306a36Sopenharmony_ci * should be the 9162306a36Sopenharmony_ci * 1st member 9262306a36Sopenharmony_ci */ 9362306a36Sopenharmony_ci struct csio_lnode *lnp; /* Pointer to owning 9462306a36Sopenharmony_ci * Lnode */ 9562306a36Sopenharmony_ci uint32_t flowid; /* Firmware ID */ 9662306a36Sopenharmony_ci struct list_head host_cmpl_q; /* SCSI IOs 9762306a36Sopenharmony_ci * pending to completed 9862306a36Sopenharmony_ci * to Mid-layer. 9962306a36Sopenharmony_ci */ 10062306a36Sopenharmony_ci /* FC identifiers for remote node */ 10162306a36Sopenharmony_ci uint32_t nport_id; 10262306a36Sopenharmony_ci uint16_t fcp_flags; /* FCP Flags */ 10362306a36Sopenharmony_ci uint8_t cur_evt; /* Current event */ 10462306a36Sopenharmony_ci uint8_t prev_evt; /* Previous event */ 10562306a36Sopenharmony_ci uint32_t role; /* Fabric/Target/ 10662306a36Sopenharmony_ci * Initiator/NS 10762306a36Sopenharmony_ci */ 10862306a36Sopenharmony_ci struct fcoe_rdev_entry *rdev_entry; /* Rdev entry */ 10962306a36Sopenharmony_ci struct csio_service_parms rn_sparm; 11062306a36Sopenharmony_ci 11162306a36Sopenharmony_ci /* FC transport attributes */ 11262306a36Sopenharmony_ci struct fc_rport *rport; /* FC transport rport */ 11362306a36Sopenharmony_ci uint32_t supp_classes; /* Supported FC classes */ 11462306a36Sopenharmony_ci uint32_t maxframe_size; /* Max Frame size */ 11562306a36Sopenharmony_ci uint32_t scsi_id; /* Transport given SCSI id */ 11662306a36Sopenharmony_ci 11762306a36Sopenharmony_ci struct csio_rnode_stats stats; /* Common rnode stats */ 11862306a36Sopenharmony_ci}; 11962306a36Sopenharmony_ci 12062306a36Sopenharmony_ci#define csio_rn_flowid(rn) ((rn)->flowid) 12162306a36Sopenharmony_ci#define csio_rn_wwpn(rn) ((rn)->rn_sparm.wwpn) 12262306a36Sopenharmony_ci#define csio_rn_wwnn(rn) ((rn)->rn_sparm.wwnn) 12362306a36Sopenharmony_ci#define csio_rnode_to_lnode(rn) ((rn)->lnp) 12462306a36Sopenharmony_ci 12562306a36Sopenharmony_ciint csio_is_rnode_ready(struct csio_rnode *rn); 12662306a36Sopenharmony_civoid csio_rnode_state_to_str(struct csio_rnode *rn, int8_t *str); 12762306a36Sopenharmony_ci 12862306a36Sopenharmony_cistruct csio_rnode *csio_rnode_lookup_portid(struct csio_lnode *, uint32_t); 12962306a36Sopenharmony_cistruct csio_rnode *csio_confirm_rnode(struct csio_lnode *, 13062306a36Sopenharmony_ci uint32_t, struct fcoe_rdev_entry *); 13162306a36Sopenharmony_ci 13262306a36Sopenharmony_civoid csio_rnode_fwevt_handler(struct csio_rnode *rn, uint8_t fwevt); 13362306a36Sopenharmony_ci 13462306a36Sopenharmony_civoid csio_put_rnode(struct csio_lnode *ln, struct csio_rnode *rn); 13562306a36Sopenharmony_ci 13662306a36Sopenharmony_civoid csio_reg_rnode(struct csio_rnode *); 13762306a36Sopenharmony_civoid csio_unreg_rnode(struct csio_rnode *); 13862306a36Sopenharmony_ci 13962306a36Sopenharmony_civoid csio_rnode_devloss_handler(struct csio_rnode *); 14062306a36Sopenharmony_ci 14162306a36Sopenharmony_ci#endif /* ifndef __CSIO_RNODE_H__ */ 142