aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/bfa/bfa_fcs.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/bfa/bfa_fcs.h')
-rw-r--r--drivers/scsi/bfa/bfa_fcs.h779
1 files changed, 779 insertions, 0 deletions
diff --git a/drivers/scsi/bfa/bfa_fcs.h b/drivers/scsi/bfa/bfa_fcs.h
new file mode 100644
index 000000000000..d75045df1e7e
--- /dev/null
+++ b/drivers/scsi/bfa/bfa_fcs.h
@@ -0,0 +1,779 @@
1/*
2 * Copyright (c) 2005-2010 Brocade Communications Systems, Inc.
3 * All rights reserved
4 * www.brocade.com
5 *
6 * Linux driver for Brocade Fibre Channel Host Bus Adapter.
7 *
8 * This program is free software; you can redistribute it and/or modify it
9 * under the terms of the GNU General Public License (GPL) Version 2 as
10 * published by the Free Software Foundation
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 */
17
18#ifndef __BFA_FCS_H__
19#define __BFA_FCS_H__
20
21#include "bfa_cs.h"
22#include "bfa_defs.h"
23#include "bfa_defs_fcs.h"
24#include "bfa_modules.h"
25#include "bfa_fc.h"
26
27#define BFA_FCS_OS_STR_LEN 64
28
29/*
30 * !!! Only append to the enums defined here to avoid any versioning
31 * !!! needed between trace utility and driver version
32 */
33enum {
34 BFA_TRC_FCS_FCS = 1,
35 BFA_TRC_FCS_PORT = 2,
36 BFA_TRC_FCS_RPORT = 3,
37 BFA_TRC_FCS_FCPIM = 4,
38};
39
40
41struct bfa_fcs_s;
42
43#define __fcs_min_cfg(__fcs) ((__fcs)->min_cfg)
44void bfa_fcs_modexit_comp(struct bfa_fcs_s *fcs);
45
46#define BFA_FCS_BRCD_SWITCH_OUI 0x051e
47#define N2N_LOCAL_PID 0x010000
48#define N2N_REMOTE_PID 0x020000
49#define BFA_FCS_RETRY_TIMEOUT 2000
50#define BFA_FCS_PID_IS_WKA(pid) ((bfa_os_ntoh3b(pid) > 0xFFF000) ? 1 : 0)
51
52
53
54struct bfa_fcs_lport_ns_s {
55 bfa_sm_t sm; /* state machine */
56 struct bfa_timer_s timer;
57 struct bfa_fcs_lport_s *port; /* parent port */
58 struct bfa_fcxp_s *fcxp;
59 struct bfa_fcxp_wqe_s fcxp_wqe;
60};
61
62
63struct bfa_fcs_lport_scn_s {
64 bfa_sm_t sm; /* state machine */
65 struct bfa_timer_s timer;
66 struct bfa_fcs_lport_s *port; /* parent port */
67 struct bfa_fcxp_s *fcxp;
68 struct bfa_fcxp_wqe_s fcxp_wqe;
69};
70
71
72struct bfa_fcs_lport_fdmi_s {
73 bfa_sm_t sm; /* state machine */
74 struct bfa_timer_s timer;
75 struct bfa_fcs_lport_ms_s *ms; /* parent ms */
76 struct bfa_fcxp_s *fcxp;
77 struct bfa_fcxp_wqe_s fcxp_wqe;
78 u8 retry_cnt; /* retry count */
79 u8 rsvd[3];
80};
81
82
83struct bfa_fcs_lport_ms_s {
84 bfa_sm_t sm; /* state machine */
85 struct bfa_timer_s timer;
86 struct bfa_fcs_lport_s *port; /* parent port */
87 struct bfa_fcxp_s *fcxp;
88 struct bfa_fcxp_wqe_s fcxp_wqe;
89 struct bfa_fcs_lport_fdmi_s fdmi; /* FDMI component of MS */
90 u8 retry_cnt; /* retry count */
91 u8 rsvd[3];
92};
93
94
95struct bfa_fcs_lport_fab_s {
96 struct bfa_fcs_lport_ns_s ns; /* NS component of port */
97 struct bfa_fcs_lport_scn_s scn; /* scn component of port */
98 struct bfa_fcs_lport_ms_s ms; /* MS component of port */
99};
100
101#define MAX_ALPA_COUNT 127
102
103struct bfa_fcs_lport_loop_s {
104 u8 num_alpa; /* Num of ALPA entries in the map */
105 u8 alpa_pos_map[MAX_ALPA_COUNT]; /* ALPA Positional
106 *Map */
107 struct bfa_fcs_lport_s *port; /* parent port */
108};
109
110struct bfa_fcs_lport_n2n_s {
111 u32 rsvd;
112 u16 reply_oxid; /* ox_id from the req flogi to be
113 *used in flogi acc */
114 wwn_t rem_port_wwn; /* Attached port's wwn */
115};
116
117
118union bfa_fcs_lport_topo_u {
119 struct bfa_fcs_lport_fab_s pfab;
120 struct bfa_fcs_lport_loop_s ploop;
121 struct bfa_fcs_lport_n2n_s pn2n;
122};
123
124
125struct bfa_fcs_lport_s {
126 struct list_head qe; /* used by port/vport */
127 bfa_sm_t sm; /* state machine */
128 struct bfa_fcs_fabric_s *fabric; /* parent fabric */
129 struct bfa_lport_cfg_s port_cfg; /* port configuration */
130 struct bfa_timer_s link_timer; /* timer for link offline */
131 u32 pid:24; /* FC address */
132 u8 lp_tag; /* lport tag */
133 u16 num_rports; /* Num of r-ports */
134 struct list_head rport_q; /* queue of discovered r-ports */
135 struct bfa_fcs_s *fcs; /* FCS instance */
136 union bfa_fcs_lport_topo_u port_topo; /* fabric/loop/n2n details */
137 struct bfad_port_s *bfad_port; /* driver peer instance */
138 struct bfa_fcs_vport_s *vport; /* NULL for base ports */
139 struct bfa_fcxp_s *fcxp;
140 struct bfa_fcxp_wqe_s fcxp_wqe;
141 struct bfa_lport_stats_s stats;
142 struct bfa_wc_s wc; /* waiting counter for events */
143};
144#define BFA_FCS_GET_HAL_FROM_PORT(port) (port->fcs->bfa)
145#define BFA_FCS_GET_NS_FROM_PORT(port) (&port->port_topo.pfab.ns)
146#define BFA_FCS_GET_SCN_FROM_PORT(port) (&port->port_topo.pfab.scn)
147#define BFA_FCS_GET_MS_FROM_PORT(port) (&port->port_topo.pfab.ms)
148#define BFA_FCS_GET_FDMI_FROM_PORT(port) (&port->port_topo.pfab.ms.fdmi)
149#define BFA_FCS_VPORT_IS_INITIATOR_MODE(port) \
150 (port->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM)
151
152/*
153 * forward declaration
154 */
155struct bfad_vf_s;
156
157enum bfa_fcs_fabric_type {
158 BFA_FCS_FABRIC_UNKNOWN = 0,
159 BFA_FCS_FABRIC_SWITCHED = 1,
160 BFA_FCS_FABRIC_N2N = 2,
161};
162
163
164struct bfa_fcs_fabric_s {
165 struct list_head qe; /* queue element */
166 bfa_sm_t sm; /* state machine */
167 struct bfa_fcs_s *fcs; /* FCS instance */
168 struct bfa_fcs_lport_s bport; /* base logical port */
169 enum bfa_fcs_fabric_type fab_type; /* fabric type */
170 enum bfa_port_type oper_type; /* current link topology */
171 u8 is_vf; /* is virtual fabric? */
172 u8 is_npiv; /* is NPIV supported ? */
173 u8 is_auth; /* is Security/Auth supported ? */
174 u16 bb_credit; /* BB credit from fabric */
175 u16 vf_id; /* virtual fabric ID */
176 u16 num_vports; /* num vports */
177 u16 rsvd;
178 struct list_head vport_q; /* queue of virtual ports */
179 struct list_head vf_q; /* queue of virtual fabrics */
180 struct bfad_vf_s *vf_drv; /* driver vf structure */
181 struct bfa_timer_s link_timer; /* Link Failure timer. Vport */
182 wwn_t fabric_name; /* attached fabric name */
183 bfa_boolean_t auth_reqd; /* authentication required */
184 struct bfa_timer_s delay_timer; /* delay timer */
185 union {
186 u16 swp_vfid;/* switch port VF id */
187 } event_arg;
188 struct bfa_wc_s wc; /* wait counter for delete */
189 struct bfa_vf_stats_s stats; /* fabric/vf stats */
190 struct bfa_lps_s *lps; /* lport login services */
191 u8 fabric_ip_addr[BFA_FCS_FABRIC_IPADDR_SZ];
192 /* attached fabric's ip addr */
193};
194
195#define bfa_fcs_fabric_npiv_capable(__f) ((__f)->is_npiv)
196#define bfa_fcs_fabric_is_switched(__f) \
197 ((__f)->fab_type == BFA_FCS_FABRIC_SWITCHED)
198
199/**
200 * The design calls for a single implementation of base fabric and vf.
201 */
202#define bfa_fcs_vf_t struct bfa_fcs_fabric_s
203
204struct bfa_vf_event_s {
205 u32 undefined;
206};
207
208struct bfa_fcs_s;
209struct bfa_fcs_fabric_s;
210
211/*
212 * @todo : need to move to a global config file.
213 * Maximum Rports supported per port (physical/logical).
214 */
215#define BFA_FCS_MAX_RPORTS_SUPP 256 /* @todo : tentative value */
216
217#define bfa_fcs_lport_t struct bfa_fcs_lport_s
218
219/**
220 * Symbolic Name related defines
221 * Total bytes 255.
222 * Physical Port's symbolic name 128 bytes.
223 * For Vports, Vport's symbolic name is appended to the Physical port's
224 * Symbolic Name.
225 *
226 * Physical Port's symbolic name Format : (Total 128 bytes)
227 * Adapter Model number/name : 12 bytes
228 * Driver Version : 10 bytes
229 * Host Machine Name : 30 bytes
230 * Host OS Info : 48 bytes
231 * Host OS PATCH Info : 16 bytes
232 * ( remaining 12 bytes reserved to be used for separator)
233 */
234#define BFA_FCS_PORT_SYMBNAME_SEPARATOR " | "
235
236#define BFA_FCS_PORT_SYMBNAME_MODEL_SZ 12
237#define BFA_FCS_PORT_SYMBNAME_VERSION_SZ 10
238#define BFA_FCS_PORT_SYMBNAME_MACHINENAME_SZ 30
239#define BFA_FCS_PORT_SYMBNAME_OSINFO_SZ 48
240#define BFA_FCS_PORT_SYMBNAME_OSPATCH_SZ 16
241
242/**
243 * Get FC port ID for a logical port.
244 */
245#define bfa_fcs_lport_get_fcid(_lport) ((_lport)->pid)
246#define bfa_fcs_lport_get_pwwn(_lport) ((_lport)->port_cfg.pwwn)
247#define bfa_fcs_lport_get_nwwn(_lport) ((_lport)->port_cfg.nwwn)
248#define bfa_fcs_lport_get_psym_name(_lport) ((_lport)->port_cfg.sym_name)
249#define bfa_fcs_lport_is_initiator(_lport) \
250 ((_lport)->port_cfg.roles & BFA_LPORT_ROLE_FCP_IM)
251#define bfa_fcs_lport_get_nrports(_lport) \
252 ((_lport) ? (_lport)->num_rports : 0)
253
254static inline struct bfad_port_s *
255bfa_fcs_lport_get_drvport(struct bfa_fcs_lport_s *port)
256{
257 return port->bfad_port;
258}
259
260#define bfa_fcs_lport_get_opertype(_lport) ((_lport)->fabric->oper_type)
261#define bfa_fcs_lport_get_fabric_name(_lport) ((_lport)->fabric->fabric_name)
262#define bfa_fcs_lport_get_fabric_ipaddr(_lport) \
263 ((_lport)->fabric->fabric_ip_addr)
264
265/**
266 * bfa fcs port public functions
267 */
268
269bfa_boolean_t bfa_fcs_lport_is_online(struct bfa_fcs_lport_s *port);
270struct bfa_fcs_lport_s *bfa_fcs_get_base_port(struct bfa_fcs_s *fcs);
271void bfa_fcs_lport_get_rports(struct bfa_fcs_lport_s *port,
272 wwn_t rport_wwns[], int *nrports);
273
274wwn_t bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn,
275 int index, int nrports, bfa_boolean_t bwwn);
276
277struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
278 u16 vf_id, wwn_t lpwwn);
279
280void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port,
281 struct bfa_lport_info_s *port_info);
282void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port,
283 struct bfa_lport_attr_s *port_attr);
284void bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s *fcs_port,
285 struct bfa_lport_stats_s *port_stats);
286void bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s *fcs_port);
287enum bfa_port_speed bfa_fcs_lport_get_rport_max_speed(
288 struct bfa_fcs_lport_s *port);
289
290/* MS FCS routines */
291void bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s *port);
292void bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s *port);
293void bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s *port);
294void bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s *port);
295
296/* FDMI FCS routines */
297void bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s *ms);
298void bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s *ms);
299void bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s *ms);
300void bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s *lport, struct fchs_s *fchs,
301 u16 len);
302void bfa_fcs_lport_attach(struct bfa_fcs_lport_s *lport, struct bfa_fcs_s *fcs,
303 u16 vf_id, struct bfa_fcs_vport_s *vport);
304void bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport,
305 struct bfa_lport_cfg_s *port_cfg);
306void bfa_fcs_lport_online(struct bfa_fcs_lport_s *port);
307void bfa_fcs_lport_offline(struct bfa_fcs_lport_s *port);
308void bfa_fcs_lport_delete(struct bfa_fcs_lport_s *port);
309struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pid(
310 struct bfa_fcs_lport_s *port, u32 pid);
311struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pwwn(
312 struct bfa_fcs_lport_s *port, wwn_t pwwn);
313struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_nwwn(
314 struct bfa_fcs_lport_s *port, wwn_t nwwn);
315void bfa_fcs_lport_add_rport(struct bfa_fcs_lport_s *port,
316 struct bfa_fcs_rport_s *rport);
317void bfa_fcs_lport_del_rport(struct bfa_fcs_lport_s *port,
318 struct bfa_fcs_rport_s *rport);
319void bfa_fcs_lport_modinit(struct bfa_fcs_s *fcs);
320void bfa_fcs_lport_modexit(struct bfa_fcs_s *fcs);
321void bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s *vport);
322void bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *vport);
323void bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *vport);
324void bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port);
325void bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *vport);
326void bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *vport);
327void bfa_fcs_lport_scn_online(struct bfa_fcs_lport_s *vport);
328void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port,
329 struct fchs_s *rx_frame, u32 len);
330
331struct bfa_fcs_vport_s {
332 struct list_head qe; /* queue elem */
333 bfa_sm_t sm; /* state machine */
334 bfa_fcs_lport_t lport; /* logical port */
335 struct bfa_timer_s timer;
336 struct bfad_vport_s *vport_drv; /* Driver private */
337 struct bfa_vport_stats_s vport_stats; /* vport statistics */
338 struct bfa_lps_s *lps; /* Lport login service*/
339 int fdisc_retries;
340};
341
342#define bfa_fcs_vport_get_port(vport) \
343 ((struct bfa_fcs_lport_s *)(&vport->port))
344
345/**
346 * bfa fcs vport public functions
347 */
348bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport,
349 struct bfa_fcs_s *fcs, u16 vf_id,
350 struct bfa_lport_cfg_s *port_cfg,
351 struct bfad_vport_s *vport_drv);
352bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport,
353 struct bfa_fcs_s *fcs, u16 vf_id,
354 struct bfa_lport_cfg_s *port_cfg,
355 struct bfad_vport_s *vport_drv);
356bfa_boolean_t bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s *vport);
357bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport);
358bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport);
359bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport);
360void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
361 struct bfa_vport_attr_s *vport_attr);
362void bfa_fcs_vport_get_stats(struct bfa_fcs_vport_s *vport,
363 struct bfa_vport_stats_s *vport_stats);
364void bfa_fcs_vport_clr_stats(struct bfa_fcs_vport_s *vport);
365struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs,
366 u16 vf_id, wwn_t vpwwn);
367void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport);
368void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport);
369void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport);
370void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport);
371void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport);
372
373#define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */
374#define BFA_FCS_RPORT_MAX_RETRIES (5)
375
376/*
377 * forward declarations
378 */
379struct bfad_rport_s;
380
381struct bfa_fcs_itnim_s;
382struct bfa_fcs_tin_s;
383struct bfa_fcs_iprp_s;
384
385/* Rport Features (RPF) */
386struct bfa_fcs_rpf_s {
387 bfa_sm_t sm; /* state machine */
388 struct bfa_fcs_rport_s *rport; /* parent rport */
389 struct bfa_timer_s timer; /* general purpose timer */
390 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
391 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
392 int rpsc_retries; /* max RPSC retry attempts */
393 enum bfa_port_speed rpsc_speed;
394 /* Current Speed from RPSC. O if RPSC fails */
395 enum bfa_port_speed assigned_speed;
396 /**
397 * Speed assigned by the user. will be used if RPSC is
398 * not supported by the rport.
399 */
400};
401
402struct bfa_fcs_rport_s {
403 struct list_head qe; /* used by port/vport */
404 struct bfa_fcs_lport_s *port; /* parent FCS port */
405 struct bfa_fcs_s *fcs; /* fcs instance */
406 struct bfad_rport_s *rp_drv; /* driver peer instance */
407 u32 pid; /* port ID of rport */
408 u16 maxfrsize; /* maximum frame size */
409 u16 reply_oxid; /* OX_ID of inbound requests */
410 enum fc_cos fc_cos; /* FC classes of service supp */
411 bfa_boolean_t cisc; /* CISC capable device */
412 bfa_boolean_t prlo; /* processing prlo or LOGO */
413 wwn_t pwwn; /* port wwn of rport */
414 wwn_t nwwn; /* node wwn of rport */
415 struct bfa_rport_symname_s psym_name; /* port symbolic name */
416 bfa_sm_t sm; /* state machine */
417 struct bfa_timer_s timer; /* general purpose timer */
418 struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */
419 struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */
420 struct bfa_fcs_iprp_s *iprp; /* IP/FC role */
421 struct bfa_rport_s *bfa_rport; /* BFA Rport */
422 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
423 int plogi_retries; /* max plogi retry attempts */
424 int ns_retries; /* max NS query retry attempts */
425 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
426 struct bfa_rport_stats_s stats; /* rport stats */
427 enum bfa_rport_function scsi_function; /* Initiator/Target */
428 struct bfa_fcs_rpf_s rpf; /* Rport features module */
429};
430
431static inline struct bfa_rport_s *
432bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
433{
434 return rport->bfa_rport;
435}
436
437/**
438 * bfa fcs rport API functions
439 */
440bfa_status_t bfa_fcs_rport_add(struct bfa_fcs_lport_s *port, wwn_t *pwwn,
441 struct bfa_fcs_rport_s *rport,
442 struct bfad_rport_s *rport_drv);
443bfa_status_t bfa_fcs_rport_remove(struct bfa_fcs_rport_s *rport);
444void bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
445 struct bfa_rport_attr_s *attr);
446void bfa_fcs_rport_get_stats(struct bfa_fcs_rport_s *rport,
447 struct bfa_rport_stats_s *stats);
448void bfa_fcs_rport_clear_stats(struct bfa_fcs_rport_s *rport);
449struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port,
450 wwn_t rpwwn);
451struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn(
452 struct bfa_fcs_lport_s *port, wwn_t rnwwn);
453void bfa_fcs_rport_set_del_timeout(u8 rport_tmo);
454
455void bfa_fcs_rport_set_speed(struct bfa_fcs_rport_s *rport,
456 enum bfa_port_speed speed);
457void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport,
458 struct fchs_s *fchs, u16 len);
459void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport);
460
461struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_lport_s *port,
462 u32 pid);
463void bfa_fcs_rport_delete(struct bfa_fcs_rport_s *rport);
464void bfa_fcs_rport_online(struct bfa_fcs_rport_s *rport);
465void bfa_fcs_rport_offline(struct bfa_fcs_rport_s *rport);
466void bfa_fcs_rport_start(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
467 struct fc_logi_s *plogi_rsp);
468void bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port,
469 struct fchs_s *rx_fchs,
470 struct fc_logi_s *plogi);
471void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
472 struct fc_logi_s *plogi);
473void bfa_fcs_rport_logo_imp(struct bfa_fcs_rport_s *rport);
474void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, u16 ox_id);
475
476void bfa_fcs_rport_itnim_ack(struct bfa_fcs_rport_s *rport);
477void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport);
478void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport);
479int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport);
480struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn(
481 struct bfa_fcs_lport_s *port, wwn_t wwn);
482void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport);
483void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport);
484void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport);
485
486/*
487 * forward declarations
488 */
489struct bfad_itnim_s;
490
491struct bfa_fcs_itnim_s {
492 bfa_sm_t sm; /* state machine */
493 struct bfa_fcs_rport_s *rport; /* parent remote rport */
494 struct bfad_itnim_s *itnim_drv; /* driver peer instance */
495 struct bfa_fcs_s *fcs; /* fcs instance */
496 struct bfa_timer_s timer; /* timer functions */
497 struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */
498 u32 prli_retries; /* max prli retry attempts */
499 bfa_boolean_t seq_rec; /* seq recovery support */
500 bfa_boolean_t rec_support; /* REC supported */
501 bfa_boolean_t conf_comp; /* FCP_CONF support */
502 bfa_boolean_t task_retry_id; /* task retry id supp */
503 struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */
504 struct bfa_fcxp_s *fcxp; /* FCXP in use */
505 struct bfa_itnim_stats_s stats; /* itn statistics */
506};
507#define bfa_fcs_fcxp_alloc(__fcs) \
508 bfa_fcxp_alloc(NULL, (__fcs)->bfa, 0, 0, NULL, NULL, NULL, NULL)
509
510#define bfa_fcs_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, __alloc_cbarg) \
511 bfa_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, __alloc_cbarg, \
512 NULL, 0, 0, NULL, NULL, NULL, NULL)
513
514static inline struct bfad_port_s *
515bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim)
516{
517 return itnim->rport->port->bfad_port;
518}
519
520
521static inline struct bfa_fcs_lport_s *
522bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim)
523{
524 return itnim->rport->port;
525}
526
527
528static inline wwn_t
529bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim)
530{
531 return itnim->rport->nwwn;
532}
533
534
535static inline wwn_t
536bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim)
537{
538 return itnim->rport->pwwn;
539}
540
541
542static inline u32
543bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim)
544{
545 return itnim->rport->pid;
546}
547
548
549static inline u32
550bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim)
551{
552 return itnim->rport->maxfrsize;
553}
554
555
556static inline enum fc_cos
557bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim)
558{
559 return itnim->rport->fc_cos;
560}
561
562
563static inline struct bfad_itnim_s *
564bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim)
565{
566 return itnim->itnim_drv;
567}
568
569
570static inline struct bfa_itnim_s *
571bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim)
572{
573 return itnim->bfa_itnim;
574}
575
576/**
577 * bfa fcs FCP Initiator mode API functions
578 */
579void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim,
580 struct bfa_itnim_attr_s *attr);
581void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim,
582 struct bfa_itnim_stats_s *stats);
583struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port,
584 wwn_t rpwwn);
585bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
586 struct bfa_itnim_attr_s *attr);
587bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
588 struct bfa_itnim_stats_s *stats);
589bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port,
590 wwn_t rpwwn);
591struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport);
592void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim);
593void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim);
594void bfa_fcs_itnim_rport_online(struct bfa_fcs_itnim_s *itnim);
595bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim);
596void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim);
597void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
598 struct fchs_s *fchs, u16 len);
599
600#define BFA_FCS_FDMI_SUPORTED_SPEEDS (FDMI_TRANS_SPEED_1G | \
601 FDMI_TRANS_SPEED_2G | \
602 FDMI_TRANS_SPEED_4G | \
603 FDMI_TRANS_SPEED_8G)
604
605/*
606 * HBA Attribute Block : BFA internal representation. Note : Some variable
607 * sizes have been trimmed to suit BFA For Ex : Model will be "Brocade". Based
608 * on this the size has been reduced to 16 bytes from the standard's 64 bytes.
609 */
610struct bfa_fcs_fdmi_hba_attr_s {
611 wwn_t node_name;
612 u8 manufacturer[64];
613 u8 serial_num[64];
614 u8 model[16];
615 u8 model_desc[256];
616 u8 hw_version[8];
617 u8 driver_version[8];
618 u8 option_rom_ver[BFA_VERSION_LEN];
619 u8 fw_version[8];
620 u8 os_name[256];
621 u32 max_ct_pyld;
622};
623
624/*
625 * Port Attribute Block
626 */
627struct bfa_fcs_fdmi_port_attr_s {
628 u8 supp_fc4_types[32]; /* supported FC4 types */
629 u32 supp_speed; /* supported speed */
630 u32 curr_speed; /* current Speed */
631 u32 max_frm_size; /* max frame size */
632 u8 os_device_name[256]; /* OS device Name */
633 u8 host_name[256]; /* host name */
634};
635
636struct bfa_fcs_stats_s {
637 struct {
638 u32 untagged; /* untagged receive frames */
639 u32 tagged; /* tagged receive frames */
640 u32 vfid_unknown; /* VF id is unknown */
641 } uf;
642};
643
644struct bfa_fcs_driver_info_s {
645 u8 version[BFA_VERSION_LEN]; /* Driver Version */
646 u8 host_machine_name[BFA_FCS_OS_STR_LEN];
647 u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */
648 u8 host_os_patch[BFA_FCS_OS_STR_LEN]; /* patch or service pack */
649 u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */
650};
651
652struct bfa_fcs_s {
653 struct bfa_s *bfa; /* corresponding BFA bfa instance */
654 struct bfad_s *bfad; /* corresponding BDA driver instance */
655 struct bfa_trc_mod_s *trcmod; /* tracing module */
656 bfa_boolean_t vf_enabled; /* VF mode is enabled */
657 bfa_boolean_t fdmi_enabled; /* FDMI is enabled */
658 bfa_boolean_t min_cfg; /* min cfg enabled/disabled */
659 u16 port_vfid; /* port default VF ID */
660 struct bfa_fcs_driver_info_s driver_info;
661 struct bfa_fcs_fabric_s fabric; /* base fabric state machine */
662 struct bfa_fcs_stats_s stats; /* FCS statistics */
663 struct bfa_wc_s wc; /* waiting counter */
664};
665
666/*
667 * bfa fcs API functions
668 */
669void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
670 struct bfad_s *bfad,
671 bfa_boolean_t min_cfg);
672void bfa_fcs_init(struct bfa_fcs_s *fcs);
673void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
674 struct bfa_fcs_driver_info_s *driver_info);
675void bfa_fcs_set_fdmi_param(struct bfa_fcs_s *fcs, bfa_boolean_t fdmi_enable);
676void bfa_fcs_exit(struct bfa_fcs_s *fcs);
677void bfa_fcs_trc_init(struct bfa_fcs_s *fcs, struct bfa_trc_mod_s *trcmod);
678void bfa_fcs_start(struct bfa_fcs_s *fcs);
679
680/**
681 * bfa fcs vf public functions
682 */
683bfa_status_t bfa_fcs_vf_mode_enable(struct bfa_fcs_s *fcs, u16 vf_id);
684bfa_status_t bfa_fcs_vf_mode_disable(struct bfa_fcs_s *fcs);
685bfa_status_t bfa_fcs_vf_create(bfa_fcs_vf_t *vf, struct bfa_fcs_s *fcs,
686 u16 vf_id, struct bfa_lport_cfg_s *port_cfg,
687 struct bfad_vf_s *vf_drv);
688bfa_status_t bfa_fcs_vf_delete(bfa_fcs_vf_t *vf);
689void bfa_fcs_vf_list(struct bfa_fcs_s *fcs, u16 *vf_ids, int *nvfs);
690void bfa_fcs_vf_list_all(struct bfa_fcs_s *fcs, u16 *vf_ids, int *nvfs);
691void bfa_fcs_vf_get_attr(bfa_fcs_vf_t *vf, struct bfa_vf_attr_s *vf_attr);
692void bfa_fcs_vf_get_stats(bfa_fcs_vf_t *vf,
693 struct bfa_vf_stats_s *vf_stats);
694void bfa_fcs_vf_clear_stats(bfa_fcs_vf_t *vf);
695void bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t vpwwn[], int *nports);
696bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id);
697u16 bfa_fcs_fabric_vport_count(struct bfa_fcs_fabric_s *fabric);
698
699/*
700 * fabric protected interface functions
701 */
702void bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs);
703void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs);
704void bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs);
705void bfa_fcs_fabric_modsusp(struct bfa_fcs_s *fcs);
706void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric);
707void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric);
708void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
709 struct bfa_fcs_vport_s *vport);
710void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
711 struct bfa_fcs_vport_s *vport);
712int bfa_fcs_fabric_is_online(struct bfa_fcs_fabric_s *fabric);
713struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup(
714 struct bfa_fcs_fabric_s *fabric, wwn_t pwwn);
715void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs);
716void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric,
717 struct fchs_s *fchs, u16 len);
718bfa_boolean_t bfa_fcs_fabric_is_loopback(struct bfa_fcs_fabric_s *fabric);
719bfa_boolean_t bfa_fcs_fabric_is_auth_failed(struct bfa_fcs_fabric_s *fabric);
720enum bfa_port_type bfa_fcs_fabric_port_type(struct bfa_fcs_fabric_s *fabric);
721void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric);
722void bfa_fcs_fabric_port_delete_comp(struct bfa_fcs_fabric_s *fabric);
723bfa_status_t bfa_fcs_fabric_addvf(struct bfa_fcs_fabric_s *vf,
724 struct bfa_fcs_s *fcs, struct bfa_lport_cfg_s *port_cfg,
725 struct bfad_vf_s *vf_drv);
726void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
727 wwn_t fabric_name);
728u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric);
729void bfa_fcs_uf_attach(struct bfa_fcs_s *fcs);
730void bfa_fcs_port_attach(struct bfa_fcs_s *fcs);
731
732/**
733 * BFA FCS callback interfaces
734 */
735
736/**
737 * fcb Main fcs callbacks
738 */
739
740struct bfad_port_s;
741struct bfad_vf_s;
742struct bfad_vport_s;
743struct bfad_rport_s;
744
745/**
746 * lport callbacks
747 */
748struct bfad_port_s *bfa_fcb_lport_new(struct bfad_s *bfad,
749 struct bfa_fcs_lport_s *port,
750 enum bfa_lport_role roles,
751 struct bfad_vf_s *vf_drv,
752 struct bfad_vport_s *vp_drv);
753void bfa_fcb_lport_delete(struct bfad_s *bfad, enum bfa_lport_role roles,
754 struct bfad_vf_s *vf_drv,
755 struct bfad_vport_s *vp_drv);
756
757/**
758 * vport callbacks
759 */
760void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s);
761
762/**
763 * rport callbacks
764 */
765bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
766 struct bfa_fcs_rport_s **rport,
767 struct bfad_rport_s **rport_drv);
768
769/**
770 * itnim callbacks
771 */
772void bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
773 struct bfad_itnim_s **itnim_drv);
774void bfa_fcb_itnim_free(struct bfad_s *bfad,
775 struct bfad_itnim_s *itnim_drv);
776void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
777void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv);
778
779#endif /* __BFA_FCS_H__ */