0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035 #ifndef __CSIO_LNODE_H__
0036 #define __CSIO_LNODE_H__
0037
0038 #include <linux/kref.h>
0039 #include <linux/timer.h>
0040 #include <linux/workqueue.h>
0041 #include <scsi/fc/fc_els.h>
0042
0043
0044 #include "csio_defs.h"
0045 #include "csio_hw.h"
0046
0047 #define CSIO_FCOE_MAX_NPIV 128
0048 #define CSIO_FCOE_MAX_RNODES 2048
0049
0050
0051 #define CSIO_HBA_PORTSPEED_UNKNOWN 0x8000
0052
0053 extern int csio_fcoe_rnodes;
0054 extern int csio_fdmi_enable;
0055
0056
0057 enum csio_ln_ev {
0058 CSIO_LNE_NONE = (uint32_t)0,
0059 CSIO_LNE_LINKUP,
0060 CSIO_LNE_FAB_INIT_DONE,
0061 CSIO_LNE_LINK_DOWN,
0062 CSIO_LNE_DOWN_LINK,
0063 CSIO_LNE_LOGO,
0064 CSIO_LNE_CLOSE,
0065 CSIO_LNE_MAX_EVENT,
0066 };
0067
0068
0069 struct csio_fcf_info {
0070 struct list_head list;
0071 uint8_t priority;
0072 uint8_t mac[6];
0073 uint8_t name_id[8];
0074 uint8_t fabric[8];
0075 uint16_t vf_id;
0076 uint8_t vlan_id;
0077 uint16_t max_fcoe_size;
0078 uint8_t fc_map[3];
0079 uint32_t fka_adv;
0080 uint32_t fcfi;
0081 uint8_t get_next:1;
0082 uint8_t link_aff:1;
0083 uint8_t fpma:1;
0084 uint8_t spma:1;
0085 uint8_t login:1;
0086 uint8_t portid;
0087 uint8_t spma_mac[6];
0088 struct kref kref;
0089 };
0090
0091
0092 #define CSIO_LNF_FIPSUPP 0x00000001
0093 #define CSIO_LNF_NPIVSUPP 0x00000002
0094 #define CSIO_LNF_LINK_ENABLE 0x00000004
0095 #define CSIO_LNF_FDMI_ENABLE 0x00000008
0096
0097
0098 enum csio_ln_fc_evt {
0099 CSIO_LN_FC_LINKUP = 1,
0100 CSIO_LN_FC_LINKDOWN,
0101 CSIO_LN_FC_RSCN,
0102 CSIO_LN_FC_ATTRIB_UPDATE,
0103 };
0104
0105
0106 struct csio_lnode_stats {
0107 uint32_t n_link_up;
0108 uint32_t n_link_down;
0109 uint32_t n_err;
0110 uint32_t n_err_nomem;
0111 uint32_t n_inval_parm;
0112 uint32_t n_evt_unexp;
0113 uint32_t n_evt_drop;
0114 uint32_t n_rnode_match;
0115 uint32_t n_dev_loss_tmo;
0116 uint32_t n_fdmi_err;
0117 uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO + 1];
0118 enum csio_ln_ev n_evt_sm[CSIO_LNE_MAX_EVENT];
0119 uint32_t n_rnode_alloc;
0120 uint32_t n_rnode_free;
0121 uint32_t n_rnode_nomem;
0122 uint32_t n_input_requests;
0123 uint32_t n_output_requests;
0124 uint32_t n_control_requests;
0125 uint32_t n_input_bytes;
0126 uint32_t n_output_bytes;
0127 uint32_t rsvd1;
0128 };
0129
0130
0131 struct csio_lnode_params {
0132 uint32_t ra_tov;
0133 uint32_t fcfi;
0134 uint32_t log_level;
0135 };
0136
0137 struct csio_service_parms {
0138 struct fc_els_csp csp;
0139 uint8_t wwpn[8];
0140 uint8_t wwnn[8];
0141 struct fc_els_cssp clsp[4];
0142 uint8_t vvl[16];
0143 };
0144
0145
0146 struct csio_lnode {
0147 struct csio_sm sm;
0148
0149
0150 struct csio_hw *hwp;
0151 uint8_t portid;
0152 uint8_t rsvd1;
0153 uint16_t rsvd2;
0154 uint32_t dev_num;
0155 uint32_t flags;
0156 struct list_head fcf_lsthead;
0157 struct csio_fcf_info *fcfinfo;
0158 struct csio_ioreq *mgmt_req;
0159
0160
0161 uint8_t mac[6];
0162 uint32_t nport_id;
0163 struct csio_service_parms ln_sparm;
0164
0165
0166 uint32_t fcf_flowid;
0167 uint32_t vnp_flowid;
0168 uint16_t ssn_cnt;
0169 uint8_t cur_evt;
0170 uint8_t prev_evt;
0171
0172
0173 struct list_head cln_head;
0174
0175
0176 uint32_t num_vports;
0177 struct csio_lnode *pln;
0178
0179
0180 struct list_head cmpl_q;
0181
0182
0183 struct list_head rnhead;
0184 uint32_t num_reg_rnodes;
0185
0186
0187 uint32_t n_scsi_tgts;
0188
0189
0190 uint32_t last_scan_ntgts;
0191
0192
0193 uint32_t tgt_scan_tick;
0194
0195
0196
0197 struct fc_vport *fc_vport;
0198 struct fc_host_statistics fch_stats;
0199
0200 struct csio_lnode_stats stats;
0201 struct csio_lnode_params params;
0202 };
0203
0204 #define csio_lnode_to_hw(ln) ((ln)->hwp)
0205 #define csio_root_lnode(ln) (csio_lnode_to_hw((ln))->rln)
0206 #define csio_parent_lnode(ln) ((ln)->pln)
0207 #define csio_ln_flowid(ln) ((ln)->vnp_flowid)
0208 #define csio_ln_wwpn(ln) ((ln)->ln_sparm.wwpn)
0209 #define csio_ln_wwnn(ln) ((ln)->ln_sparm.wwnn)
0210
0211 #define csio_is_root_ln(ln) (((ln) == csio_root_lnode((ln))) ? 1 : 0)
0212 #define csio_is_phys_ln(ln) (((ln)->pln == NULL) ? 1 : 0)
0213 #define csio_is_npiv_ln(ln) (((ln)->pln != NULL) ? 1 : 0)
0214
0215
0216 #define csio_ln_dbg(_ln, _fmt, ...) \
0217 csio_dbg(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
0218 CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
0219
0220 #define csio_ln_err(_ln, _fmt, ...) \
0221 csio_err(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
0222 CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
0223
0224 #define csio_ln_warn(_ln, _fmt, ...) \
0225 csio_warn(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
0226 CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
0227
0228
0229 enum csio_ln_notify {
0230 CSIO_LN_NOTIFY_HWREADY = 1,
0231 CSIO_LN_NOTIFY_HWSTOP,
0232 CSIO_LN_NOTIFY_HWREMOVE,
0233 CSIO_LN_NOTIFY_HWRESET,
0234 };
0235
0236 void csio_fcoe_fwevt_handler(struct csio_hw *, __u8 cpl_op, __be64 *);
0237 int csio_is_lnode_ready(struct csio_lnode *);
0238 void csio_lnode_state_to_str(struct csio_lnode *ln, int8_t *str);
0239 struct csio_lnode *csio_lnode_lookup_by_wwpn(struct csio_hw *, uint8_t *);
0240 int csio_get_phy_port_stats(struct csio_hw *, uint8_t ,
0241 struct fw_fcoe_port_stats *);
0242 int csio_scan_done(struct csio_lnode *, unsigned long, unsigned long,
0243 unsigned long, unsigned long);
0244 void csio_notify_lnodes(struct csio_hw *, enum csio_ln_notify);
0245 void csio_disable_lnodes(struct csio_hw *, uint8_t, bool);
0246 void csio_lnode_async_event(struct csio_lnode *, enum csio_ln_fc_evt);
0247 int csio_ln_fdmi_start(struct csio_lnode *, void *);
0248 int csio_lnode_start(struct csio_lnode *);
0249 void csio_lnode_stop(struct csio_lnode *);
0250 void csio_lnode_close(struct csio_lnode *);
0251 int csio_lnode_init(struct csio_lnode *, struct csio_hw *,
0252 struct csio_lnode *);
0253 void csio_lnode_exit(struct csio_lnode *);
0254
0255 #endif