blob: ef0ec66f714af2674c63762874defbb52fdf230c [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 */
Krishna Gudipatib7044952010-12-13 16:17:42 -080041 BFA_LPS_SM_SET_N2N_PID = 8, /* Set assigned PID for n2n */
Maggie Zhangf7f738122010-12-09 19:08:43 -080042};
43
44
45/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070046 * !!! 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)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070060
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
Maggie Zhangf16a1752010-12-09 19:12:32 -080065#define BFA_FCS_PID_IS_WKA(pid) ((bfa_ntoh3b(pid) > 0xFFF000) ? 1 : 0)
Krishna Gudipatia36c61f2010-09-15 11:50:55 -070066
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;
Maggie50444a32010-11-29 18:26:32 -0800127 __be16 reply_oxid; /* ox_id from the req flogi to be
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700128 *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
Jing Huangacdc79a2010-10-18 17:15:55 -0700214/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700215 * 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
Jing Huangacdc79a2010-10-18 17:15:55 -0700234/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700235 * 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
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700257/* bb_scn value in 2^bb_scn */
258#define BFA_FCS_PORT_DEF_BB_SCN 3
259
Jing Huangacdc79a2010-10-18 17:15:55 -0700260/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700261 * 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
Jing Huangacdc79a2010-10-18 17:15:55 -0700283/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700284 * 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);
Krishna Gudipatiee1a4a42012-08-22 19:50:43 -0700289void bfa_fcs_lport_get_rport_quals(struct bfa_fcs_lport_s *port,
290 struct bfa_rport_qualifier_s rport[], int *nrports);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700291wwn_t bfa_fcs_lport_get_rport(struct bfa_fcs_lport_s *port, wwn_t wwn,
292 int index, int nrports, bfa_boolean_t bwwn);
293
294struct bfa_fcs_lport_s *bfa_fcs_lookup_port(struct bfa_fcs_s *fcs,
295 u16 vf_id, wwn_t lpwwn);
296
297void bfa_fcs_lport_get_info(struct bfa_fcs_lport_s *port,
298 struct bfa_lport_info_s *port_info);
299void bfa_fcs_lport_get_attr(struct bfa_fcs_lport_s *port,
300 struct bfa_lport_attr_s *port_attr);
301void bfa_fcs_lport_get_stats(struct bfa_fcs_lport_s *fcs_port,
302 struct bfa_lport_stats_s *port_stats);
303void bfa_fcs_lport_clear_stats(struct bfa_fcs_lport_s *fcs_port);
304enum bfa_port_speed bfa_fcs_lport_get_rport_max_speed(
305 struct bfa_fcs_lport_s *port);
306
307/* MS FCS routines */
308void bfa_fcs_lport_ms_init(struct bfa_fcs_lport_s *port);
309void bfa_fcs_lport_ms_offline(struct bfa_fcs_lport_s *port);
310void bfa_fcs_lport_ms_online(struct bfa_fcs_lport_s *port);
311void bfa_fcs_lport_ms_fabric_rscn(struct bfa_fcs_lport_s *port);
312
313/* FDMI FCS routines */
314void bfa_fcs_lport_fdmi_init(struct bfa_fcs_lport_ms_s *ms);
315void bfa_fcs_lport_fdmi_offline(struct bfa_fcs_lport_ms_s *ms);
316void bfa_fcs_lport_fdmi_online(struct bfa_fcs_lport_ms_s *ms);
317void bfa_fcs_lport_uf_recv(struct bfa_fcs_lport_s *lport, struct fchs_s *fchs,
318 u16 len);
319void bfa_fcs_lport_attach(struct bfa_fcs_lport_s *lport, struct bfa_fcs_s *fcs,
320 u16 vf_id, struct bfa_fcs_vport_s *vport);
321void bfa_fcs_lport_init(struct bfa_fcs_lport_s *lport,
322 struct bfa_lport_cfg_s *port_cfg);
323void bfa_fcs_lport_online(struct bfa_fcs_lport_s *port);
324void bfa_fcs_lport_offline(struct bfa_fcs_lport_s *port);
325void bfa_fcs_lport_delete(struct bfa_fcs_lport_s *port);
326struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pid(
327 struct bfa_fcs_lport_s *port, u32 pid);
Krishna Gudipatiee1a4a42012-08-22 19:50:43 -0700328struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_old_pid(
329 struct bfa_fcs_lport_s *port, u32 pid);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700330struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_pwwn(
331 struct bfa_fcs_lport_s *port, wwn_t pwwn);
332struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_nwwn(
333 struct bfa_fcs_lport_s *port, wwn_t nwwn);
Krishna Gudipatiee1a4a42012-08-22 19:50:43 -0700334struct bfa_fcs_rport_s *bfa_fcs_lport_get_rport_by_qualifier(
335 struct bfa_fcs_lport_s *port, wwn_t pwwn, u32 pid);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700336void bfa_fcs_lport_add_rport(struct bfa_fcs_lport_s *port,
337 struct bfa_fcs_rport_s *rport);
338void bfa_fcs_lport_del_rport(struct bfa_fcs_lport_s *port,
339 struct bfa_fcs_rport_s *rport);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700340void bfa_fcs_lport_ns_init(struct bfa_fcs_lport_s *vport);
341void bfa_fcs_lport_ns_offline(struct bfa_fcs_lport_s *vport);
342void bfa_fcs_lport_ns_online(struct bfa_fcs_lport_s *vport);
343void bfa_fcs_lport_ns_query(struct bfa_fcs_lport_s *port);
Krishna Gudipatiebfe8392012-08-22 19:50:20 -0700344void bfa_fcs_lport_ns_util_send_rspn_id(void *cbarg,
345 struct bfa_fcxp_s *fcxp_alloced);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700346void bfa_fcs_lport_scn_init(struct bfa_fcs_lport_s *vport);
347void bfa_fcs_lport_scn_offline(struct bfa_fcs_lport_s *vport);
348void bfa_fcs_lport_scn_online(struct bfa_fcs_lport_s *vport);
349void bfa_fcs_lport_scn_process_rscn(struct bfa_fcs_lport_s *port,
350 struct fchs_s *rx_frame, u32 len);
351
352struct bfa_fcs_vport_s {
353 struct list_head qe; /* queue elem */
354 bfa_sm_t sm; /* state machine */
355 bfa_fcs_lport_t lport; /* logical port */
356 struct bfa_timer_s timer;
357 struct bfad_vport_s *vport_drv; /* Driver private */
358 struct bfa_vport_stats_s vport_stats; /* vport statistics */
359 struct bfa_lps_s *lps; /* Lport login service*/
360 int fdisc_retries;
361};
362
363#define bfa_fcs_vport_get_port(vport) \
364 ((struct bfa_fcs_lport_s *)(&vport->port))
365
Jing Huangacdc79a2010-10-18 17:15:55 -0700366/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700367 * bfa fcs vport public functions
368 */
369bfa_status_t bfa_fcs_vport_create(struct bfa_fcs_vport_s *vport,
370 struct bfa_fcs_s *fcs, u16 vf_id,
371 struct bfa_lport_cfg_s *port_cfg,
372 struct bfad_vport_s *vport_drv);
373bfa_status_t bfa_fcs_pbc_vport_create(struct bfa_fcs_vport_s *vport,
374 struct bfa_fcs_s *fcs, u16 vf_id,
375 struct bfa_lport_cfg_s *port_cfg,
376 struct bfad_vport_s *vport_drv);
377bfa_boolean_t bfa_fcs_is_pbc_vport(struct bfa_fcs_vport_s *vport);
378bfa_status_t bfa_fcs_vport_delete(struct bfa_fcs_vport_s *vport);
379bfa_status_t bfa_fcs_vport_start(struct bfa_fcs_vport_s *vport);
380bfa_status_t bfa_fcs_vport_stop(struct bfa_fcs_vport_s *vport);
381void bfa_fcs_vport_get_attr(struct bfa_fcs_vport_s *vport,
382 struct bfa_vport_attr_s *vport_attr);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700383struct bfa_fcs_vport_s *bfa_fcs_vport_lookup(struct bfa_fcs_s *fcs,
384 u16 vf_id, wwn_t vpwwn);
385void bfa_fcs_vport_cleanup(struct bfa_fcs_vport_s *vport);
386void bfa_fcs_vport_online(struct bfa_fcs_vport_s *vport);
387void bfa_fcs_vport_offline(struct bfa_fcs_vport_s *vport);
388void bfa_fcs_vport_delete_comp(struct bfa_fcs_vport_s *vport);
389void bfa_fcs_vport_fcs_delete(struct bfa_fcs_vport_s *vport);
Krishna Gudipatidd5aaf42011-06-13 15:51:24 -0700390void bfa_fcs_vport_stop_comp(struct bfa_fcs_vport_s *vport);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700391
392#define BFA_FCS_RPORT_DEF_DEL_TIMEOUT 90 /* in secs */
393#define BFA_FCS_RPORT_MAX_RETRIES (5)
394
395/*
396 * forward declarations
397 */
398struct bfad_rport_s;
399
400struct bfa_fcs_itnim_s;
401struct bfa_fcs_tin_s;
402struct bfa_fcs_iprp_s;
403
404/* Rport Features (RPF) */
405struct bfa_fcs_rpf_s {
406 bfa_sm_t sm; /* state machine */
407 struct bfa_fcs_rport_s *rport; /* parent rport */
408 struct bfa_timer_s timer; /* general purpose timer */
409 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
410 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
411 int rpsc_retries; /* max RPSC retry attempts */
412 enum bfa_port_speed rpsc_speed;
413 /* Current Speed from RPSC. O if RPSC fails */
414 enum bfa_port_speed assigned_speed;
Jing Huangacdc79a2010-10-18 17:15:55 -0700415 /*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700416 * Speed assigned by the user. will be used if RPSC is
417 * not supported by the rport.
418 */
419};
420
421struct bfa_fcs_rport_s {
422 struct list_head qe; /* used by port/vport */
423 struct bfa_fcs_lport_s *port; /* parent FCS port */
424 struct bfa_fcs_s *fcs; /* fcs instance */
425 struct bfad_rport_s *rp_drv; /* driver peer instance */
426 u32 pid; /* port ID of rport */
Krishna Gudipatiee1a4a42012-08-22 19:50:43 -0700427 u32 old_pid; /* PID before rport goes offline */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700428 u16 maxfrsize; /* maximum frame size */
Maggie50444a32010-11-29 18:26:32 -0800429 __be16 reply_oxid; /* OX_ID of inbound requests */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700430 enum fc_cos fc_cos; /* FC classes of service supp */
431 bfa_boolean_t cisc; /* CISC capable device */
432 bfa_boolean_t prlo; /* processing prlo or LOGO */
Krishna Gudipatid7be54c2011-06-24 20:24:52 -0700433 bfa_boolean_t plogi_pending; /* Rx Plogi Pending */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700434 wwn_t pwwn; /* port wwn of rport */
435 wwn_t nwwn; /* node wwn of rport */
436 struct bfa_rport_symname_s psym_name; /* port symbolic name */
437 bfa_sm_t sm; /* state machine */
438 struct bfa_timer_s timer; /* general purpose timer */
439 struct bfa_fcs_itnim_s *itnim; /* ITN initiator mode role */
440 struct bfa_fcs_tin_s *tin; /* ITN initiator mode role */
441 struct bfa_fcs_iprp_s *iprp; /* IP/FC role */
442 struct bfa_rport_s *bfa_rport; /* BFA Rport */
443 struct bfa_fcxp_s *fcxp; /* FCXP needed for discarding */
444 int plogi_retries; /* max plogi retry attempts */
445 int ns_retries; /* max NS query retry attempts */
446 struct bfa_fcxp_wqe_s fcxp_wqe; /* fcxp wait queue element */
447 struct bfa_rport_stats_s stats; /* rport stats */
448 enum bfa_rport_function scsi_function; /* Initiator/Target */
449 struct bfa_fcs_rpf_s rpf; /* Rport features module */
450};
451
452static inline struct bfa_rport_s *
453bfa_fcs_rport_get_halrport(struct bfa_fcs_rport_s *rport)
454{
455 return rport->bfa_rport;
456}
457
Jing Huangacdc79a2010-10-18 17:15:55 -0700458/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700459 * bfa fcs rport API functions
460 */
Krishna Gudipati60138062011-06-24 20:25:15 -0700461void bfa_fcs_rport_get_attr(struct bfa_fcs_rport_s *rport,
462 struct bfa_rport_attr_s *attr);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700463struct bfa_fcs_rport_s *bfa_fcs_rport_lookup(struct bfa_fcs_lport_s *port,
464 wwn_t rpwwn);
465struct bfa_fcs_rport_s *bfa_fcs_rport_lookup_by_nwwn(
466 struct bfa_fcs_lport_s *port, wwn_t rnwwn);
467void bfa_fcs_rport_set_del_timeout(u8 rport_tmo);
468
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700469void bfa_fcs_rport_uf_recv(struct bfa_fcs_rport_s *rport,
470 struct fchs_s *fchs, u16 len);
471void bfa_fcs_rport_scn(struct bfa_fcs_rport_s *rport);
472
473struct bfa_fcs_rport_s *bfa_fcs_rport_create(struct bfa_fcs_lport_s *port,
474 u32 pid);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700475void bfa_fcs_rport_start(struct bfa_fcs_lport_s *port, struct fchs_s *rx_fchs,
476 struct fc_logi_s *plogi_rsp);
477void bfa_fcs_rport_plogi_create(struct bfa_fcs_lport_s *port,
478 struct fchs_s *rx_fchs,
479 struct fc_logi_s *plogi);
480void bfa_fcs_rport_plogi(struct bfa_fcs_rport_s *rport, struct fchs_s *fchs,
481 struct fc_logi_s *plogi);
Maggie50444a32010-11-29 18:26:32 -0800482void bfa_fcs_rport_prlo(struct bfa_fcs_rport_s *rport, __be16 ox_id);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700483
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700484void bfa_fcs_rport_itntm_ack(struct bfa_fcs_rport_s *rport);
485void bfa_fcs_rport_fcptm_offline_done(struct bfa_fcs_rport_s *rport);
486int bfa_fcs_rport_get_state(struct bfa_fcs_rport_s *rport);
487struct bfa_fcs_rport_s *bfa_fcs_rport_create_by_wwn(
488 struct bfa_fcs_lport_s *port, wwn_t wwn);
489void bfa_fcs_rpf_init(struct bfa_fcs_rport_s *rport);
490void bfa_fcs_rpf_rport_online(struct bfa_fcs_rport_s *rport);
491void bfa_fcs_rpf_rport_offline(struct bfa_fcs_rport_s *rport);
492
493/*
494 * forward declarations
495 */
496struct bfad_itnim_s;
497
498struct bfa_fcs_itnim_s {
499 bfa_sm_t sm; /* state machine */
500 struct bfa_fcs_rport_s *rport; /* parent remote rport */
501 struct bfad_itnim_s *itnim_drv; /* driver peer instance */
502 struct bfa_fcs_s *fcs; /* fcs instance */
503 struct bfa_timer_s timer; /* timer functions */
504 struct bfa_itnim_s *bfa_itnim; /* BFA itnim struct */
505 u32 prli_retries; /* max prli retry attempts */
506 bfa_boolean_t seq_rec; /* seq recovery support */
507 bfa_boolean_t rec_support; /* REC supported */
508 bfa_boolean_t conf_comp; /* FCP_CONF support */
509 bfa_boolean_t task_retry_id; /* task retry id supp */
510 struct bfa_fcxp_wqe_s fcxp_wqe; /* wait qelem for fcxp */
511 struct bfa_fcxp_s *fcxp; /* FCXP in use */
512 struct bfa_itnim_stats_s stats; /* itn statistics */
513};
514#define bfa_fcs_fcxp_alloc(__fcs) \
515 bfa_fcxp_alloc(NULL, (__fcs)->bfa, 0, 0, NULL, NULL, NULL, NULL)
516
517#define bfa_fcs_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, __alloc_cbarg) \
518 bfa_fcxp_alloc_wait(__bfa, __wqe, __alloc_cbfn, __alloc_cbarg, \
519 NULL, 0, 0, NULL, NULL, NULL, NULL)
520
521static inline struct bfad_port_s *
522bfa_fcs_itnim_get_drvport(struct bfa_fcs_itnim_s *itnim)
523{
524 return itnim->rport->port->bfad_port;
525}
526
527
528static inline struct bfa_fcs_lport_s *
529bfa_fcs_itnim_get_port(struct bfa_fcs_itnim_s *itnim)
530{
531 return itnim->rport->port;
532}
533
534
535static inline wwn_t
536bfa_fcs_itnim_get_nwwn(struct bfa_fcs_itnim_s *itnim)
537{
538 return itnim->rport->nwwn;
539}
540
541
542static inline wwn_t
543bfa_fcs_itnim_get_pwwn(struct bfa_fcs_itnim_s *itnim)
544{
545 return itnim->rport->pwwn;
546}
547
548
549static inline u32
550bfa_fcs_itnim_get_fcid(struct bfa_fcs_itnim_s *itnim)
551{
552 return itnim->rport->pid;
553}
554
555
556static inline u32
557bfa_fcs_itnim_get_maxfrsize(struct bfa_fcs_itnim_s *itnim)
558{
559 return itnim->rport->maxfrsize;
560}
561
562
563static inline enum fc_cos
564bfa_fcs_itnim_get_cos(struct bfa_fcs_itnim_s *itnim)
565{
566 return itnim->rport->fc_cos;
567}
568
569
570static inline struct bfad_itnim_s *
571bfa_fcs_itnim_get_drvitn(struct bfa_fcs_itnim_s *itnim)
572{
573 return itnim->itnim_drv;
574}
575
576
577static inline struct bfa_itnim_s *
578bfa_fcs_itnim_get_halitn(struct bfa_fcs_itnim_s *itnim)
579{
580 return itnim->bfa_itnim;
581}
582
Jing Huangacdc79a2010-10-18 17:15:55 -0700583/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700584 * bfa fcs FCP Initiator mode API functions
585 */
586void bfa_fcs_itnim_get_attr(struct bfa_fcs_itnim_s *itnim,
587 struct bfa_itnim_attr_s *attr);
588void bfa_fcs_itnim_get_stats(struct bfa_fcs_itnim_s *itnim,
589 struct bfa_itnim_stats_s *stats);
590struct bfa_fcs_itnim_s *bfa_fcs_itnim_lookup(struct bfa_fcs_lport_s *port,
591 wwn_t rpwwn);
592bfa_status_t bfa_fcs_itnim_attr_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
593 struct bfa_itnim_attr_s *attr);
594bfa_status_t bfa_fcs_itnim_stats_get(struct bfa_fcs_lport_s *port, wwn_t rpwwn,
595 struct bfa_itnim_stats_s *stats);
596bfa_status_t bfa_fcs_itnim_stats_clear(struct bfa_fcs_lport_s *port,
597 wwn_t rpwwn);
598struct bfa_fcs_itnim_s *bfa_fcs_itnim_create(struct bfa_fcs_rport_s *rport);
599void bfa_fcs_itnim_delete(struct bfa_fcs_itnim_s *itnim);
600void bfa_fcs_itnim_rport_offline(struct bfa_fcs_itnim_s *itnim);
601void bfa_fcs_itnim_rport_online(struct bfa_fcs_itnim_s *itnim);
602bfa_status_t bfa_fcs_itnim_get_online_state(struct bfa_fcs_itnim_s *itnim);
603void bfa_fcs_itnim_is_initiator(struct bfa_fcs_itnim_s *itnim);
604void bfa_fcs_fcpim_uf_recv(struct bfa_fcs_itnim_s *itnim,
605 struct fchs_s *fchs, u16 len);
606
Krishna Gudipatid7be54c2011-06-24 20:24:52 -0700607#define BFA_FCS_FDMI_SUPP_SPEEDS_4G (FDMI_TRANS_SPEED_1G | \
608 FDMI_TRANS_SPEED_2G | \
609 FDMI_TRANS_SPEED_4G)
610
611#define BFA_FCS_FDMI_SUPP_SPEEDS_8G (FDMI_TRANS_SPEED_1G | \
612 FDMI_TRANS_SPEED_2G | \
613 FDMI_TRANS_SPEED_4G | \
614 FDMI_TRANS_SPEED_8G)
615
616#define BFA_FCS_FDMI_SUPP_SPEEDS_16G (FDMI_TRANS_SPEED_2G | \
617 FDMI_TRANS_SPEED_4G | \
618 FDMI_TRANS_SPEED_8G | \
619 FDMI_TRANS_SPEED_16G)
620
621#define BFA_FCS_FDMI_SUPP_SPEEDS_10G FDMI_TRANS_SPEED_10G
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700622
623/*
624 * HBA Attribute Block : BFA internal representation. Note : Some variable
625 * sizes have been trimmed to suit BFA For Ex : Model will be "Brocade". Based
626 * on this the size has been reduced to 16 bytes from the standard's 64 bytes.
627 */
628struct bfa_fcs_fdmi_hba_attr_s {
629 wwn_t node_name;
630 u8 manufacturer[64];
631 u8 serial_num[64];
632 u8 model[16];
633 u8 model_desc[256];
634 u8 hw_version[8];
635 u8 driver_version[8];
636 u8 option_rom_ver[BFA_VERSION_LEN];
637 u8 fw_version[8];
638 u8 os_name[256];
Maggie50444a32010-11-29 18:26:32 -0800639 __be32 max_ct_pyld;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700640};
641
642/*
643 * Port Attribute Block
644 */
645struct bfa_fcs_fdmi_port_attr_s {
646 u8 supp_fc4_types[32]; /* supported FC4 types */
Maggie50444a32010-11-29 18:26:32 -0800647 __be32 supp_speed; /* supported speed */
648 __be32 curr_speed; /* current Speed */
649 __be32 max_frm_size; /* max frame size */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700650 u8 os_device_name[256]; /* OS device Name */
651 u8 host_name[256]; /* host name */
652};
653
654struct bfa_fcs_stats_s {
655 struct {
656 u32 untagged; /* untagged receive frames */
657 u32 tagged; /* tagged receive frames */
658 u32 vfid_unknown; /* VF id is unknown */
659 } uf;
660};
661
662struct bfa_fcs_driver_info_s {
663 u8 version[BFA_VERSION_LEN]; /* Driver Version */
664 u8 host_machine_name[BFA_FCS_OS_STR_LEN];
665 u8 host_os_name[BFA_FCS_OS_STR_LEN]; /* OS name and version */
666 u8 host_os_patch[BFA_FCS_OS_STR_LEN]; /* patch or service pack */
667 u8 os_device_name[BFA_FCS_OS_STR_LEN]; /* Driver Device Name */
668};
669
670struct bfa_fcs_s {
671 struct bfa_s *bfa; /* corresponding BFA bfa instance */
672 struct bfad_s *bfad; /* corresponding BDA driver instance */
673 struct bfa_trc_mod_s *trcmod; /* tracing module */
674 bfa_boolean_t vf_enabled; /* VF mode is enabled */
675 bfa_boolean_t fdmi_enabled; /* FDMI is enabled */
Krishna Gudipatibe540a92011-06-13 15:53:04 -0700676 bfa_boolean_t bbscn_enabled; /* Driver Config Parameter */
677 bfa_boolean_t bbscn_flogi_rjt;/* FLOGI reject due to BB_SCN */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700678 bfa_boolean_t min_cfg; /* min cfg enabled/disabled */
679 u16 port_vfid; /* port default VF ID */
680 struct bfa_fcs_driver_info_s driver_info;
681 struct bfa_fcs_fabric_s fabric; /* base fabric state machine */
682 struct bfa_fcs_stats_s stats; /* FCS statistics */
683 struct bfa_wc_s wc; /* waiting counter */
Krishna Gudipati7826f302011-07-20 16:59:13 -0700684 int fcs_aen_seq;
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700685};
686
687/*
Maggie Zhangf7f738122010-12-09 19:08:43 -0800688 * fcs_fabric_sm fabric state machine functions
689 */
690
691/*
692 * Fabric state machine events
693 */
694enum bfa_fcs_fabric_event {
695 BFA_FCS_FABRIC_SM_CREATE = 1, /* create from driver */
696 BFA_FCS_FABRIC_SM_DELETE = 2, /* delete from driver */
697 BFA_FCS_FABRIC_SM_LINK_DOWN = 3, /* link down from port */
698 BFA_FCS_FABRIC_SM_LINK_UP = 4, /* link up from port */
699 BFA_FCS_FABRIC_SM_CONT_OP = 5, /* flogi/auth continue op */
700 BFA_FCS_FABRIC_SM_RETRY_OP = 6, /* flogi/auth retry op */
701 BFA_FCS_FABRIC_SM_NO_FABRIC = 7, /* from flogi/auth */
702 BFA_FCS_FABRIC_SM_PERF_EVFP = 8, /* from flogi/auth */
703 BFA_FCS_FABRIC_SM_ISOLATE = 9, /* from EVFP processing */
704 BFA_FCS_FABRIC_SM_NO_TAGGING = 10, /* no VFT tagging from EVFP */
705 BFA_FCS_FABRIC_SM_DELAYED = 11, /* timeout delay event */
706 BFA_FCS_FABRIC_SM_AUTH_FAILED = 12, /* auth failed */
707 BFA_FCS_FABRIC_SM_AUTH_SUCCESS = 13, /* auth successful */
708 BFA_FCS_FABRIC_SM_DELCOMP = 14, /* all vports deleted event */
709 BFA_FCS_FABRIC_SM_LOOPBACK = 15, /* Received our own FLOGI */
710 BFA_FCS_FABRIC_SM_START = 16, /* from driver */
711};
712
713/*
714 * fcs_rport_sm FCS rport state machine events
715 */
716
717enum rport_event {
718 RPSM_EVENT_PLOGI_SEND = 1, /* new rport; start with PLOGI */
719 RPSM_EVENT_PLOGI_RCVD = 2, /* Inbound PLOGI from remote port */
720 RPSM_EVENT_PLOGI_COMP = 3, /* PLOGI completed to rport */
721 RPSM_EVENT_LOGO_RCVD = 4, /* LOGO from remote device */
722 RPSM_EVENT_LOGO_IMP = 5, /* implicit logo for SLER */
723 RPSM_EVENT_FCXP_SENT = 6, /* Frame from has been sent */
724 RPSM_EVENT_DELETE = 7, /* RPORT delete request */
725 RPSM_EVENT_SCN = 8, /* state change notification */
726 RPSM_EVENT_ACCEPTED = 9, /* Good response from remote device */
727 RPSM_EVENT_FAILED = 10, /* Request to rport failed. */
728 RPSM_EVENT_TIMEOUT = 11, /* Rport SM timeout event */
729 RPSM_EVENT_HCB_ONLINE = 12, /* BFA rport online callback */
730 RPSM_EVENT_HCB_OFFLINE = 13, /* BFA rport offline callback */
731 RPSM_EVENT_FC4_OFFLINE = 14, /* FC-4 offline complete */
732 RPSM_EVENT_ADDRESS_CHANGE = 15, /* Rport's PID has changed */
733 RPSM_EVENT_ADDRESS_DISC = 16, /* Need to Discover rport's PID */
734 RPSM_EVENT_PRLO_RCVD = 17, /* PRLO from remote device */
Lucas De Marchi25985ed2011-03-30 22:57:33 -0300735 RPSM_EVENT_PLOGI_RETRY = 18, /* Retry PLOGI continuously */
Maggie Zhangf7f738122010-12-09 19:08:43 -0800736};
737
738/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700739 * bfa fcs API functions
740 */
741void bfa_fcs_attach(struct bfa_fcs_s *fcs, struct bfa_s *bfa,
742 struct bfad_s *bfad,
743 bfa_boolean_t min_cfg);
744void bfa_fcs_init(struct bfa_fcs_s *fcs);
Krishna Gudipati75332a72011-06-13 15:54:31 -0700745void bfa_fcs_pbc_vport_init(struct bfa_fcs_s *fcs);
746void bfa_fcs_update_cfg(struct bfa_fcs_s *fcs);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700747void bfa_fcs_driver_info_init(struct bfa_fcs_s *fcs,
748 struct bfa_fcs_driver_info_s *driver_info);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700749void bfa_fcs_exit(struct bfa_fcs_s *fcs);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700750
Jing Huangacdc79a2010-10-18 17:15:55 -0700751/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700752 * bfa fcs vf public functions
753 */
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700754bfa_fcs_vf_t *bfa_fcs_vf_lookup(struct bfa_fcs_s *fcs, u16 vf_id);
Krishna Gudipatib85daaf2011-06-13 15:55:11 -0700755void bfa_fcs_vf_get_ports(bfa_fcs_vf_t *vf, wwn_t vpwwn[], int *nports);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700756
757/*
758 * fabric protected interface functions
759 */
760void bfa_fcs_fabric_attach(struct bfa_fcs_s *fcs);
761void bfa_fcs_fabric_modinit(struct bfa_fcs_s *fcs);
762void bfa_fcs_fabric_modexit(struct bfa_fcs_s *fcs);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700763void bfa_fcs_fabric_link_up(struct bfa_fcs_fabric_s *fabric);
764void bfa_fcs_fabric_link_down(struct bfa_fcs_fabric_s *fabric);
765void bfa_fcs_fabric_addvport(struct bfa_fcs_fabric_s *fabric,
766 struct bfa_fcs_vport_s *vport);
767void bfa_fcs_fabric_delvport(struct bfa_fcs_fabric_s *fabric,
768 struct bfa_fcs_vport_s *vport);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700769struct bfa_fcs_vport_s *bfa_fcs_fabric_vport_lookup(
770 struct bfa_fcs_fabric_s *fabric, wwn_t pwwn);
771void bfa_fcs_fabric_modstart(struct bfa_fcs_s *fcs);
772void bfa_fcs_fabric_uf_recv(struct bfa_fcs_fabric_s *fabric,
773 struct fchs_s *fchs, u16 len);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700774void bfa_fcs_fabric_psymb_init(struct bfa_fcs_fabric_s *fabric);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700775void bfa_fcs_fabric_set_fabric_name(struct bfa_fcs_fabric_s *fabric,
776 wwn_t fabric_name);
777u16 bfa_fcs_fabric_get_switch_oui(struct bfa_fcs_fabric_s *fabric);
778void bfa_fcs_uf_attach(struct bfa_fcs_s *fcs);
779void bfa_fcs_port_attach(struct bfa_fcs_s *fcs);
Maggie Zhangf7f738122010-12-09 19:08:43 -0800780void bfa_fcs_fabric_sm_online(struct bfa_fcs_fabric_s *fabric,
781 enum bfa_fcs_fabric_event event);
782void bfa_fcs_fabric_sm_loopback(struct bfa_fcs_fabric_s *fabric,
783 enum bfa_fcs_fabric_event event);
784void bfa_fcs_fabric_sm_auth_failed(struct bfa_fcs_fabric_s *fabric,
785 enum bfa_fcs_fabric_event event);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700786
Jing Huangacdc79a2010-10-18 17:15:55 -0700787/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700788 * BFA FCS callback interfaces
789 */
790
Jing Huangacdc79a2010-10-18 17:15:55 -0700791/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700792 * fcb Main fcs callbacks
793 */
794
795struct bfad_port_s;
796struct bfad_vf_s;
797struct bfad_vport_s;
798struct bfad_rport_s;
799
Jing Huangacdc79a2010-10-18 17:15:55 -0700800/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700801 * lport callbacks
802 */
803struct bfad_port_s *bfa_fcb_lport_new(struct bfad_s *bfad,
804 struct bfa_fcs_lport_s *port,
805 enum bfa_lport_role roles,
806 struct bfad_vf_s *vf_drv,
807 struct bfad_vport_s *vp_drv);
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700808
Jing Huangacdc79a2010-10-18 17:15:55 -0700809/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700810 * vport callbacks
811 */
812void bfa_fcb_pbc_vport_create(struct bfad_s *bfad, struct bfi_pbc_vport_s);
813
Jing Huangacdc79a2010-10-18 17:15:55 -0700814/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700815 * rport callbacks
816 */
817bfa_status_t bfa_fcb_rport_alloc(struct bfad_s *bfad,
818 struct bfa_fcs_rport_s **rport,
819 struct bfad_rport_s **rport_drv);
820
Jing Huangacdc79a2010-10-18 17:15:55 -0700821/*
Krishna Gudipatia36c61f2010-09-15 11:50:55 -0700822 * itnim callbacks
823 */
824void bfa_fcb_itnim_alloc(struct bfad_s *bfad, struct bfa_fcs_itnim_s **itnim,
825 struct bfad_itnim_s **itnim_drv);
826void bfa_fcb_itnim_free(struct bfad_s *bfad,
827 struct bfad_itnim_s *itnim_drv);
828void bfa_fcb_itnim_online(struct bfad_itnim_s *itnim_drv);
829void bfa_fcb_itnim_offline(struct bfad_itnim_s *itnim_drv);
830
831#endif /* __BFA_FCS_H__ */