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