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