1 /* SPDX-License-Identifier: GPL-2.0-only */
2 /*
3 * Copyright (c) 2005-2014 Brocade Communications Systems, Inc.
4 * Copyright (c) 2014- QLogic Corporation.
5 * All rights reserved
6 * www.qlogic.com
7 *
8 * Linux driver for QLogic BR-series Fibre Channel Host Bus Adapter.
9 */
10
11 #ifndef __BFA_FCS_H__
12 #define __BFA_FCS_H__
13
14 #include "bfa_cs.h"
15 #include "bfa_defs.h"
16 #include "bfa_defs_fcs.h"
17 #include "bfa_modules.h"
18 #include "bfa_fc.h"
19
20 #define BFA_FCS_OS_STR_LEN 64
21
22 /*
23 * lps_pvt BFA LPS private functions
24 */
25
26 enum bfa_lps_event {
27 BFA_LPS_SM_LOGIN = 1, /* login request from user */
28 BFA_LPS_SM_LOGOUT = 2, /* logout request from user */
29 BFA_LPS_SM_FWRSP = 3, /* f/w response to login/logout */
30 BFA_LPS_SM_RESUME = 4, /* space present in reqq queue */
31 BFA_LPS_SM_DELETE = 5, /* lps delete from user */
32 BFA_LPS_SM_OFFLINE = 6, /* Link is offline */
33 BFA_LPS_SM_RX_CVL = 7, /* Rx clear virtual link */
34 BFA_LPS_SM_SET_N2N_PID = 8, /* Set assigned PID for n2n */
35 };
36
37
38 /*
39 * !!! Only append to the enums defined here to avoid any versioning
40 * !!! needed between trace utility and driver version
41 */
42 enum {
43 BFA_TRC_FCS_FCS = 1,
44 BFA_TRC_FCS_PORT = 2,
45 BFA_TRC_FCS_RPORT = 3,
46 BFA_TRC_FCS_FCPIM = 4,
47 };
48
49
50 struct bfa_fcs_s;
51
52 #define __fcs_min_cfg(__fcs) ((__fcs)->min_cfg)
53
54 #define BFA_FCS_BRCD_SWITCH_OUI 0x051e
55 #define N2N_LOCAL_PID 0x010000
56 #define N2N_REMOTE_PID 0x020000
57 #define BFA_FCS_RETRY_TIMEOUT 2000
58 #define BFA_FCS_MAX_NS_RETRIES 5
59 #define BFA_FCS_PID_IS_WKA(pid) ((bfa_ntoh3b(pid) > 0xFFF000) ? 1 : 0)
60 #define BFA_FCS_MAX_RPORT_LOGINS 1024
61
62 struct bfa_fcs_lport_ns_s {
63 bfa_sm_t sm; /* state machine */
64 struct bfa_timer_s timer;
65 struct bfa_fcs_lport_s *port; /* parent port */
66 struct bfa_fcxp_s *fcxp;
67 struct bfa_fcxp_wqe_s fcxp_wqe;
68 u8 num_rnnid_retries;
69 u8 num_rsnn_nn_retries;
70 };
71
72
73 struct bfa_fcs_lport_scn_s {
74 bfa_sm_t sm; /* state machine */
75 struct bfa_timer_s timer;
76 struct bfa_fcs_lport_s *port; /* parent port */
77 struct bfa_fcxp_s *fcxp;
78 struct bfa_fcxp_wqe_s fcxp_wqe;
79 };
80
81
82 struct bfa_fcs_lport_fdmi_s {
83 bfa_sm_t sm; /* state machine */
84 struct bfa_timer_s timer;
85 struct bfa_fcs_lport_ms_s *ms; /* parent ms */
86 struct bfa_fcxp_s *fcxp;
87 struct bfa_fcxp_wqe_s fcxp_wqe;
88 u8 retry_cnt; /* retry count */
89 u8 rsvd[3];
90 };
91
92
93 struct bfa_fcs_lport_ms_s {
94 bfa_sm_t sm; /* state machine */
95 struct bfa_timer_s timer;
96 struct bfa_fcs_lport_s *port; /* parent port */
97 struct bfa_fcxp_s *fcxp;
98 struct bfa_fcxp_wqe_s fcxp_wqe;
99 struct bfa_fcs_lport_fdmi_s fdmi; /* FDMI component of MS */
100 u8 retry_cnt; /* retry count */
101 u8 rsvd[3];
102 };
103
104
105 struct bfa_fcs_lport_fab_s {
106 struct bfa_fcs_lport_ns_s ns; /* NS component of port */
107 struct bfa_fcs_lport_scn_s scn; /* scn component of port */
108 struct bfa_fcs_lport_ms_s ms; /* MS component of port */
109 };
110
111 #define MAX_ALPA_COUNT 127
112
113 struct bfa_fcs_lport_loop_s {
114 u8 num_alpa; /* Num of ALPA entries in the map */
115 u8 alpabm_valid; /* alpa bitmap valid or not (1 or 0) */
116 u8 alpa_pos_map[MAX_ALPA_COUNT]; /* ALPA Positional Map */
117 struct bfa_fcs_lport_s *port; /* parent port */
118 };
119
120 struct bfa_fcs_lport_n2n_s {
121 u32 rsvd;
122 __be16 reply_oxid; /* ox_id from the req flogi to be
123 *used in flogi acc */
124 wwn_t rem_port_wwn; /* Attached port's wwn */
125 };
126
127
128 union bfa_fcs_lport_topo_u {
129 struct bfa_fcs_lport_fab_s pfab;
130 struct bfa_fcs_lport_loop_s ploop;
131 struct bfa_fcs_lport_n2n_s pn2n;
132 };
133
134
135 struct bfa_fcs_lport_s {
136 struct list_head qe; /* used by port/vport */
137 bfa_sm_t sm; /* state machine */
138 struct bfa_fcs_fabric_s *fabric; /* parent fabric */
139 struct bfa_lport_cfg_s port_cfg; /* port configuration */
140 struct bfa_timer_s link_timer; /* timer for link offline */
141 u32 pid:24; /* FC address */
142 u8 lp_tag; /* lport tag */
143 u16 num_rports; /* Num of r-ports */
144 struct list_head rport_q; /* queue of discovered r-ports */
145 struct bfa_fcs_s *fcs; /* FCS instance */
146 union bfa_fcs_lport_topo_u port_topo; /* fabric/loop/n2n details */
147 struct bfad_port_s *bfad_port; /* driver peer instance */
148 struct bfa_fcs_vport_s *vport; /* NULL for base ports */
149 struct bfa_fcxp_s *fcxp;
150 struct bfa_fcxp_wqe_s fcxp_wqe;
151 struct bfa_lport_stats_s stats;
152 struct bfa_wc_s wc; /* waiting counter for events */
153 };
154 #define BFA_FCS_GET_HAL_FROM_PORT(port) (port->fcs->bfa)
155 #define BFA_FCS_GET_NS_FROM_PORT(port) (&port->port_topo.pfab.ns)
156 #define BFA_FCS_GET_SCN_FROM_PORT(port) (&port->port_topo.pfab.scn)
157 #define BFA_FCS_GET_MS_FROM_PORT(port) (&port->port_topo.pfab.ms)
158 #define BFA_FCS_GET_FDMI_FROM_PORT(port) (&port->port_topo.pfab.ms.fdmi)
159 #define BFA_FCS_VPORT_IS_INITIATOR_MODE(port) \
160 (port->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM)
161
162 /*
163 * forward declaration
164 */
165 struct bfad_vf_s;
166
167 enum bfa_fcs_fabric_type {
168 BFA_FCS_FABRIC_UNKNOWN = 0,
169 BFA_FCS_FABRIC_SWITCHED = 1,
170 BFA_FCS_FABRIC_N2N = 2,
171 BFA_FCS_FABRIC_LOOP = 3,
172 };
173
174
175 struct bfa_fcs_fabric_s {
176 struct list_head qe; /* queue element */
177 bfa_sm_t sm; /* state machine */
178 struct bfa_fcs_s *fcs; /* FCS instance */
179 struct bfa_fcs_lport_s bport; /* base logical port */
180 enum bfa_fcs_fabric_type fab_type; /* fabric type */
181 enum bfa_port_type oper_type; /* current link topology */
182 u8 is_vf; /* is virtual fabric? */
183 u8 is_npiv; /* is NPIV supported ? */
184 u8 is_auth; /* is Security/Auth supported ? */
185 u16 bb_credit; /* BB credit from fabric */
186 u16 vf_id; /* virtual fabric ID */
187 u16 num_vports; /* num vports */
188 u16 rsvd;
189 struct list_head vport_q; /* queue of virtual ports */
190 struct list_head vf_q; /* queue of virtual fabrics */
191 struct bfad_vf_s *vf_drv; /* driver vf structure */
192 struct bfa_timer_s link_timer; /* Link Failure timer. Vport */
193 wwn_t fabric_name; /* attached fabric name */
194 bfa_boolean_t auth_reqd; /* authentication required */
195 struct bfa_timer_s delay_timer; /* delay timer */
196 union {
197 u16 swp_vfid;/* switch port VF id */
198 } event_arg;
199 struct bfa_wc_s wc; /* wait counter for delete */
200 struct bfa_vf_stats_s stats; /* fabric/vf stats */
201 struct bfa_lps_s *lps; /* lport login services */
202 u8 fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ];
203 /* attached fabric's ip addr */
204 struct bfa_wc_s stop_wc; /* wait counter for stop */
205 };
206
207 #define bfa_fcs_fabric_npiv_capable(__f) ((__f)->is_npiv)
208 #define bfa_fcs_fabric_is_switched(__f) \
209 ((__f)->fab_type == BFA_FCS_FABRIC_SWITCHED)
210
211 /*
212 * The design calls for a single implementation of base fabric and vf.
213 */
214 #define bfa_fcs_vf_t struct bfa_fcs_fabric_s
215
216 struct bfa_vf_event_s {
217 u32 undefined;
218 };
219
220 /*
221 * @todo : need to move to a global config file.
222 * Maximum Rports supported per port (physical/logical).
223 */
224 #define BFA_FCS_MAX_RPORTS_SUPP 256 /* @todo : tentative value */
225
226 #define bfa_fcs_lport_t struct bfa_fcs_lport_s
227
228 /*
229 * Symbolic Name related defines
230 * Total bytes 255.
231 * Physical Port's symbolic name 128 bytes.
232 * For Vports, Vport's symbolic name is appended to the Physical port's
233 * Symbolic Name.
234 *
235 * Physical Port's symbolic name Format : (Total 128 bytes)
236 * Adapter Model number/name : 16 bytes
237 * Driver Version : 10 bytes
238 * Host Machine Name : 30 bytes
239 * Host OS Info : 44 bytes
240 * Host OS PATCH Info : 16 bytes
241 * ( remaining 12 bytes reserved to be used for separator)
242 */
243 #define BFA_FCS_PORT_SYMBNAME_SEPARATOR " | "
244
245 #define BFA_FCS_PORT_SYMBNAME_MODEL_SZ 16
246 #define BFA_FCS_PORT_SYMBNAME_VERSION_SZ 10
247 #define BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ 30
248 #define BFA_FCS_PORT_SYMBNAME_OSINFO_SZ 44
249 #define BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ 16
250
251 /*
252 * Get FC port ID for a logical port.
253 */
254 #define bfa_fcs_lport_get_fcid(_lport) ((_lport)->pid)
255 #define bfa_fcs_lport_get_pwwn(_lport) ((_lport)->port_cfg.pwwn)
256 #define bfa_fcs_lport_get_nwwn(_lport) ((_lport)->port_cfg.nwwn)
257 #define bfa_fcs_lport_get_psym_name(_lport) ((_lport)->port_cfg.sym_name)
258 #define bfa_fcs_lport_get_nsym_name(_lport) ((_lport)->port_cfg.node_sym_name)
259 #define bfa_fcs_lport_is_initiator(_lport) \
260 ((_lport)->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM)
261 #define bfa_fcs_lport_get_nrports(_lport) \
262 ((_lport) ? (_lport)->num_rports : 0)
263
264 static inline struct bfad_port_s *
bfa_fcs_lport_get_drvport(struct bfa_fcs_lport_s * port)265 bfa_fcs_lport_get_drvport(struct bfa_fcs_lport_s *port)
266 {
267 return port->bfad_port;
268 }
269
270 #define bfa_fcs_lport_get_opertype(_lport) ((_lport)->fabric->oper_type)
271 #define bfa_fcs_lport_get_fabric_name(_lport) ((_lport)->fabric->fabric_name)
272 #define bfa_fcs_lport_get_fabric_ipaddr(_lport) \
273 ((_lport)->fabric->fabric_ip_addr)
274
275 /*
276 * bfa fcs port public functions
277 */
278
279 bfa_boolean_t bfa_fcs_lport_is_online(struct bfa_fcs_lport_s *port);
280 struct bfa_fcs_lport_s *bfa_fcs_get_base_port(struct bfa_fcs_s *fcs);
281 void bfa_fcs_lport_get_rport_quals(struct bfa_fcs_lport_s *port,
282 struct bfa_rport_qualifier_s rport[], int *nrports);
283 wwn_t bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn,
284 int index, int nrports, bfa_boolean_t bwwn);
285
286 struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
287 u16 vf_id, wwn_t lpwwn);
288
289 void bfa_fcs_lport_set_symname(struct bfa_fcs_lport_s *port, char *symname);
290 void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port,
291 struct bfa_lport_info_s *port_info);
292 void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port,
293 struct bfa_lport_attr_s *port_attr);
294 void bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s *fcs_port,
295 struct bfa_lport_stats_s *port_stats);
296 void bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s *fcs_port);
297 enum bfa_port_speed bfa_fcs_lport_get_rport_max_speed(
298 struct bfa_fcs_lport_s *port);
299
300 /* MS FCS routines */
301 void bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s *port);
302 void bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s *port);
303 void bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s *port);
304 void bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s *port);
305
306 /* FDMI FCS routines */
307 void bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s *ms);
308 void bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s *ms);
309 void bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s *ms);
310 void bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s *lport, struct fchs_s *fchs,
311 u16 len);
312 void bfa_fcs_lport_attach(struct bfa_fcs_lport_s *lport, struct bfa_fcs_s *fcs,
313 u16 vf_id, struct bfa_fcs_vport_s *vport);
314 void bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport,
315 struct bfa_lport_cfg_s *port_cfg);
316 void bfa_fcs_lport_online(struct bfa_fcs_lport_s *port);
317 void bfa_fcs_lport_offline(struct bfa_fcs_lport_s *port);
318 void bfa_fcs_lport_delete(struct bfa_fcs_lport_s *port);
319 void bfa_fcs_lport_stop(struct bfa_fcs_lport_s *port);
320 struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pid(
321 struct bfa_fcs_lport_s *port, u32 pid);
322 struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_old_pid(
323 struct bfa_fcs_lport_s *port, u32 pid);
324 struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pwwn(
325 struct bfa_fcs_lport_s *port, wwn_t pwwn);
326 struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_nwwn(
327 struct bfa_fcs_lport_s *port, wwn_t nwwn);
328 struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_qualifier(
329 struct bfa_fcs_lport_s *port, wwn_t pwwn, u32 pid);
330 void bfa_fcs_lport_add_rport(struct bfa_fcs_lport_s *port,
331 struct bfa_fcs_rport_s *rport);
332 void bfa_fcs_lport_del_rport(struct bfa_fcs_lport_s *port,
333 struct bfa_fcs_rport_s *rport);
334 void bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s *vport);
335 void bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *vport);
336 void bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *vport);
337 void bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port);
338 void bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg,
339 struct bfa_fcxp_s *fcxp_alloced);
340 void bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *vport);
341 void bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *vport);
342 void bfa_fcs_lport_fab_scn_online(struct bfa_fcs_lport_s *vport);
343 void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port,
344 struct fchs_s *rx_frame, u32 len);
345 void bfa_fcs_lport_lip_scn_online(bfa_fcs_lport_t *port);
346
347 struct bfa_fcs_vport_s {
348 struct list_head qe; /* queue elem */
349 bfa_sm_t sm; /* state machine */
350 bfa_fcs_lport_t lport; /* logical port */
351 struct bfa_timer_s timer;
352 struct bfad_vport_s *vport_drv; /* Driver private */
353 struct bfa_vport_stats_s vport_stats; /* vport statistics */
354 struct bfa_lps_s *lps; /* Lport login service*/
355 int fdisc_retries;
356 };
357
358 #define bfa_fcs_vport_get_port(vport) \
359 ((struct bfa_fcs_lport_s *)(&vport->port))
360
361 /*
362 * bfa fcs vport public functions
363 */
364 bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport,
365 struct bfa_fcs_s *fcs, u16 vf_id,
366 struct bfa_lport_cfg_s *port_cfg,
367 struct bfad_vport_s *vport_drv);
368 bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport,
369 struct bfa_fcs_s *fcs, u16 vf_id,
370 struct bfa_lport_cfg_s *port_cfg,
371 struct bfad_vport_s *vport_drv);
372 bfa_boolean_t bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s *vport);
373 bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport);
374 bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport);
375 bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport);
376 void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
377 struct bfa_vport_attr_s *vport_attr);
378 struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs,
379 u16 vf_id, wwn_t vpwwn);
380 void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport);
381 void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport);
382 void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport);
383 void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport);
384 void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport);
385 void bfa_fcs_vport_fcs_stop(struct bfa_fcs_vport_s *vport);
386 void bfa_fcs_vport_stop_comp(struct bfa_fcs_vport_s *vport);
387
388 #define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */
389 #define BFA_FCS_RPORT_MAX_RETRIES (5)
390
391 /*
392 * forward declarations
393 */
394 struct bfad_rport_s;
395
396 struct bfa_fcs_itnim_s;
397 struct bfa_fcs_tin_s;
398 struct bfa_fcs_iprp_s;
399
400 /* Rport Features (RPF) */
401 struct bfa_fcs_rpf_s {
402 bfa_sm_t sm; /* state machine */
403 struct bfa_fcs_rport_s *rport; /* parent rport */
404 struct bfa_timer_s timer; /* general purpose timer */
405 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
406 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
407 int rpsc_retries; /* max RPSC retry attempts */
408 enum bfa_port_speed rpsc_speed;
409 /* Current Speed from RPSC. O if RPSC fails */
410 enum bfa_port_speed assigned_speed;
411 /*
412 * Speed assigned by the user. will be used if RPSC is
413 * not supported by the rport.
414 */
415 };
416
417 struct bfa_fcs_rport_s {
418 struct list_head qe; /* used by port/vport */
419 struct bfa_fcs_lport_s *port; /* parent FCS port */
420 struct bfa_fcs_s *fcs; /* fcs instance */
421 struct bfad_rport_s *rp_drv; /* driver peer instance */
422 u32 pid; /* port ID of rport */
423 u32 old_pid; /* PID before rport goes offline */
424 u16 maxfrsize; /* maximum frame size */
425 __be16 reply_oxid; /* OX_ID of inbound requests */
426 enum fc_cos fc_cos; /* FC classes of service supp */
427 bfa_boolean_t cisc; /* CISC capable device */
428 bfa_boolean_t prlo; /* processing prlo or LOGO */
429 bfa_boolean_t plogi_pending; /* Rx Plogi Pending */
430 wwn_t pwwn; /* port wwn of rport */
431 wwn_t nwwn; /* node wwn of rport */
432 struct bfa_rport_symname_s psym_name; /* port symbolic name */
433 bfa_sm_t sm; /* state machine */
434 struct bfa_timer_s timer; /* general purpose timer */
435 struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */
436 struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */
437 struct bfa_fcs_iprp_s *iprp; /* IP/FC role */
438 struct bfa_rport_s *bfa_rport; /* BFA Rport */
439 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
440 int plogi_retries; /* max plogi retry attempts */
441 int ns_retries; /* max NS query retry attempts */
442 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
443 struct bfa_rport_stats_s stats; /* rport stats */
444 enum bfa_rport_function scsi_function; /* Initiator/Target */
445 struct bfa_fcs_rpf_s rpf; /* Rport features module */
446 bfa_boolean_t scn_online; /* SCN online flag */
447 };
448
449 static inline struct bfa_rport_s *
bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s * rport)450 bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
451 {
452 return rport->bfa_rport;
453 }
454
455 /*
456 * bfa fcs rport API functions
457 */
458 void bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
459 struct bfa_rport_attr_s *attr);
460 struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port,
461 wwn_t rpwwn);
462 struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn(
463 struct bfa_fcs_lport_s *port, wwn_t rnwwn);
464 void bfa_fcs_rport_set_del_timeout(u8 rport_tmo);
465 void bfa_fcs_rport_set_max_logins(u32 max_logins);
466 void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport,
467 struct fchs_s *fchs, u16 len);
468 void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport);
469
470 struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_lport_s *port,
471 u32 pid);
472 void bfa_fcs_rport_start(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
473 struct fc_logi_s *plogi_rsp);
474 void bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port,
475 struct fchs_s *rx_fchs,
476 struct fc_logi_s *plogi);
477 void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
478 struct fc_logi_s *plogi);
479 void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id);
480
481 void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport);
482 void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport);
483 int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport);
484 struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn(
485 struct bfa_fcs_lport_s *port, wwn_t wwn);
486 void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport);
487 void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport);
488 void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport);
489
490 /*
491 * forward declarations
492 */
493 struct bfad_itnim_s;
494
495 struct bfa_fcs_itnim_s {
496 bfa_sm_t sm; /* state machine */
497 struct bfa_fcs_rport_s *rport; /* parent remote rport */
498 struct bfad_itnim_s *itnim_drv; /* driver peer instance */
499 struct bfa_fcs_s *fcs; /* fcs instance */
500 struct bfa_timer_s timer; /* timer functions */
501 struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */
502 u32 prli_retries; /* max prli retry attempts */
503 bfa_boolean_t seq_rec; /* seq recovery support */
504 bfa_boolean_t rec_support; /* REC supported */
505 bfa_boolean_t conf_comp; /* FCP_CONF support */
506 bfa_boolean_t task_retry_id; /* task retry id supp */
507 struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */
508 struct bfa_fcxp_s *fcxp; /* FCXP in use */
509 struct bfa_itnim_stats_s stats; /* itn statistics */
510 };
511 #define bfa_fcs_fcxp_alloc(__fcs, __req) \
512 bfa_fcxp_req_rsp_alloc(NULL, (__fcs)->bfa, 0, 0, \
513 NULL, NULL, NULL, NULL, __req)
514 #define bfa_fcs_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, \
515 __alloc_cbarg, __req) \
516 bfa_fcxp_req_rsp_alloc_wait(__bfa, __wqe, __alloc_cbfn, \
517 __alloc_cbarg, NULL, 0, 0, NULL, NULL, NULL, NULL, __req)
518
519 static inline struct bfad_port_s *
bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s * itnim)520 bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim)
521 {
522 return itnim->rport->port->bfad_port;
523 }
524
525
526 static inline struct bfa_fcs_lport_s *
bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s * itnim)527 bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim)
528 {
529 return itnim->rport->port;
530 }
531
532
533 static inline wwn_t
bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s * itnim)534 bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim)
535 {
536 return itnim->rport->nwwn;
537 }
538
539
540 static inline wwn_t
bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s * itnim)541 bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim)
542 {
543 return itnim->rport->pwwn;
544 }
545
546
547 static inline u32
bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s * itnim)548 bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim)
549 {
550 return itnim->rport->pid;
551 }
552
553
554 static inline u32
bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s * itnim)555 bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim)
556 {
557 return itnim->rport->maxfrsize;
558 }
559
560
561 static inline enum fc_cos
bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s * itnim)562 bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim)
563 {
564 return itnim->rport->fc_cos;
565 }
566
567
568 static inline struct bfad_itnim_s *
bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s * itnim)569 bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim)
570 {
571 return itnim->itnim_drv;
572 }
573
574
575 static inline struct bfa_itnim_s *
bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s * itnim)576 bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim)
577 {
578 return itnim->bfa_itnim;
579 }
580
581 /*
582 * bfa fcs FCP Initiator mode API functions
583 */
584 void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim,
585 struct bfa_itnim_attr_s *attr);
586 void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim,
587 struct bfa_itnim_stats_s *stats);
588 struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port,
589 wwn_t rpwwn);
590 bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
591 struct bfa_itnim_attr_s *attr);
592 bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
593 struct bfa_itnim_stats_s *stats);
594 bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port,
595 wwn_t rpwwn);
596 struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport);
597 void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim);
598 void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim);
599 void bfa_fcs_itnim_brp_online(struct bfa_fcs_itnim_s *itnim);
600 bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim);
601 void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim);
602 void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
603 struct fchs_s *fchs, u16 len);
604
605 #define BFA_FCS_FDMI_SUPP_SPEEDS_4G (FDMI_TRANS_SPEED_1G | \
606 FDMI_TRANS_SPEED_2G | \
607 FDMI_TRANS_SPEED_4G)
608
609 #define BFA_FCS_FDMI_SUPP_SPEEDS_8G (FDMI_TRANS_SPEED_1G | \
610 FDMI_TRANS_SPEED_2G | \
611 FDMI_TRANS_SPEED_4G | \
612 FDMI_TRANS_SPEED_8G)
613
614 #define BFA_FCS_FDMI_SUPP_SPEEDS_16G (FDMI_TRANS_SPEED_2G | \
615 FDMI_TRANS_SPEED_4G | \
616 FDMI_TRANS_SPEED_8G | \
617 FDMI_TRANS_SPEED_16G)
618
619 #define BFA_FCS_FDMI_SUPP_SPEEDS_10G FDMI_TRANS_SPEED_10G
620
621 #define BFA_FCS_FDMI_VENDOR_INFO_LEN 8
622 #define BFA_FCS_FDMI_FC4_TYPE_LEN 32
623
624 /*
625 * HBA Attribute Block : BFA internal representation. Note : Some variable
626 * sizes have been trimmed to suit BFA For Ex : Model will be "QLogic ". Based
627 * on this the size has been reduced to 16 bytes from the standard's 64 bytes.
628 */
629 struct bfa_fcs_fdmi_hba_attr_s {
630 wwn_t node_name;
631 u8 manufacturer[64];
632 u8 serial_num[64];
633 u8 model[16];
634 u8 model_desc[128];
635 u8 hw_version[8];
636 u8 driver_version[BFA_VERSION_LEN];
637 u8 option_rom_ver[BFA_VERSION_LEN];
638 u8 fw_version[BFA_VERSION_LEN];
639 u8 os_name[256];
640 __be32 max_ct_pyld;
641 struct bfa_lport_symname_s node_sym_name;
642 u8 vendor_info[BFA_FCS_FDMI_VENDOR_INFO_LEN];
643 __be32 num_ports;
644 wwn_t fabric_name;
645 u8 bios_ver[BFA_VERSION_LEN];
646 };
647
648 /*
649 * Port Attribute Block
650 */
651 struct bfa_fcs_fdmi_port_attr_s {
652 u8 supp_fc4_types[BFA_FCS_FDMI_FC4_TYPE_LEN];
653 __be32 supp_speed; /* supported speed */
654 __be32 curr_speed; /* current Speed */
655 __be32 max_frm_size; /* max frame size */
656 u8 os_device_name[256]; /* OS device Name */
657 u8 host_name[256]; /* host name */
658 wwn_t port_name;
659 wwn_t node_name;
660 struct bfa_lport_symname_s port_sym_name;
661 __be32 port_type;
662 enum fc_cos scos;
663 wwn_t port_fabric_name;
664 u8 port_act_fc4_type[BFA_FCS_FDMI_FC4_TYPE_LEN];
665 __be32 port_state;
666 __be32 num_ports;
667 };
668
669 struct bfa_fcs_stats_s {
670 struct {
671 u32 untagged; /* untagged receive frames */
672 u32 tagged; /* tagged receive frames */
673 u32 vfid_unknown; /* VF id is unknown */
674 } uf;
675 };
676
677 struct bfa_fcs_driver_info_s {
678 u8 version[BFA_VERSION_LEN]; /* Driver Version */
679 u8 host_machine_name[BFA_FCS_OS_STR_LEN];
680 u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */
681 u8 host_os_patch[BFA_FCS_OS_STR_LEN]; /* patch or service pack */
682 u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */
683 };
684
685 struct bfa_fcs_s {
686 struct bfa_s *bfa; /* corresponding BFA bfa instance */
687 struct bfad_s *bfad; /* corresponding BDA driver instance */
688 struct bfa_trc_mod_s *trcmod; /* tracing module */
689 bfa_boolean_t vf_enabled; /* VF mode is enabled */
690 bfa_boolean_t fdmi_enabled; /* FDMI is enabled */
691 bfa_boolean_t min_cfg; /* min cfg enabled/disabled */
692 u16 port_vfid; /* port default VF ID */
693 struct bfa_fcs_driver_info_s driver_info;
694 struct bfa_fcs_fabric_s fabric; /* base fabric state machine */
695 struct bfa_fcs_stats_s stats; /* FCS statistics */
696 struct bfa_wc_s wc; /* waiting counter */
697 int fcs_aen_seq;
698 u32 num_rport_logins;
699 };
700
701 /*
702 * fcs_fabric_sm fabric state machine functions
703 */
704
705 /*
706 * Fabric state machine events
707 */
708 enum bfa_fcs_fabric_event {
709 BFA_FCS_FABRIC_SM_CREATE = 1, /* create from driver */
710 BFA_FCS_FABRIC_SM_DELETE = 2, /* delete from driver */
711 BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */
712 BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */
713 BFA_FCS_FABRIC_SM_CONT_OP = 5, /* flogi/auth continue op */
714 BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* flogi/auth retry op */
715 BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* from flogi/auth */
716 BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* from flogi/auth */
717 BFA_FCS_FABRIC_SM_ISOLATE = 9, /* from EVFP processing */
718 BFA_FCS_FABRIC_SM_NO_TAGGING = 10, /* no VFT tagging from EVFP */
719 BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */
720 BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* auth failed */
721 BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* auth successful */
722 BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */
723 BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */
724 BFA_FCS_FABRIC_SM_START = 16, /* from driver */
725 BFA_FCS_FABRIC_SM_STOP = 17, /* Stop from driver */
726 BFA_FCS_FABRIC_SM_STOPCOMP = 18, /* Stop completion */
727 BFA_FCS_FABRIC_SM_LOGOCOMP = 19, /* FLOGO completion */
728 };
729
730 /*
731 * fcs_rport_sm FCS rport state machine events
732 */
733
734 enum rport_event {
735 RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */
736 RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */
737 RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */
738 RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */
739 RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */
740 RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */
741 RPSM_EVENT_DELETE = 7, /* RPORT delete request */
742 RPSM_EVENT_FAB_SCN = 8, /* state change notification */
743 RPSM_EVENT_ACCEPTED = 9, /* Good response from remote device */
744 RPSM_EVENT_FAILED = 10, /* Request to rport failed. */
745 RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */
746 RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */
747 RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */
748 RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */
749 RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */
750 RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */
751 RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */
752 RPSM_EVENT_PLOGI_RETRY = 18, /* Retry PLOGI continuously */
753 RPSM_EVENT_SCN_OFFLINE = 19, /* loop scn offline */
754 RPSM_EVENT_SCN_ONLINE = 20, /* loop scn online */
755 RPSM_EVENT_FC4_FCS_ONLINE = 21, /* FC-4 FCS online complete */
756 };
757
758 /*
759 * fcs_itnim_sm FCS itnim state machine events
760 */
761 enum bfa_fcs_itnim_event {
762 BFA_FCS_ITNIM_SM_FCS_ONLINE = 1, /* rport online event */
763 BFA_FCS_ITNIM_SM_OFFLINE = 2, /* rport offline */
764 BFA_FCS_ITNIM_SM_FRMSENT = 3, /* prli frame is sent */
765 BFA_FCS_ITNIM_SM_RSP_OK = 4, /* good response */
766 BFA_FCS_ITNIM_SM_RSP_ERROR = 5, /* error response */
767 BFA_FCS_ITNIM_SM_TIMEOUT = 6, /* delay timeout */
768 BFA_FCS_ITNIM_SM_HCB_OFFLINE = 7, /* BFA online callback */
769 BFA_FCS_ITNIM_SM_HCB_ONLINE = 8, /* BFA offline callback */
770 BFA_FCS_ITNIM_SM_INITIATOR = 9, /* rport is initiator */
771 BFA_FCS_ITNIM_SM_DELETE = 10, /* delete event from rport */
772 BFA_FCS_ITNIM_SM_PRLO = 11, /* delete event from rport */
773 BFA_FCS_ITNIM_SM_RSP_NOT_SUPP = 12, /* cmd not supported rsp */
774 BFA_FCS_ITNIM_SM_HAL_ONLINE = 13, /* bfa rport online event */
775 };
776
777 /*
778 * bfa fcs API functions
779 */
780 void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
781 struct bfad_s *bfad,
782 bfa_boolean_t min_cfg);
783 void bfa_fcs_init(struct bfa_fcs_s *fcs);
784 void bfa_fcs_pbc_vport_init(struct bfa_fcs_s *fcs);
785 void bfa_fcs_update_cfg(struct bfa_fcs_s *fcs);
786 void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
787 struct bfa_fcs_driver_info_s *driver_info);
788 void bfa_fcs_exit(struct bfa_fcs_s *fcs);
789 void bfa_fcs_stop(struct bfa_fcs_s *fcs);
790
791 /*
792 * bfa fcs vf public functions
793 */
794 bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id);
795 void bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t vpwwn[], int *nports);
796
797 /*
798 * fabric protected interface functions
799 */
800 void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs);
801 void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric);
802 void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric);
803 void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
804 struct bfa_fcs_vport_s *vport);
805 void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
806 struct bfa_fcs_vport_s *vport);
807 struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup(
808 struct bfa_fcs_fabric_s *fabric, wwn_t pwwn);
809 void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs);
810 void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric,
811 struct fchs_s *fchs, u16 len);
812 void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric);
813 void bfa_fcs_fabric_nsymb_init(struct bfa_fcs_fabric_s *fabric);
814 void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
815 wwn_t fabric_name);
816 u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric);
817 void bfa_fcs_fabric_modstop(struct bfa_fcs_s *fcs);
818 void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
819 enum bfa_fcs_fabric_event event);
820 void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
821 enum bfa_fcs_fabric_event event);
822 void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
823 enum bfa_fcs_fabric_event event);
824
825 /*
826 * BFA FCS callback interfaces
827 */
828
829 /*
830 * fcb Main fcs callbacks
831 */
832
833 struct bfad_port_s;
834 struct bfad_vf_s;
835 struct bfad_vport_s;
836 struct bfad_rport_s;
837
838 /*
839 * lport callbacks
840 */
841 struct bfad_port_s *bfa_fcb_lport_new(struct bfad_s *bfad,
842 struct bfa_fcs_lport_s *port,
843 enum bfa_lport_role roles,
844 struct bfad_vf_s *vf_drv,
845 struct bfad_vport_s *vp_drv);
846
847 /*
848 * vport callbacks
849 */
850 void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s);
851
852 /*
853 * rport callbacks
854 */
855 bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
856 struct bfa_fcs_rport_s **rport,
857 struct bfad_rport_s **rport_drv);
858
859 /*
860 * itnim callbacks
861 */
862 int bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
863 struct bfad_itnim_s **itnim_drv);
864 void bfa_fcb_itnim_free(struct bfad_s *bfad,
865 struct bfad_itnim_s *itnim_drv);
866 void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
867 void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv);
868
869 #endif /* __BFA_FCS_H__ */
870