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