| 1 | |
| 2 | * This file is part of the Chelsio FCoE driver for Linux.
|
| 3 | *
|
| 4 | * Copyright (c) 2008-2012 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 __CSIO_LNODE_H__
|
| 36 | #define __CSIO_LNODE_H__
|
| 37 |
|
| 38 | #include <linux/kref.h>
|
| 39 | #include <linux/timer.h>
|
| 40 | #include <linux/workqueue.h>
|
| 41 | #include <scsi/fc/fc_els.h>
|
| 42 |
|
| 43 |
|
| 44 | #include "csio_defs.h"
|
| 45 | #include "csio_hw.h"
|
| 46 |
|
| 47 | #define CSIO_FCOE_MAX_NPIV 128
|
| 48 | #define CSIO_FCOE_MAX_RNODES 2048
|
| 49 |
|
| 50 |
|
| 51 | #define CSIO_HBA_PORTSPEED_UNKNOWN 0x8000
|
| 52 |
|
| 53 | extern int csio_fcoe_rnodes;
|
| 54 | extern int csio_fdmi_enable;
|
| 55 |
|
| 56 | struct csio_fcf_info {
|
| 57 | struct list_head list;
|
| 58 | uint8_t priority;
|
| 59 | uint8_t mac[6];
|
| 60 | uint8_t name_id[8];
|
| 61 | uint8_t fabric[8];
|
| 62 | uint16_t vf_id;
|
| 63 | uint8_t vlan_id;
|
| 64 | uint16_t max_fcoe_size;
|
| 65 | uint8_t fc_map[3];
|
| 66 | uint32_t fka_adv;
|
| 67 | uint32_t fcfi;
|
| 68 | uint8_t get_next:1;
|
| 69 | uint8_t link_aff:1;
|
| 70 | uint8_t fpma:1;
|
| 71 | uint8_t spma:1;
|
| 72 | uint8_t login:1;
|
| 73 | uint8_t portid;
|
| 74 | uint8_t spma_mac[6];
|
| 75 | struct kref kref;
|
| 76 | };
|
| 77 |
|
| 78 |
|
| 79 | #define CSIO_LNF_FIPSUPP 0x00000001
|
| 80 | #define CSIO_LNF_NPIVSUPP 0x00000002
|
| 81 | #define CSIO_LNF_LINK_ENABLE 0x00000004
|
| 82 | #define CSIO_LNF_FDMI_ENABLE 0x00000008
|
| 83 |
|
| 84 |
|
| 85 | enum csio_ln_fc_evt {
|
| 86 | CSIO_LN_FC_LINKUP = 1,
|
| 87 | CSIO_LN_FC_LINKDOWN,
|
| 88 | CSIO_LN_FC_RSCN,
|
| 89 | CSIO_LN_FC_ATTRIB_UPDATE,
|
| 90 | };
|
| 91 |
|
| 92 |
|
| 93 | struct csio_lnode_stats {
|
| 94 | uint32_t n_link_up;
|
| 95 | uint32_t n_link_down;
|
| 96 | uint32_t n_err;
|
| 97 | uint32_t n_err_nomem;
|
| 98 | uint32_t n_inval_parm;
|
| 99 | uint32_t n_evt_unexp;
|
| 100 | uint32_t n_evt_drop;
|
| 101 | uint32_t n_rnode_match;
|
| 102 | uint32_t n_dev_loss_tmo;
|
| 103 | uint32_t n_fdmi_err;
|
| 104 | uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO + 1];
|
| 105 | enum csio_ln_ev n_evt_sm[CSIO_LNE_MAX_EVENT];
|
| 106 | uint32_t n_rnode_alloc;
|
| 107 | uint32_t n_rnode_free;
|
| 108 | uint32_t n_rnode_nomem;
|
| 109 | uint32_t n_input_requests;
|
| 110 | uint32_t n_output_requests;
|
| 111 | uint32_t n_control_requests;
|
| 112 | uint32_t n_input_bytes;
|
| 113 | uint32_t n_output_bytes;
|
| 114 | uint32_t rsvd1;
|
| 115 | };
|
| 116 |
|
| 117 |
|
| 118 | struct csio_lnode_params {
|
| 119 | uint32_t ra_tov;
|
| 120 | uint32_t fcfi;
|
| 121 | uint32_t log_level;
|
| 122 | };
|
| 123 |
|
| 124 | struct csio_service_parms {
|
| 125 | struct fc_els_csp csp;
|
| 126 | uint8_t wwpn[8];
|
| 127 | uint8_t wwnn[8];
|
| 128 | struct fc_els_cssp clsp[4];
|
| 129 | uint8_t vvl[16];
|
| 130 | };
|
| 131 |
|
| 132 |
|
| 133 | struct csio_lnode {
|
| 134 | struct csio_sm sm; |
| 135 | * lnode list.
|
| 136 |
|
| 137 | struct csio_hw *hwp;
|
| 138 | uint8_t portid;
|
| 139 | uint8_t rsvd1;
|
| 140 | uint16_t rsvd2;
|
| 141 | uint32_t dev_num;
|
| 142 | uint32_t flags;
|
| 143 | struct list_head fcf_lsthead;
|
| 144 | struct csio_fcf_info *fcfinfo;
|
| 145 | struct csio_ioreq *mgmt_req;
|
| 146 |
|
| 147 |
|
| 148 | uint8_t mac[6];
|
| 149 | uint32_t nport_id;
|
| 150 | struct csio_service_parms ln_sparm;
|
| 151 |
|
| 152 |
|
| 153 | uint32_t fcf_flowid;
|
| 154 | uint32_t vnp_flowid;
|
| 155 | uint16_t ssn_cnt;
|
| 156 | uint8_t cur_evt;
|
| 157 | uint8_t prev_evt;
|
| 158 |
|
| 159 |
|
| 160 | struct list_head cln_head; |
| 161 | * list.
|
| 162 |
|
| 163 | uint32_t num_vports;
|
| 164 | struct csio_lnode *pln; |
| 165 | * lnodes.
|
| 166 |
|
| 167 | struct list_head cmpl_q;
|
| 168 |
|
| 169 |
|
| 170 | struct list_head rnhead;
|
| 171 | uint32_t num_reg_rnodes; |
| 172 | * with the host.
|
| 173 |
|
| 174 | uint32_t n_scsi_tgts; |
| 175 | * found
|
| 176 |
|
| 177 | uint32_t last_scan_ntgts; |
| 178 | * found per last scan.
|
| 179 |
|
| 180 | uint32_t tgt_scan_tick; |
| 181 | * new tgt found
|
| 182 |
|
| 183 |
|
| 184 | struct fc_vport *fc_vport;
|
| 185 | struct fc_host_statistics fch_stats;
|
| 186 |
|
| 187 | struct csio_lnode_stats stats;
|
| 188 | struct csio_lnode_params params;
|
| 189 | };
|
| 190 |
|
| 191 | #define csio_lnode_to_hw(ln) ((ln)->hwp)
|
| 192 | #define csio_root_lnode(ln) (csio_lnode_to_hw((ln))->rln)
|
| 193 | #define csio_parent_lnode(ln) ((ln)->pln)
|
| 194 | #define csio_ln_flowid(ln) ((ln)->vnp_flowid)
|
| 195 | #define csio_ln_wwpn(ln) ((ln)->ln_sparm.wwpn)
|
| 196 | #define csio_ln_wwnn(ln) ((ln)->ln_sparm.wwnn)
|
| 197 |
|
| 198 | #define csio_is_root_ln(ln) (((ln) == csio_root_lnode((ln))) ? 1 : 0)
|
| 199 | #define csio_is_phys_ln(ln) (((ln)->pln == NULL) ? 1 : 0)
|
| 200 | #define csio_is_npiv_ln(ln) (((ln)->pln != NULL) ? 1 : 0)
|
| 201 |
|
| 202 |
|
| 203 | #define csio_ln_dbg(_ln, _fmt, ...) \
|
| 204 | csio_dbg(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
|
| 205 | CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
|
| 206 |
|
| 207 | #define csio_ln_err(_ln, _fmt, ...) \
|
| 208 | csio_err(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
|
| 209 | CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
|
| 210 |
|
| 211 | #define csio_ln_warn(_ln, _fmt, ...) \
|
| 212 | csio_warn(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
|
| 213 | CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
|
| 214 |
|
| 215 |
|
| 216 | enum csio_ln_notify {
|
| 217 | CSIO_LN_NOTIFY_HWREADY = 1,
|
| 218 | CSIO_LN_NOTIFY_HWSTOP,
|
| 219 | CSIO_LN_NOTIFY_HWREMOVE,
|
| 220 | CSIO_LN_NOTIFY_HWRESET,
|
| 221 | };
|
| 222 |
|
| 223 | void csio_fcoe_fwevt_handler(struct csio_hw *, __u8 cpl_op, __be64 *);
|
| 224 | int csio_is_lnode_ready(struct csio_lnode *);
|
| 225 | void csio_lnode_state_to_str(struct csio_lnode *ln, int8_t *str);
|
| 226 | struct csio_lnode *csio_lnode_lookup_by_wwpn(struct csio_hw *, uint8_t *);
|
| 227 | int csio_get_phy_port_stats(struct csio_hw *, uint8_t ,
|
| 228 | struct fw_fcoe_port_stats *);
|
| 229 | int csio_scan_done(struct csio_lnode *, unsigned long, unsigned long,
|
| 230 | unsigned long, unsigned long);
|
| 231 | void csio_notify_lnodes(struct csio_hw *, enum csio_ln_notify);
|
| 232 | void csio_disable_lnodes(struct csio_hw *, uint8_t, bool);
|
| 233 | void csio_lnode_async_event(struct csio_lnode *, enum csio_ln_fc_evt);
|
| 234 | int csio_ln_fdmi_start(struct csio_lnode *, void *);
|
| 235 | int csio_lnode_start(struct csio_lnode *);
|
| 236 | void csio_lnode_stop(struct csio_lnode *);
|
| 237 | void csio_lnode_close(struct csio_lnode *);
|
| 238 | int csio_lnode_init(struct csio_lnode *, struct csio_hw *,
|
| 239 | struct csio_lnode *);
|
| 240 | void csio_lnode_exit(struct csio_lnode *);
|
| 241 |
|
| 242 | #endif
|