Back to home page

OSCL-LXR

 
 

    


0001 /*
0002  * This file is part of the Chelsio FCoE driver for Linux.
0003  *
0004  * Copyright (c) 2008-2012 Chelsio Communications, Inc. All rights reserved.
0005  *
0006  * This software is available to you under a choice of one of two
0007  * licenses.  You may choose to be licensed under the terms of the GNU
0008  * General Public License (GPL) Version 2, available from the file
0009  * COPYING in the main directory of this source tree, or the
0010  * OpenIB.org BSD license below:
0011  *
0012  *     Redistribution and use in source and binary forms, with or
0013  *     without modification, are permitted provided that the following
0014  *     conditions are met:
0015  *
0016  *      - Redistributions of source code must retain the above
0017  *        copyright notice, this list of conditions and the following
0018  *        disclaimer.
0019  *
0020  *      - Redistributions in binary form must reproduce the above
0021  *        copyright notice, this list of conditions and the following
0022  *        disclaimer in the documentation and/or other materials
0023  *        provided with the distribution.
0024  *
0025  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
0026  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
0027  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
0028  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
0029  * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
0030  * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
0031  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
0032  * SOFTWARE.
0033  */
0034 
0035 #ifndef __CSIO_RNODE_H__
0036 #define __CSIO_RNODE_H__
0037 
0038 #include "csio_defs.h"
0039 
0040 /* State machine evets */
0041 enum csio_rn_ev {
0042     CSIO_RNFE_NONE = (uint32_t)0,           /* None */
0043     CSIO_RNFE_LOGGED_IN,                /* [N/F]Port login
0044                              * complete.
0045                              */
0046     CSIO_RNFE_PRLI_DONE,                /* PRLI completed */
0047     CSIO_RNFE_PLOGI_RECV,               /* Received PLOGI */
0048     CSIO_RNFE_PRLI_RECV,                /* Received PLOGI */
0049     CSIO_RNFE_LOGO_RECV,                /* Received LOGO */
0050     CSIO_RNFE_PRLO_RECV,                /* Received PRLO */
0051     CSIO_RNFE_DOWN,                 /* Rnode is down */
0052     CSIO_RNFE_CLOSE,                /* Close rnode */
0053     CSIO_RNFE_NAME_MISSING,             /* Rnode name missing
0054                              * in name server.
0055                              */
0056     CSIO_RNFE_MAX_EVENT,
0057 };
0058 
0059 /* rnode stats */
0060 struct csio_rnode_stats {
0061     uint32_t    n_err;      /* error */
0062     uint32_t    n_err_inval;    /* invalid parameter */
0063     uint32_t    n_err_nomem;    /* error nomem */
0064     uint32_t    n_evt_unexp;    /* unexpected event */
0065     uint32_t    n_evt_drop; /* unexpected event */
0066     uint32_t    n_evt_fw[PROTO_ERR_IMPL_LOGO + 1];  /* fw events */
0067     enum csio_rn_ev n_evt_sm[CSIO_RNFE_MAX_EVENT];  /* State m/c events */
0068     uint32_t    n_lun_rst;  /* Number of resets of
0069                      * of LUNs under this
0070                      * target
0071                      */
0072     uint32_t    n_lun_rst_fail; /* Number of LUN reset
0073                      * failures.
0074                      */
0075     uint32_t    n_tgt_rst;  /* Number of target resets */
0076     uint32_t    n_tgt_rst_fail; /* Number of target reset
0077                      * failures.
0078                      */
0079 };
0080 
0081 /* Defines for rnode role */
0082 #define CSIO_RNFR_INITIATOR 0x1
0083 #define CSIO_RNFR_TARGET    0x2
0084 #define CSIO_RNFR_FABRIC    0x4
0085 #define CSIO_RNFR_NS        0x8
0086 #define CSIO_RNFR_NPORT     0x10
0087 
0088 struct csio_rnode {
0089     struct csio_sm      sm;         /* State machine -
0090                              * should be the
0091                              * 1st member
0092                              */
0093     struct csio_lnode   *lnp;           /* Pointer to owning
0094                              * Lnode */
0095     uint32_t        flowid;         /* Firmware ID */
0096     struct list_head    host_cmpl_q;        /* SCSI IOs
0097                              * pending to completed
0098                              * to Mid-layer.
0099                              */
0100     /* FC identifiers for remote node */
0101     uint32_t        nport_id;
0102     uint16_t        fcp_flags;      /* FCP Flags */
0103     uint8_t         cur_evt;        /* Current event */
0104     uint8_t         prev_evt;       /* Previous event */
0105     uint32_t        role;           /* Fabric/Target/
0106                              * Initiator/NS
0107                              */
0108     struct fcoe_rdev_entry      *rdev_entry;    /* Rdev entry */
0109     struct csio_service_parms   rn_sparm;
0110 
0111     /* FC transport attributes */
0112     struct fc_rport     *rport;     /* FC transport rport */
0113     uint32_t        supp_classes;   /* Supported FC classes */
0114     uint32_t        maxframe_size;  /* Max Frame size */
0115     uint32_t        scsi_id;    /* Transport given SCSI id */
0116 
0117     struct csio_rnode_stats stats;      /* Common rnode stats */
0118 };
0119 
0120 #define csio_rn_flowid(rn)          ((rn)->flowid)
0121 #define csio_rn_wwpn(rn)            ((rn)->rn_sparm.wwpn)
0122 #define csio_rn_wwnn(rn)            ((rn)->rn_sparm.wwnn)
0123 #define csio_rnode_to_lnode(rn)         ((rn)->lnp)
0124 
0125 int csio_is_rnode_ready(struct csio_rnode *rn);
0126 void csio_rnode_state_to_str(struct csio_rnode *rn, int8_t *str);
0127 
0128 struct csio_rnode *csio_rnode_lookup_portid(struct csio_lnode *, uint32_t);
0129 struct csio_rnode *csio_confirm_rnode(struct csio_lnode *,
0130                       uint32_t, struct fcoe_rdev_entry *);
0131 
0132 void csio_rnode_fwevt_handler(struct csio_rnode *rn, uint8_t fwevt);
0133 
0134 void csio_put_rnode(struct csio_lnode *ln, struct csio_rnode *rn);
0135 
0136 void csio_reg_rnode(struct csio_rnode *);
0137 void csio_unreg_rnode(struct csio_rnode *);
0138 
0139 void csio_rnode_devloss_handler(struct csio_rnode *);
0140 
0141 #endif /* ifndef __CSIO_RNODE_H__ */