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