1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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
57 enum csio_ln_ev {
58 CSIO_LNE_NONE = (uint32_t)0,
59 CSIO_LNE_LINKUP,
60 CSIO_LNE_FAB_INIT_DONE,
61 CSIO_LNE_LINK_DOWN,
62 CSIO_LNE_DOWN_LINK,
63 CSIO_LNE_LOGO,
64 CSIO_LNE_CLOSE,
65 CSIO_LNE_MAX_EVENT,
66 };
67
68
69 struct csio_fcf_info {
70 struct list_head list;
71 uint8_t priority;
72 uint8_t mac[6];
73 uint8_t name_id[8];
74 uint8_t fabric[8];
75 uint16_t vf_id;
76 uint8_t vlan_id;
77 uint16_t max_fcoe_size;
78 uint8_t fc_map[3];
79 uint32_t fka_adv;
80 uint32_t fcfi;
81 uint8_t get_next:1;
82 uint8_t link_aff:1;
83 uint8_t fpma:1;
84 uint8_t spma:1;
85 uint8_t login:1;
86 uint8_t portid;
87 uint8_t spma_mac[6];
88 struct kref kref;
89 };
90
91
92 #define CSIO_LNF_FIPSUPP 0x00000001
93 #define CSIO_LNF_NPIVSUPP 0x00000002
94 #define CSIO_LNF_LINK_ENABLE 0x00000004
95 #define CSIO_LNF_FDMI_ENABLE 0x00000008
96
97
98 enum csio_ln_fc_evt {
99 CSIO_LN_FC_LINKUP = 1,
100 CSIO_LN_FC_LINKDOWN,
101 CSIO_LN_FC_RSCN,
102 CSIO_LN_FC_ATTRIB_UPDATE,
103 };
104
105
106 struct csio_lnode_stats {
107 uint32_t n_link_up;
108 uint32_t n_link_down;
109 uint32_t n_err;
110 uint32_t n_err_nomem;
111 uint32_t n_inval_parm;
112 uint32_t n_evt_unexp;
113 uint32_t n_evt_drop;
114 uint32_t n_rnode_match;
115 uint32_t n_dev_loss_tmo;
116 uint32_t n_fdmi_err;
117 uint32_t n_evt_fw[PROTO_ERR_IMPL_LOGO + 1];
118 enum csio_ln_ev n_evt_sm[CSIO_LNE_MAX_EVENT];
119 uint32_t n_rnode_alloc;
120 uint32_t n_rnode_free;
121 uint32_t n_rnode_nomem;
122 uint32_t n_input_requests;
123 uint32_t n_output_requests;
124 uint32_t n_control_requests;
125 uint32_t n_input_bytes;
126 uint32_t n_output_bytes;
127 uint32_t rsvd1;
128 };
129
130
131 struct csio_lnode_params {
132 uint32_t ra_tov;
133 uint32_t fcfi;
134 uint32_t log_level;
135 };
136
137 struct csio_service_parms {
138 struct fc_els_csp csp;
139 uint8_t wwpn[8];
140 uint8_t wwnn[8];
141 struct fc_els_cssp clsp[4];
142 uint8_t vvl[16];
143 };
144
145
146 struct csio_lnode {
147 struct csio_sm sm;
148
149
150 struct csio_hw *hwp;
151 uint8_t portid;
152 uint8_t rsvd1;
153 uint16_t rsvd2;
154 uint32_t dev_num;
155 uint32_t flags;
156 struct list_head fcf_lsthead;
157 struct csio_fcf_info *fcfinfo;
158 struct csio_ioreq *mgmt_req;
159
160
161 uint8_t mac[6];
162 uint32_t nport_id;
163 struct csio_service_parms ln_sparm;
164
165
166 uint32_t fcf_flowid;
167 uint32_t vnp_flowid;
168 uint16_t ssn_cnt;
169 uint8_t cur_evt;
170 uint8_t prev_evt;
171
172
173 struct list_head cln_head;
174
175
176 uint32_t num_vports;
177 struct csio_lnode *pln;
178
179
180 struct list_head cmpl_q;
181
182
183 struct list_head rnhead;
184 uint32_t num_reg_rnodes;
185
186
187 uint32_t n_scsi_tgts;
188
189
190 uint32_t last_scan_ntgts;
191
192
193 uint32_t tgt_scan_tick;
194
195
196
197 struct fc_vport *fc_vport;
198 struct fc_host_statistics fch_stats;
199
200 struct csio_lnode_stats stats;
201 struct csio_lnode_params params;
202 };
203
204 #define csio_lnode_to_hw(ln) ((ln)->hwp)
205 #define csio_root_lnode(ln) (csio_lnode_to_hw((ln))->rln)
206 #define csio_parent_lnode(ln) ((ln)->pln)
207 #define csio_ln_flowid(ln) ((ln)->vnp_flowid)
208 #define csio_ln_wwpn(ln) ((ln)->ln_sparm.wwpn)
209 #define csio_ln_wwnn(ln) ((ln)->ln_sparm.wwnn)
210
211 #define csio_is_root_ln(ln) (((ln) == csio_root_lnode((ln))) ? 1 : 0)
212 #define csio_is_phys_ln(ln) (((ln)->pln == NULL) ? 1 : 0)
213 #define csio_is_npiv_ln(ln) (((ln)->pln != NULL) ? 1 : 0)
214
215
216 #define csio_ln_dbg(_ln, _fmt, ...) \
217 csio_dbg(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
218 CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
219
220 #define csio_ln_err(_ln, _fmt, ...) \
221 csio_err(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
222 CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
223
224 #define csio_ln_warn(_ln, _fmt, ...) \
225 csio_warn(_ln->hwp, "%x:%x "_fmt, CSIO_DEVID_HI(_ln), \
226 CSIO_DEVID_LO(_ln), ##__VA_ARGS__);
227
228
229 enum csio_ln_notify {
230 CSIO_LN_NOTIFY_HWREADY = 1,
231 CSIO_LN_NOTIFY_HWSTOP,
232 CSIO_LN_NOTIFY_HWREMOVE,
233 CSIO_LN_NOTIFY_HWRESET,
234 };
235
236 void csio_fcoe_fwevt_handler(struct csio_hw *, __u8 cpl_op, __be64 *);
237 int csio_is_lnode_ready(struct csio_lnode *);
238 void csio_lnode_state_to_str(struct csio_lnode *ln, int8_t *str);
239 struct csio_lnode *csio_lnode_lookup_by_wwpn(struct csio_hw *, uint8_t *);
240 int csio_get_phy_port_stats(struct csio_hw *, uint8_t ,
241 struct fw_fcoe_port_stats *);
242 int csio_scan_done(struct csio_lnode *, unsigned long, unsigned long,
243 unsigned long, unsigned long);
244 void csio_notify_lnodes(struct csio_hw *, enum csio_ln_notify);
245 void csio_disable_lnodes(struct csio_hw *, uint8_t, bool);
246 void csio_lnode_async_event(struct csio_lnode *, enum csio_ln_fc_evt);
247 int csio_ln_fdmi_start(struct csio_lnode *, void *);
248 int csio_lnode_start(struct csio_lnode *);
249 void csio_lnode_stop(struct csio_lnode *);
250 void csio_lnode_close(struct csio_lnode *);
251 int csio_lnode_init(struct csio_lnode *, struct csio_hw *,
252 struct csio_lnode *);
253 void csio_lnode_exit(struct csio_lnode *);
254
255 #endif